Changeset 4756


Ignore:
Timestamp:
07/22/10 14:28:50 (15 years ago)
Author:
Mathieu Morlighem
Message:

Added folds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/ismodelselfconsistent.m

    r4683 r4756  
    77%tolerance we use in litmus checks for the consistency of the model
    88tolerance=10^-12;
    9 
    10 %check usage
     9%check usage {{{1
    1110if nargin~=1,
    1211        help ismodelselfconsistent
    1312        error('ismodelselfconsistent error message: wrong usage');
    1413end
    15 
    16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   TRANSIENT   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    17 
    18 %check analysis
     14%}}}
     15
     16%recursive call for TRANSIENT {{{1
    1917if (md.analysis_type==Transient2DSolutionEnum | md.analysis_type==Transient3DSolutionEnum),
    2018        if md.dt<=0,
     
    3432        end
    3533end
    36 
    37 
    38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   COMMON CHECKS   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    39 
    40 %COUNTER
     34%}}}
     35
     36% Common checks
     37%COUNTER {{{1
    4138if md.counter<3,
    4239        error(['model ' md.name ' is not correctly configured. You forgot one step in the following sequence (mesh, geography, parameterize,setelementstype)!']);
    4340end
    44 
    45 %NAME
     41%}}}
     42%NAME{{{1
    4643if isempty(md.name),
    4744        error(['model is not correctly configured: missing name!']);
    4845end
    49 
    50 %ELEMENTSTYPE
     46%}}}
     47%ELEMENTS{{{1
     48fields={'elements'};
     49if (md.dim==2),
     50        checksize(md,fields,[md.numberofelements 3]);
     51else
     52        checksize(md,fields,[md.numberofelements 6]);
     53end
     54%}}}
     55%ELEMENTSTYPE{{{1
    5156if size(md.elements_type,1)~=md.numberofelements | size(md.elements_type,2)~=2,
    5257        error(['model not consistent: types of elements have not been set properly, run setelementstype first'])
     
    7277        error(['model not consistent: Stokes transient not implemented yet']);
    7378end
    74 
    75 %ICEFRONT
     79%}}}
     80%DG {{{1
     81if md.prognostic_DG=1;
     82        %CHECK THE COMPATIBILITY OF THE EDGES
     83        fields={'edges'};
     84        checksize(md,fields,[NaN 4]);
     85        checknan(md,fields);
     86end
     87%}}}
     88%PRESSURELOAD{{{1
    7689if (md.dim==2),
    7790        fields={'pressureload'};
     
    8396        error('type should be either ''2d'' or ''3d''');
    8497end
    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
    95100fields={'numberofelements','numberofgrids','x','y','z','drag_coefficient','drag_type','drag_p','drag_q',...
    96101        'rho_ice','rho_water','rheology_B','elementoniceshelf','surface','thickness','bed','g','lowmem','sparsity','nsteps','maxiter',...
    97102        'tolx','np','eps_res','max_nonlinear_iterations','exclusive','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
    98103checknan(md,fields);
    99 
    100 %FIELDS >= 0
     104%}}}}
     105%FIELDS >= 0 {{{1
    101106fields={'numberofelements','numberofgrids','elements','drag_coefficient','drag_type','drag_p','drag_q',...
    102107        'rho_ice','rho_water','rheology_B','elementoniceshelf','thickness','g','eps_res','max_nonlinear_iterations','eps_rel','eps_abs','nsteps','maxiter','tolx','exclusive',...
    103108        'sparsity','lowmem','rheology_n','gridonbed','gridonsurface','elementonbed','elementonsurface','deltaH','DeltaH','timeacc','timedec'};
    104109checkgreater(md,fields,0);
    105 
    106 %FIELDS > 0
     110%}}}
     111%FIELDS > 0 {{{1
    107112fields={'numberofelements','numberofgrids','elements','drag_type','drag_p',...
    108113        'rho_ice','rho_water','rheology_B','thickness','g','max_nonlinear_iterations','eps_res','eps_rel','eps_abs','maxiter','tolx',...
    109114        'sparsity','deltaH','DeltaH','timeacc','timedec'};
    110115checkgreaterstrict(md,fields,0);
    111 
    112 %SIZE NUMBEROFELEMENTS
     116%}}}
     117%SIZE NUMBEROFELEMENTS {{{1
    113118fields={'drag_p','drag_q','elementoniceshelf','rheology_n','elementonbed'};
    114119checksize(md,fields,[md.numberofelements 1]);
    115 
    116 %SIZE NUMBEROFGRIDS
     120%}}}
     121%SIZE NUMBEROFGRIDS {{{1
    117122fields={'x','y','z','rheology_B','drag_coefficient','melting_rate','accumulation_rate','surface','thickness','bed','gridonbed','gridonsurface'};
    118123checksize(md,fields,[md.numberofgrids 1]);
    119 
    120 %SIZE 6
     124%}}}
     125%OTHER SIZES {{{1
    121126fields={'spcvelocity'};
    122127checksize(md,fields,[md.numberofgrids 6]);
    123 
    124 %THICKNESS = SURFACE - BED
     128%}}}
     129%THICKNESS = SURFACE - BED {{{1
    125130if any((md.thickness-md.surface+md.bed)>tolerance),
    126131        error(['model not consistent: model ' md.name ' violates the equality thickness=surface-bed!']);
    127132end
    128 
    129 %RIFTS
     133%}}}
     134%RIFTS{{{1
    130135if md.numrifts,
    131136        if ~(md.dim==2),
     
    146151        end
    147152end
    148 
    149 %ARTIFICIAL DIFFUSIVITY
     153%}}}
     154%FLAGS (0 or 1){{{1
    150155if ~ismember(md.artificial_diffusivity,[0 1]),
    151156        error('model not consistent: artificial_diffusivity should be a scalar (1 or 0)');
    152157end
    153 
    154 %PARAMETEROUTPUT
     158if ~ismember(md.prognostic_DG,[0 1]),
     159        error('model not consistent: prognostic_DG should be a scalar (1 or 0)');
     160end
     161if ~ismember(md.lowmem,[0 1]),
     162        error(['model not consistent: model ' md.name ' lowmem field should be 0 or 1']);
     163end
     164%}}}
     165%PARAMETEROUTPUT {{{1
    155166if md.numoutput~=length(md.parameteroutput),
    156167        error('model not consistent: numoutput should be the same size as parameteroutput');
    157168end
    158 
    159 %CONNECTIVITY
     169%}}}
     170%CONNECTIVITY {{{1
    160171if (md.dim==2),
    161172        if md.connectivity<9,
     
    168179        end
    169180end
    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
    177183if ~strcmpi(md.cluster,'none'),
    178184
     
    186192
    187193end
    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
    225198if md.analysis_type==DiagnosticSolutionEnum,
    226199
     
    259232        end
    260233end
    261 
    262 %PROGNOSTIC
     234%}}}
     235%PROGNOSTIC{{{1
    263236if md.analysis_type==PrognosticSolutionEnum,
    264237
     
    276249
    277250end
    278 
    279 %STEADYSTATE
     251%}}}
     252%STEADYSTATE{{{1
    280253if md.analysis_type==SteadystateSolutionEnum,
    281254
     
    300273        end
    301274end
    302 
     275%}}}
     276%THERMAL {{{1
    303277%THERMAL STEADY AND THERMAL TRANSIENT
    304278if md.analysis_type==ThermalSolutionEnum,
     
    338312
    339313end
    340 
    341 %BALANCEDTHICKNESS
     314%}}}
     315%BALANCEDTHICKNESS{{{1
    342316if md.analysis_type==BalancedthicknessSolutionEnum
    343317
    344318        %VELOCITIES MELTING AND ACCUMULATION
    345         fields={'vx','vy','accumulation_rate','melting_rate'};
     319        fields={'vx','vy','accumulation_rate','melting_rate','dhdt'};
    346320        checksize(md,fields,[md.numberofgrids 1]);
    347321        checknan(md,fields);
     
    352326        end
    353327end
    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
    370330if md.analysis_type==BalancedvelocitiesSolutionEnum
    371331
     
    380340        end
    381341end
    382 
    383 %CONTROL
     342%}}}
     343%CONTROL{{{1
    384344if md.control_analysis,
    385345
     
    418378        checknan(md,fields);
    419379end
    420 
    421 %QMU
     380%}}}
     381%QMU {{{1
     382if 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
     412end
     413
    422414if strcmpi(md.analysis_type,'qmu'),
    423415        if ~strcmpi(md.cluster,'none'),
     
    427419        end
    428420end
    429 
    430 end %end function
    431 
    432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHECK FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    433 
     421%}}}
     422
     423end
     424
     425%checks additional functions
     426%checklength {{{1
    434427function checklength(md,fields,fieldlength)
    435428        %CHECKSIZE - check length of a field
     
    440433        end
    441434end
    442 
     435%}}}
     436%checksize {{{1
    443437function checksize(md,fields,fieldsize)
    444438        %CHECKSIZE - check size of a field
     
    475469        end
    476470end
    477 
     471%}}}
     472%checknan {{{1
    478473function checknan(md,fields)
    479474        %CHECKNAN - check nan values of a field
     
    484479        end
    485480end
    486 
     481%}}}
     482%checkreal{{{1
    487483function checkreal(md,fields)
    488484        %CHECKREAL - check real values of a field
     
    493489        end
    494490end
    495 
     491%}}}
     492%checkgreaterstrict{{{1
    496493function checkgreaterstrict(md,fields,lowerbound)
    497494        %CHECKGREATERSTRICT - check values of a field
     
    502499        end
    503500end
    504 
     501%}}}
     502%checkgreater{{{1
    505503function checkgreater(md,fields,lowerbound)
    506504        %CHECKGREATER - check values of a field
     
    511509        end
    512510end
    513 
     511%}}}
     512%checklessstrict{{{1
    514513function checklessstrict(md,fields,upperbound)
    515514        %CHECKLESSSTRICT - check values of a field
     
    520519        end
    521520end
    522 
     521%}}}
     522%checkless{{{1
    523523function checkless(md,fields,upperbound)
    524524        %CHECKLESS - check values of a field
     
    529529        end
    530530end
    531 
     531%}}}
     532%checkvalues {{{1
    532533function checkvalues(md,fields,values)
    533534        %CHECKVALUE - check that a field has a certain value
     
    538539        end
    539540end
     541%}}}
Note: See TracChangeset for help on using the changeset viewer.