Changeset 4756
- Timestamp:
- 07/22/10 14:28:50 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/classes/public/ismodelselfconsistent.m
r4683 r4756 7 7 %tolerance we use in litmus checks for the consistency of the model 8 8 tolerance=10^-12; 9 10 %check usage 9 %check usage {{{1 11 10 if nargin~=1, 12 11 help ismodelselfconsistent 13 12 error('ismodelselfconsistent error message: wrong usage'); 14 13 end 15 16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TRANSIENT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 18 %check analysis 14 %}}} 15 16 %recursive call for TRANSIENT {{{1 19 17 if (md.analysis_type==Transient2DSolutionEnum | md.analysis_type==Transient3DSolutionEnum), 20 18 if md.dt<=0, … … 34 32 end 35 33 end 36 37 38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMON CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 39 40 %COUNTER 34 %}}} 35 36 % Common checks 37 %COUNTER {{{1 41 38 if md.counter<3, 42 39 error(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']); 43 40 end 44 45 %NAME 41 %}}} 42 %NAME{{{1 46 43 if isempty(md.name), 47 44 error(['model is not correctly configured: missing name!']); 48 45 end 49 50 %ELEMENTSTYPE 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 51 56 if size(md.elements_type,1)~=md.numberofelements | size(md.elements_type,2)~=2, 52 57 error(['model not consistent: types of elements have not been set properly, run setelementstype first']) … … 72 77 error(['model not consistent: Stokes transient not implemented yet']); 73 78 end 74 75 %ICEFRONT 79 %}}} 80 %DG {{{1 81 if md.prognostic_DG=1; 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 76 89 if (md.dim==2), 77 90 fields={'pressureload'}; … … 83 96 error('type should be either ''2d'' or ''3d'''); 84 97 end 85 86 %ELEMENTS 87 fields={'elements'}; 88 if (md.dim==2), 89 checksize(md,fields,[md.numberofelements 3]); 90 else 91 checksize(md,fields,[md.numberofelements 6]); 92 end 93 94 %NO NAN 98 %}}} 99 %NO NAN {{{1 95 100 fields={'numberofelements','numberofgrids','x','y','z','drag_coefficient','drag_type','drag_p','drag_q',... 96 101 'rho_ice','rho_water','rheology_B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',... 97 102 'tolx','np','eps_res','max_nonlinear_iterations','exclusive','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'}; 98 103 checknan(md,fields); 99 100 %FIELDS >= 0 104 %}}}} 105 %FIELDS >= 0 {{{1 101 106 fields={'numberofelements','numberofgrids','elements','drag_coefficient','drag_type','drag_p','drag_q',... 102 107 'rho_ice','rho_water','rheology_B','elementoniceshelf','thickness','g','eps_res','max_nonlinear_iterations','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',... 103 108 'sparsity','lowmem','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'}; 104 109 checkgreater(md,fields,0); 105 106 %FIELDS > 0 110 %}}} 111 %FIELDS > 0 {{{1 107 112 fields={'numberofelements','numberofgrids','elements','drag_type','drag_p',... 108 113 'rho_ice','rho_water','rheology_B','thickness','g','max_nonlinear_iterations','eps_res','eps_rel','eps_abs','maxiter','tolx',... 109 114 'sparsity','deltaH','DeltaH','timeacc','timedec'}; 110 115 checkgreaterstrict(md,fields,0); 111 112 %SIZE NUMBEROFELEMENTS 116 %}}} 117 %SIZE NUMBEROFELEMENTS {{{1 113 118 fields={'drag_p','drag_q','elementoniceshelf','rheology_n','elementonbed'}; 114 119 checksize(md,fields,[md.numberofelements 1]); 115 116 %SIZE NUMBEROFGRIDS 120 %}}} 121 %SIZE NUMBEROFGRIDS {{{1 117 122 fields={'x','y','z','rheology_B','drag_coefficient','melting_rate','accumulation_rate','surface','thickness','bed','gridonbed','gridonsurface'}; 118 123 checksize(md,fields,[md.numberofgrids 1]); 119 120 % SIZE 6124 %}}} 125 %OTHER SIZES {{{1 121 126 fields={'spcvelocity'}; 122 127 checksize(md,fields,[md.numberofgrids 6]); 123 124 %THICKNESS = SURFACE - BED 128 %}}} 129 %THICKNESS = SURFACE - BED {{{1 125 130 if any((md.thickness-md.surface+md.bed)>tolerance), 126 131 error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']); 127 132 end 128 129 %RIFTS 133 %}}} 134 %RIFTS{{{1 130 135 if md.numrifts, 131 136 if ~(md.dim==2), … … 146 151 end 147 152 end 148 149 % ARTIFICIAL DIFFUSIVITY153 %}}} 154 %FLAGS (0 or 1){{{1 150 155 if ~ismember(md.artificial_diffusivity,[0 1]), 151 156 error('model not consistent: artificial_diffusivity should be a scalar (1 or 0)'); 152 157 end 153 154 %PARAMETEROUTPUT 158 if ~ismember(md.prognostic_DG,[0 1]), 159 error('model not consistent: prognostic_DG should be a scalar (1 or 0)'); 160 end 161 if ~ismember(md.lowmem,[0 1]), 162 error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']); 163 end 164 %}}} 165 %PARAMETEROUTPUT {{{1 155 166 if md.numoutput~=length(md.parameteroutput), 156 167 error('model not consistent: numoutput should be the same size as parameteroutput'); 157 168 end 158 159 %CONNECTIVITY 169 %}}} 170 %CONNECTIVITY {{{1 160 171 if (md.dim==2), 161 172 if md.connectivity<9, … … 168 179 end 169 180 end 170 171 %LOWMEM = 0 or 1 172 if ((md.lowmem ~= 1) & (md.lowmem~=0)), 173 error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']); 174 end 175 176 %PARALLEL 181 %}}} 182 %PARALLEL{{{1 177 183 if ~strcmpi(md.cluster,'none'), 178 184 … … 186 192 187 193 end 188 189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SOLUTION CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 190 191 %QMU 192 if md.qmu_analysis, 193 if md.qmu_params.evaluation_concurrency~=1, 194 error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']); 195 end 196 if ~isempty(md.part), 197 if numel(md.part)~=md.numberofgrids, 198 error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']); 199 end 200 if find(md.part)>=md.numberofgrids, 201 error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']); 202 end 203 if min(md.part)~=0, 204 error(['model not consistent: partition vector not indexed from 0 on']); 205 end 206 if max(md.part)>=md.numberofgrids, 207 error(['model not consistent: partition vector cannot have maximum index larger than number of grids']); 208 end 209 if ~isempty(find(md.part<0)), 210 error(['model not consistent: partition vector cannot have values less than 0']); 211 end 212 if ~isempty(find(md.part>=md.npart)), 213 error(['model not consistent: partition vector cannot have values more than md.npart-1']); 214 end 215 if max(md.part)>=md.npart, 216 error(['model not consistent: for qmu analysis, partitioning vector cannot go over npart, number of partition areas']); 217 end 218 end 219 if md.eps_rel>1.1*10^-5, 220 error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']); 221 end 222 end 223 224 %DIAGNOSTIC 194 %}}} 195 196 % Solution checks 197 %DIAGNOSTIC{{{1 225 198 if md.analysis_type==DiagnosticSolutionEnum, 226 199 … … 259 232 end 260 233 end 261 262 %PROGNOSTIC 234 %}}} 235 %PROGNOSTIC{{{1 263 236 if md.analysis_type==PrognosticSolutionEnum, 264 237 … … 276 249 277 250 end 278 279 %STEADYSTATE 251 %}}} 252 %STEADYSTATE{{{1 280 253 if md.analysis_type==SteadystateSolutionEnum, 281 254 … … 300 273 end 301 274 end 302 275 %}}} 276 %THERMAL {{{1 303 277 %THERMAL STEADY AND THERMAL TRANSIENT 304 278 if md.analysis_type==ThermalSolutionEnum, … … 338 312 339 313 end 340 341 %BALANCEDTHICKNESS 314 %}}} 315 %BALANCEDTHICKNESS{{{1 342 316 if md.analysis_type==BalancedthicknessSolutionEnum 343 317 344 318 %VELOCITIES MELTING AND ACCUMULATION 345 fields={'vx','vy','accumulation_rate','melting_rate' };319 fields={'vx','vy','accumulation_rate','melting_rate','dhdt'}; 346 320 checksize(md,fields,[md.numberofgrids 1]); 347 321 checknan(md,fields); … … 352 326 end 353 327 end 354 355 %BALANCEDTHICKNESS2 356 if md.analysis_type==Balancedthickness2SolutionEnum 357 358 %VELOCITIES MELTING AND ACCUMULATION 359 fields={'vx','vy','accumulation_rate','melting_rate','dhdt'}; 360 checksize(md,fields,[md.numberofgrids 1]); 361 checknan(md,fields); 362 363 %CHECK THE COMPATIBILITY OF THE EDGES 364 fields={'edges'}; 365 checksize(md,fields,[NaN 4]); 366 checknan(md,fields); 367 end 368 369 %BALANCEDVELOCITIES 328 %}}} 329 %BALANCEDVELOCITIES{{{1 370 330 if md.analysis_type==BalancedvelocitiesSolutionEnum 371 331 … … 380 340 end 381 341 end 382 383 %CONTROL 342 %}}} 343 %CONTROL{{{1 384 344 if md.control_analysis, 385 345 … … 418 378 checknan(md,fields); 419 379 end 420 421 %QMU 380 %}}} 381 %QMU {{{1 382 if md.qmu_analysis, 383 if md.qmu_params.evaluation_concurrency~=1, 384 error(['model not consistent: concurrency should be set to 1 when running dakota in library mode']); 385 end 386 if ~isempty(md.part), 387 if numel(md.part)~=md.numberofgrids, 388 error(['model not consistent: user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']); 389 end 390 if find(md.part)>=md.numberofgrids, 391 error(['model not consistent: user supplied partition should be indexed from 0 (c-convention)']); 392 end 393 if min(md.part)~=0, 394 error(['model not consistent: partition vector not indexed from 0 on']); 395 end 396 if max(md.part)>=md.numberofgrids, 397 error(['model not consistent: partition vector cannot have maximum index larger than number of grids']); 398 end 399 if ~isempty(find(md.part<0)), 400 error(['model not consistent: partition vector cannot have values less than 0']); 401 end 402 if ~isempty(find(md.part>=md.npart)), 403 error(['model not consistent: partition vector cannot have values more than md.npart-1']); 404 end 405 if max(md.part)>=md.npart, 406 error(['model not consistent: for qmu analysis, partitioning vector cannot go over npart, number of partition areas']); 407 end 408 end 409 if md.eps_rel>1.1*10^-5, 410 error(['model not consistent: for qmu analysis, eps_rel should be least than 10^-5, 10^-15 being a better value']); 411 end 412 end 413 422 414 if strcmpi(md.analysis_type,'qmu'), 423 415 if ~strcmpi(md.cluster,'none'), … … 427 419 end 428 420 end 429 430 end %end function 431 432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHECK FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 433 421 %}}} 422 423 end 424 425 %checks additional functions 426 %checklength {{{1 434 427 function checklength(md,fields,fieldlength) 435 428 %CHECKSIZE - check length of a field … … 440 433 end 441 434 end 442 435 %}}} 436 %checksize {{{1 443 437 function checksize(md,fields,fieldsize) 444 438 %CHECKSIZE - check size of a field … … 475 469 end 476 470 end 477 471 %}}} 472 %checknan {{{1 478 473 function checknan(md,fields) 479 474 %CHECKNAN - check nan values of a field … … 484 479 end 485 480 end 486 481 %}}} 482 %checkreal{{{1 487 483 function checkreal(md,fields) 488 484 %CHECKREAL - check real values of a field … … 493 489 end 494 490 end 495 491 %}}} 492 %checkgreaterstrict{{{1 496 493 function checkgreaterstrict(md,fields,lowerbound) 497 494 %CHECKGREATERSTRICT - check values of a field … … 502 499 end 503 500 end 504 501 %}}} 502 %checkgreater{{{1 505 503 function checkgreater(md,fields,lowerbound) 506 504 %CHECKGREATER - check values of a field … … 511 509 end 512 510 end 513 511 %}}} 512 %checklessstrict{{{1 514 513 function checklessstrict(md,fields,upperbound) 515 514 %CHECKLESSSTRICT - check values of a field … … 520 519 end 521 520 end 522 521 %}}} 522 %checkless{{{1 523 523 function checkless(md,fields,upperbound) 524 524 %CHECKLESS - check values of a field … … 529 529 end 530 530 end 531 531 %}}} 532 %checkvalues {{{1 532 533 function checkvalues(md,fields,values) 533 534 %CHECKVALUE - check that a field has a certain value … … 538 539 end 539 540 end 541 %}}}
Note:
See TracChangeset
for help on using the changeset viewer.