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

Last change on this file was 26304, checked in by Mathieu Morlighem, 4 years ago

CHG: minor

File size: 2.9 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 //should we interpolate forcings between timesteps?
16 this.interp_forcing=1;
17 this.cycle_forcing=0;
18 } //}}}
19 this.disp= function(){ //{{{
20
21 var unit;
22 console.log(sprintf(' timestepping parameters:'));
23 unit = 'yr';
24 fielddisplay(this,'start_time','simulation starting time ['+ unit + ']');
25 fielddisplay(this,'final_time','final time to stop the simulation ['+ unit + ']');
26 fielddisplay(this,'time_step','length of time steps [' +unit+ ']');
27 fielddisplay(this,'interp_forcing','interpolate in time between requested forcing values ? (0 or 1)');
28 fielddisplay(this,'cycle_forcing','cycle through forcing ? (0 or 1)');
29 fielddisplay(this,'coupling_time','length of coupling time steps with ocean model [' +unit+ ']');
30
31 } //}}}
32 this.classname= function(){ //{{{
33 return "timestepping";
34
35 } //}}}
36 this.checkconsistency = function(md,solution,analyses) { //{{{
37
38 checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1,'Inf',1);
39 checkfield(md,'fieldname','timestepping.final_time','numel',[1],'NaN',1,'Inf',1);
40 checkfield(md,'fieldname','timestepping.time_step','numel',[1],'>=',0,'NaN',1,'Inf',1);
41 checkfield(md,'fieldname','timestepping.interp_forcing','numel',[1],'values',[0,1]);
42 checkfield(md,'fieldname','timestepping.cycle_forcing','numel',[1],'values',[0,1]);
43 checkfield(md,'fieldname','timestepping.coupling_time','numel',[1],'>=',0,'NaN',1,'Inf',1);
44 if (this.final_time-this.start_time<0){
45 md.checkmessage('timestepping.final_time should be larger than timestepping.start_time');
46 }
47 if (solution=='TransientSolution'){
48 checkfield(md,'fieldname','timestepping.time_step','numel',[1],'>',0,'NaN',1,'Inf',1);
49 }
50 } // }}}
51 this.marshall=function(md,prefix,fid) { //{{{
52
53 var scale;
54 scale = md.constants.yts;
55
56 WriteData(fid,prefix,'name','md.timestepping.type','data',1,'format','Integer');
57 WriteData(fid,prefix,'object',this,'fieldname','start_time','format','Double','scale',scale);
58 WriteData(fid,prefix,'object',this,'fieldname','final_time','format','Double','scale',scale);
59 WriteData(fid,prefix,'object',this,'fieldname','time_step','format','Double','scale',scale);
60 WriteData(fid,prefix,'object',this,'fieldname','interp_forcing','format','Boolean');
61 WriteData(fid,prefix,'object',this,'fieldname','cycle_forcing','format','Boolean');
62 WriteData(fid,prefix,'object',this,'fieldname','coupling_time','format','Double','scale',scale);
63
64 }//}}}
65 this.fix=function() { //{{{
66 }//}}}
67 //properties
68 // {{{
69 this.start_time = 0.;
70 this.final_time = 0.;
71 this.time_step = 0.;
72 this.interp_forcing = 1;
73 this.cycle_forcing = 1;
74 this.coupling_time = 0.;
75
76 this.setdefaultparameters();
77 //}}}
78}
Note: See TracBrowser for help on using the repository browser.