Home > p2plib > newmesh.m

newmesh

PURPOSE ^

build new mesh and interpolate (u,tau) to it

SYNOPSIS ^

function q=newmesh(p)

DESCRIPTION ^

 build new mesh and interpolate (u,tau) to it

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function q=newmesh(p) 
0002 % build new mesh and interpolate (u,tau) to it
0003 q=p; 
0004 msel=0; msel=asknu('Delaunay (0) or point-mesh(1)?',msel);
0005 if(msel==0)
0006     xmin=min(p.points(1,:)); xmax=max(p.points(2,:)); 
0007     ymin=min(p.points(2,:)); ymax=max(p.points(2,:)); 
0008     hmax=min((xmax-xmin)/20,(ymax-ymin)/20);
0009     hmax=asknu('hmax:', hmax); q=stanmesh(q,hmax);
0010 else nx=20;ny=20; nx=asknu('nx', nx);ny=asknu('ny', ny);
0011     q=stanmesh(q,nx,ny);
0012 end
0013 x=p.points(1,:); y=p.points(2,:); xn=q.points(1,:);yn=q.points(2,:);
0014 for i=1:p.neq % interpolate u to new mesh
0015     z = p.u((i-1)*p.np+1:i*p.np); 
0016     ui=p2interpol(xn,yn,z,x,y); un((i-1)*q.np+1:i*q.np)=ui; 
0017 end 
0018 q.u=un'; plotsol(q,q.ifig,q.pcmp,q.pstyle);  xi=1/q.np; 
0019 if(q.isw>1); fprintf('old xi=%g, new xi=%g\n',q.xi,xi); xi=asknu('xi:',q.xi); end 
0020 q.xi=xi; 
0021 lamd=p.tau(p.neq*p.np+1); tau=zeros(q.np*q.neq,1); 
0022 for i=1:q.neq % interpolate tau
0023   z = p.tau((i-1)*p.np+1:i*p.np);
0024   taui=p2interpol(xn,yn,z,x,y); 
0025   tau((i-1)*q.np+1:i*q.np) = taui; 
0026 end
0027 tau(q.np*q.neq+1)=lamd; q.tau=tau/xinorm(tau,q.xi);
0028

Generated on Wed 15-Aug-2012 10:09:15 by m2html © 2005