source: issm/trunk/src/m/classes/public/ismodelselfconsistent.m@ 1862

Last change on this file since 1862 was 1862, checked in by seroussi, 16 years ago

changed thermalstatic to steadystate

File size: 14.4 KB
Line 
1function bool=ismodelselfconsistent(md,package),
2%ISMODELSELFCONSISTENT - check that model forms a closed form solvable problem.
3%
4% Usage:
5% bool=ismodelselfconsistent(md,package),
6
7%tolerance we use in litmus tests for the consistency of the model
8tolerance=10^-12;
9if (nargin~=2 )
10 help ismodelselfconsistent
11 error('ismodelselfconsistent error message: wrong usage');
12end
13
14%initialize output
15bool=1;
16
17%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% COMMON CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
19%COUNTER
20if md.counter<3,
21 disp(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize)!']);
22 bool=0;return;
23end
24
25%NAME
26if isempty(md.name),
27 disp(['model is not correctly configured: missing name!']);
28 bool=0;return;
29end
30
31%MESH
32if md.numberofelements<=0,
33 disp(['model ' md.name ' does not have any elements!']);
34 bool=0; return;
35end
36if md.numberofgrids<=0,
37 disp(['model ' md.name ' does not have any grids!']);
38 bool=0; return;
39end
40
41%ELEMENTSTYPE
42if size(md.elements_type,1)~=md.numberofelements | size(md.elements_type,2)~=2,
43 disp(['Types of elements have not been set properly, run setelementstype first'])
44 bool=0;return;
45end
46if any(ones(md.numberofelements,1)-((md.elements_type(:,1)==HutterFormulationEnum) + (md.elements_type(:,1)==MacAyealFormulationEnum) + (md.elements_type(:,1)==PattynFormulationEnum)))
47 disp(['Types of elements have not been set properly, run setelementstype first'])
48 bool=0;return;
49end
50if any(ones(md.numberofelements,1)-((md.elements_type(:,2)==StokesFormulationEnum) + (md.elements_type(:,2)==NoneFormulationEnum)))
51 disp(['Types of elements have not been set properly, run setelementstype first'])
52 bool=0;return;
53end
54if strcmpi(md.type,'2d'),
55 if (ismember(PattynFormulationEnum,md.elements_type(:,1)) | ismember(StokesFormulationEnum,md.elements_type(:,2))),
56 disp(['For a 2d model, only MacAyeal''s and Hutter''s elements are allowed']);
57 bool=0;return;
58 end
59end
60
61if (md.ismacayealpattyn==0 && md.ishutter==0 && md.isstokes==0),
62 disp(['no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
63 bool=0;return;
64end
65
66%ICEFRONT
67if strcmpi(md.type,'2d'),
68 if size(md.pressureload,2)~=3 ,
69 disp(['pressureload in ' md.name ' shoud have three columns']);
70 bool=0;return;
71 end
72elseif strcmpi(md.type,'3d'),
73 if size(md.pressureload,2)~=5 ,
74 disp(['pressureload in ' md.name ' shoud have five columns']);
75 bool=0;return;
76 end
77end
78
79%NO NAN
80fields={'numberofelements','numberofgrids','x','y','z','drag','drag_type','p','q',...
81 'rho_ice','rho_water','B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',...
82 'tolx','np','eps_res','exclusive','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
83for i=1:length(fields),
84 if ~isempty(md.(fields{i})),
85 if any(isnan(md.(fields{i}))),
86 disp(['model ' md.name ' has an NaN value in field ' fields{i} '!']);
87 bool=0; return;
88 end
89 end
90end
91
92%FIELDS >= 0
93fields={'numberofelements','numberofgrids','elements','drag','drag_type','p','q',...
94 'rho_ice','rho_water','B','elementoniceshelf','thickness','g','eps_res','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',...
95 'sparsity','lowmem','n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
96for i=1:length(fields),
97 if ~isempty(md.(fields{i})),
98 if any(md.(fields{i})<0),
99 disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
100 bool=0; return;
101 end
102 end
103end
104if any(md.p<=0),
105 disp(['model ' md.name ' has some p<0 friction coefficientsin sliding law']);
106 bool=0; return;
107end
108
109%FIELDS ~=0
110fields={'numberofelements','numberofgrids','elements','drag_type',...
111 'rho_ice','rho_water','B','thickness','g','eps_res','eps_rel','eps_abs','maxiter','tolx',...
112 'sparsity','deltaH','DeltaH','timeacc','timedec'};
113for i=1:length(fields),
114 if ~isempty(md.(fields{i})),
115 if any(md.(fields{i})==0),
116 disp(['model ' md.name ' has a =0 value in field ' fields{i} '!']);
117 bool=0; return;
118 end
119 end
120end
121
122%SIZE NUMBEROFELEMENTS
123fields={'elements','p','q','elementoniceshelf','n','elementonbed'};
124for i=1:size(fields,2),
125 if (size(md.(fields{i}),1)~=md.numberofelements),
126 disp(['model ' md.name ' field ' fields{i} ' should be of size ' num2str(md.numberofelements) '!']);
127 bool=0; return;
128 end
129end
130
131%SIZE NUMBEROFGRIDS
132fields={'x','y','z','B','drag','spcvelocity','melting','accumulation','surface','thickness','bed','gridonbed','gridonsurface'};
133for i=1:length(fields),
134 if length(md.(fields{i}))~=md.numberofgrids,
135 disp(['model ' md.name ' field ' fields{i} ' should be of size ' num2str(md.numberofgrids) '!']);
136 bool=0; return;
137 end
138end
139
140%THICKNESS = SURFACE - BED
141if any((md.thickness-md.surface+md.bed)>tolerance),
142 disp(['model ' md.name ' violates the equality thickness=surface-bed!']);
143 bool=0; return;
144end
145
146%RIFTS
147if md.numrifts,
148 if ~strcmpi(md.type,'2d'),
149 disp(['Models with rifts are only supported in 2d for now!']);
150 bool=0;return;
151 end
152end
153if ~isstruct(md.rifts),
154 if ~isnan(md.rifts),
155 if ~isempty(find(md.segmentmarkers>=2)),
156 %We have segments with rift markers, but no rift structure!
157 disp(['model ' md.name ' should be processed for rifts (run meshprocessrifts)!']);
158 bool=0; return;
159 end
160 end
161end
162
163%ARTIFICIAL DIFFUSIVITY
164if ~isscalar(md.artificial_diffusivity),
165 disp('artificial_diffusivity should be a scalar (1 or 0)');
166 bool=0;return;
167end
168
169%CLUSTER
170if ~strcmpi(package,'cielo') & ~strcmpi(md.cluster,'none')
171 disp(['parallel solution not supported by package ' package '. Use cluster=''none'' ']);
172 bool=0;return;
173end
174
175%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SOLUTION CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176%QMU
177if md.qmu_analysis,
178 if md.qmu_params.evaluation_concurrency~=1,
179 disp(['concurrency should be set to 1 when running dakota in library mode']);
180 bool=0;return;
181 end
182 if ~isempty(md.part),
183 if numel(md.part)~=md.numberofgrids,
184 disp(['user supplied partition for qmu analysis should have size md.numberofgrids x 1 ']);
185 bool=0;return;
186 end
187 if find(md.part)>=md.numberofgrids,
188 disp(['user supplied partition should be indexed from 0 (c-convention)']);
189 bool=0;return;
190 end
191 if md.npart~=md.numberofgrids,
192 disp(['user supplied partition should have same size as md.npart']);
193 bool=0;return;
194 end
195
196 end
197end
198
199%DIAGNOSTIC
200if md.analysis_type==DiagnosticAnalysisEnum,
201
202 %HUTTER ON ICESHELF WARNING
203 if any(md.elements_type(:,1)==HutterFormulationEnum & md.elementoniceshelf),
204 disp(sprintf('\n !!! Warning: Hutter''s model is not consistent on ice shelves !!!\n'));
205 end
206
207 %SINGULAR
208 if ~any(sum(md.spcvelocity(:,1:3),2)==3),
209 disp(['model ' md.name ' is not well posed (singular). You need at least one grid with fixed velocity!'])
210 bool=0;return;
211 end
212
213 %DIRICHLET IF THICKNESS <= 0
214 if any(md.thickness<=0),
215 pos=find(md.thickness<=0);
216 if any(find(md.spcthickness(pos,1)==0)),
217 disp(['model ' md.name ' has some grids with 0 thickness']);
218 bool=0; return;
219 end
220 end
221end
222
223%PROGNOSTIC
224if md.analysis_type==PrognosticAnalysisEnum,
225
226 %VELOCITIES
227 if (size(md.vx,1)~=md.numberofgrids | size(md.vy,1)~=md.numberofgrids),
228 disp(['a 3d velocity is required. Run ''diagnostic'' solution first!'])
229 bool=0; return;
230 end
231end
232
233%steadystate
234if md.analysis_type==steadystateAnalysisEnum,
235 %PRESSURE
236 if isnans(md.pressure),
237 disp(['For a steadystate computation, the model must have an initial pressure, even lithostatic will do.']);
238 bool=0;return;
239 end
240
241 %eps:
242 if isnan(md.eps_rel),
243 disp(['For a steadystate computation, eps_rel (relative convergence criterion) must be defined!']);
244 bool=0;return;
245 end
246
247 %dim:
248 if strcmpi(md.type,'2d'),
249 disp(['For a steadystate computation, model needs to be 3d']);
250 bool=0;return;
251 end
252
253
254
255end
256
257%THERMAL STEADY AND THERMAL TRANSIENT
258if md.analysis_type==ThermalAnalysisEnum,
259
260 %EXTRUSION
261 if strcmp(md.type,'2d'),
262 disp(['For a ' md.analysis_type ' computation, the model must be 3d, extrude it first!'])
263 bool=0;return;
264 end
265
266 %VELOCITIES AND PRESSURE
267 if (length(md.vx)~=md.numberofgrids | length(md.vy)~=md.numberofgrids | length(md.vz)~=md.numberofgrids),
268 disp(['a 3d velocity is required. Run ''diagnostic'' solution first!'])
269 bool=0;return;
270 end
271 if (length(md.pressure)~=md.numberofgrids),
272 disp(['pressure is required. Run ''diagnostic'' solution first!'])
273 bool=0;return;
274 end
275end
276
277%THERMAL TRANSIENT
278if md.analysis_type==ThermalAnalysisEnum & md.sub_analysis_type==TransientAnalysisEnum,
279
280 %DT and NDT
281 fields={'dt','ndt'};
282 for i=1:length(fields),
283 if any(md.(fields{i})<0),
284 disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
285 bool=0; return;
286 end
287 end
288
289 %INITIAL TEMPERATURE, MELTING AND ACCUMULATION
290 if (length(md.temperature)~=md.numberofgrids),
291 disp(['An initial temperature is needed for a transient thermal computation'])
292 bool=0;return;
293 end
294 if (length(md.temperature)~=md.numberofgrids | length(md.accumulation)~=md.numberofgrids | length(md.melting)~=md.numberofgrids),
295 disp(['The initial temperature, melting or accumulation should be a list and not a structure'])
296 bool=0;return;
297 end
298end
299
300%PARAMETERS
301if md.analysis_type==ParametersAnalysisEnum,
302
303 %PACKAGE
304 if ~strcmpi(package,'ice'),
305 disp('parameter solution only supported by package ice yet');
306 bool=0;return;
307 end
308
309 %OUTPUT
310 if ~iscell(md.parameteroutput)
311 disp(['parameteroutput field must be a cell, example {''strainrate'',''stress'',''deviatoricstress'',''viscousheating''}']);
312 bool=0; return;
313 end
314 for i=1:length(md.parameteroutput)
315 if ~strcmpi(md.parameteroutput(i),'strainrate') & ~strcmpi(md.parameteroutput(i),'stress') & ~strcmpi(md.parameteroutput(i),'deviatoricstress') & ~strcmpi(md.parameteroutput(i),'viscousheating') ...
316 & ~strcmpi(md.parameteroutput(i),'pressure_elem') & ~strcmpi(md.parameteroutput(i),'stress_bed') & ~strcmpi(md.parameteroutput(i),'stress_surface')
317 disp(['one of the parameteroutput is not supported yet']);
318 bool=0; return;
319 end
320 end
321 %VELOCITY
322 if ~(size(md.vx,1)==md.numberofgrids & size(md.vy,1)==md.numberofgrids & (size(md.vz,1)==md.numberofgrids | strcmpi(md.type,'2d')))
323 disp(['velocities are required!']);
324 bool=0;return;
325 end
326
327 %HUTTER
328 if any(md.elements_type(:,1)==HutterFormulationEnum);
329 disp(['The model has Hutter''s elements. Impossible to compute parameters']);
330 bool=0;return;
331 end
332end
333
334%CONTROL
335if md.analysis_type==ControlAnalysisEnum,
336
337 %CONTROL TYPE
338 if ~ischar(md.control_type),
339 disp('control_type should be a string');
340 bool=0;return;
341 end
342
343 %LENGTH CONTROL FIELDS
344 if (length(md.maxiter)~=md.nsteps | length(md.optscal)~=md.nsteps | length(md.fit)~=md.nsteps)
345 disp('maxiter, optscal and fit must have the length specified by nsteps')
346 bool=0;return;
347 end
348
349 %FIT
350 if sum((double(md.fit==1) + double(md.fit==0) + double(md.fit==2))==1)~=md.nsteps
351 disp('wrong fits: fit should be a vector of size nsteps holding 0, 1 and 2 only')
352 bool=0;return;
353 end
354
355 %OBSERVED VELOCITIES
356 fields={'vx_obs','vy_obs'};
357 for i=1:length(fields),
358 if any(length(md.(fields{i}))~=md.numberofgrids),
359 disp(['model ' md.name ' field ' fields{i} ' should be of size ' num2str(md.numberofgrids) '!']);
360 bool=0; return;
361 end
362 end
363
364 %SINGULAR
365 if ~any(sum(md.spcvelocity(:,1:3),2)==3),
366 disp(['model ' md.name ' is not well posed (singular). You need at least one grid with fixed velocity!'])
367 bool=0;return;
368 end
369
370 %DIRICHLET IF THICKNESS <= 0
371 if any(md.thickness<=0),
372 pos=find(md.thickness<=0);
373 if any(find(md.spcthickness(pos,1)==0)),
374 disp(['model ' md.name ' has some grids with 0 thickness']);
375 bool=0; return;
376 end
377 end
378end
379
380%QMU
381if strcmpi(md.analysis_type,'qmu'),
382 if ~strcmpi(md.cluster,'none'),
383 if md.waitonlock==0,
384 disp(['model is not correctly configured: waitonlock should be activated when running qmu in parallel mode!']);
385 bool=0;return;
386 end
387 end
388end
389
390%MESH2GRID
391if md.analysis_type==Mesh2gridAnalysisEnum,
392 if ~strcmpi(md.cluster,'none'),
393 disp(['model is not correctly configured: mesh2grid not supported in parallel yet!']);
394 bool=0;return;
395 end
396end
397
398
399%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PACKAGE CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400
401%CIELO
402if strcmpi(package,'cielo'),
403
404 %NAN VALUES
405 fields={'sparsity'};
406 for i=1:length(fields),
407 if ~isempty(md.(fields{i})),
408 if any(isnan(md.(fields{i}))),
409 disp(['model ' md.name ' has an NaN value in field ' fields{i} '!']);
410 bool=0; return;
411 end
412 end
413 end
414
415 %FIELD > 0
416 fields={'sparsity'};
417 for i=1:length(fields),
418 if ~isempty(md.(fields{i})),
419 if any(md.(fields{i})<0),
420 disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
421 bool=0; return;
422 end
423 end
424 end
425
426 %FIELD ~= 0
427 fields={'sparsity'};
428 for i=1:length(fields),
429 if ~isempty(md.(fields{i})),
430 if any(md.(fields{i})==0),
431 disp(['model ' md.name ' has a =0 value in field ' fields{i} '!']);
432 bool=0; return;
433 end
434 end
435 end
436
437 %SPARSITY BETWEEN 0 AND 1
438 if ( (md.sparsity<=0) | (md.sparsity>1)),
439 disp(['model ' md.name ' sparsity should be inside the [0 1] range']);
440 bool=0; return;
441 end
442
443 %CONNECTIVITY
444 if strcmpi(md.type,'2d'),
445 if md.connectivity<9,
446 disp('connectivity should be at least 9 for 2d models');
447 bool=0;return;
448 end
449 end
450 if strcmpi(md.type,'3d'),
451 if md.connectivity<24,
452 disp('connectivity should be at least 24 for 3d models');
453 bool=0;return;
454 end
455 end
456
457 %LOWMEM = 0 or 1
458 if ((md.lowmem ~= 1) & (md.lowmem~=0)),
459 disp(['model ' md.name ' lowmem field should be 0 or 1']);
460 bool=0; return;
461 end
462
463%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARALLEL CHECKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
464
465 if ~strcmpi(md.cluster,'none'),
466
467 %NAN VALUES
468 fields={'time','np'};
469 for i=1:length(fields),
470 if ~isempty(md.(fields{i})),
471 if any(isnan(md.(fields{i}))),
472 disp(['model ' md.name ' has an NaN value in field ' fields{i} '!']);
473 bool=0; return;
474 end
475 end
476 end
477
478 %FIELD > 0
479 fields={'time','np'};
480 for i=1:length(fields),
481 if ~isempty(md.(fields{i})),
482 if any(md.(fields{i})<0),
483 disp(['model ' md.name ' has a <0 value in field ' fields{i} '!']);
484 bool=0; return;
485 end
486 end
487 end
488
489 %FIELD ~= 0
490 fields={'time','np'};
491 for i=1:length(fields),
492 if ~isempty(md.(fields{i})),
493 if any(md.(fields{i})==0),
494 disp(['model ' md.name ' has a =0 value in field ' fields{i} '!']);
495 bool=0; return;
496 end
497 end
498 end
499
500 end
501
502end
503
504%ICE and MACAYEAL
505if (strcmpi(package,'ice') | strcmpi(package,'macayeal')),
506
507 if (isnan(md.eps_rel) & isnan(md.eps_abs)),
508 disp(['At least eps_rel must be positive since eps_res not supported by package ' package '!']);
509 bool=0; return;
510 end
511
512end
Note: See TracBrowser for help on using the repository browser.