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