[21787] | 1 | //TIMESTEPPINGADAPTIVE class definition
|
---|
| 2 | //
|
---|
| 3 | // Usage:
|
---|
| 4 | // timesteppingadaptive=new timesteppingadaptive();
|
---|
| 5 |
|
---|
| 6 | function 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;
|
---|
[26744] | 21 | this.cycle_forcing=0;
|
---|
[21787] | 22 | }// }}}
|
---|
| 23 | this.disp= function(){// {{{
|
---|
| 24 |
|
---|
| 25 | var unit;
|
---|
| 26 | console.log(sprintf(' timesteppingadaptive parameters:'));
|
---|
| 27 | unit = 'yr';
|
---|
| 28 | fielddisplay(this,'start_time','simulation starting time ['+ unit + ']');
|
---|
| 29 | fielddisplay(this,'final_time','final time to stop the simulation ['+ unit + ']');
|
---|
| 30 | fielddisplay(this,'time_step_min','minimum length of time steps [' +unit+ ']');
|
---|
| 31 | fielddisplay(this,'time_step_max','maximum length of time steps [' +unit+ ']');
|
---|
| 32 | fielddisplay(this,'cfl_coefficient','coefficient applied to cfl condition');
|
---|
| 33 | fielddisplay(this,'interp_forcings','interpolate in time between requested forcing values ? (0 or 1)');
|
---|
[26744] | 34 | fielddisplay(this,'cycle_forcing','cycle through forcing ? (0 or 1)');
|
---|
[22459] | 35 | fielddisplay(this,'coupling_time','coupling time steps with ocean model [' +unit+ ']');
|
---|
[21787] | 36 |
|
---|
| 37 | }// }}}
|
---|
| 38 | this.classname= function(){// {{{
|
---|
| 39 | return "timesteppingadaptive";
|
---|
| 40 |
|
---|
| 41 | }// }}}
|
---|
| 42 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
| 43 |
|
---|
| 44 | checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1,'Inf',1);
|
---|
| 45 | checkfield(md,'fieldname','timestepping.final_time','numel',[1],'NaN',1,'Inf',1);
|
---|
| 46 | checkfield(md,'fieldname','timestepping.time_step_min','numel',[1],'>=',0,'NaN',1,'Inf',1);
|
---|
| 47 | checkfield(md,'fieldname','timestepping.time_step_max','numel',[1],'>=',md.timestepping.time_step_max,'NaN',1,'Inf',1);
|
---|
| 48 | checkfield(md,'fieldname','timestepping.cfl_coefficient','numel',[1],'>',0,'<=',1);
|
---|
| 49 | checkfield(md,'fieldname','timestepping.interp_forcings','numel',[1],'values',[0,1]);
|
---|
[26744] | 50 | checkfield(md,'fieldname','timestepping.cycle_forcing','numel',[1],'values',[0,1]);
|
---|
[21787] | 51 | if (this.final_time-this.start_time<0){
|
---|
| 52 | md.checkmessage('timestepping.final_time should be larger than timestepping.start_time');
|
---|
| 53 | }
|
---|
[22459] | 54 | checkfield(md,'fieldname','timestepping.coupling_time','numel',[1],'>=',0,'NaN',1,'Inf',1);
|
---|
[21787] | 55 | } // }}}
|
---|
| 56 | this.marshall=function(md,prefix,fid) { //{{{
|
---|
| 57 |
|
---|
| 58 | var scale;
|
---|
| 59 | scale = md.constants.yts;
|
---|
| 60 |
|
---|
| 61 | WriteData(fid,prefix,'name','md.timestepping.type','data',2,'format','Integer');
|
---|
| 62 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','start_time','format','Double','scale',scale);
|
---|
| 63 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','final_time','format','Double','scale',scale);
|
---|
| 64 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','time_step_min','format','Double','scale',scale);
|
---|
| 65 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','time_step_max','format','Double','scale',scale);
|
---|
| 66 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','cfl_coefficient','format','Double');
|
---|
| 67 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','interp_forcings','format','Boolean');
|
---|
[26744] | 68 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','cycle_forcing','format','Boolean');
|
---|
[22459] | 69 | WriteData(fid,prefix,'object',this,'class','timestepping','fieldname','coupling_time','format','Double','scale',scale);
|
---|
[21787] | 70 |
|
---|
| 71 | }//}}}
|
---|
| 72 | this.fix=function() { //{{{
|
---|
| 73 | }//}}}
|
---|
| 74 | //properties
|
---|
| 75 | // {{{
|
---|
| 76 | this.start_time = 0.;
|
---|
| 77 | this.final_time = 0.;
|
---|
| 78 | this.time_step_min = 0.;
|
---|
| 79 | this.time_step_max = 0.;
|
---|
| 80 | this.cfl_coefficient = 0.;
|
---|
| 81 | this.interp_forcings = 1;
|
---|
[26744] | 82 | this.cycle_forcing = 0;
|
---|
[22459] | 83 | this.coupling_time = 0.;
|
---|
[21787] | 84 |
|
---|
| 85 | this.setdefaultparameters();
|
---|
| 86 | //}}}
|
---|
| 87 | }
|
---|