Solving PDE system in Matlab: Derivatives on a mesh -
i using matlab solve system of coupled pdes, pdenonlin
.
i create mesh geometry (a square box circular hole in middle), , refine until :
[p,e,t] = initmesh('defectgeom2'); [p,e,t] = refinemesh('defectgeom2',p,e,t);
i solve system
% solution: u = pdenonlin(b_s,p,e,t,c_s,a_s,f_s); % extract different functions full solutions (systems): np = size(p,2); % number of node points uk = reshape(u,np,[]); % each uk column has 1 component of u
therefore have uk
(in case 3) solutions.
now want calculate integrals , derivatives of approximate solutions. tried interpolating uniform grid using tri2grid
:
x=linspace(-1,1,npts); y=x; psi=tri2grid(p,t,uk(:,3),x,y); theta=tri2grid(p,t,uk(:,1),x,y); theta_y=derivative(theta,1,2); psi_x=derivative(psi,1,1);
and calculate:
pressure = trapz(x,psi_x-cos(2*theta).*theta_y+sin(2*theta));
but gives me poor approximation, guess because of fact grid uniform whereas mesh finer around central circle , coarser elsewhere.
is there way use matlab built-in functions calculate derivatives of solutions of pdenonlin
without brutally interpolate tri2grid
on uniform grid?
there pdeinterpolant
class in pde toolbox might useful. use meshtopet
generate input arguments mesh , evaluate
query interpolant.
you can specify different grid when query interpolant if use finer grid stage might better results without having alter original mesh.
Comments
Post a Comment