assemble K for advective terms. b=b(i,k), i=1..2N^2, k=1,..,nt is row-vector on triangles p=mesh-points, t=triangles, e=edges,
0001 function K=assemadv(p,t,b) 0002 % assemble K for advective terms. 0003 % b=b(i,k), i=1..2N^2, k=1,..,nt is row-vector on triangles 0004 % p=mesh-points, t=triangles, e=edges, 0005 N=sqrt(size(b,1)/2); 0006 m1=1;m2=2; np=size(p,2); ks=sparse(N*np,N*np,0); 0007 for l=1:N % column blocks in K 0008 for k=1:N % row-blocks in K 0009 if(any(b(m1:m2,:))) ks1=assemadv1(p,t,b(m1:m2,:)); 0010 [ii,jj,kss]=find(ks1); 0011 ks=ks+sparse(ii+(k-1)*np,jj+(l-1)*np,kss,N*np,N*np); 0012 end 0013 m1=m1+2; m2=m2+2; 0014 end 0015 end 0016 K=ks;