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