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