source: issm/branches/trunk-jpl-damage/src/m/utils/Numerics/cfl_step.m@ 12878

Last change on this file since 12878 was 12878, checked in by cborstad, 13 years ago

merged trunk-jpl into trunk-jpl-damage through revision 12877

  • Property svn:executable set to *
File size: 757 bytes
Line 
1function maxtime=cfl_step(md,vx,vy);
2%CFL_STEP - return the maximum time step for the model in years
3%
4% Dt < 0.5 / ( u/Dx +v/Dy )
5%
6% Usage:
7% maxtime=cfl_step(md,vx,vy);
8%
9% Example:
10% dt=cfl_step(md,md.results.DiagnosticSolution.Vx,md.results.DiagnosticSolution.Vy)
11
12%Check length of velocities
13if size(vx,1)~=md.mesh.numberofvertices & size(vy,1)~=md.mesh.numberofvertices,
14 error('timestpes error message: size of velocity components must be the same as md.mesh.numberofvertices');
15end
16
17index=md.mesh.elements;
18edgex=max(md.mesh.x(index),[],2)-min(md.mesh.x(index),[],2);
19edgey=max(md.mesh.y(index),[],2)-min(md.mesh.y(index),[],2);
20vx=max(abs(vx(index)),[],2);
21vy=max(abs(vy(index)),[],2);
22
23maxtime=1/2*min(1./(vx./edgex+vy./edgey));
Note: See TracBrowser for help on using the repository browser.