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 | love = loadinglove();
|
---|
12 | rotational = rotational();
|
---|
13 | planetradius = planetradius('earth');
|
---|
14 | requested_outputs = {};
|
---|
15 | transitions = {};
|
---|
16 | end
|
---|
17 | methods
|
---|
18 | function self = solidearth(varargin) % {{{
|
---|
19 | switch nargin
|
---|
20 | case 0
|
---|
21 | self=setdefaultparameters(self);
|
---|
22 | otherwise
|
---|
23 | error('constructor not supported');
|
---|
24 | end
|
---|
25 | end % }}}
|
---|
26 | function self = setdefaultparameters(self) % {{{
|
---|
27 |
|
---|
28 | %output default:
|
---|
29 | self.requested_outputs={'default'};
|
---|
30 |
|
---|
31 | %transitions should be a cell array of vectors:
|
---|
32 | self.transitions={};
|
---|
33 |
|
---|
34 | %earth radius
|
---|
35 | self.planetradius= planetradius('earth');
|
---|
36 |
|
---|
37 | end % }}}
|
---|
38 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
39 |
|
---|
40 | if ~ismember('SealevelriseAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.isslr==0),
|
---|
41 | return;
|
---|
42 | end
|
---|
43 |
|
---|
44 | md = checkfield(md,'fieldname','solidearth.sealevel','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices 1]);
|
---|
45 | md = checkfield(md,'fieldname','solidearth.requested_outputs','stringrow',1);
|
---|
46 |
|
---|
47 | self.settings.checkconsistency(md,solution,analyses);
|
---|
48 | self.surfaceload.checkconsistency(md,solution,analyses);
|
---|
49 | self.love.checkconsistency(md,solution,analyses);
|
---|
50 | self.rotational.checkconsistency(md,solution,analyses);
|
---|
51 |
|
---|
52 |
|
---|
53 | end % }}}
|
---|
54 | function list=defaultoutputs(self,md) % {{{
|
---|
55 | list = {'Sealevel'};
|
---|
56 | end % }}}
|
---|
57 | function disp(self) % {{{
|
---|
58 | disp(sprintf(' solidearth inputs, forcings and settings:'));
|
---|
59 |
|
---|
60 | fielddisplay(self,'sealevel','current sea level (prior to computation) [m]');
|
---|
61 | fielddisplay(self,'planetradius','planet radius [m]');
|
---|
62 | fielddisplay(self,'transitions','indices into parts of the mesh that will be icecaps');
|
---|
63 | fielddisplay(self,'requested_outputs','additional outputs requested');
|
---|
64 | self.settings.disp();
|
---|
65 | self.surfaceload.disp();
|
---|
66 | self.love.disp();
|
---|
67 | self.rotational.disp();
|
---|
68 |
|
---|
69 | end % }}}
|
---|
70 | function marshall(self,prefix,md,fid) % {{{
|
---|
71 |
|
---|
72 | WriteData(fid,prefix,'object',self,'fieldname','sealevel','mattype',1,'format','DoubleMat','timeserieslength',md.mesh.numberofvertices+1,'yts',md.constants.yts);
|
---|
73 | WriteData(fid,prefix,'object',self,'fieldname','planetradius','format','Double');
|
---|
74 | WriteData(fid,prefix,'object',self,'fieldname','transitions','format','MatArray');
|
---|
75 |
|
---|
76 | self.settings.marshall(prefix,md,fid);
|
---|
77 | self.surfaceload.marshall(prefix,md,fid);
|
---|
78 | self.love.marshall(prefix,md,fid);
|
---|
79 | self.rotational.marshall(prefix,md,fid);
|
---|
80 |
|
---|
81 | %process requested outputs
|
---|
82 | outputs = self.requested_outputs;
|
---|
83 | pos = find(ismember(outputs,'default'));
|
---|
84 | if ~isempty(pos),
|
---|
85 | outputs(pos) = []; %remove 'default' from outputs
|
---|
86 | outputs = [outputs defaultoutputs(self,md)]; %add defaults
|
---|
87 | end
|
---|
88 | WriteData(fid,prefix,'data',outputs,'name','md.solidearth.requested_outputs','format','StringArray');
|
---|
89 |
|
---|
90 | end % }}}
|
---|
91 | function savemodeljs(self,fid,modelname) % {{{
|
---|
92 |
|
---|
93 | writejs1Darray(fid,[modelname '.solidearth.sealevel'],self.sealevel);
|
---|
94 | self.settings.savemodeljs(fid,modelname);
|
---|
95 | self.surfaceload.savemodeljs(fid,modelname);
|
---|
96 | self.love.savemodeljs(fid,modelname);
|
---|
97 | self.rotational.savemodeljs(fid,modelname);
|
---|
98 | writejscellstring(fid,[modelname '.solidearth.requested_outputs'],self.requested_outputs);
|
---|
99 | writejscellarray(fid,[modelname '.solidearth.transitions'],self.transitions);
|
---|
100 | end % }}}
|
---|
101 | function self = extrude(self,md) % {{{
|
---|
102 | self.sealevel=project3d(md,'vector',self.sealevel,'type','node');
|
---|
103 | end % }}}
|
---|
104 | end
|
---|
105 | end
|
---|