function f = periodic_left_right(Nx, Ny, f, f_temp) %%%% This function should be used in conjunction with the subroutine %%%% stream_2 or equivalent. It streams the distribution function, %%%% using f_temp to update f, for periodic boundary conditions. %%%% Particles exiting on the right boundary re-enter on the left %%%% boundary, and vice-versa. The function is particular to a D2Q9 %%%% lattice. in = 1; out = Nx; i = in; i_n = out; % periodic boundary for j = 1:Ny j_n = (j-1)*(j~=1) + (Ny)*(j==1); % periodic boundary j_p = (j+1)*(j