SETFUN_LAP_3D Sets functions and coefficients for lap_3d [uex,uexx,uexy,uexz,ff,gam]=setfun_lap_3d Output: uex =@(x,y,z)[....] function handle to the expression of exact solution uexx =@(x,y,z)[....] function handle to the expression of the first x-derivative of the exact solution uexy =@(x,y,z)[....] function handle to the expression of the first y-derivative of the exact solution uexz =@(x,y,z)[....] function handle to the expression of the first z-derivative of the exact solution ff =@(x,y,z)[....] function handle to the expression of function at right hand side gam = coefficient of zero-order term (constant >=0)
0001 function [uex,uexx,uexy,uexz,ff,gam]=setfun_lap_3d 0002 % SETFUN_LAP_3D Sets functions and coefficients for lap_3d 0003 % 0004 % [uex,uexx,uexy,uexz,ff,gam]=setfun_lap_3d 0005 % 0006 % Output: uex =@(x,y,z)[....] function handle to the expression of exact 0007 % solution 0008 % uexx =@(x,y,z)[....] function handle to the expression of the first 0009 % x-derivative of the exact solution 0010 % uexy =@(x,y,z)[....] function handle to the expression of the first 0011 % y-derivative of the exact solution 0012 % uexz =@(x,y,z)[....] function handle to the expression of the first 0013 % z-derivative of the exact solution 0014 % ff =@(x,y,z)[....] function handle to the expression of function 0015 % at right hand side 0016 % gam = coefficient of zero-order term (constant >=0) 0017 % 0018 0019 % Written by Paola Gervasio 0020 % $Date: 2007/04/01$ 0021 0022 0023 syms x y z 0024 gam=0; 0025 Uex=(x.^2+y.^3+3*z);% sin(2*pi*x)*cos(2*pi*y)*sin(2*pi*z); % exact solution 0026 Uexx=diff(Uex,x); % first x-derivative of exact solution 0027 Uexy=diff(Uex,y); % first y-derivative of exact solution 0028 Uexz=diff(Uex,z); % first z-derivative of exact solution 0029 Uexx2=diff(Uexx,x); % second x-derivative of exact solution 0030 Uexy2=diff(Uexy,y); % second y-derivative of exact solution 0031 Uexz2=diff(Uexz,z); % second z-derivative of exact solution 0032 Ff=(gam*(Uex)-(Uexx2+Uexy2+Uexz2)); % right hand side 0033 0034 uex=strrep(char(Uex),'*','.*'); 0035 uexx=strrep(char(Uexx),'*','.*'); 0036 uexy=strrep(char(Uexy),'*','.*'); 0037 uexz=strrep(char(Uexz),'*','.*'); 0038 ff=strrep(char(Ff),'*','.*'); 0039 0040 uex=strrep(char(uex),'/','./'); 0041 uexx=strrep(char(uexx),'/','./'); 0042 uexy=strrep(char(uexy),'/','./'); 0043 uexz=strrep(char(uexz),'/','./'); 0044 ff=strrep(char(ff),'/','./'); 0045 0046 uex=strrep(char(uex),'^','.^'); 0047 uexx=strrep(char(uexx),'^','.^'); 0048 uexy=strrep(char(uexy),'^','.^'); 0049 uexz=strrep(char(uexz),'^','.^'); 0050 ff=strrep(char(ff),'^','.^'); 0051 0052 0053 uex=@(x,y,z)[eval(uex)]; 0054 uexx=@(x,y,z)[eval(uexx)]; 0055 uexy=@(x,y,z)[eval(uexy)]; 0056 uexz=@(x,y,z)[eval(uexz)]; 0057 ff=@(x,y,z)[eval(ff)]; 0058