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