[25118] | 1 | %SOLIDEARTHSETTINGS class definition
|
---|
| 2 | %
|
---|
| 3 | % Usage:
|
---|
| 4 | % solidearthsettings=solidearthsettings();
|
---|
| 5 |
|
---|
| 6 | classdef solidearthsettings
|
---|
[26299] | 7 | properties (SetAccess=public)
|
---|
[25118] | 8 | reltol = 0;
|
---|
| 9 | abstol = 0;
|
---|
| 10 | maxiter = 0;
|
---|
[26296] | 11 | selfattraction = 1;
|
---|
| 12 | elastic = 1;
|
---|
| 13 | viscous = 1;
|
---|
| 14 | rotation = 1;
|
---|
[26299] | 15 | grdocean = 1;
|
---|
[25118] | 16 | ocean_area_scaling = 0;
|
---|
| 17 | runfrequency = 1; %how many time steps we skip before we run grd_core
|
---|
[26296] | 18 | sealevelloading = 1; %will sea-level loads be computed?
|
---|
[26229] | 19 | isgrd = 0; %will GRD patterns be computed?
|
---|
| 20 | compute_bp_grd = 0; %will GRD patterns for bottom pressures be computed?
|
---|
[26272] | 21 | degacc = 0; %degree increment for resolution of Green tables.
|
---|
[27131] | 22 | timeacc = 1; %time step accuracy required to compute Green tables
|
---|
[25118] | 23 | horiz = 0; %compute horizontal deformation
|
---|
[27131] | 24 | grdmodel = 1; %grd model (0 by default, 1 for (visco-)elastic, 2 for Ivins)
|
---|
[26047] | 25 | cross_section_shape = 0; %cross section only used when grd model is Ivins
|
---|
[25118] | 26 | end
|
---|
[26296] | 27 | methods (Static)
|
---|
| 28 | function self = loadobj(self) % {{{
|
---|
| 29 | % This function is directly called by matlab when a model object is
|
---|
| 30 | % loaded. If the input is a struct it is an old version of this class and
|
---|
| 31 | % old fields must be recovered (make sure they are in the deprecated
|
---|
| 32 | % model properties)
|
---|
| 33 |
|
---|
| 34 | if isstruct(self)
|
---|
| 35 | % 2021, Jun 4
|
---|
| 36 | if isfield(self,'rigid')
|
---|
| 37 | self.selfattraction = self.rigid;
|
---|
| 38 | end
|
---|
| 39 | if isfield(self,'computesealevelchange')
|
---|
| 40 | self.sealevelloading = self.computesealevelchange;
|
---|
| 41 | end
|
---|
| 42 | self = structtoobj(solidearthsettings(),self);
|
---|
| 43 |
|
---|
| 44 | end
|
---|
| 45 | end% }}}
|
---|
| 46 | end
|
---|
[25118] | 47 | methods
|
---|
[26296] | 48 |
|
---|
[25118] | 49 | function self = solidearthsettings(varargin) % {{{
|
---|
| 50 | switch nargin
|
---|
| 51 | case 0
|
---|
| 52 | self=setdefaultparameters(self);
|
---|
| 53 | otherwise
|
---|
| 54 | error('constructor not supported');
|
---|
| 55 | end
|
---|
| 56 | end % }}}
|
---|
| 57 | function self = setdefaultparameters(self) % {{{
|
---|
| 58 |
|
---|
[26358] | 59 | %Convergence criterion: absolute, relative and residual
|
---|
| 60 | self.reltol=0.01; % 1 percent
|
---|
| 61 | self.abstol=NaN; % default
|
---|
[25118] | 62 |
|
---|
[26358] | 63 | %maximum of non-linear iterations.
|
---|
| 64 | self.maxiter=5;
|
---|
[25118] | 65 |
|
---|
[26358] | 66 | %computational flags:
|
---|
| 67 | self.selfattraction=1;
|
---|
| 68 | self.elastic=1;
|
---|
| 69 | self.viscous=1;
|
---|
| 70 | self.rotation=1;
|
---|
| 71 | self.grdocean=1;
|
---|
| 72 | self.ocean_area_scaling=0;
|
---|
| 73 | self.compute_bp_grd=0;
|
---|
| 74 | self.isgrd=0;
|
---|
| 75 | self.sealevelloading=1;
|
---|
[25118] | 76 |
|
---|
[26358] | 77 | %numerical discretization accuracy
|
---|
| 78 | self.degacc=.01;
|
---|
| 79 | self.timeacc=1;
|
---|
[26299] | 80 |
|
---|
[26358] | 81 | %how many time steps we skip before we run solidearthsettings solver during transient
|
---|
| 82 | self.runfrequency=1;
|
---|
[26299] | 83 |
|
---|
[26358] | 84 | %horizontal displacement? (not on by default)
|
---|
| 85 | self.horiz=0;
|
---|
[26047] | 86 |
|
---|
[26358] | 87 | %cross section for Ivins model
|
---|
| 88 | self.cross_section_shape=1; %square as default (see iedge in GiaDeflectionCorex)
|
---|
[26047] | 89 |
|
---|
[27417] | 90 | %grd model by default
|
---|
[27131] | 91 | self.grdmodel=1;
|
---|
[26358] | 92 |
|
---|
[25118] | 93 | end % }}}
|
---|
[26301] | 94 | function disp(self) % {{{
|
---|
| 95 | disp(sprintf(' solidearth settings:'));
|
---|
[27131] | 96 | disp(sprintf(' core:'));
|
---|
[26301] | 97 | fielddisplay(self,'isgrd','compute GRD patterns (default: 1)');
|
---|
[27131] | 98 | fielddisplay(self,'grdmodel','type of deformation model, 0 for no GRD, 1 for spherical GRD model (SESAW model), 2 for half-space planar GRD (visco-elastic model from Ivins)');
|
---|
| 99 | fielddisplay(self,'runfrequency','How many time steps we let masstransport core accumulate changes before each run of the sealevelchange core (default: 1, i.e run slc every time step)');
|
---|
| 100 | disp(sprintf(' computational flags:'));
|
---|
[26301] | 101 | fielddisplay(self,'selfattraction','enables surface mass load to perturb the gravity field');
|
---|
| 102 | fielddisplay(self,'elastic','enables elastic deformation from surface loading');
|
---|
| 103 | fielddisplay(self,'viscous','enables viscous deformation from surface loading');
|
---|
| 104 | fielddisplay(self,'rotation','enables polar motion to feedback on the GRD fields');
|
---|
[27131] | 105 | fielddisplay(self,'compute_bp_grd','compute GRD patterns for bottom pressure loads (default: 1)');
|
---|
| 106 | fielddisplay(self,'cross_section_shape','1: square-edged (default). 2: elliptical. See iedge in GiaDeflectionCore. Used only for grdmodel=2 only');
|
---|
| 107 | disp(sprintf(' resolution:'));
|
---|
| 108 | fielddisplay(self,'degacc','spatial accuracy (default: .01 deg) for numerical discretization of the Green''s functions');
|
---|
[26301] | 109 | fielddisplay(self,'timeacc','time accuracy (default: 1 yr) for numerical discretization of the Green''s functions');
|
---|
[27131] | 110 | disp(sprintf(' sea-level equation:'));
|
---|
| 111 | fielddisplay(self,'grdocean','does this planet have an ocean, if set to 1: global water mass is conserved in GRD module (default: 1)');
|
---|
| 112 | fielddisplay(self,'sealevelloading','enables surface loading from sea-level change (default: 1)');
|
---|
| 113 | fielddisplay(self,'maxiter','maximum number of nonlinear iterations');
|
---|
| 114 | fielddisplay(self,'reltol','sea level change relative convergence criterion (default, NaN: not applied)');
|
---|
| 115 | fielddisplay(self,'abstol','sea level change absolute convergence criterion(default, NaN: not applied)');
|
---|
| 116 | fielddisplay(self,'ocean_area_scaling','correction for model representation of ocean area (default: No correction)');
|
---|
| 117 |
|
---|
[26301] | 118 | end % }}}
|
---|
[25118] | 119 | function md = checkconsistency(self,md,solution,analyses) % {{{
|
---|
| 120 |
|
---|
[25956] | 121 | if ~ismember('SealevelchangeAnalysis',analyses) | (strcmp(solution,'TransientSolution') & md.transient.isslc==0),
|
---|
[25118] | 122 | return;
|
---|
| 123 | end
|
---|
| 124 | md = checkfield(md,'fieldname','solidearth.settings.reltol','size',[1 1]);
|
---|
| 125 | md = checkfield(md,'fieldname','solidearth.settings.abstol','size',[1 1]);
|
---|
| 126 | md = checkfield(md,'fieldname','solidearth.settings.maxiter','size',[1 1],'>=',1);
|
---|
| 127 | md = checkfield(md,'fieldname','solidearth.settings.runfrequency','size',[1 1],'>=',1);
|
---|
| 128 | md = checkfield(md,'fieldname','solidearth.settings.degacc','size',[1 1],'>=',1e-10);
|
---|
[26272] | 129 | md = checkfield(md,'fieldname','solidearth.settings.timeacc','size',[1 1],'>',0);
|
---|
[25118] | 130 | md = checkfield(md,'fieldname','solidearth.settings.horiz','NaN',1,'Inf',1,'values',[0 1]);
|
---|
[26229] | 131 | md = checkfield(md,'fieldname','solidearth.settings.grdmodel','>=',0,'<=',2);
|
---|
[26047] | 132 | md = checkfield(md,'fieldname','solidearth.settings.cross_section_shape','numel',[1],'values',[1,2]);
|
---|
[26299] | 133 |
|
---|
[26296] | 134 | if self.elastic==1 & self.selfattraction==0,
|
---|
| 135 | error('solidearthsettings checkconsistency error message: need selfattraction on if elastic flag is set');
|
---|
[25767] | 136 | end
|
---|
[26272] | 137 | if self.viscous==1 & self.elastic==0,
|
---|
| 138 | error('solidearthsettings checkconsistency error message: need elastic on if viscous flag is set');
|
---|
| 139 | end
|
---|
[27131] | 140 | if self.rotation==1 & self.elastic==0,
|
---|
| 141 | error('solidearthsettings checkconsistency error message: need elastic on if rotation flag is set');
|
---|
| 142 | end
|
---|
[25767] | 143 |
|
---|
[26060] | 144 | %a GRD computation has been requested, make some checks on the nature of the meshes provided.
|
---|
[25763] | 145 | if self.isgrd,
|
---|
[26047] | 146 | if strcmpi(class(md.mesh),'mesh3dsurface'),
|
---|
| 147 | if self.grdmodel==2,
|
---|
| 148 | error('model requires a 2D mesh to run gia Ivins computations (change mesh from mesh3dsurface to mesh2d)');
|
---|
| 149 | end
|
---|
[25118] | 150 | else
|
---|
[26047] | 151 | if self.grdmodel==1,
|
---|
[26060] | 152 | error('model requires a 3D surface mesh to run GRD computations (change mesh from mesh2d to mesh3dsurface)');
|
---|
[25118] | 153 | end
|
---|
| 154 | end
|
---|
[26296] | 155 | if self.sealevelloading==1 & self.grdocean==0
|
---|
| 156 | error('solidearthsettings checkconsistency error message: need grdocean on if sealevelloading flag is set');
|
---|
| 157 | end
|
---|
[25118] | 158 | end
|
---|
| 159 |
|
---|
[26047] | 160 | if self.compute_bp_grd==1 & md.solidearth.settings.isgrd==0,
|
---|
| 161 | error('solidearthsettings checkconsistency error message; if bottom pressure grd patterns are requested, solidearth settings class should have isgrd flag on');
|
---|
| 162 | end
|
---|
| 163 |
|
---|
[25118] | 164 | end % }}}
|
---|
| 165 | function marshall(self,prefix,md,fid) % {{{
|
---|
| 166 | WriteData(fid,prefix,'object',self,'fieldname','reltol','name','md.solidearth.settings.reltol','format','Double');
|
---|
| 167 | WriteData(fid,prefix,'object',self,'fieldname','abstol','name','md.solidearth.settings.abstol','format','Double');
|
---|
| 168 | WriteData(fid,prefix,'object',self,'fieldname','maxiter','name','md.solidearth.settings.maxiter','format','Integer');
|
---|
[26296] | 169 | WriteData(fid,prefix,'object',self,'fieldname','selfattraction','name','md.solidearth.settings.selfattraction','format','Boolean');
|
---|
[25118] | 170 | WriteData(fid,prefix,'object',self,'fieldname','elastic','name','md.solidearth.settings.elastic','format','Boolean');
|
---|
[26272] | 171 | WriteData(fid,prefix,'object',self,'fieldname','viscous','name','md.solidearth.settings.viscous','format','Boolean');
|
---|
[25118] | 172 | WriteData(fid,prefix,'object',self,'fieldname','rotation','name','md.solidearth.settings.rotation','format','Boolean');
|
---|
[26296] | 173 | WriteData(fid,prefix,'object',self,'fieldname','grdocean','name','md.solidearth.settings.grdocean','format','Boolean');
|
---|
[25118] | 174 | WriteData(fid,prefix,'object',self,'fieldname','ocean_area_scaling','name','md.solidearth.settings.ocean_area_scaling','format','Boolean');
|
---|
| 175 | WriteData(fid,prefix,'object',self,'fieldname','runfrequency','name','md.solidearth.settings.runfrequency','format','Integer');
|
---|
| 176 | WriteData(fid,prefix,'object',self,'fieldname','degacc','name','md.solidearth.settings.degacc','format','Double');
|
---|
[26272] | 177 | WriteData(fid,prefix,'object',self,'fieldname','timeacc','name','md.solidearth.settings.timeacc','format','Double','scale',md.constants.yts);
|
---|
[25118] | 178 | WriteData(fid,prefix,'object',self,'fieldname','horiz','name','md.solidearth.settings.horiz','format','Integer');
|
---|
[26296] | 179 | WriteData(fid,prefix,'object',self,'fieldname','sealevelloading','name','md.solidearth.settings.sealevelloading','format','Integer');
|
---|
[25763] | 180 | WriteData(fid,prefix,'object',self,'fieldname','isgrd','name','md.solidearth.settings.isgrd','format','Integer');
|
---|
[26047] | 181 | WriteData(fid,prefix,'object',self,'fieldname','compute_bp_grd','name','md.solidearth.settings.compute_bp_grd','format','Integer');
|
---|
| 182 | WriteData(fid,prefix,'object',self,'fieldname','grdmodel','name','md.solidearth.settings.grdmodel','format','Integer');
|
---|
| 183 | WriteData(fid,prefix,'object',self,'fieldname','cross_section_shape','name','md.solidearth.settings.cross_section_shape','format','Integer');
|
---|
[25118] | 184 | end % }}}
|
---|
[26299] | 185 | function self = extrude(self,md) % {{{
|
---|
| 186 | end % }}}
|
---|
[25118] | 187 | function savemodeljs(self,fid,modelname) % {{{
|
---|
[26358] | 188 | % TODO: Update the following fields so that coverage is complete
|
---|
[25956] | 189 | writejsdouble(fid,[modelname '.solidearth.settings.maxiter'],self.maxiter);
|
---|
| 190 | writejsdouble(fid,[modelname '.solidearth.settings.reltol'],self.reltol);
|
---|
| 191 | writejsdouble(fid,[modelname '.solidearth.settings.abstol'],self.abstol);
|
---|
[26296] | 192 | writejsdouble(fid,[modelname '.solidearth.settings.selfattraction'],self.selfattraction);
|
---|
[25956] | 193 | writejsdouble(fid,[modelname '.solidearth.settings.elastic'],self.elastic);
|
---|
[26272] | 194 | writejsdouble(fid,[modelname '.solidearth.settings.viscous'],self.viscous);
|
---|
[25956] | 195 | writejsdouble(fid,[modelname '.solidearth.settings.rotation'],self.rotation);
|
---|
[27131] | 196 | writejsdouble(fid,[modelname '.solidearth.settings.grdocean'],self.grdocean);
|
---|
[25956] | 197 | writejsdouble(fid,[modelname '.solidearth.settings.ocean_area_scaling'],self.ocean_area_scaling);
|
---|
| 198 | writejsdouble(fid,[modelname '.solidearth.settings.run_frequency'],self.run_frequency);
|
---|
| 199 | writejsdouble(fid,[modelname '.solidearth.settings.degacc'],self.degacc);
|
---|
[26272] | 200 | writejsdouble(fid,[modelname '.solidearth.settings.timeacc'],self.timeacc);
|
---|
[26047] | 201 | writejsdouble(fid,[modelname '.solidearth.settings.cross_section_shape'],self.cross_section_shape);
|
---|
[25118] | 202 | end % }}}
|
---|
| 203 | end
|
---|
| 204 | end
|
---|