Home > p2plib > cfail.m

cfail

PURPOSE ^

convergence failure handling.

SYNOPSIS ^

function [p,stepok,u1,lam1,res,iter,Gu,Glam]=cfail(p,u1,lam1,res,iter,Gu,Glam,dss)

DESCRIPTION ^

 convergence failure handling. 
 Offer a number of options, mainly: 
 return with stepok=-1 and abort cont! 
 reduce dsmin and return with stepok=0;
 increase tol or dlammax and return with stepok=1;
 try nlooppde and return with stepok=1 if success, 0 else;
 try meshref/meshadac and return with stepok=0 even if success since tau,
     Gu, etc might need to be redone

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [p,stepok,u1,lam1,res,iter,Gu,Glam]=cfail(p,u1,lam1,res,iter,Gu,Glam,dss) 
0002 % convergence failure handling.
0003 % Offer a number of options, mainly:
0004 % return with stepok=-1 and abort cont!
0005 % reduce dsmin and return with stepok=0;
0006 % increase tol or dlammax and return with stepok=1;
0007 % try nlooppde and return with stepok=1 if success, 0 else;
0008 % try meshref/meshadac and return with stepok=0 even if success since tau,
0009 %     Gu, etc might need to be redone
0010 fprintf('NO CONVERGENCE, ds=%g, dsmin=%g, tol=%g, res=%g \n', p.ds,p.dsmin,p.tol,res);
0011 stepok=0; choi=0; % standard setting: abort cont
0012 if(p.isw>0);  % user interaction if desired
0013   fprintf('options:\n0: return,  1: change dsmin, 2: change tol, 3: change other sw/param,\n');
0014   fprintf('4: correct with fixed lam,  5: refine mesh,  6: adapt mesh\n');
0015   choi=asknu('your choice:',choi); 
0016 end
0017 switch choi;
0018   case 0; stepok=-1; return; 
0019   case 1; p.dsmin=p.dsmin/2; p.dsmin=asknu('new dsmin',p.dsmin); 
0020   case 2; p.tol=p.tol*2; p.tol=asknu('new tol',p.tol); if (res<p.tol); stepok=1; end; 
0021   case 3; p.imax=asknu('imax',p.imax); p.dlammax=asknu('new dlammax',p.dlammax);
0022   case 4; p.imax=asknu('imax',p.imax);
0023       [u1,res,iter,Gu,Glam]=nlooppde(p,u1,lam1); 
0024       if(res<p.tol) fprintf('now res=%g, OK\n',res); stepok=1; end 
0025   case 5; p.imax=asknu('imax',p.imax); [p,res]=meshref(p); p.ds=dss; 
0026   case 6; p.imax=asknu('imax',p.imax); [p,res]=meshadac(p); p.ds=dss; 
0027 end

Generated on Wed 15-Aug-2012 10:09:15 by m2html © 2005