[19753] | 1 | //SMBforcing Class definition
|
---|
| 2 | //
|
---|
| 3 | // Usage:
|
---|
| 4 | // SMB=SMBforcing();
|
---|
| 5 |
|
---|
| 6 | function SMBforcing(){
|
---|
| 7 | //methods
|
---|
| 8 | this.setdefaultparameters = function(){// {{{
|
---|
[19860] | 9 | this.requested_outputs=['default'];
|
---|
[19753] | 10 | } // }}}
|
---|
| 11 | this.disp = function(){ // {{{
|
---|
| 12 | console.log(sprintf(' surface forcings parameters:'));
|
---|
| 13 | fielddisplay(this,'mass_balance','surface mass balance [m/yr ice eq]');
|
---|
| 14 | fielddisplay(this,'requested_outputs','additional outputs requested');
|
---|
| 15 | } // }}}
|
---|
[19791] | 16 | this.defaultoutputs = function(){ // {{{
|
---|
| 17 | return '';
|
---|
| 18 | }//}}}
|
---|
| 19 | this.classname = function(){ // {{{
|
---|
| 20 | return "SMBforcing";
|
---|
| 21 | } // }}}
|
---|
[19759] | 22 | this.initialize = function(md) {// {{{
|
---|
| 23 |
|
---|
[20690] | 24 | if (isNaN(this.mass_balance)){
|
---|
| 25 | this.mass_balance=NewArrayFill(md.mesh.numberofvertices,0);
|
---|
[19759] | 26 | console.log(' no smb.mass_balance specified: values set as zero');
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | } // }}}
|
---|
[19780] | 30 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
| 31 |
|
---|
| 32 | if(ArrayAnyEqual(ArrayIsMember(MasstransportAnalysisEnum(),analyses),1)){
|
---|
[19901] | 33 | checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1,'Inf',1);
|
---|
[19780] | 34 | }
|
---|
| 35 | if(ArrayAnyEqual(ArrayIsMember(BalancethicknessAnalysisEnum(),analyses),1)){
|
---|
[19901] | 36 | checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices,1],'NaN',1,'Inf',1);
|
---|
[19780] | 37 | }
|
---|
| 38 | checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
|
---|
| 39 |
|
---|
| 40 | } // }}}
|
---|
[20777] | 41 | this.marshall=function(md,prefix,fid) { //{{{
|
---|
[19791] | 42 |
|
---|
| 43 | var yts=365.0*24.0*3600.0;
|
---|
| 44 |
|
---|
[20690] | 45 | WriteData(fid,prefix,'name','md.smb.model','data',SMBforcingEnum(),'format','Integer');
|
---|
| 46 | WriteData(fid,prefix,'object',this,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1);
|
---|
[19791] | 47 |
|
---|
| 48 | //process requested outputs
|
---|
[19860] | 49 | var outputs = this.requested_outputs.slice();
|
---|
[19793] | 50 | for (var i=0;i<outputs.length;i++){
|
---|
[19791] | 51 | if (outputs[i] == 'default') {
|
---|
| 52 | outputs.splice(i,1);
|
---|
[19860] | 53 | var newoutputs=this.defaultoutputs(md);
|
---|
[19793] | 54 | for (var j=0;j<newoutputs.length;j++) outputs.push(newoutputs[j]);
|
---|
[19791] | 55 | }
|
---|
| 56 | }
|
---|
[20690] | 57 | WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray');
|
---|
[19791] | 58 |
|
---|
| 59 | }//}}}
|
---|
[19860] | 60 | this.fix=function() { //{{{
|
---|
| 61 | }//}}}
|
---|
[19753] | 62 | //properties
|
---|
| 63 | this.mass_balance = NaN;
|
---|
[19793] | 64 | this.requested_outputs = [];
|
---|
[19753] | 65 | this.setdefaultparameters();
|
---|
| 66 | }
|
---|