Changeset 9860


Ignore:
Timestamp:
09/20/11 16:12:30 (14 years ago)
Author:
Mathieu Morlighem
Message:

Better and simpler consistency checks

Location:
issm/trunk/src/m
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/balancethickness.m

    r9854 r9860  
    4343                        if solution~=BalancethicknessSolutionEnum, return; end
    4444
    45                         if ~ismember(md.balancethickness.stabilization,[0 1 3]),
    46                                 checkmessage('model not consistent: balancethickness.stabilization should be a scalar (0 or 1 or 3)');
    47                         end
    48 
     45                        checkfield(md,'balancethickness.spcthickness','forcing',1);
     46                        checkfield(md,'balancethickness.thickening_rate','size',[md.mesh.numberofvertices 1],'NaN',1);
     47                        checkfield(md,'balancethickness.stabilization','size',[1 1],'values',[0 1 3]);
    4948                end % }}}
    5049                function disp(obj) % {{{
  • issm/trunk/src/m/classes/basalforcings.m

    r9854 r9860  
    3737                function checkconsistency(obj,md,solution,analyses) % {{{
    3838
    39                         fields={'geothermalflux'};
    40                         %checksize(md,'basalforcings',fields,[md.mesh.numberofvertices 1]);
    4139                        if ismember(PrognosticAnalysisEnum,analyses),
    42                                 fields={'melting_rate'};
    43                                 checkforcing(md,'basalforcings',fields);
     40                                checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
    4441                        end
    4542                        if ismember(BalancethicknessAnalysisEnum,analyses),
    46                                 fields={'melting_rate'};
    47                                 checksize(md,'basalforcings',fields,[md.mesh.numberofvertices 1]);
    48                                 checknan(md, 'basalforcings',fields);
     43                                checkfield(md,'basalforcings.melting_rate','NaN',1,'size',[md.mesh.numberofvertices 1]);
    4944                        end
    5045                        if ismember(ThermalAnalysisEnum,analyses),
    51                                 fields={'geothermalflux'};
    52                                 checksize(md,'basalforcings',fields,[md.mesh.numberofvertices 1]);
    53                                 checknan(md, 'basalforcings',fields);
     46                                checkfield(md,'basalforcings.melting_rate','NaN',1,'forcing',1);
     47                                checkfield(md,'basalforcings.geothermalflux','NaN',1,'forcing',1,'>=',0);
    5448                        end
    5549                end % }}}
  • issm/trunk/src/m/classes/constants.m

    r9853 r9860  
    4747                function flag = checkconsistency(obj,md,solution,analyses) % {{{
    4848
    49                         fields={'g'};
    50                         checknan(md,'constants',fields);
    51                         checkgreaterstrict(md,'constants',fields,0);
     49                        checkfield(md,'constants.g','>',0,'size',[1 1]);
     50                        checkfield(md,'constants.yts','>',0,'size',[1 1]);
     51                        checkfield(md,'constants.referencetemperature','size',[1 1]);
    5252
    5353                end % }}}
  • issm/trunk/src/m/classes/diagnostic.m

    r9854 r9860  
    7979                function checkconsistency(obj,md,solution,analyses) % {{{
    8080
    81                         fields={'restol','maxiter'};
    82                         checknan(md,'diagnostic',fields);
     81                        %Early return
     82                        if ~ismember(DiagnosticHorizAnalysisEnum,analyses), return; end
    8383
    84                         fields={'abstol','restol','reltol'};
    85                         checkgreaterstrict(md,'diagnostic',fields,0);
     84                        checkfield(md,'diagnostic.spcvx','forcing',1);
     85                        checkfield(md,'diagnostic.spcvy','forcing',1);
     86                        if md.mesh.dimension==3, checkfield(md,'diagnostic.spcvz','forcing',1); end
     87                        checkfield(md,'diagnostic.restol','size',[1 1],'>',0);
     88                        checkfield(md,'diagnostic.reltol','size',[1 1]);
     89                        checkfield(md,'diagnostic.abstol','size',[1 1]);
     90                        checkfield(md,'diagnostic.stokesreconditioning','size',[1 1],'NaN',1);
     91                        checkfield(md,'diagnostic.viscosity_overshoot','size',[1 1],'NaN',1);
     92                        if md.mesh.dimension==2,
     93                                checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1);
     94                        else
     95                                checkfield(md,'diagnostic.icefront','size',[NaN 6],'NaN',1);
     96                        end
     97                        checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]);
     98                        checkfield(md,'diagnostic.maxiter','size',[1 1],'>=',1);
     99                        checkfield(md,'diagnostic.referential','size',[md.mesh.numberofvertices 6]);
     100                        if ~isempty(md.diagnostic.requested_outputs),
     101                                checkfield(md,'diagnostic.requested_outputs','size',[NaN 1]);
     102                        end
    86103
    87                         fields={'icefront'};
    88                         if (md.mesh.dimension==2),
    89                                 checksize(md,'diagnostic',fields,[NaN 4]);
    90                         elseif md.mesh.dimension==3,
    91                                 checksize(md,'diagnostic',fields,[NaN 6]);
     104                        %singular solution
     105                        if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
     106                                checkmessage(['model ' md.miscellaneous.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
    92107                        end
    93                         fields={'icefront(:,end)'};
    94                         checkvalues(md,'diagnostic',fields,[0 1 2]);
    95 
    96                         fields={'referential'};
    97                         checksize(md,'diagnostic',fields,[md.mesh.numberofvertices 6]);
    98 
    99                         if ~isempty(md.diagnostic.requested_outputs),
    100                                 if(size(md.diagnostic.requested_outputs,2)~=1),
    101                                         checkmessage(['model ' md.miscellaneous.name ' requested outputs should be a column vector']);
     108                        %CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
     109                        if any(sum(isnan(md.diagnostic.referential),2)~=0 & sum(isnan(md.diagnostic.referential),2)~=6),
     110                                checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
     111                        end
     112                        %CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
     113                        if any(sum(isnan(md.diagnostic.referential),2)==0),
     114                                pos=find(sum(isnan(md.diagnostic.referential),2)==0);
     115                                if any(dot(md.diagnostic.referential(pos,1:3),md.diagnostic.referential(pos,4:6))),
     116                                        dot(md.diagnostic.referential(pos,1:3),md.diagnostic.referential(pos,4:6))
     117                                        checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
    102118                                end
    103119                        end
    104 
    105                         if ismember(DiagnosticHorizAnalysisEnum,analyses),
    106                                 %singular solution
    107                                 if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
    108                                         checkmessage(['model ' md.miscellaneous.name ' is not well posed (singular). You need at least one node with fixed velocity!'])
     120                        %CHECK THAT ROTATION IS IN THE (X,Y) PLANE FOR 2D MODELS
     121                        if md.mesh.dimension==2,
     122                                pos=find(sum(isnan(md.diagnostic.referential),2)==0  & md.flowequation.vertex_equation==2);
     123                                if any(md.diagnostic.referential(pos,3:5)~=0);
     124                                        checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. The rotation should be in the (x,y) plane for 2D diagnostic models (nodeonmacayeal)']);
    109125                                end
    110                                 %ROTATED SPC
    111                                 %CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
    112                                 if any(sum(isnan(md.diagnostic.referential),2)~=0 & sum(isnan(md.diagnostic.referential),2)~=6),
    113                                         checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Each line of diagnostic.referential should contain either only NaN values or no NaN values']);
    114                                 end
    115                                 %CHECK THAT THE TWO VECTORS PROVIDED ARE ORTHOGONAL
    116                                 if any(sum(isnan(md.diagnostic.referential),2)==0),
    117                                         pos=find(sum(isnan(md.diagnostic.referential),2)==0);
    118                                         if any(dot(md.diagnostic.referential(pos,1:3),md.diagnostic.referential(pos,4:6))),
    119                                                 dot(md.diagnostic.referential(pos,1:3),md.diagnostic.referential(pos,4:6))
    120                                                 checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. Vectors in diagnostic.referential (colums 1 to 3 and 4 to 6) must be orthogonal']);
    121                                         end
    122 
    123                                 end
    124                                 %CHECK THAT ROTATION IS IN THE (X,Y) PLANE FOR 2D MODELS
    125                                 if md.mesh.dimension==2,
    126                                         pos=find(sum(isnan(md.diagnostic.referential),2)==0  & md.flowequation.vertex_equation==2);
    127                                         if any(md.diagnostic.referential(pos,3:5)~=0);
    128                                                 checkmessage(['model ' md.miscellaneous.name ' has problem with rotated spc. The rotation should be in the (x,y) plane for 2D diagnostic models (nodeonmacayeal)']);
    129                                         end
    130                                 end
    131 
    132126                        end
    133 
    134127                end % }}}
    135128                function disp(obj) % {{{
  • issm/trunk/src/m/classes/flaim.m

    r9853 r9860  
    4343                function checkconsistency(obj,md,solution,analyses) % {{{
    4444
    45                         if solution~=FlaimSolutionEnum,
    46                                 return;
    47                         end
     45                        %Early return
     46                        if solution~=FlaimSolutionEnum, return; end
    4847
    49                         if ~exist(obj.tracks,'file')
    50                                 checkmessage(['flaim.tracks file ''' md.flaim.tracks ''' does not exist.']);
    51                         end
    52                         %   probably going to need some checks on flaim.flightreqs here
    53                         if (numel(obj.criterion)~=md.mesh.numberofvertices) & (numel(obj.criterion)~=md.mesh.numberofelements),
    54                                 checkmessage(['flaim.criterion vector must have number of nodes (' ...
    55                                         int2str(md.mesh.numberofvertices) ') or elements (' int2str(md.mesh.numberofelements)...
    56                                         ') values, not ' int2str(numel(md.flaim.criterion)) ' values.']);
    57                         end
     48                        checkfield(md,'flaim.tracks','file',1);
     49                        checkfield(md,'flaim.criterion','numel',[md.mesh.numberofvertices md.mesh.numberofelements]);
    5850
    5951                end % }}}
  • issm/trunk/src/m/classes/flowequation.m

    r9854 r9860  
    4444
    4545                        if ismember(DiagnosticHorizAnalysisEnum,analyses),
    46                                 %Check the size of flowequation.element_equation
    47                                 fields={'element_equation'};
    48                                 checksize(md,'flowequation',fields,[md.mesh.numberofelements 1]);
    49                                 %Check the values of flowequation.element_equation
    50                                 checkvalues(md,'flowequation',fields,[0:7]);
     46
     47                                checkfield(md,'flowequation.ismacayealpattyn','numel',1,'values',[0 1]);
     48                                checkfield(md,'flowequation.ishutter','numel',1,'values',[0 1]);
     49                                checkfield(md,'flowequation.isstokes','numel',1,'values',[0 1]);
    5150                                if (md.mesh.dimension==2),
    52                                         checkvalues(md,'flowequation',fields,[1 2]);
    53                                 end
    54                                 if (md.flowequation.ismacayealpattyn==0 && md.flowequation.ishutter==0 && md.flowequation.isstokes==0),
    55                                         checkmessage(['no elements type set for this model. at least one of ismacayealpattyn, ishutter and isstokes need to be =1']);
    56                                 end
    57 
    58                                 %VERTICESTYPE
    59                                 %Check the size of verticess_type
    60                                 fields={'vertex_equation'};
    61                                 checksize(md,'flowequation',fields,[md.mesh.numberofvertices 1]);
    62                                 %Check the values of flowequation.vertex_equation
    63                                 checkvalues(md,'flowequation',fields,[0:7]);
    64                                 if (md.mesh.dimension==2),
    65                                         checkvalues(md,'flowequation',fields,[1 2]);
     51                                        checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[1:2]);
     52                                        checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[1:2]);
     53                                else
     54                                        checkfield(md,'flowequation.vertex_equation','size',[md.mesh.numberofvertices 1],'values',[0:7]);
     55                                        checkfield(md,'flowequation.element_equation','size',[md.mesh.numberofelements 1],'values',[0:7]);
    6656                                end
    6757                                if (md.flowequation.ismacayealpattyn==0 && md.flowequation.ishutter==0 && md.flowequation.isstokes==0),
  • issm/trunk/src/m/classes/friction.m

    r9853 r9860  
    3838                function checkconsistency(obj,md,solution,analyses) % {{{
    3939
    40                         fields={'coefficient','p','q'};
    41                         checknan(md,'friction',fields);
    42                         checkgreater(md,'friction',fields,0);
     40                        %Early return
     41                        if ~ismember(DiagnosticHorizAnalysisEnum,analyses) & ~ismember(ThermalAnalysisEnum,analyses), return; end
    4342
    44                         fields={'p','q'};
    45                         checksize(md,'friction',fields,[md.mesh.numberofelements 1]);
    46 
    47                         fields={'coefficient'};
    48                         checksize(md,'friction',fields,[md.mesh.numberofvertices 1]);
     43                        checkfield(md,'friction.coefficient','NaN',1,'size',[md.mesh.numberofvertices 1]);
     44                        checkfield(md,'friction.q','NaN',1,'size',[md.mesh.numberofelements 1]);
     45                        checkfield(md,'friction.p','NaN',1,'size',[md.mesh.numberofelements 1]);
    4946                end % }}}
    5047                function disp(obj) % {{{
  • issm/trunk/src/m/classes/geometry.m

    r9854 r9860  
    3939                end % }}}
    4040                function checkconsistency(obj,md,solution,analyses) % {{{
    41                         fields={'surface','thickness','bed'};
    42                         checknan(md,'geometry',fields);
    43                         checksize(md,'geometry',fields,[md.mesh.numberofvertices 1]);
    4441
    45                         fields={'thickness'};
    46                         checkgreater(md,'geometry',fields,0);
    47 
     42                        checkfield(md,'geometry.surface'  ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
     43                        checkfield(md,'geometry.bed'      ,'NaN',1,'size',[md.mesh.numberofvertices 1]);
     44                        checkfield(md,'geometry.thickness','NaN',1,'size',[md.mesh.numberofvertices 1],'>',0);
    4845                        if any((obj.thickness-obj.surface+obj.bed)>10^-9),
    4946                                checkmessage(['equality thickness=surface-bed violated']);
    5047                        end
    51 
    52                         if ismember(PrognosticAnalysisEnum,analyses),
    53                                 fields={'thickness'};
    54                                 checkgreaterstrict(md,'geometry',fields,0);
    55                         end
    5648                end % }}}
    5749                function disp(obj) % {{{
  • issm/trunk/src/m/classes/groundingline.m

    r9853 r9860  
    4444                function checkconsistency(obj,md,solution,analyses) % {{{
    4545
    46                         if ~ismember({obj.migration},{'None' 'AgressiveMigration' 'SoftMigration'}),
    47                                 checkmessage(['groundingline.migration field should be ''None'' ''AgressiveMigration'' or ''SoftMigration''']);
    48                         end
     46                        checkfield(md,'groundingline.migration','values',{'None' 'AgressiveMigration' 'SoftMigration'});
     47
    4948                        if ~strcmp(obj.migration,'None'),
    5049                                if (md.mesh.dimension==3 | strcmpi(md.cluster.name,'none')),
  • issm/trunk/src/m/classes/mesh.m

    r9854 r9860  
    8080                function checkconsistency(obj,md,solution,analyses) % {{{
    8181
    82                         fields={'x','y','z','elements','elementonbed','elementonsurface','vertexonbed','vertexonsurface','elementconnectivity'};
    83                         checknan(md,'mesh',fields);
    84 
    85                         fields={'elements','elementonbed','elementonsurface','vertexonbed','vertexonsurface','elementconnectivity'};
    86                         checkgreater(md,'mesh',fields,0);
    87 
    88                         fields={'dimension','elements','numberofelements','numberofvertices'};
    89                         checkgreaterstrict(md,'mesh',fields,0);
    90                        
    91                         fields={'vertexonbed','vertexonsurface','x','y','z'};
    92                         checksize(md,'mesh',fields,[md.mesh.numberofvertices 1]);
    93 
    94                         fields={'elementonbed','elementonsurface'};
    95                         checksize(md,'mesh',fields,[md.mesh.numberofelements 1]);
    96 
    97                         fields={'elements'};
     82                        checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices 1]);
     83                        checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices 1]);
     84                        checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices 1]);
     85                        checkfield(md,'mesh.elements','NaN',1,'>',0,'values',1:md.mesh.numberofvertices);
    9886                        if(md.mesh.dimension==2),
    99                                 checksize(md,'mesh',fields,[md.mesh.numberofelements 3]);
     87                                checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 3]);
    10088                        else
    101                                 checksize(md,'mesh',fields,[md.mesh.numberofelements 6]);
     89                                checkfield(md,'mesh.elements','size',[md.mesh.numberofelements 6]);
    10290                        end
    10391                        if any(~ismember(1:md.mesh.numberofvertices,sort(unique(md.mesh.elements(:)))));
    104                                 checkmessage('orphan nodes have been found. Check the mesh');
     92                                checkmessage('orphan nodes have been found. Check the mesh outline');
    10593                        end
    106 
    107 
     94                        checkfield(md,'mesh.dimension','values',[2 3]);
     95                        checkfield(md,'mesh.numberoflayers','>=',0);
     96                        checkfield(md,'mesh.numberofelements','>',0);
     97                        checkfield(md,'mesh.numberofvertices','>',0);
     98                        %no checks for numberofedges lat long and hemisphere
     99                        checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]);
     100                        checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements 1],'values',[0 1]);
     101                        checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices 1],'values',[0 1]);
     102                        checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices 1],'values',[0 1]);
    108103                        if (md.mesh.dimension==2),
    109                                 if md.mesh.average_vertex_connectivity<9,
    110                                         checkmessage('model not consistent: connectivity should be at least 9 for 2d models');
    111                                 end
    112                         end
    113                         if md.mesh.dimension==3,
    114                                 if md.mesh.average_vertex_connectivity<24,
    115                                         checkmessage('model not consistent: connectivity should be at least 24 for 3d models');
    116                                 end
     104                                checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message','''mesh.average_vertex_connectivity'' should be at least 9 in 2d');
     105                        else
     106                                checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message','''mesh.average_vertex_connectivity'' should be at least 24 in 3d');
    117107                        end
    118108
     
    121111                                case PrognosticSolutionEnum,
    122112                                        if md.prognostic.stabilization==3,
    123                                                 if md.mesh.dimension~=2, checkmessage('Discontinuous Galerkin only supported for 2d meshes'); end
    124                                                 fields={'edges'};
    125                                                 checksize(md,'mesh',fields,[NaN 4]);
    126                                                 fields={'edges(:,1:3)'};
    127                                                 checknan(md,'mesh',fields);
    128                                                 checkgreaterstrict(md,'mesh',fields,0);
     113                                                checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
     114                                                checkfield(md,'mesh.edges','size',[NaN 4]);
     115                                                checkfield(md,'mesh.edges(:,1:3)','>',0);
    129116                                        end
    130117                                case BalancethicknessSolutionEnum,
    131118                                        if md.balancethickness.stabilization==3,
    132                                                 if md.mesh.dimension~=2, checkmessage('Discontinuous Galerkin only supported for 2d meshes'); end
    133                                                 fields={'edges'};
    134                                                 checksize(md,'mesh',fields,[NaN 4]);
    135                                                 fields={'edges(:,1:3)'};
    136                                                 checknan(md,'mesh',fields);
    137                                                 checkgreaterstrict(md,'mesh',fields,0);
     119                                                checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
     120                                                checkfield(md,'mesh.edges','size',[NaN 4]);
     121                                                checkfield(md,'mesh.edges(:,1:3)','>',0);
    138122                                        end
    139123                                case TransientSolutionEnum,
    140124                                        if md.transient.isprognostic & md.prognostic.stabilization==3,
    141                                                 if md.mesh.dimension~=2, checkmessage('Discontinuous Galerkin only supported for 2d meshes'); end
    142                                                 fields={'edges'};
    143                                                 checksize(md,'mesh',fields,[NaN 4]);
    144                                                 fields={'edges(:,1:3)'};
    145                                                 checknan(md,'mesh',fields);
    146                                                 checkgreaterstrict(md,'mesh',fields,0);
     125                                                checkfield(md,'mesh.dimension','values',2,'message','Discontinuous Galerkin only supported for 2d meshes');
     126                                                checkfield(md,'mesh.edges','size',[NaN 4]);
     127                                                checkfield(md,'mesh.edges(:,1:3)','>',0);
    147128                                        end
    148129                                case ThermalSolutionEnum,
    149                                         if md.mesh.dimension~=3, checkmessage('thermal solution only supported on 3d meshes'); end
     130                                        checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes');
    150131                        end
    151132                end % }}}
Note: See TracChangeset for help on using the changeset viewer.