source: issm/trunk-jpl/src/m/classes/timestepping.js@ 19780

Last change on this file since 19780 was 19780, checked in by Eric.Larour, 9 years ago

NEW,CHG: going through consistency check for classes.

File size: 2.1 KB
Line 
1//TIMESTEPPING class definition
2//
3// Usage:
4// timestepping=new timestepping();
5
6function timestepping (){
7 //methods
8 this.setdefaultparameters = function(){// {{{
9 //time between 2 time steps
10 this.time_step=1./2.;
11
12 //final time
13 this.final_time=10.*this.time_step;
14
15 //time adaptation?
16 this.time_adapt=0;
17 this.cfl_coefficient=0.5;
18
19 //should we interpolate forcings between timesteps?
20 this.interp_forcings=1;
21
22 //In years by default
23 this.in_years = 1;
24
25 }// }}}
26 this.disp= function(){// {{{
27 console.log(sprintf(' timestepping parameters:'));
28
29 if(this.in_years) unit = 'yr';
30 else unit = 's';
31 fielddisplay(this,'start_time','simulation starting time ['+ unit + ']');
32 fielddisplay(this,'final_time','final time to stop the simulation ['+ unit + ']');
33 fielddisplay(this,'time_step','length of time steps [' +unit+ ']');
34 fielddisplay(this,'time_adapt','use cfl condition to define time step ? (0 or 1) ');
35 fielddisplay(this,'cfl_coefficient','coefficient applied to cfl condition');
36 fielddisplay(this,'interp_forcings','interpolate in time between requested forcing values ? (0 or 1)');
37 fielddisplay(this,'in_years','time unit, 1: years, 0: seconds');
38
39
40 }// }}}
41 this.checkconsistency = function(md,solution,analyses) { //{{{
42
43 checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1);
44 checkfield(md,'fieldname','timestepping.final_time','numel',[1],'NaN',1);
45 checkfield(md,'fieldname','timestepping.time_step','numel',[1],'>=',0,'NaN',1);
46 checkfield(md,'fieldname','timestepping.time_adapt','numel',[1],'values',[0,1]);
47 checkfield(md,'fieldname','timestepping.cfl_coefficient','numel',[1],'>',0,'<=',1);
48 checkfield(md,'fieldname','timestepping.interp_forcings','numel',[1],'values',[0,1]);
49 if (this.final_time-this.start_time<0){
50 md.checkmessage('timestepping.final_time should be larger than timestepping.start_time');
51 }
52 } // }}}
53 //properties
54 // {{{
55 this.start_time = 0.;
56 this.final_time = 0.;
57 this.time_step = 0.;
58 this.time_adapt = 0;
59 this.cfl_coefficient = 0.;
60 this.interp_forcings = 1;
61 this.in_years = 1;
62
63 this.setdefaultparameters();
64 //}}}
65}
Note: See TracBrowser for help on using the repository browser.