1 | //SMBforcing Class definition
|
---|
2 | //
|
---|
3 | // Usage:
|
---|
4 | // SMB=SMBforcing();
|
---|
5 |
|
---|
6 | function SMBforcing(){
|
---|
7 | //methods
|
---|
8 | this.setdefaultparameters = function(){// {{{
|
---|
9 | this.requested_outputs=['default'];
|
---|
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 | } // }}}
|
---|
16 | this.defaultoutputs = function(){ // {{{
|
---|
17 | return '';
|
---|
18 | }//}}}
|
---|
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 | return this;
|
---|
25 | }//}}}
|
---|
26 | this.initialize = function(md) {// {{{
|
---|
27 |
|
---|
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 | }
|
---|
32 |
|
---|
33 | } // }}}
|
---|
34 | this.checkconsistency = function(md,solution,analyses) { //{{{
|
---|
35 |
|
---|
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);
|
---|
43 |
|
---|
44 | } // }}}
|
---|
45 | this.marshall=function(md,prefix,fid) { //{{{
|
---|
46 |
|
---|
47 | var yts=md.constants.yts;
|
---|
48 |
|
---|
49 | WriteData(fid,prefix,'name','md.smb.model','data',1,'format','Integer');
|
---|
50 | WriteData(fid,prefix,'object',this,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1);
|
---|
51 |
|
---|
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 | }//}}}
|
---|
66 | //properties
|
---|
67 | // {{{
|
---|
68 | this.mass_balance = NaN;
|
---|
69 | this.requested_outputs = [];
|
---|
70 | this.setdefaultparameters();
|
---|
71 | // }}}
|
---|
72 | }
|
---|