0001 function p=cont(p)
0002
0003
0004
0005
0006 if(p.pnamesw==1)
0007 dum1=p.count; dum2=p.branch; dum3=p.bcount;
0008 [p,ok]=setfn(p,inputname(1));
0009 p.count=dum1; p.branch=dum2; p.bcount=dum3;
0010 if ok~=1; return; end
0011 end
0012 p.ntime=0; p.tstime=0; p.sptime=0; totime=cputime;
0013 is=0;
0014 ineg0=-1;
0015 p.headfu(p);
0016 while is<p.nsteps
0017 if (length(p.tau)~=p.neq*p.np+1)||(p.restart>0)
0018 [p,iok]=inistep(p); if iok==0; return; end
0019 plotsol(p,1,1,p.pstyle); is=is+2;
0020 end
0021 stime=cputime; iter=0; res=10*p.tol; stepok=0;
0022 dss=p.ds;
0023 while stepok==0
0024 lamd=p.tau(p.neq*p.np+1);
0025 u1=p.u+p.ds*p.tau(1:p.neq*p.np); lam1=p.lam+p.ds*lamd;
0026 ntime=cputime;
0027 if(p.parasw==0 || (p.parasw==1 && abs(lamd)>p.lamdtol))
0028 [u1,res,iter,Gu,Glam]=nlooppde(p,u1,lam1); p.meth='nat';
0029 else
0030 [u1,lam1,res,iter,Gu,Glam]=nloopext(p,u1,lam1,p.ds); p.meth='arc';
0031 end
0032 p.ntime=p.ntime+cputime-ntime;
0033 ds=p.ds;
0034 [p,stepok,u1,lam1,res,iter,Gu,Glam]=sscontrol(p,u1,lam1,res,iter,Gu,Glam,dss);
0035 if(stepok==-1); return; end;
0036 end
0037 if p.spcalcsw>0
0038 sptime=cputime; ineg0=p.ineg;
0039 [p.ineg,p.muv]=spcalc(Gu,p);
0040 p.sptime=p.sptime+cputime-sptime;
0041 end
0042
0043 amat=[[Gu Glam]; [p.xi*p.tau(1:p.neq*p.np)' (1-p.xi)*p.tau(p.neq*p.np+1)]];
0044 tau1=p.blss(amat,[zeros(p.neq*p.np,1);1],p,lam1); tau1=tau1/xinorm(tau1,p.xi);
0045 if(p.bifchecksw>0)
0046 newds=p.ds; p.ds=ds;
0047 biftime=cputime; p=bifdetec(p,u1,lam1,tau1,Gu,Glam,ineg0);
0048 p.biftime=p.biftime+cputime-biftime; p.ds=newds;
0049 end
0050 p.restart=0; p.u=u1; p.lam=lam1; p.tau=tau1;
0051 p.res=res; p.iter=iter; p.lamd=lamd;
0052 if(p.errchecksw>0); p.err=errcheck(p);
0053 if(p.err>p.errbound && p.errbound>0)
0054 if(p.errchecksw==1)
0055 fprintf('err.est.=%g>errbound=%g. Consider mesh-refinement.\n', p.err, p.errbound);
0056 end
0057 if(p.errchecksw==2);
0058 fprintf('err.est.=%g>errbound=%g. Adapting mesh\n', p.err, p.errbound);
0059 p=meshadac(p,'eb',p.errbound);
0060 end
0061 if(p.errchecksw>2);
0062 p=meshref(p,'eb',p.errbound);
0063 end
0064 end
0065 end
0066 if mod(p.count,p.amod)==0;
0067 fprintf('adapting mesh\n'); p=meshadac(p,'maxt',p.maxt,'eb',0); end
0068 if mod(p.count,p.brmod)==0
0069 brout=p.outfu(p,p.u,p.lam);
0070 p.branch=[p.branch [p.count; p.ineg; p.lam; p.err; brout]];
0071 figure(p.brfig); hold on;
0072 if p.ineg<=0; plot(lam1,real(brout(p.bpcmp)),'*');
0073 else plot(lam1,real(brout(p.bpcmp)),'+'); end
0074 end
0075 if(p.count>0 && mod(p.count,p.smod)==0)
0076 fname=[p.pname,sprintf('%i',p.count),'.mat']; save(fname,'p'); end
0077 p.tstime=p.tstime+cputime-stime;
0078 if(mod(p.count,p.pmod)==0); plotsol(p,p.pfig,p.pcmp,p.pstyle); end
0079 cstop=p.ufu(p,brout,ds);
0080 p.count=p.count+1; is=is+1;
0081 if(cstop==1) break; end
0082 end
0083
0084 if(p.smod~=0); fname=[p.pname,sprintf('%i',p.count-1),'.mat']; save(fname,'p'); end
0085 p.totime=cputime-totime;
0086 if(p.timesw>0)
0087 fprintf('Timing: total=%g, av.step=%g, av.newton=%g, av.spcalc=%g\n',...
0088 p.totime,p.tstime/is,p.ntime/is,p.sptime/is);
0089 end