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

Select_Colour_Redistribution_Method_2010c.m
% same code as above but in vectorial fashion usind abosolute

if  strcmp(Refill_method,'Keller'),  % VECTORIAL CODE
%tC2=C2(:,1:8);
new_order = repmat(int32(0),lenag,9); %

if(0)
[~, new_order] = sort(Grad_List,2,'descend'); % use 2009b
new_order = int32(new_order);
new_order = [new_order(:,1:4), repmat(int32(9),lenag,1) , new_order(:,5:8)]; % RP=9 ... link prioritization !
else % breaking sort in two parts ( positiva values & neg. values)

G_listma0 = zeros(lenag,4,'single') ; %G_listmi0 = zeros(lenag,4,'single');
ima0m=zeros(lenag,4,'int32') ;% imi0m=zeros(lenag,4,'int32') ;
zetre=int32([0,1,2,3]).*lenag;

indicx1=repmat(zetre,lenag,1)+repmat((1:lenag)',1,4);

%%%
bneq4 = sum(bima0,2)~=4;
%[~,idx] = max(cumsum(bima0,2),[],2);

if(0)
[irx,icx] = find(bima0==1) ;
for ino=1:lenag
if bneq4(ino)
iz= find(bima0(ino,:)==0,1);   bima0(ino,iz(1))=1;
ima0m(ino,:) = int32(find(bima0(ino,:))) ;
else % i.e 4
ima0m(ino,:) = icx(irx==ino)'; ;
end
end

end   %%%  if(0)

if(1)

if any(bneq4)
for ino=1:lenag,
if bneq4(ino)
iz = find(bima0(ino,:)==0,1);
bima0(ino,iz(1))=1;
end
end
else
for ino=1:lenag,
ima0m(ino,:)= int32( find(bima0(ino,:),4) ) ;

end
end

end

indicx2=(ima0m-ones(lenag,4,'int32')).*lenag+repmat((1:lenag)',1,4);
[~,isma] = sort(G_listma0,2,'descend');

isma=int32(isma);

indicx3=(isma-ones(lenag,4,'int32')).*lenag+repmat((1:lenag)',1,4);
ima0m(indicx1(:))=ima0m(indicx3);

imi0m = ic_op( fliplr(ima0m) ) ;

new_order=[ima0m, repmat(int32(9),lenag,1) ,imi0m];

end

%new_order = repmat(double(ijagr(:)),1,9) + double(NxM)*(new_order-1); % 9 elements vector
new_order = repmat(ijagr(:),1,9) + NxM.*(int32(new_order-1)); % 9 elements  su ogni riga
%%
%Colour_refill_vector_based; % sequential fast m code ( as today)
%Colour_refill_parfor; % slow m code
%Colour_refill_vector_based_Luigino; % seq medium speed m code
%Colour_refill_parfor_4; % new but still slow m code
%Colour_refill_parfor_41; % new but still slow m code
Colour_refill_all_at_once;
end % END VECTORIAL SECTION

if strcmp(Refill_method,'Latvo_Kakko') % LATVA KOKKO IMPROVED METHOD Physical Review E 72 2005
Latva_Kokko_Colour_Redistribution_Vet;
end