Home > p2plib > getder.m

getder

PURPOSE ^

calc Gu, Glam depending on p.jsw;

SYNOPSIS ^

function [Gu,Glam]=getder(p,u,lam,r)

DESCRIPTION ^

 calc Gu, Glam depending on p.jsw;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Gu,Glam]=getder(p,u,lam,r) 
0002 % calc Gu, Glam depending on p.jsw;
0003 global pj lamj; % for call of numjac
0004 bc=p.bcf(p,u,lam); zerov=zeros(p.neq,1); del=1e-6; % for FD in lam
0005 if(p.jsw==0) % Gu and Glam analytically
0006    [c,fu,flam,b]=p.jac(p,u,lam);
0007    [Gu,Glam]=assempde(bc,p.points,p.edges,p.tria,c,-fu,-flam); 
0008    if(any(b)) Kadv=assemadv(p.points,p.tria,b); %,p.neq);
0009        %i=pdesde(p.edges); for m=0:p.neq-1; Kadv(i+m*p.np,:)=0; end % edge-Zeilen zu null setzen
0010        Gu=Gu-Kadv; 
0011    end 
0012 end
0013 if(p.jsw==1) % Gu analytically, Glam numerically
0014    [c,fu,flam,b]=p.jac(p,u,lam);
0015    [Gu,Glam]=assempde(bc,p.points,p.edges,p.tria,c,-fu,zerov);
0016    if(any(b)) Kadv=assemadv(p.points,p.tria,b); %,p.neq);
0017        %i=pdesde(p.edges); for m=0:p.neq-1; Kadv(i+m*p.np,:)=0; end % edge-Zeilen zu null setzen
0018        Gu=Gu-Kadv; 
0019    end 
0020    r1=resi(p,u,lam+del);Glam=-(r-r1)/del; 
0021 end
0022 if(p.jsw==2) % Gu numerically, easy resinj, Glam analytically
0023   [S,F]=assempde(bc,p.points,p.edges,p.tria,0,ones(p.neq*p.neq,1),0,ones(p.np*p.neq,1));
0024   thresh=del*ones(size(u)); pj=p; lamj=lam; % global variable to pass to resinj
0025   [Gu,fac,G]=numjac('resinj',0,u,r,thresh,[],0,S,[]); % numerical F_u
0026   [c,fu,flam]=p.jac(p,u,lam);[Gus,Glam]=assempde(bc,p.points,p.edges,p.tria,c,-fu,-flam); 
0027  end
0028 if(p.jsw==3) % both numerically
0029   [S,F]=assempde(bc,p.points,p.edges,p.tria,0,ones(p.neq*p.neq,1),0,ones(p.np*p.neq,1));
0030   thresh=del*ones(size(u)); pj=p; lamj=lam; % global variables to pass to resinj
0031   [Gu,fac,G]=numjac('resinj',0,u,r,thresh,[],0,S,[]);
0032   r1=resi(p,u,lam+del);Glam=-(r-r1)/del; 
0033 end

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