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