Code covered by the BSD License

immiscible LB

by

G. Sken (view profile)

23 Jul 2009 (Updated )

Implements Immiscible Lattice Boltzmann (ILB, D2Q9) method for two phase flows

Velocities_ux_uy.m
```% MACROSCOPIC
if (0) % SCALAR
ux=zeros(Nr,Mc);uy=zeros(Nr,Mc);
for ic=1:N_c-1;
ux = ux + double(C_x(ic)).*f(:,:,ic) ;
uy = uy + double(C_y(ic)).*f(:,:,ic)  ;
end
end

if (0) % VECTORIAL
uy=f(:,:,2) +f(:,:,5)+f(:,:,6)-f(:,:,4)-f(:,:,7)-f(:,:,8); % in short !
ux=f(:,:,1) +f(:,:,5)+f(:,:,8)-f(:,:,3)-f(:,:,6)-f(:,:,7); % in short !

end

if (1) %

ux=zeros(lena,1); uy=zeros(lena,1);

for ic=1:N_c-1;
indeces=ija + NxM*(ic-1);

if(C_x(ic) ~=0),
ux = ux + double(C_x(ic)).*f(indeces) ;
end

if(C_y(ic) ~=0),
uy = uy + double(C_y(ic)).*f(indeces) ;
end
end

rhoij=rho(ija);
% ux=ux./rhoij;
% uy=uy./rhoij;

%   % N gost P.J. Dellar
%   N_gost=zeros(NxM*8,1); Nij_gost=zeros(lena,1);
%   N_gost=-2.*sum(f(:,:,1:4),3)+4.*sum(f(:,:,5:8),3)+f(:,:,9);
%   Nij_gost=N_gost(ija);

end

if (0) %  with repmat
ux=zeros(Nr,Mc); uy=zeros(Nr,Mc);

%b=ones(1,8); b=b.*double(C_x(1:8)); a(1,1,1:8) = b(1:8);

a(1,1,1:8)= double(C_x(1:8)); %  b=repmat(a,Nr,Mc);
ux = sum(repmat(a,Nr,Mc).*f(:,:,1:8),3);

a(1,1,1:8)= double(C_y(1:8)); %
uy = sum(repmat(a,Nr,Mc).*f(:,:,1:8),3) ;
end
```