www.pudn.com > 87361026FEA.rar > lstest3.m, change:2002-10-01,size:1412b


clear
colordef black

clf
L=10;
H=4;

numx=41;
numy=17;

node=square_node_array([0 -H/2],[L -H/2],[L H/2],[0 H/2],numx,numy);
conn = [ make_elem([1 2 numx+1],numx-1,numy-1,1,numx);
         make_elem([numx+2 numx+1 2],numx-1,numy-1,1,numx) ];
         
numnode=size(node,1);
numelem=size(conn,1);

% define velocity field
v=[ones(numnode,1) zeros(numnode,1)];

% define level set
R=1.0;
x0=2*R;

he=.25;
bw=1.0;
reps=4*he;
rsteps=1;
rinc=1;

phi=sqrt( (node(:,1)-x0).^2 + node(:,2).^2 ) - R;
[nearNode,nearConn,nnMap]=findNearElements(node,conn,phi,bw);
farNode = setdiff( (1:numnode)',nnMap);
phi( farNode ) = 1.1*bw*sign( phi(farNode) );

% plot level set
figure(1)
%plot_field(node,conn,'T3',phi);
hold on
plot_mesh(node,conn,'T3','g-')
contura(node(:,1),node(:,2),phi,-2:.25:2)
contura(node(:,1),node(:,2),phi,[0 0],'w')
title('n=0')
pause(0.1)

numStep=1;
delt=0.05;
for n=1:numStep
  
  % update level set
  phi(nnMap) = lsupdateT3(nearNode,nearConn,phi(nnMap),v(nnMap,:),delt);
  [nearNode,nearConn,nnMap]=findNearElements(node,conn,phi,bw);
  
  if ( mod(n,rinc) == 0 )
    phi(nnMap) = lsreinitT3(nearNode,nearConn,phi(nnMap),reps,rsteps);
  end
  
  % plot level set
  figure(1)
  clf
  %plot_field(node,conn,'T3',phi);
  hold on
  plot_mesh(node,conn,'T3','g-')
  contura(node(:,1),node(:,2),phi,-2:.25:2)
  contura(node(:,1),node(:,2),phi,[0 0],'w')
  title(['n=',num2str(n)])
  pause(0.1)
  
end