source: issm/trunk/src/m/classes/timesteppingadaptive.js@ 22758

Last change on this file since 22758 was 22758, checked in by Mathieu Morlighem, 7 years ago

merged trunk-jpl and trunk for revision 22757

File size: 3.4 KB
Line 
1//TIMESTEPPINGADAPTIVE class definition
2//
3// Usage:
4// timesteppingadaptive=new timesteppingadaptive();
5
6function timesteppingadaptive (){
7 //methods
8 this.setdefaultparameters = function(){// {{{
9 //time between 2 time steps
10 this.time_step_min=0.01;
11 this.time_step_max=10.;
12
13 //final time
14 this.final_time=10.*this.time_step_max;
15
16 //time adaptation?
17 this.cfl_coefficient=0.5;
18
19 //should we interpolate forcings between timesteps?
20 this.interp_forcings=1;
21 }// }}}
22 this.disp= function(){// {{{
23
24 var unit;
25 console.log(sprintf(' timesteppingadaptive parameters:'));
26 unit = 'yr';
27 fielddisplay(this,'start_time','simulation starting time ['+ unit + ']');
28 fielddisplay(this,'final_time','final time to stop the simulation ['+ unit + ']');
29 fielddisplay(this,'time_step_min','minimum length of time steps [' +unit+ ']');
30 fielddisplay(this,'time_step_max','maximum length of time steps [' +unit+ ']');
31 fielddisplay(this,'cfl_coefficient','coefficient applied to cfl condition');
32 fielddisplay(this,'interp_forcings','interpolate in time between requested forcing values ? (0 or 1)');
33 fielddisplay(this,'coupling_time','coupling time steps with ocean model [' +unit+ ']');
34
35 }// }}}
36 this.classname= function(){// {{{
37 return "timesteppingadaptive";
38
39 }// }}}
40 this.checkconsistency = function(md,solution,analyses) { //{{{
41
42 checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1,'Inf',1);
43 checkfield(md,'fieldname','timestepping.final_time','numel',[1],'NaN',1,'Inf',1);
44 checkfield(md,'fieldname','timestepping.time_step_min','numel',[1],'>=',0,'NaN',1,'Inf',1);
45 checkfield(md,'fieldname','timestepping.time_step_max','numel',[1],'>=',md.timestepping.time_step_max,'NaN',1,'Inf',1);
46 checkfield(md,'fieldname','timestepping.cfl_coefficient','numel',[1],'>',0,'<=',1);
47 checkfield(md,'fieldname','timestepping.interp_forcings','numel',[1],'values',[0,1]);
48 if (this.final_time-this.start_time<0){
49 md.checkmessage('timestepping.final_time should be larger than timestepping.start_time');
50 }
51 checkfield(md,'fieldname','timestepping.coupling_time','numel',[1],'>=',0,'NaN',1,'Inf',1);
52 } // }}}
53 this.marshall=function(md,prefix,fid) { //{{{
54
55 var scale;
56 scale = md.constants.yts;
57
58 WriteData(fid,prefix,'name','md.timestepping.type','data',2,'format','Integer');
59 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','start_time','format','Double','scale',scale);
60 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','final_time','format','Double','scale',scale);
61 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','time_step_min','format','Double','scale',scale);
62 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','time_step_max','format','Double','scale',scale);
63 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','cfl_coefficient','format','Double');
64 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','interp_forcings','format','Boolean');
65 WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','coupling_time','format','Double','scale',scale);
66
67 }//}}}
68 this.fix=function() { //{{{
69 }//}}}
70 //properties
71 // {{{
72 this.start_time = 0.;
73 this.final_time = 0.;
74 this.time_step_min = 0.;
75 this.time_step_max = 0.;
76 this.cfl_coefficient = 0.;
77 this.interp_forcings = 1;
78 this.coupling_time = 0.;
79
80 this.setdefaultparameters();
81 //}}}
82}
Note: See TracBrowser for help on using the repository browser.