Home > demos > bratu > bratuinit.m

bratuinit

PURPOSE ^

init-routine

SYNOPSIS ^

function p=bratuinit(p)

DESCRIPTION ^

 init-routine

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function p=bratuinit(p) 
0002 % init-routine
0003 p=stanparam(p); % set standard parameters, usually call this first
0004 p.neq=1; p.f=@bratuf; p.jac=@bratujac; % the coefficients and the jacobian
0005 [p.geo,bc]=recnbc1(0.5,0.5); % geometry and boundary conditions
0006 p.bcf=@(p,u,lam) bc; % define inline dummy BC function (as BC are fixed)
0007 nx=20;p=stanmesh(p,nx,nx); % rectangular mesh
0008 p=setbmesh(p); % set current mesh as 'base mesh' for adaption
0009 p.maxt=2*p.nt; % usual goal for mesh-adaption
0010 pre=sprintf('%s',inputname(1)); p=setfn(p,pre); % set filenames
0011 p.tau=1; % set to something (will be generated in inistep)
0012 p.xi=1/p.np; % and set xi to its standard value
0013 p.cm=hot; % colormap for 3D surf plot
0014 p.nsteps=50; p.dsmax=1; % number of steps and maximal stepsize
0015 p.dlammax=0.02; % maximal stepsize in lambda;
0016 p.lammin=0.05;  % minimal lambda, used as stopping criterion
0017 p.lam=0.2; % starting point in lam;
0018 p.u=0.1*ones(p.np,1);p.ds=0.05;  % starting point u on homogen. branch
0019 % next (and final) steps not necessary but good practice to assess
0020 % quality of initial guess and provide first point on branch
0021 res=norm(resi(p,p.u,p.lam), p.normsw); % calculate first residual
0022 fprintf('initial res=%g\n',res); % and print it
0023 [p.u,p.res,p.iter]=nlooppde(p,p.u,p.lam); % correct initial guess
0024 fprintf('first res=%g with %i iterations\n',p.res,p.iter); % and inform user
0025 plotsol(p,1,1,p.pstyle);
0026

Generated on Wed 15-Aug-2012 12:53:02 by m2html © 2005