source: issm/trunk-jpl/src/m/classes/SMBforcing.js@ 26300

Last change on this file since 26300 was 26300, checked in by dlcheng, 4 years ago

CHG (JS): Large update of JS classes in for solid earth/sea level solver.

File size: 3.3 KB
Line 
1//SMBforcing Class definition
2//
3// Usage:
4// SMB=SMBforcing();
5
6function 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,'steps_per_step', 'number of smb steps per time step');
15 fielddisplay(this,'requested_outputs','additional outputs requested');
16 fielddisplay(this,'averaging','averaging methods from short to long steps');
17 console.log(sprintf('%51s 0: Arithmetic (default)',' '));
18 console.log(sprintf('%51s 1: Geometric',' '));
19 console.log(sprintf('%51s 2: Harmonic',' '));
20 } // }}}
21 this.defaultoutputs = function(){ // {{{
22 return '';
23 }//}}}
24 this.classname = function(){ // {{{
25 return "SMBforcing";
26 } // }}}
27 this.extrude = function(md) {//{{{
28 this.mass_balance=project3d(md,'vector',this.mass_balance,'type','node');
29 return this;
30 }//}}}
31 this.initialize = function(md) {// {{{
32
33 if (isNaN(this.mass_balance)){
34 this.mass_balance=NewArrayFill(md.mesh.numberofvertices,0);
35 console.log(' no smb.mass_balance specified: values set as zero');
36 }
37
38 } // }}}
39 this.checkconsistency = function(md,solution,analyses) { //{{{
40 if (solution=='TransientSolution' && md.transient.issmb == 0) return;
41 if(ArrayAnyEqual(ArrayIsMember('MasstransportAnalysis',analyses),1)){
42 checkfield(md,'fieldname','smb.mass_balance','timeseries',1,'NaN',1,'Inf',1);
43 }
44 if(ArrayAnyEqual(ArrayIsMember('BalancethicknessAnalysis',analyses),1)){
45 checkfield(md,'fieldname','smb.mass_balance','size',[md.mesh.numberofvertices,1],'NaN',1,'Inf',1);
46 }
47 checkfield(md,'fieldname','smb.steps_per_step','>=',1,'numel',[1]);
48 checkfield(md,'fieldname','smb.requested_outputs','stringrow',1);
49 checkfield(md,'fieldname','smb.averaging','numel',[1],'values',[0,1,2]);
50 } // }}}
51 this.marshall=function(md,prefix,fid) { //{{{
52
53 var yts=md.constants.yts;
54
55 WriteData(fid,prefix,'name','md.smb.model','data',1,'format','Integer');
56 WriteData(fid,prefix,'object',this,'class','smb','fieldname','mass_balance','format','DoubleMat','mattype',1,'scale',1./yts,'timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
57 WriteData(fid,prefix,'object',this,'fieldname','steps_per_step','format','Integer');
58 WriteData(fid,prefix,'object',this,'fieldname','averaging','format','Integer');
59
60 //process requested outputs
61 var outputs = this.requested_outputs.slice();
62 for (var i=0;i<outputs.length;i++){
63 if (outputs[i] == 'default') {
64 outputs.splice(i,1);
65 var newoutputs=this.defaultoutputs(md);
66 for (var j=0;j<newoutputs.length;j++) outputs.push(newoutputs[j]);
67 }
68 }
69 WriteData(fid,prefix,'data',outputs,'name','md.smb.requested_outputs','format','StringArray');
70
71 }//}}}
72 this.fix=function() { //{{{
73 }//}}}
74 //properties
75 // {{{
76 this.mass_balance = NaN;
77 this.requested_outputs = [];
78 this.steps_per_step = 1;
79 this.averaging = 0;
80 this.setdefaultparameters();
81 // }}}
82}
Note: See TracBrowser for help on using the repository browser.