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