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