Code covered by the BSD License  

Highlights from
immiscible LB

immiscible LB

by

 

23 Jul 2009 (Updated )

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

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

if  strcmp(Refill_method,'Keller'),  % VECTORIAL CODE
   
    %tC2=C2(:,1:8);

    if(1) % use sort for link priority 
        new_order= repmat(int32(0),lenag,9); %
        [~, new_order] = sort(Grad_List,2,'descend'); % use 2009b
        %
        new_order=[new_order(:,1:4), repmat(9,lenag,1) , new_order(:,5:8)]; % RP=9 ... link prioritization !
        %
    else % alternative that avoids using matlab sort function  
    new_order= repmat(int32(0),lenag,9); %
        % auto sorting i.e. without using the sort functio
        % find the link with the angle closest to the gradient angle % ijagr=ija(Flag_Grad); 
        repm_ic_rad= repmat(ic_rad,lenag,1); % ripeti ic_rad
        
       % [~, first_linK]= min( abs(bsxfun(@minus,phi_Grad(ijagr),repm_ic_rad)),[],2 ); % min row by row
       % [~, first_linK]= min( abs(bsxfun(@minus,phi_Grad(ijagr)',[ic_rad,6.2830])),[],2 );
     
       [~,first_linK]=max(Grad_List,[],2); % auto sorting i.e. without using the sort functio
       first_linK=int32(first_linK); 
        
        iradpiu= phi_Grad(ijagr) > repm_ic_rad( (first_linK(:)-1).*lenag+(1:lenag)' )>0; % true if it is larger, logical vector 
     
        signN=find(~iradpiu); 
        new_order(signN,1:9)=SortedN(first_linK(signN),(1:9));
        
        signP=int32(find(iradpiu)); 
        new_order(signP,1:9)=SortedP(first_linK(signP),(1:9));
        

        % new order is a matrix of 9 colums and as mamy rows as the
        % cells-position with a colour gradient deserving attention (i.e.
        % recolouring) 
        % see Flag_Grad  ijagr=ija(Flag_Grad); lenag=length(ijagr); in colous
        % gradient and tables load in D2Q9_lattice

    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

Contact us