[2326] | 1 | function ismodelselfconsistent(md),
|
---|
[1] | 2 | %ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
|
---|
| 3 | %
|
---|
| 4 | % Usage:
|
---|
[2326] | 5 | % ismodelselfconsistent(md),
|
---|
[1] | 6 |
|
---|
[2366] | 7 | %tolerance we use in litmus checks for the consistency of the model
|
---|
[1] | 8 | tolerance=10^-12;
|
---|
[4756] | 9 | %check usage {{{1
|
---|
[2326] | 10 | if nargin~=1,
|
---|
[27] | 11 | help ismodelselfconsistent
|
---|
| 12 | error('ismodelselfconsistent error message: wrong usage');
|
---|
[1] | 13 | end
|
---|
[4756] | 14 | %}}}
|
---|
[1] | 15 |
|
---|
[4756] | 16 | %recursive call for TRANSIENT {{{1
|
---|
[4303] | 17 | if (md.analysis_type==Transient2DSolutionEnum | md.analysis_type==Transient3DSolutionEnum),
|
---|
[2326] | 18 | if md.dt<=0,
|
---|
| 19 | error('model not consistent: field dt must be positive for a transient run')
|
---|
| 20 | end
|
---|
| 21 |
|
---|
| 22 | %recursive call to ismodelselfconsistent
|
---|
[3994] | 23 | if (md.dim==2),
|
---|
[4303] | 24 | analysis=[DiagnosticSolutionEnum PrognosticSolutionEnum];
|
---|
[2528] | 25 | else
|
---|
[4303] | 26 | analysis=[DiagnosticSolutionEnum PrognosticSolutionEnum ThermalSolutionEnum];
|
---|
[2528] | 27 | end
|
---|
| 28 |
|
---|
[2326] | 29 | for i=1:length(analysis),
|
---|
[2520] | 30 | md.analysis_type=analysis(i);
|
---|
[2326] | 31 | ismodelselfconsistent(md);
|
---|
| 32 | end
|
---|
| 33 | end
|
---|
[4756] | 34 | %}}}
|
---|
[2326] | 35 |
|
---|
[4756] | 36 | % Common checks
|
---|
| 37 | %COUNTER {{{1
|
---|
[27] | 38 | if md.counter<3,
|
---|
[2326] | 39 | error(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']);
|
---|
[1] | 40 | end
|
---|
[4756] | 41 | %}}}
|
---|
| 42 | %NAME{{{1
|
---|
[1] | 43 | if isempty(md.name),
|
---|
[2326] | 44 | error(['model is not correctly configured: missing name!']);
|
---|
[1] | 45 | end
|
---|
[4756] | 46 | %}}}
|
---|
| 47 | %ELEMENTS{{{1
|
---|
| 48 | fields={'elements'};
|
---|
| 49 | if (md.dim==2),
|
---|
| 50 | checksize(md,fields,[md.numberofelements 3]);
|
---|
| 51 | else
|
---|
| 52 | checksize(md,fields,[md.numberofelements 6]);
|
---|
| 53 | end
|
---|
| 54 | %}}}
|
---|
| 55 | %ELEMENTSTYPE{{{1
|
---|
[1] | 56 | if size(md.elements_type,1)~=md.numberofelements | size(md.elements_type,2)~=2,
|
---|
[2326] | 57 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
[1] | 58 | end
|
---|
[1651] | 59 | if any(ones(md.numberofelements,1)-((md.elements_type(:,1)==HutterFormulationEnum) + (md.elements_type(:,1)==MacAyealFormulationEnum) + (md.elements_type(:,1)==PattynFormulationEnum)))
|
---|
[2326] | 60 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
[1] | 61 | end
|
---|
[1651] | 62 | if any(ones(md.numberofelements,1)-((md.elements_type(:,2)==StokesFormulationEnum) + (md.elements_type(:,2)==NoneFormulationEnum)))
|
---|
[2326] | 63 | error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
|
---|
[1] | 64 | end
|
---|
[3994] | 65 | if (md.dim==2),
|
---|
[1651] | 66 | if (ismember(PattynFormulationEnum,md.elements_type(:,1)) | ismember(StokesFormulationEnum,md.elements_type(:,2))),
|
---|
[2326] | 67 | error(['model not consistent: for a 2d model, only MacAyeal''s and Hutter''s elements are allowed']);
|
---|
[1] | 68 | end
|
---|
| 69 | end
|
---|
[358] | 70 | if (md.ismacayealpattyn==0 && md.ishutter==0 && md.isstokes==0),
|
---|
[2326] | 71 | error(['model not consistent: no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
|
---|
[358] | 72 | end
|
---|
[4303] | 73 | if (md.analysis_type==DiagnosticSolutionEnum & any(ismember(MacAyealFormulationEnum,md.elements_type(:,1)) & ismember(PattynFormulationEnum,md.elements_type(:,1))))
|
---|
[2326] | 74 | error(['model not consistent: coupling MacAyeal/Pattyn not implemented yet']);
|
---|
[2164] | 75 | end
|
---|
[4303] | 76 | if (md.isstokes & md.analysis_type==Transient3DSolutionEnum());
|
---|
[2326] | 77 | error(['model not consistent: Stokes transient not implemented yet']);
|
---|
[2164] | 78 | end
|
---|
[4756] | 79 | %}}}
|
---|
| 80 | %DG {{{1
|
---|
[4764] | 81 | if md.prognostic_DG==1;
|
---|
[4756] | 82 | %CHECK THE COMPATIBILITY OF THE EDGES
|
---|
| 83 | fields={'edges'};
|
---|
| 84 | checksize(md,fields,[NaN 4]);
|
---|
| 85 | checknan(md,fields);
|
---|
| 86 | end
|
---|
| 87 | %}}}
|
---|
| 88 | %PRESSURELOAD{{{1
|
---|
[3994] | 89 | if (md.dim==2),
|
---|
[2326] | 90 | fields={'pressureload'};
|
---|
[3099] | 91 | checksize(md,fields,[NaN 4]);
|
---|
[3994] | 92 | elseif md.dim==3,
|
---|
[2326] | 93 | fields={'pressureload'};
|
---|
[3099] | 94 | checksize(md,fields,[NaN 6]);
|
---|
[3356] | 95 | else
|
---|
[4796] | 96 | error('dim should be either 2 3');
|
---|
[1796] | 97 | end
|
---|
[4870] | 98 | checkvalues(md,{'pressureload(:,end)'},[WaterEnum() AirEnum()]);
|
---|
[4756] | 99 | %}}}
|
---|
| 100 | %NO NAN {{{1
|
---|
[3758] | 101 | fields={'numberofelements','numberofgrids','x','y','z','drag_coefficient','drag_type','drag_p','drag_q',...
|
---|
| 102 | 'rho_ice','rho_water','rheology_B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',...
|
---|
| 103 | 'tolx','np','eps_res','max_nonlinear_iterations','exclusive','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
[2366] | 104 | checknan(md,fields);
|
---|
[4756] | 105 | %}}}}
|
---|
| 106 | %FIELDS >= 0 {{{1
|
---|
[3758] | 107 | fields={'numberofelements','numberofgrids','elements','drag_coefficient','drag_type','drag_p','drag_q',...
|
---|
| 108 | 'rho_ice','rho_water','rheology_B','elementoniceshelf','thickness','g','eps_res','max_nonlinear_iterations','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',...
|
---|
| 109 | 'sparsity','lowmem','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
|
---|
[2366] | 110 | checkgreater(md,fields,0);
|
---|
[4756] | 111 | %}}}
|
---|
| 112 | %FIELDS > 0 {{{1
|
---|
[3758] | 113 | fields={'numberofelements','numberofgrids','elements','drag_type','drag_p',...
|
---|
| 114 | 'rho_ice','rho_water','rheology_B','thickness','g','max_nonlinear_iterations','eps_res','eps_rel','eps_abs','maxiter','tolx',...
|
---|
[27] | 115 | 'sparsity','deltaH','DeltaH','timeacc','timedec'};
|
---|
[2366] | 116 | checkgreaterstrict(md,fields,0);
|
---|
[4756] | 117 | %}}}
|
---|
| 118 | %SIZE NUMBEROFELEMENTS {{{1
|
---|
[3759] | 119 | fields={'drag_p','drag_q','elementoniceshelf','rheology_n','elementonbed'};
|
---|
[2991] | 120 | checksize(md,fields,[md.numberofelements 1]);
|
---|
[4756] | 121 | %}}}
|
---|
| 122 | %SIZE NUMBEROFGRIDS {{{1
|
---|
[3758] | 123 | fields={'x','y','z','rheology_B','drag_coefficient','melting_rate','accumulation_rate','surface','thickness','bed','gridonbed','gridonsurface'};
|
---|
[2991] | 124 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
[4756] | 125 | %}}}
|
---|
| 126 | %OTHER SIZES {{{1
|
---|
[2405] | 127 | fields={'spcvelocity'};
|
---|
| 128 | checksize(md,fields,[md.numberofgrids 6]);
|
---|
[4756] | 129 | %}}}
|
---|
| 130 | %THICKNESS = SURFACE - BED {{{1
|
---|
[681] | 131 | if any((md.thickness-md.surface+md.bed)>tolerance),
|
---|
[2326] | 132 | error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
|
---|
[27] | 133 | end
|
---|
[4756] | 134 | %}}}
|
---|
| 135 | %RIFTS{{{1
|
---|
[27] | 136 | if md.numrifts,
|
---|
[3994] | 137 | if ~(md.dim==2),
|
---|
[2326] | 138 | error(['model not consistent: models with rifts are only supported in 2d for now!']);
|
---|
[1] | 139 | end
|
---|
[2660] | 140 | if ~isstruct(md.rifts),
|
---|
| 141 | error(['model not consistent: md.rifts should be a structure!']);
|
---|
| 142 | end
|
---|
| 143 | if ~isempty(find(md.segmentmarkers>=2)),
|
---|
| 144 | %We have segments with rift markers, but no rift structure!
|
---|
| 145 | error(['model not consistent: model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
|
---|
| 146 | end
|
---|
| 147 | %Check that rifts are filled with proper material
|
---|
| 148 | checkvalues(md,{'rifts.fill'},[WaterEnum() AirEnum() IceEnum() MelangeEnum()]);
|
---|
| 149 | else
|
---|
[2748] | 150 | if ~isnans(md.rifts),
|
---|
[2660] | 151 | error(['model not consistent: md.rifts shoud be NaN since md.numrifts is 0!']);
|
---|
[27] | 152 | end
|
---|
| 153 | end
|
---|
[4756] | 154 | %}}}
|
---|
| 155 | %FLAGS (0 or 1){{{1
|
---|
[2326] | 156 | if ~ismember(md.artificial_diffusivity,[0 1]),
|
---|
| 157 | error('model not consistent: artificial_diffusivity should be a scalar (1 or 0)');
|
---|
[1] | 158 | end
|
---|
[4756] | 159 | if ~ismember(md.prognostic_DG,[0 1]),
|
---|
| 160 | error('model not consistent: prognostic_DG should be a scalar (1 or 0)');
|
---|
| 161 | end
|
---|
| 162 | if ~ismember(md.lowmem,[0 1]),
|
---|
| 163 | error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
|
---|
| 164 | end
|
---|
| 165 | %}}}
|
---|
| 166 | %PARAMETEROUTPUT {{{1
|
---|
[2307] | 167 | if md.numoutput~=length(md.parameteroutput),
|
---|
[2326] | 168 | error('model not consistent: numoutput should be the same size as parameteroutput');
|
---|
[2307] | 169 | end
|
---|
[4756] | 170 | %}}}
|
---|
| 171 | %CONNECTIVITY {{{1
|
---|
[3994] | 172 | if (md.dim==2),
|
---|
[2326] | 173 | if md.connectivity<9,
|
---|
| 174 | error('model not consistent: connectivity should be at least 9 for 2d models');
|
---|
| 175 | end
|
---|
| 176 | end
|
---|
[3994] | 177 | if md.dim==3,
|
---|
[2326] | 178 | if md.connectivity<24,
|
---|
| 179 | error('model not consistent: connectivity should be at least 24 for 3d models');
|
---|
| 180 | end
|
---|
| 181 | end
|
---|
[4756] | 182 | %}}}
|
---|
| 183 | %PARALLEL{{{1
|
---|
[2326] | 184 | if ~strcmpi(md.cluster,'none'),
|
---|
| 185 |
|
---|
| 186 | %NAN VALUES
|
---|
| 187 | fields={'time','np'};
|
---|
[2366] | 188 | checknan(md,fields);
|
---|
[2326] | 189 |
|
---|
| 190 | %FIELD > 0
|
---|
| 191 | fields={'time','np'};
|
---|
[2366] | 192 | checkgreaterstrict(md,fields,0);
|
---|
[2326] | 193 |
|
---|
| 194 | end
|
---|
[4756] | 195 | %}}}
|
---|
[2326] | 196 |
|
---|
[4756] | 197 | % Solution checks
|
---|
| 198 | %DIAGNOSTIC{{{1
|
---|
[4303] | 199 | if md.analysis_type==DiagnosticSolutionEnum,
|
---|
[27] | 200 |
|
---|
[2208] | 201 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
[4683] | 202 | if isempty(find(~md.spcvelocity(:,1:2))),
|
---|
| 203 | error(['model not consistent: model ' md.name ' is totally constrained horizontally, no need to solve!']);
|
---|
| 204 | end
|
---|
| 205 | if (md.dim==3),
|
---|
| 206 | if isempty(find(~md.spcvelocity(:,3))),
|
---|
| 207 | error(['model not consistent: model ' md.name ' is totally constrained vertically, no need to solve!']);
|
---|
[2208] | 208 | end
|
---|
| 209 | end
|
---|
| 210 |
|
---|
[27] | 211 | %HUTTER ON ICESHELF WARNING
|
---|
[1651] | 212 | if any(md.elements_type(:,1)==HutterFormulationEnum & md.elementoniceshelf),
|
---|
[27] | 213 | disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
|
---|
| 214 | end
|
---|
| 215 |
|
---|
| 216 | %SINGULAR
|
---|
[2282] | 217 | if ~any(sum(md.spcvelocity(:,1:2),2)==2),
|
---|
[2326] | 218 | error(['model not consistent: model ' md.name ' is not well posed (singular). You need at least one grid with fixed velocity!'])
|
---|
[1] | 219 | end
|
---|
| 220 |
|
---|
[27] | 221 | %DIRICHLET IF THICKNESS <= 0
|
---|
[681] | 222 | if any(md.thickness<=0),
|
---|
[27] | 223 | pos=find(md.thickness<=0);
|
---|
[1755] | 224 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
[2326] | 225 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
[27] | 226 | end
|
---|
| 227 | end
|
---|
[2357] | 228 |
|
---|
[2367] | 229 | %INITIAL VELOCITY
|
---|
| 230 | if length(md.vx)==md.numberofgrids & length(md.vy)==md.numberofgrids,
|
---|
| 231 | fields={'vx','vy'};
|
---|
| 232 | checknan(md,fields);
|
---|
| 233 | end
|
---|
[1] | 234 | end
|
---|
[4756] | 235 | %}}}
|
---|
| 236 | %PROGNOSTIC{{{1
|
---|
[4303] | 237 | if md.analysis_type==PrognosticSolutionEnum,
|
---|
[1] | 238 |
|
---|
[2357] | 239 | %INITIAL VELOCITIES
|
---|
| 240 | fields={'vx','vy'};
|
---|
[2366] | 241 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 242 | checknan(md,fields);
|
---|
[2357] | 243 |
|
---|
[2519] | 244 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
[3994] | 245 | if (md.dim==2),
|
---|
[2519] | 246 | if isempty(find(~md.spcthickness(:,1))),
|
---|
| 247 | error(['model not consistent: model ' md.name ' is totally constrained for prognostic, no need to solve!']);
|
---|
| 248 | end
|
---|
| 249 | end
|
---|
| 250 |
|
---|
[1] | 251 | end
|
---|
[4756] | 252 | %}}}
|
---|
| 253 | %STEADYSTATE{{{1
|
---|
[4303] | 254 | if md.analysis_type==SteadystateSolutionEnum,
|
---|
[2326] | 255 |
|
---|
[1901] | 256 | %NDT
|
---|
| 257 | if md.dt~=0,
|
---|
[2326] | 258 | error(['model not consistent: for a steadystate computation, dt must be zero.']);
|
---|
[1901] | 259 | end
|
---|
[2326] | 260 |
|
---|
[1787] | 261 | %PRESSURE
|
---|
| 262 | if isnans(md.pressure),
|
---|
[2326] | 263 | error(['model not consistent: for a steadystate computation, the model must have an initial pressure, even lithostatic will do.']);
|
---|
[1787] | 264 | end
|
---|
| 265 |
|
---|
| 266 | %eps:
|
---|
| 267 | if isnan(md.eps_rel),
|
---|
[2326] | 268 | error(['model not consistent: for a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
|
---|
[1787] | 269 | end
|
---|
| 270 |
|
---|
| 271 | %dim:
|
---|
[3994] | 272 | if (md.dim==2),
|
---|
[2326] | 273 | error(['model not consistent: for a steadystate computation, model needs to be 3d']);
|
---|
[1787] | 274 | end
|
---|
| 275 | end
|
---|
[4756] | 276 | %}}}
|
---|
| 277 | %THERMAL {{{1
|
---|
[27] | 278 | %THERMAL STEADY AND THERMAL TRANSIENT
|
---|
[4303] | 279 | if md.analysis_type==ThermalSolutionEnum,
|
---|
[27] | 280 |
|
---|
| 281 | %EXTRUSION
|
---|
[3994] | 282 | if (md.dim==2),
|
---|
[2326] | 283 | error(['model not consistent: for a ' md.analysis_type ' computation, the model must be 3d, extrude it first!'])
|
---|
[1] | 284 | end
|
---|
[27] | 285 |
|
---|
[2519] | 286 | %CHECK THAT WE ARE NOT FULLY CONSTRAINED
|
---|
[3994] | 287 | if isempty(find(~md.spctemperature(:,1))),
|
---|
| 288 | error(['model not consistent: model ' md.name ' is totally constrained for temperature, no need to solve!']);
|
---|
[2519] | 289 | end
|
---|
| 290 |
|
---|
[27] | 291 | %VELOCITIES AND PRESSURE
|
---|
[2357] | 292 | fields={'vx','vy','vz','pressure'};
|
---|
[2366] | 293 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 294 | checknan(md,fields);
|
---|
[2357] | 295 |
|
---|
[1] | 296 | end
|
---|
| 297 |
|
---|
[1311] | 298 | %THERMAL TRANSIENT
|
---|
[4303] | 299 | if md.analysis_type==ThermalSolutionEnum & md.dt~=0,
|
---|
[27] | 300 |
|
---|
| 301 | %DT and NDT
|
---|
| 302 | fields={'dt','ndt'};
|
---|
[2366] | 303 | checkgreaterstrict(md,fields,0);
|
---|
[27] | 304 |
|
---|
[1311] | 305 | %INITIAL TEMPERATURE, MELTING AND ACCUMULATION
|
---|
[3758] | 306 | fields={'temperature','accumulation_rate','melting_rate'};
|
---|
[2366] | 307 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
[2440] | 308 | checknan(md,fields);
|
---|
[1] | 309 |
|
---|
[2714] | 310 | %INITIAL TEMPERATURE
|
---|
[2669] | 311 | fields={'temperature','spctemperature(:,2)','observed_temperature'};
|
---|
| 312 | checkgreater(md,fields,0)
|
---|
| 313 |
|
---|
[1] | 314 | end
|
---|
[4756] | 315 | %}}}
|
---|
| 316 | %BALANCEDTHICKNESS{{{1
|
---|
[4303] | 317 | if md.analysis_type==BalancedthicknessSolutionEnum
|
---|
[2714] | 318 |
|
---|
| 319 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
[4756] | 320 | fields={'vx','vy','accumulation_rate','melting_rate','dhdt'};
|
---|
[3589] | 321 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 322 | checknan(md,fields);
|
---|
| 323 |
|
---|
| 324 | %SPC
|
---|
| 325 | if any(md.spcthickness(find(md.gridonboundary))~=1),
|
---|
| 326 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcthickness']);
|
---|
| 327 | end
|
---|
| 328 | end
|
---|
[4756] | 329 | %}}}
|
---|
| 330 | %BALANCEDVELOCITIES{{{1
|
---|
[4303] | 331 | if md.analysis_type==BalancedvelocitiesSolutionEnum
|
---|
[2723] | 332 |
|
---|
| 333 | %VELOCITIES MELTING AND ACCUMULATION
|
---|
[3758] | 334 | fields={'vx','vy','accumulation_rate','melting_rate'};
|
---|
[2723] | 335 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 336 | checknan(md,fields);
|
---|
| 337 |
|
---|
| 338 | %SPC
|
---|
| 339 | if any(md.spcvelocity(find(md.gridonboundary),[1:2])~=1),
|
---|
| 340 | error(['model not consistent: model ' md.name ' should have all the nodes on boundary constrained in field spcvelocity']);
|
---|
| 341 | end
|
---|
| 342 | end
|
---|
[4756] | 343 | %}}}
|
---|
| 344 | %CONTROL{{{1
|
---|
[1907] | 345 | if md.control_analysis,
|
---|
[1] | 346 |
|
---|
[27] | 347 | %CONTROL TYPE
|
---|
[45] | 348 | if ~ischar(md.control_type),
|
---|
[2326] | 349 | error('model not consistent: control_type should be a string');
|
---|
[1] | 350 | end
|
---|
[4848] | 351 | if ~(strcmpi(md.control_type,'rheology_B') | strcmpi(md.control_type,'drag_coefficient')),
|
---|
| 352 | error('model not consistent: control_type should be rheology_B or drag_coefficient');
|
---|
| 353 | end
|
---|
[1] | 354 |
|
---|
[27] | 355 | %LENGTH CONTROL FIELDS
|
---|
[2326] | 356 | fields={'maxiter','optscal','fit','cm_jump'};
|
---|
[2991] | 357 | checksize(md,fields,[md.nsteps 1]);
|
---|
[27] | 358 |
|
---|
| 359 | %FIT
|
---|
[3189] | 360 | checkvalues(md,{'fit'},[0 1 2 3 4]);
|
---|
[1] | 361 |
|
---|
[3203] | 362 | %WEIGHTS
|
---|
| 363 | fields={'weights'};
|
---|
| 364 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 365 | checkgreater(md,fields,0);
|
---|
| 366 |
|
---|
[27] | 367 | %OBSERVED VELOCITIES
|
---|
| 368 | fields={'vx_obs','vy_obs'};
|
---|
[2366] | 369 | checksize(md,fields,[md.numberofgrids 1]);
|
---|
| 370 | checknan(md,fields);
|
---|
[1361] | 371 |
|
---|
| 372 | %DIRICHLET IF THICKNESS <= 0
|
---|
| 373 | if any(md.thickness<=0),
|
---|
| 374 | pos=find(md.thickness<=0);
|
---|
[1755] | 375 | if any(find(md.spcthickness(pos,1)==0)),
|
---|
[2326] | 376 | error(['model not consistent: model ' md.name ' has some grids with 0 thickness']);
|
---|
[1361] | 377 | end
|
---|
| 378 | end
|
---|
[2686] | 379 |
|
---|
| 380 | %parameters
|
---|
| 381 | fields={'cm_noisedmp'};
|
---|
| 382 | checknan(md,fields);
|
---|
[1] | 383 | end
|
---|
[4756] | 384 | %}}}
|
---|
| 385 | %QMU {{{1
|
---|
| 386 | if md.qmu_analysis,
|
---|
| 387 | if md.qmu_params.evaluation_concurrency~=1,
|
---|
| 388 | error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']);
|
---|
| 389 | end
|
---|
| 390 | if ~isempty(md.part),
|
---|
| 391 | if numel(md.part)~=md.numberofgrids,
|
---|
| 392 | error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']);
|
---|
| 393 | end
|
---|
| 394 | if find(md.part)>=md.numberofgrids,
|
---|
| 395 | error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']);
|
---|
| 396 | end
|
---|
| 397 | if min(md.part)~=0,
|
---|
| 398 | error(['model not consistent: partition vector not indexed from 0 on']);
|
---|
| 399 | end
|
---|
| 400 | if max(md.part)>=md.numberofgrids,
|
---|
| 401 | error(['model not consistent: partition vector cannot have maximum index larger than number of grids']);
|
---|
| 402 | end
|
---|
| 403 | if ~isempty(find(md.part<0)),
|
---|
| 404 | error(['model not consistent: partition vector cannot have values less than 0']);
|
---|
| 405 | end
|
---|
| 406 | if ~isempty(find(md.part>=md.npart)),
|
---|
| 407 | error(['model not consistent: partition vector cannot have values more than md.npart-1']);
|
---|
| 408 | end
|
---|
| 409 | if max(md.part)>=md.npart,
|
---|
| 410 | error(['model not consistent: for qmu analysis, partitioning vector cannot go over npart, number of partition areas']);
|
---|
| 411 | end
|
---|
| 412 | end
|
---|
| 413 | if md.eps_rel>1.1*10^-5,
|
---|
| 414 | error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']);
|
---|
| 415 | end
|
---|
| 416 | end
|
---|
[1] | 417 |
|
---|
[465] | 418 | if strcmpi(md.analysis_type,'qmu'),
|
---|
[27] | 419 | if ~strcmpi(md.cluster,'none'),
|
---|
| 420 | if md.waitonlock==0,
|
---|
[2326] | 421 | error(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
|
---|
[1] | 422 | end
|
---|
| 423 | end
|
---|
| 424 | end
|
---|
[4756] | 425 | %}}}
|
---|
[1] | 426 |
|
---|
[4756] | 427 | end
|
---|
[1] | 428 |
|
---|
[4756] | 429 | %checks additional functions
|
---|
| 430 | %checklength {{{1
|
---|
[2366] | 431 | function checklength(md,fields,fieldlength)
|
---|
| 432 | %CHECKSIZE - check length of a field
|
---|
[2326] | 433 | for i=1:length(fields),
|
---|
| 434 | if length(eval(['md.' fields{i}]))~=fieldlength,
|
---|
| 435 | error(['model not consistent: field ' fields{i} ' length should be ' num2str(fieldlength)]);
|
---|
[2164] | 436 | end
|
---|
| 437 | end
|
---|
| 438 | end
|
---|
[4756] | 439 | %}}}
|
---|
| 440 | %checksize {{{1
|
---|
[2366] | 441 | function checksize(md,fields,fieldsize)
|
---|
| 442 | %CHECKSIZE - check size of a field
|
---|
[2326] | 443 | for i=1:length(fields),
|
---|
| 444 | if isnan(fieldsize(1)),
|
---|
| 445 | if (size(eval(['md.' fields{i}]),2)~=fieldsize(2)),
|
---|
[3203] | 446 | %LOG warnings:
|
---|
[3104] | 447 | if strcmpi(fields{i},'pressureload'),
|
---|
| 448 | disp(' ');
|
---|
| 449 | disp(' If pressureload does not have the right size (one column missing), this is due to a change in md.pressure.');
|
---|
| 450 | disp(' To update your model, use the following line');
|
---|
| 451 | disp(' md.pressureload=[md.pressureload WaterEnum*md.elementoniceshelf(md.pressureload(:,end))+AirEnum*md.elementonicesheet(md.pressureload(:,end))];');
|
---|
| 452 | disp(' ');
|
---|
| 453 | end
|
---|
[2326] | 454 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(2)) ' columns']);
|
---|
| 455 | end
|
---|
| 456 | elseif isnan(fieldsize(2)),
|
---|
| 457 | if (size(eval(['md.' fields{i}]),1)~=fieldsize(1)),
|
---|
| 458 | error(['model not consistent: field ' fields{i} ' should have ' num2str(fieldsize(1)) ' rows']);
|
---|
| 459 | end
|
---|
| 460 | else
|
---|
| 461 | if ((size(eval(['md.' fields{i}]),1)~=fieldsize(1)) | (size(eval(['md.' fields{i}]),2)~=fieldsize(2)))
|
---|
[3219] | 462 | %LOG warnings:
|
---|
| 463 | if strcmpi(fields{i},'weights'),
|
---|
| 464 | disp(' ');
|
---|
| 465 | disp(' ''weights'' is a new field that should be of length numberofgrids.');
|
---|
| 466 | disp(' To update your model, use the following line');
|
---|
| 467 | disp(' md.weights=ones(md.numberofgrids,1)');
|
---|
| 468 | disp(' ');
|
---|
| 469 | end
|
---|
[2326] | 470 | error(['model not consistent: field ' fields{i} ' size should be ' num2str(fieldsize(1)) ' x ' num2str(fieldsize(2))]);
|
---|
| 471 | end
|
---|
[2164] | 472 | end
|
---|
| 473 | end
|
---|
| 474 | end
|
---|
[4756] | 475 | %}}}
|
---|
| 476 | %checknan {{{1
|
---|
[2366] | 477 | function checknan(md,fields)
|
---|
| 478 | %CHECKNAN - check nan values of a field
|
---|
[2326] | 479 | for i=1:length(fields),
|
---|
| 480 | if any(isnan(eval(['md.' fields{i}]))),
|
---|
| 481 | error(['model not consistent: NaN values in field ' fields{i}]);
|
---|
[2164] | 482 | end
|
---|
| 483 | end
|
---|
| 484 | end
|
---|
[4756] | 485 | %}}}
|
---|
| 486 | %checkreal{{{1
|
---|
[2366] | 487 | function checkreal(md,fields)
|
---|
| 488 | %CHECKREAL - check real values of a field
|
---|
[2326] | 489 | for i=1:length(fields),
|
---|
| 490 | if any(eval(['~isreal(md.' fields{i} ')'])),
|
---|
| 491 | error(['model not consistent: complex values in field ' fields{i}]);
|
---|
| 492 | end
|
---|
| 493 | end
|
---|
[2164] | 494 | end
|
---|
[4756] | 495 | %}}}
|
---|
| 496 | %checkgreaterstrict{{{1
|
---|
[2366] | 497 | function checkgreaterstrict(md,fields,lowerbound)
|
---|
| 498 | %CHECKGREATERSTRICT - check values of a field
|
---|
[2326] | 499 | for i=1:length(fields),
|
---|
| 500 | if any(eval(['md.' fields{i} '<=' num2str(lowerbound) ])),
|
---|
| 501 | error(['model not consistent: field ' fields{i} ' should have values stricly above ' num2str(lowerbound)]);
|
---|
| 502 | end
|
---|
[2164] | 503 | end
|
---|
| 504 | end
|
---|
[4756] | 505 | %}}}
|
---|
| 506 | %checkgreater{{{1
|
---|
[2366] | 507 | function checkgreater(md,fields,lowerbound)
|
---|
| 508 | %CHECKGREATER - check values of a field
|
---|
[27] | 509 | for i=1:length(fields),
|
---|
[2326] | 510 | if any(eval(['md.' fields{i} '<' num2str(lowerbound) ])),
|
---|
| 511 | error(['model not consistent: field ' fields{i} ' should have values above ' num2str(lowerbound)]);
|
---|
[27] | 512 | end
|
---|
| 513 | end
|
---|
[2326] | 514 | end
|
---|
[4756] | 515 | %}}}
|
---|
| 516 | %checklessstrict{{{1
|
---|
[2366] | 517 | function checklessstrict(md,fields,upperbound)
|
---|
| 518 | %CHECKLESSSTRICT - check values of a field
|
---|
[27] | 519 | for i=1:length(fields),
|
---|
[2326] | 520 | if any(eval(['md.' fields{i} '>=' num2str(upperbound) ])),
|
---|
| 521 | error(['model not consistent: field ' fields{i} ' should have values stricly below ' num2str(upperbound)]);
|
---|
[27] | 522 | end
|
---|
| 523 | end
|
---|
[2326] | 524 | end
|
---|
[4756] | 525 | %}}}
|
---|
| 526 | %checkless{{{1
|
---|
[2366] | 527 | function checkless(md,fields,upperbound)
|
---|
| 528 | %CHECKLESS - check values of a field
|
---|
[27] | 529 | for i=1:length(fields),
|
---|
[2326] | 530 | if any(eval(['md.' fields{i} '>' num2str(upperbound) ])),
|
---|
| 531 | error(['model not consistent: field ' fields{i} ' should have values below ' num2str(upperbound)]);
|
---|
[27] | 532 | end
|
---|
[1] | 533 | end
|
---|
| 534 | end
|
---|
[4756] | 535 | %}}}
|
---|
| 536 | %checkvalues {{{1
|
---|
[2660] | 537 | function checkvalues(md,fields,values)
|
---|
[4870] | 538 | %CHECKVALUE - check that a field has specified values
|
---|
[2660] | 539 | for i=1:length(fields),
|
---|
[4870] | 540 | if eval(['any(~ismember( md.' fields{i} ',values))']),
|
---|
[2660] | 541 | error(['model not consistent: field ' fields{i} ' should have values in ' num2str(values)]);
|
---|
| 542 | end
|
---|
| 543 | end
|
---|
| 544 | end
|
---|
[4756] | 545 | %}}}
|
---|