source: issm/trunk/src/m/classes/basalforcings.m@ 9860

Last change on this file since 9860 was 9860, checked in by Mathieu Morlighem, 13 years ago

Better and simpler consistency checks

File size: 2.0 KB
Line 
1%BASAL FORCINGS class definition
2%
3% Usage:
4% basalforcings=basalforcings();
5
6classdef basalforcings
7 properties (SetAccess=public)
8 melting_rate = modelfield('default',NaN,'marshall',true,'format','DoubleMat','mattype',1);
9 melting_rate_correction = modelfield('default',NaN,'marshall',true,'format','DoubleMat','mattype',1);
10 geothermalflux = modelfield('default',NaN,'marshall',true,'format','DoubleMat','mattype',1);
11 end
12 methods
13 function obj = basalforcings(varargin) % {{{
14 switch nargin
15 case 0
16 obj=setdefaultparameters(obj);
17 case 1
18 in=varargin{1};
19 if (isa(in,'numeric') & in==0),
20 % requesting templates do nothing
21 else
22 error('constructor not supported');
23 end
24 otherwise
25 error('constructor not supported');
26 end
27 end % }}}
28 function obj = setdefaultparameters(obj) % {{{
29
30 %first, use the defaults provided by the properties definition above.
31 fieldnames=fields(obj);
32 for i=1:length(fieldnames),
33 fieldname=fieldnames{i};
34 obj.(fieldname)=obj.(fieldname).default;
35 end
36 end % }}}
37 function checkconsistency(obj,md,solution,analyses) % {{{
38
39 if ismember(PrognosticAnalysisEnum,analyses),
40 checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
41 end
42 if ismember(BalancethicknessAnalysisEnum,analyses),
43 checkfield(md,'basalforcings.melting_rate','NaN',1,'size',[md.mesh.numberofvertices 1]);
44 end
45 if ismember(ThermalAnalysisEnum,analyses),
46 checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
47 checkfield(md,'basalforcings.geothermalflux','NaN',1,'forcing',1,'>=',0);
48 end
49 end % }}}
50 function disp(obj) % {{{
51 disp(sprintf(' basal forcings parameters:'));
52
53 fielddisplay(obj,'melting_rate','basal melting rate (positive if melting)');
54 fielddisplay(obj,'melting_rate_correction','additional melting applied when the grounding line retreats');
55 fielddisplay(obj,'geothermalflux','geothermal heat flux [W/m^2]');
56
57 end % }}}
58 end
59end
Note: See TracBrowser for help on using the repository browser.