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

Last change on this file since 11427 was 9734, checked in by seroussi, 14 years ago

finished mesh

  • Property svn:executable set to *
File size: 740 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 < c / ( u/Dx +v/Dy )
5%
6% Usage:
7% maxtime=cfl_step(md,vx,vy);
8%
9% Example:
10% dt=cfl_step(md,md.results.diagnostic.vx,md.results.diagnostic.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.