SETFUN_ADR_1D Sets functions and coefficients for adr_1d.m [uex,uexx,ff,nu,beta,gam]=setfun_adr_1d Output: uex =@(x)[....] function handle to the expression of exact solution uexx =@(x)[....] function handle to the expression of the first derivative of the exact solution ff =@(x)[....] function handle to the expression of function at right hand side nu = viscosity coefficient (constant>0) beta =@(x)[....] function handle to the expression of transport coefficient function gam = coefficient of zero-order term (constant >=0)
0001 function [uex,uexx,ff,nu,beta,gam]=setfun_adr_1d 0002 % SETFUN_ADR_1D Sets functions and coefficients for adr_1d.m 0003 % 0004 % [uex,uexx,ff,nu,beta,gam]=setfun_adr_1d 0005 % 0006 % Output: uex =@(x)[....] function handle to the expression of exact 0007 % solution 0008 % uexx =@(x)[....] function handle to the expression of the first 0009 % derivative of the exact solution 0010 % ff =@(x)[....] function handle to the expression of function 0011 % at right hand side 0012 % nu = viscosity coefficient (constant>0) 0013 % beta =@(x)[....] function handle to the expression of 0014 % transport coefficient function 0015 % gam = coefficient of zero-order term (constant >=0) 0016 % 0017 0018 % Written by Paola Gervasio 0019 % $Date: 2007/04/01$ 0020 0021 0022 syms x 0023 gam=1; nu=1; 0024 Beta=cos((1+x)*pi*.25); 0025 Uex=cos((1+x)*pi*3).*sin((0.5+x)*pi/5)+sin(pi/10); % exact solution 0026 Uexx=diff(Uex,x); % first derivative of exact solution 0027 Ff=gam*(Uex)-diff(nu*(Uexx)+Beta*(Uex)); % right hand side 0028 0029 beta=strrep(char(Beta),'*','.*'); 0030 uex=strrep(char(Uex),'*','.*'); 0031 uexx=strrep(char(Uexx),'*','.*'); 0032 ff=strrep(char(Ff),'*','.*'); 0033 0034 beta=strrep(char(beta),'/','./'); 0035 uex=strrep(char(uex),'/','./'); 0036 uexx=strrep(char(uexx),'/','./'); 0037 ff=strrep(char(ff),'/','./'); 0038 0039 beta=strrep(char(beta),'^','.^'); 0040 uex=strrep(char(uex),'^','.^'); 0041 uexx=strrep(char(uexx),'^','.^'); 0042 ff=strrep(char(ff),'^','.^'); 0043 0044 0045 beta=@(x)[eval(beta)]; 0046 uex=@(x)[eval(uex)]; 0047 uexx=@(x)[eval(uexx)]; 0048 ff=@(x)[eval(ff)]; 0049 0050