1 | %SOLIDEARTH class definition
|
---|
2 | %
|
---|
3 | % Usage:
|
---|
4 | % solidearth=solidearth();
|
---|
5 |
|
---|
6 | classdef solidearth
|
---|
7 | properties (SetAccess=public)
|
---|
8 | sealevel = NaN;
|
---|
9 | settings = solidearthsettings();
|
---|
10 | surfaceload = surfaceload();
|
---|
11 | lovenumbers = lovenumbers();
|
---|
12 | rotational = rotational();
|
---|
13 | planetradius = planetradius('earth');
|
---|
14 | requested_outputs = {};
|
---|
15 | transitions = {};
|
---|
16 | partitionice = [];
|
---|
17 | partitionhydro = [];
|
---|
18 | end
|
---|
19 | methods
|
---|
20 | function self = solidearth(varargin) % {{{
|
---|
21 | switch nargin
|
---|
22 | case 0
|
---|
23 | self=setdefaultparameters(self,earth);
|
---|
24 | case 1
|
---|
25 | self=setdefaultparameters(self,varargin{:});
|
---|
26 | otherwise
|
---|
27 | error('solidearth constructor error message: zero or one argument only!');
|
---|
28 | end
|
---|
29 | end % }}}
|
---|
30 | function self = setdefaultparameters(self,planet) % {{{
|
---|
31 |
|
---|
32 | %output default:
|
---|
33 | self.requested_outputs={'default'};
|
---|
34 |
|
---|
35 | %transitions should be a cell array of vectors:
|
---|
36 | self.transitions={};
|
---|
37 |
|
---|
38 | %no partitions requested for barystatic contribution:
|
---|
39 | self.partitionice=[];
|
---|
40 | self.partitionhydro=[];
|
---|
41 |
|
---|
42 | %earth radius
|
---|
43 | self.planetradius= planetradius(planet);
|
---|
44 |
|
---|
45 | end % }}}
|
---|
46 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
47 |
|
---|
48 | if ~ismember('SealevelriseAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.isslr==0),
|
---|
49 | return;
|
---|
50 | end
|
---|
51 |
|
---|
52 | md = checkfield(md,'fieldname','solidearth.sealevel','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
|
---|
53 | md = checkfield(md,'fieldname','solidearth.requested_outputs','stringrow',1);
|
---|
54 |
|
---|
55 | self.settings.checkconsistency(md,solution,analyses);
|
---|
56 | self.surfaceload.checkconsistency(md,solution,analyses);
|
---|
57 | self.lovenumbers.checkconsistency(md,solution,analyses);
|
---|
58 | self.rotational.checkconsistency(md,solution,analyses);
|
---|
59 |
|
---|
60 |
|
---|
61 | end % }}}
|
---|
62 | function list=defaultoutputs(self,md) % {{{
|
---|
63 | list = {'Sealevel'};
|
---|
64 | end % }}}
|
---|
65 | function disp(self) % {{{
|
---|
66 | disp(sprintf(' solidearth inputs, forcings and settings:'));
|
---|
67 |
|
---|
68 | fielddisplay(self,'sealevel','current sea level (prior to computation) [m]');
|
---|
69 | fielddisplay(self,'planetradius','planet radius [m]');
|
---|
70 | fielddisplay(self,'transitions','indices into parts of the mesh that will be icecaps');
|
---|
71 | fielddisplay(self,'requested_outputs','additional outputs requested');
|
---|
72 | fielddisplay(self,'partitionice','ice partition vector for barystatic contribution');
|
---|
73 | fielddisplay(self,'partitionhydro','hydro partition vector for barystatic contribution');
|
---|
74 | self.settings.disp();
|
---|
75 | self.surfaceload.disp();
|
---|
76 | self.lovenumbers.disp();
|
---|
77 | self.rotational.disp();
|
---|
78 |
|
---|
79 | end % }}}
|
---|
80 | function marshall(self,prefix,md,fid) % {{{
|
---|
81 |
|
---|
82 | WriteData(fid,prefix,'object',self,'fieldname','sealevel','mattype',1,'format','DoubleMat','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
|
---|
83 | WriteData(fid,prefix,'object',self,'fieldname','planetradius','format','Double');
|
---|
84 | WriteData(fid,prefix,'object',self,'fieldname','transitions','format','MatArray');
|
---|
85 |
|
---|
86 | if ~isempty(self.partitionice),
|
---|
87 | npartice=max(self.partitionice)+2;
|
---|
88 | else
|
---|
89 | npartice=0;
|
---|
90 | end
|
---|
91 | if ~isempty(self.partitionhydro),
|
---|
92 | nparthydro=max(self.partitionhydro)+2;
|
---|
93 | else
|
---|
94 | nparthydro=0;
|
---|
95 | end
|
---|
96 |
|
---|
97 |
|
---|
98 | WriteData(fid,prefix,'object',self,'fieldname','partitionice','mattype',1,'format','DoubleMat');
|
---|
99 | WriteData(fid,prefix,'data',npartice,'format','Integer','name','md.solidearth.npartice');
|
---|
100 | WriteData(fid,prefix,'object',self,'fieldname','partitionhydro','mattype',1,'format','DoubleMat');
|
---|
101 | WriteData(fid,prefix,'data',nparthydro,'format','Integer','name','md.solidearth.nparthydro');
|
---|
102 |
|
---|
103 | self.settings.marshall(prefix,md,fid);
|
---|
104 | self.surfaceload.marshall(prefix,md,fid);
|
---|
105 | self.lovenumbers.marshall(prefix,md,fid);
|
---|
106 | self.rotational.marshall(prefix,md,fid);
|
---|
107 |
|
---|
108 | %process requested outputs
|
---|
109 | outputs = self.requested_outputs;
|
---|
110 | pos = find(ismember(outputs,'default'));
|
---|
111 | if ~isempty(pos),
|
---|
112 | outputs(pos) = []; %remove 'default' from outputs
|
---|
113 | outputs = [outputs defaultoutputs(self,md)]; %add defaults
|
---|
114 | end
|
---|
115 | WriteData(fid,prefix,'data',outputs,'name','md.solidearth.requested_outputs','format','StringArray');
|
---|
116 |
|
---|
117 | end % }}}
|
---|
118 | function savemodeljs(self,fid,modelname) % {{{
|
---|
119 |
|
---|
120 | writejs1Darray(fid,[modelname '.solidearth.sealevel'],self.sealevel);
|
---|
121 | self.settings.savemodeljs(fid,modelname);
|
---|
122 | self.surfaceload.savemodeljs(fid,modelname);
|
---|
123 | self.lovenumbers.savemodeljs(fid,modelname);
|
---|
124 | self.rotational.savemodeljs(fid,modelname);
|
---|
125 | writejscellstring(fid,[modelname '.solidearth.requested_outputs'],self.requested_outputs);
|
---|
126 | writejscellarray(fid,[modelname '.solidearth.transitions'],self.transitions);
|
---|
127 | writejscellarray(fid,[modelname '.solidearth.partition'],self.partition);
|
---|
128 | end % }}}
|
---|
129 | function self = extrude(self,md) % {{{
|
---|
130 | self.sealevel=project3d(md,'vector',self.sealevel,'type','node');
|
---|
131 | end % }}}
|
---|
132 | end
|
---|
133 | end
|
---|