[25118] | 1 | %SOLIDEARTH class definition
|
---|
| 2 | %
|
---|
| 3 | % Usage:
|
---|
| 4 | % solidearth=solidearth();
|
---|
[26307] | 5 | % solidearth=solidearth('earth');
|
---|
[25118] | 6 |
|
---|
| 7 | classdef solidearth
|
---|
| 8 | properties (SetAccess=public)
|
---|
[27326] | 9 | settings = solidearthsettings();
|
---|
| 10 | external = [];
|
---|
| 11 | lovenumbers = lovenumbers();
|
---|
| 12 | rotational = rotational();
|
---|
| 13 | planetradius = planetradius('earth');
|
---|
| 14 | requested_outputs = {};
|
---|
| 15 | transitions = {};
|
---|
| 16 | transfercount = [];
|
---|
| 17 | partitionice = [];
|
---|
| 18 | partitionhydro = [];
|
---|
| 19 | partitionocean = [];
|
---|
[25118] | 20 | end
|
---|
[25969] | 21 | methods (Static)
|
---|
| 22 | function self = loadobj(self) % {{{
|
---|
| 23 | % This function is directly called by matlab when a model object is
|
---|
| 24 | % loaded. If the input is a struct it is an old version of this class and
|
---|
| 25 | % old fields must be recovered (make sure they are in the deprecated
|
---|
| 26 | % model properties)
|
---|
| 27 |
|
---|
| 28 | if isstruct(self)
|
---|
| 29 | % 2021, Jan 10
|
---|
| 30 | if isfield(self,'sealevel')
|
---|
| 31 | self.initialsealevel = self.sealevel;
|
---|
| 32 | end
|
---|
| 33 | self = structtoobj(solidearth(),self);
|
---|
| 34 |
|
---|
| 35 | end
|
---|
| 36 | end% }}}
|
---|
| 37 | end
|
---|
[25118] | 38 | methods
|
---|
| 39 | function self = solidearth(varargin) % {{{
|
---|
| 40 | switch nargin
|
---|
| 41 | case 0
|
---|
[25767] | 42 | self=setdefaultparameters(self,'earth');
|
---|
| 43 | case 1
|
---|
| 44 | self=setdefaultparameters(self,varargin{:});
|
---|
[25118] | 45 | otherwise
|
---|
[25767] | 46 | error('solidearth constructor error message: zero or one argument only!');
|
---|
[25118] | 47 | end
|
---|
| 48 | end % }}}
|
---|
[26301] | 49 | function disp(self) % {{{
|
---|
| 50 | disp(sprintf(' solidearth inputs, forcings and settings:'));
|
---|
| 51 |
|
---|
| 52 | fielddisplay(self,'planetradius','planet radius [m]');
|
---|
| 53 | fielddisplay(self,'transitions','indices into parts of the mesh that will be icecaps');
|
---|
[27308] | 54 | fielddisplay(self,'transfercount','number of icecaps vertices are part of');
|
---|
[26301] | 55 | fielddisplay(self,'requested_outputs','additional outputs requested');
|
---|
| 56 | fielddisplay(self,'partitionice','ice partition vector for barystatic contribution');
|
---|
| 57 | fielddisplay(self,'partitionhydro','hydro partition vector for barystatic contribution');
|
---|
| 58 | fielddisplay(self,'partitionocean','ocean partition vector for barystatic contribution');
|
---|
| 59 | if isempty(self.external), fielddisplay(self,'external','external solution, of the type solidearthsolution'); end
|
---|
| 60 | self.settings.disp();
|
---|
| 61 | self.lovenumbers.disp();
|
---|
| 62 | self.rotational.disp();
|
---|
| 63 | if ~isempty(self.external),
|
---|
| 64 | self.external.disp();
|
---|
| 65 | end
|
---|
| 66 |
|
---|
| 67 | end % }}}
|
---|
[25767] | 68 | function self = setdefaultparameters(self,planet) % {{{
|
---|
[25118] | 69 |
|
---|
[25767] | 70 | %output default:
|
---|
| 71 | self.requested_outputs={'default'};
|
---|
[25751] | 72 |
|
---|
[26358] | 73 | %transitions should be a cell array of vectors:
|
---|
[25767] | 74 | self.transitions={};
|
---|
[27308] | 75 | self.transfercount=[0];
|
---|
[26358] | 76 |
|
---|
| 77 | %no partitions requested for barystatic contribution:
|
---|
[25767] | 78 | self.partitionice=[];
|
---|
| 79 | self.partitionhydro=[];
|
---|
[26099] | 80 | self.partitionocean=[];
|
---|
[25763] | 81 |
|
---|
[26358] | 82 | %no external solutions by default:
|
---|
[25767] | 83 | self.external=[];
|
---|
| 84 |
|
---|
[26307] | 85 | %planet radius
|
---|
[25767] | 86 | self.planetradius= planetradius(planet);
|
---|
[25118] | 87 | end % }}}
|
---|
| 88 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
| 89 |
|
---|
[25956] | 90 | if ~ismember('SealevelchangeAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.isslc==0),
|
---|
[25118] | 91 | return;
|
---|
| 92 | end
|
---|
| 93 |
|
---|
| 94 | md = checkfield(md,'fieldname','solidearth.requested_outputs','stringrow',1);
|
---|
| 95 |
|
---|
| 96 | self.settings.checkconsistency(md,solution,analyses);
|
---|
[25144] | 97 | self.lovenumbers.checkconsistency(md,solution,analyses);
|
---|
[25118] | 98 | self.rotational.checkconsistency(md,solution,analyses);
|
---|
[25763] | 99 | if ~isempty(self.external),
|
---|
| 100 | if ~isa(self.external,'solidearthsolution'),
|
---|
| 101 | error('solidearth consistency check: external field should be a solidearthsolution');
|
---|
| 102 | end
|
---|
| 103 | self.external.checkconsistency(md,solution,analyses);
|
---|
| 104 | end
|
---|
[25118] | 105 |
|
---|
| 106 | end % }}}
|
---|
| 107 | function list=defaultoutputs(self,md) % {{{
|
---|
| 108 | list = {'Sealevel'};
|
---|
| 109 | end % }}}
|
---|
| 110 | function marshall(self,prefix,md,fid) % {{{
|
---|
[26299] | 111 |
|
---|
[25118] | 112 | WriteData(fid,prefix,'object',self,'fieldname','planetradius','format','Double');
|
---|
| 113 | WriteData(fid,prefix,'object',self,'fieldname','transitions','format','MatArray');
|
---|
[27308] | 114 | WriteData(fid,prefix,'object',self,'fieldname','transfercount','format','DoubleMat','mattype',1);
|
---|
[26299] | 115 |
|
---|
[25751] | 116 | if ~isempty(self.partitionice),
|
---|
| 117 | npartice=max(self.partitionice)+2;
|
---|
| 118 | else
|
---|
| 119 | npartice=0;
|
---|
| 120 | end
|
---|
[26358] | 121 |
|
---|
[25751] | 122 | if ~isempty(self.partitionhydro),
|
---|
| 123 | nparthydro=max(self.partitionhydro)+2;
|
---|
| 124 | else
|
---|
| 125 | nparthydro=0;
|
---|
| 126 | end
|
---|
[26099] | 127 | if ~isempty(self.partitionocean),
|
---|
| 128 | npartocean=max(self.partitionocean)+2;
|
---|
| 129 | else
|
---|
| 130 | npartocean=0;
|
---|
| 131 | end
|
---|
[25118] | 132 |
|
---|
[25751] | 133 | WriteData(fid,prefix,'object',self,'fieldname','partitionice','mattype',1,'format','DoubleMat');
|
---|
| 134 | WriteData(fid,prefix,'data',npartice,'format','Integer','name','md.solidearth.npartice');
|
---|
| 135 | WriteData(fid,prefix,'object',self,'fieldname','partitionhydro','mattype',1,'format','DoubleMat');
|
---|
| 136 | WriteData(fid,prefix,'data',nparthydro,'format','Integer','name','md.solidearth.nparthydro');
|
---|
[26099] | 137 | WriteData(fid,prefix,'object',self,'fieldname','partitionocean','mattype',1,'format','DoubleMat');
|
---|
| 138 | WriteData(fid,prefix,'data',npartocean,'format','Integer','name','md.solidearth.npartocean');
|
---|
[26299] | 139 |
|
---|
[25118] | 140 | self.settings.marshall(prefix,md,fid);
|
---|
[25144] | 141 | self.lovenumbers.marshall(prefix,md,fid);
|
---|
[25118] | 142 | self.rotational.marshall(prefix,md,fid);
|
---|
[25763] | 143 | if ~isempty(self.external),
|
---|
[25947] | 144 | WriteData(fid,prefix,'data',1,'format','Integer','name','md.solidearth.isexternal');
|
---|
[25763] | 145 | self.external.marshall(prefix,md,fid);
|
---|
[25947] | 146 | else
|
---|
| 147 | WriteData(fid,prefix,'data',0,'format','Integer','name','md.solidearth.isexternal');
|
---|
[25763] | 148 | end
|
---|
[26299] | 149 |
|
---|
[25118] | 150 | %process requested outputs
|
---|
| 151 | outputs = self.requested_outputs;
|
---|
[26299] | 152 | pos = find(ismember(outputs,'default'));
|
---|
[25118] | 153 | if ~isempty(pos),
|
---|
| 154 | outputs(pos) = []; %remove 'default' from outputs
|
---|
| 155 | outputs = [outputs defaultoutputs(self,md)]; %add defaults
|
---|
| 156 | end
|
---|
| 157 | WriteData(fid,prefix,'data',outputs,'name','md.solidearth.requested_outputs','format','StringArray');
|
---|
| 158 |
|
---|
| 159 | end % }}}
|
---|
[26299] | 160 | function self = extrude(self,md) % {{{
|
---|
| 161 | end % }}}
|
---|
[25118] | 162 | function savemodeljs(self,fid,modelname) % {{{
|
---|
| 163 |
|
---|
| 164 | self.settings.savemodeljs(fid,modelname);
|
---|
[25144] | 165 | self.lovenumbers.savemodeljs(fid,modelname);
|
---|
[25118] | 166 | self.rotational.savemodeljs(fid,modelname);
|
---|
[25763] | 167 | if ~isempty(self.external),
|
---|
| 168 | self.external.savemodeljs(fid,modelname);
|
---|
| 169 | end
|
---|
[25118] | 170 | writejscellstring(fid,[modelname '.solidearth.requested_outputs'],self.requested_outputs);
|
---|
| 171 | writejscellarray(fid,[modelname '.solidearth.transitions'],self.transitions);
|
---|
[25751] | 172 | writejscellarray(fid,[modelname '.solidearth.partition'],self.partition);
|
---|
[25118] | 173 | end % }}}
|
---|
| 174 | end
|
---|
| 175 | end
|
---|