[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 | }//}}}
|
---|
[20801] | 19 | this.classname = function(){ // {{{
|
---|
| 20 | return "SMBforcing";
|
---|
| 21 | } // }}}
|
---|
| 22 | this.extrude = function(md) {//{{{
|
---|
| 23 | this.mass_balance=project3d(md,'vector',this.mass_balance,'type','node');
|
---|
| 24 | }//}}}
|
---|
| 25 | this.initialize = function(md) {// {{{
|
---|
[19759] | 26 |
|
---|
[20801] | 27 | if (isNaN(this.mass_balance)){
|
---|
| 28 | this.mass_balance=NewArrayFill(md.mesh.numberofvertices,0);
|
---|
| 29 | console.log(' no smb.mass_balance specified: values set as zero');
|
---|
| 30 | }
|
---|
[19759] | 31 |
|
---|
[20801] | 32 | } // }}}
|
---|
| 33 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
[19780] | 34 |
|
---|
[20801] | 35 | if(ArrayAnyEqual(ArrayIsMember(MasstransportAnalysisEnum(),analyses),1)){
|
---|
| 36 | checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1,'Inf',1);
|
---|
| 37 | }
|
---|
| 38 | if(ArrayAnyEqual(ArrayIsMember(BalancethicknessAnalysisEnum(),analyses),1)){
|
---|
| 39 | checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices,1],'NaN',1,'Inf',1);
|
---|
| 40 | }
|
---|
| 41 | checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
|
---|
[19780] | 42 |
|
---|
[20801] | 43 | } // }}}
|
---|
| 44 | this.marshall=function(md,prefix,fid) { //{{{
|
---|
[19791] | 45 |
|
---|
[20801] | 46 | var yts=365.0*24.0*3600.0;
|
---|
[19791] | 47 |
|
---|
[20801] | 48 | WriteData(fid,prefix,'name','md.smb.model','data',SMBforcingEnum(),'format','Integer');
|
---|
| 49 | WriteData(fid,prefix,'object',this,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1);
|
---|
[19791] | 50 |
|
---|
[20801] | 51 | //process requested outputs
|
---|
| 52 | var outputs = this.requested_outputs.slice();
|
---|
| 53 | for (var i=0;i<outputs.length;i++){
|
---|
| 54 | if (outputs[i] == 'default') {
|
---|
| 55 | outputs.splice(i,1);
|
---|
| 56 | var newoutputs=this.defaultoutputs(md);
|
---|
| 57 | for (var j=0;j<newoutputs.length;j++) outputs.push(newoutputs[j]);
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray');
|
---|
| 61 |
|
---|
| 62 | }//}}}
|
---|
| 63 | this.fix=function() { //{{{
|
---|
| 64 | }//}}}
|
---|
[19753] | 65 | //properties
|
---|
| 66 | this.mass_balance = NaN;
|
---|
[19793] | 67 | this.requested_outputs = [];
|
---|
[19753] | 68 | this.setdefaultparameters();
|
---|
| 69 | }
|
---|