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