[19753] | 1 | //TIMESTEPPING class definition
|
---|
| 2 | //
|
---|
| 3 | // Usage:
|
---|
| 4 | // timestepping=new timestepping();
|
---|
| 5 |
|
---|
| 6 | function 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 | this.disp= function(){// {{{
|
---|
[19860] | 23 |
|
---|
| 24 | var unit;
|
---|
[19753] | 25 | console.log(sprintf(' timestepping parameters:'));
|
---|
[19857] | 26 | unit = 'yr';
|
---|
[19753] | 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','length of time steps [' +unit+ ']');
|
---|
| 30 | fielddisplay(this,'time_adapt','use cfl condition to define time step ? (0 or 1) ');
|
---|
| 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 |
|
---|
| 34 | }// }}}
|
---|
[19791] | 35 | this.classname= function(){// {{{
|
---|
| 36 | return "timestepping";
|
---|
| 37 |
|
---|
| 38 | }// }}}
|
---|
[19780] | 39 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
| 40 |
|
---|
[19901] | 41 | checkfield(md,'fieldname','timestepping.start_time','numel',[1],'NaN',1,'Inf',1);
|
---|
| 42 | checkfield(md,'fieldname','timestepping.final_time','numel',[1],'NaN',1,'Inf',1);
|
---|
| 43 | checkfield(md,'fieldname','timestepping.time_step','numel',[1],'>=',0,'NaN',1,'Inf',1);
|
---|
[19780] | 44 | checkfield(md,'fieldname','timestepping.time_adapt','numel',[1],'values',[0,1]);
|
---|
| 45 | checkfield(md,'fieldname','timestepping.cfl_coefficient','numel',[1],'>',0,'<=',1);
|
---|
| 46 | checkfield(md,'fieldname','timestepping.interp_forcings','numel',[1],'values',[0,1]);
|
---|
| 47 | if (this.final_time-this.start_time<0){
|
---|
| 48 | md.checkmessage('timestepping.final_time should be larger than timestepping.start_time');
|
---|
| 49 | }
|
---|
| 50 | } // }}}
|
---|
[19791] | 51 | this.marshall=function(md,fid) { //{{{
|
---|
| 52 |
|
---|
| 53 | var scale;
|
---|
[19857] | 54 | scale = 365.0*24.0*3600.0;
|
---|
[19791] | 55 |
|
---|
[20690] | 56 | WriteData(fid,prefix,'object',this,'fieldname','start_time','format','Double','scale',scale);
|
---|
| 57 | WriteData(fid,prefix,'object',this,'fieldname','final_time','format','Double','scale',scale);
|
---|
| 58 | WriteData(fid,prefix,'object',this,'fieldname','time_step','format','Double','scale',scale);
|
---|
| 59 | WriteData(fid,prefix,'object',this,'fieldname','time_adapt','format','Boolean');
|
---|
| 60 | WriteData(fid,prefix,'object',this,'fieldname','cfl_coefficient','format','Double');
|
---|
| 61 | WriteData(fid,prefix,'object',this,'fieldname','interp_forcings','format','Boolean');
|
---|
[19791] | 62 |
|
---|
| 63 | }//}}}
|
---|
[19860] | 64 | this.fix=function() { //{{{
|
---|
| 65 | }//}}}
|
---|
[19753] | 66 | //properties
|
---|
| 67 | // {{{
|
---|
| 68 | this.start_time = 0.;
|
---|
| 69 | this.final_time = 0.;
|
---|
| 70 | this.time_step = 0.;
|
---|
| 71 | this.time_adapt = 0;
|
---|
| 72 | this.cfl_coefficient = 0.;
|
---|
| 73 | this.interp_forcings = 1;
|
---|
| 74 |
|
---|
| 75 | this.setdefaultparameters();
|
---|
| 76 | //}}}
|
---|
| 77 | }
|
---|