Changeset 12943
- Timestamp:
- 08/08/12 11:37:55 (13 years ago)
- Location:
- issm/trunk-jpl/src/m
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/classes/mesh.m
r12663 r12943 57 57 function obj = setdefaultparameters(obj) % {{{ 58 58 59 %the connectivity is the aver gaded number of nodes linked to a59 %the connectivity is the averaged number of nodes linked to a 60 60 %given node through an edge. This connectivity is used to initially 61 61 %allocate memory to the stiffness matrix. A value of 16 seems to -
issm/trunk-jpl/src/m/classes/mesh.py
r12123 r12943 1 1 #module imports 2 import numpy 2 3 from fielddisplay import fielddisplay 4 from checkfield import * 5 from EnumDefinitions import * 6 from MatlabFuncs import * 3 7 4 8 class mesh: … … 65 69 else: 66 70 string="\n%s"%(" Elements and vertices:") 67 68 71 string="%s\n%s"%(string,fielddisplay(obj,"numberofelements","number of elements")) 69 70 71 72 73 72 string="%s\n%s"%(string,fielddisplay(obj,"numberofvertices","number of vertices")) 74 73 string="%s\n%s"%(string,fielddisplay(obj,"elements","index into (x,y,z), coordinates of the vertices")) … … 80 79 81 80 string="%s%s"%(string,"\n Properties:") 82 83 81 string="%s\n%s"%(string,fielddisplay(obj,"dimension","mesh dimension (2d or 3d)")) 84 82 string="%s\n%s"%(string,fielddisplay(obj,"numberoflayers","number of extrusion layers")) … … 92 90 string="%s\n%s"%(string,fielddisplay(obj,"lowerelements","lower element list (NaN for element on the lower layer")) 93 91 string="%s\n%s"%(string,fielddisplay(obj,"vertexonboundary","vertices on the boundary of the domain flag list")) 94 95 92 string="%s\n%s"%(string,fielddisplay(obj,"segments","edges on domain boundary (vertex1 vertex2 element)")) 96 93 string="%s\n%s"%(string,fielddisplay(obj,"segmentmarkers","number associated to each segment")) … … 100 97 101 98 string="%s%s"%(string,"\n Extracted model:") 102 103 99 string="%s\n%s"%(string,fielddisplay(obj,"extractedvertices","vertices extracted from the model")) 104 100 string="%s\n%s"%(string,fielddisplay(obj,"extractedelements","elements extracted from the model")) … … 114 110 # {{{setdefaultparameters 115 111 116 #the connectivity is the aver gaded number of nodes linked to a112 #the connectivity is the averaged number of nodes linked to a 117 113 #given node through an edge. This connectivity is used to initially 118 114 #allocate memory to the stiffness matrix. A value of 16 seems to … … 124 120 #}}} 125 121 122 def checkconsistency(self,md,solution,analyses): # {{{ 123 124 md = checkfield(md,'mesh.x','NaN',1,'size',[md.mesh.numberofvertices]) 125 md = checkfield(md,'mesh.y','NaN',1,'size',[md.mesh.numberofvertices]) 126 md = checkfield(md,'mesh.z','NaN',1,'size',[md.mesh.numberofvertices]) 127 md = checkfield(md,'mesh.elements','NaN',1,'>',0,'values',range(1,md.mesh.numberofvertices+1)) 128 if md.mesh.dimension==2: 129 md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements,3]) 130 else: 131 md = checkfield(md,'mesh.elements','size',[md.mesh.numberofelements,6]) 132 if any(numpy.logical_not(ismember(range(1,md.mesh.numberofvertices+1),md.mesh.elements))): 133 md = checkmessage(md,"orphan nodes have been found. Check the mesh outline") 134 md = checkfield(md,'mesh.dimension','values',[2,3]) 135 md = checkfield(md,'mesh.numberoflayers','>=',0) 136 md = checkfield(md,'mesh.numberofelements','>',0) 137 md = checkfield(md,'mesh.numberofvertices','>',0) 138 #no checks for numberofedges lat long and hemisphere 139 md = checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements],'values',[0,1]) 140 md = checkfield(md,'mesh.elementonsurface','size',[md.mesh.numberofelements],'values',[0,1]) 141 md = checkfield(md,'mesh.vertexonbed','size',[md.mesh.numberofvertices],'values',[0,1]) 142 md = checkfield(md,'mesh.vertexonsurface','size',[md.mesh.numberofvertices],'values',[0,1]) 143 if md.mesh.dimension==2: 144 md = checkfield(md,'mesh.average_vertex_connectivity','>=',9,'message',"'mesh.average_vertex_connectivity' should be at least 9 in 2d") 145 else: 146 md = checkfield(md,'mesh.average_vertex_connectivity','>=',24,'message',"'mesh.average_vertex_connectivity' should be at least 24 in 3d") 147 md = checkfield(md,'mesh.elementconnectivity','size',[md.mesh.numberofelements,3],'NaN',1) 148 149 #Solution specific checks 150 if solution==PrognosticSolutionEnum: 151 if md.prognostic.stabilization==3: 152 md = checkfield(md,'mesh.dimension','values',2,'message',"Discontinuous Galerkin only supported for 2d meshes") 153 md = checkfield(md,'mesh.edges','size',[float('NaN'),4]) 154 md = checkfield(md,'mesh.edges[:,1:3]','>',0) 155 elif solution==BalancethicknessSolutionEnum: 156 if md.balancethickness.stabilization==3: 157 md = checkfield(md,'mesh.dimension','values',2,'message',"Discontinuous Galerkin only supported for 2d meshes") 158 md = checkfield(md,'mesh.edges','size',[float('NaN'),4]) 159 md = checkfield(md,'mesh.edges[:,1:3]','>',0) 160 elif solution==TransientSolutionEnum: 161 if md.transient.isprognostic and md.prognostic.stabilization==3: 162 md = checkfield(md,'mesh.dimension','values',2,'message',"Discontinuous Galerkin only supported for 2d meshes") 163 md = checkfield(md,'mesh.edges','size',[float('NaN'),4]) 164 md = checkfield(md,'mesh.edges[:,1:3]','>',0) 165 elif solution==ThermalSolutionEnum: 166 md = checkfield(md,'mesh.dimension','values',3,'message','thermal solution only supported on 3d meshes') 167 168 return md 169 # }}} 170 171 def marshall(self,fid): # {{{ 172 WriteData(fid,'object',self,'fieldname','x','format','DoubleMat','mattype',1) 173 WriteData(fid,'object',self,'fieldname','y','format','DoubleMat','mattype',1) 174 WriteData(fid,'object',self,'fieldname','z','format','DoubleMat','mattype',1) 175 WriteData(fid,'object',self,'fieldname','elements','format','DoubleMat','mattype',2) 176 WriteData(fid,'object',self,'fieldname','dimension','format','Integer') 177 WriteData(fid,'object',self,'fieldname','numberoflayers','format','Integer') 178 WriteData(fid,'object',self,'fieldname','numberofelements','format','Integer') 179 WriteData(fid,'object',self,'fieldname','numberofvertices','format','Integer') 180 WriteData(fid,'object',self,'fieldname','numberofedges','format','Integer') 181 WriteData(fid,'object',self,'fieldname','elementonbed','format','BooleanMat','mattype',2) 182 WriteData(fid,'object',self,'fieldname','elementonsurface','format','BooleanMat','mattype',2) 183 WriteData(fid,'object',self,'fieldname','vertexonbed','format','BooleanMat','mattype',1) 184 WriteData(fid,'object',self,'fieldname','vertexonsurface','format','BooleanMat','mattype',1) 185 WriteData(fid,'object',self,'fieldname','lowerelements','format','DoubleMat','mattype',2) 186 WriteData(fid,'object',self,'fieldname','upperelements','format','DoubleMat','mattype',2) 187 WriteData(fid,'object',self,'fieldname','edges','format','DoubleMat','mattype',3) 188 WriteData(fid,'object',self,'fieldname','elementconnectivity','format','DoubleMat','mattype',3) 189 WriteData(fid,'object',self,'fieldname','average_vertex_connectivity','format','Integer') 190 WriteData(fid,'object',self,'fieldname','elements2d','format','DoubleMat','mattype',3) 191 WriteData(fid,'object',self,'fieldname','numberofvertices2d','format','Integer') 192 WriteData(fid,'object',self,'fieldname','numberofelements2d','format','Integer') 193 # }}} 194 -
issm/trunk-jpl/src/m/classes/private.m
r12663 r12943 31 31 fielddisplay(obj,'isconsistent','is model self consistent'); 32 32 fielddisplay(obj,'runtimename','name of the run launched'); 33 fielddisplay(obj,'bamg','structure with mesh properties construc ed if bamg is used to mesh the domain');33 fielddisplay(obj,'bamg','structure with mesh properties constructed if bamg is used to mesh the domain'); 34 34 fielddisplay(obj,'solution','type of solution launched'); 35 35 -
issm/trunk-jpl/src/m/classes/private.py
r12123 r12943 6 6 def __init__(self): 7 7 # {{{ Properties 8 self.runtimename = '' 9 self.bamg = {} 10 self.solution = ''; 8 self.isconsistent = True; 9 self.runtimename = '' 10 self.bamg = {} 11 self.solution = ''; 11 12 12 13 #set defaults … … 17 18 # {{{ Display 18 19 string=' private parameters: do not change' 20 21 string="%s\n%s"%(string,fielddisplay(obj,'isconsistent','is model self consistent')) 19 22 string="%s\n%s"%(string,fielddisplay(obj,'runtimename','name of the run launched')) 20 string="%s\n%s"%(string,fielddisplay(obj,'bamg','structure with mesh properties construc ed if bamg is used to mesh the domain'))23 string="%s\n%s"%(string,fielddisplay(obj,'bamg','structure with mesh properties constructed if bamg is used to mesh the domain')) 21 24 string="%s\n%s"%(string,fielddisplay(obj,'solution','type of solution launched')) 22 25 return string -
issm/trunk-jpl/src/m/model/WriteData.py
r12827 r12943 9 9 10 10 Usage: 11 WriteData(fid, *args)11 WriteData(fid,varargin) 12 12 """ 13 13 14 14 #process options 15 options=pairoptions( args)15 options=pairoptions(*args) 16 16 17 17 #Get data properties -
issm/trunk-jpl/src/m/model/ismodelselfconsistent.py
r12889 r12943 17 17 18 18 #Go through a model fields, check that it is a class, and call checkconsistency 19 # fields=vars('model') 20 fields=dir(md) 21 for field in fields: 19 fields=vars(md) 20 for field in fields.iterkeys(): 22 21 23 22 #Some properties do not need to be checked -
issm/trunk-jpl/src/m/model/marshall.py
r12889 r12943 26 26 fields=vars(md) 27 27 28 for field in fields.i nterkeys():28 for field in fields.iterkeys(): 29 29 30 30 #Some properties do not need to be marshalled -
issm/trunk-jpl/src/m/utils/consistency/checkfield.py
r12842 r12943 8 8 CHECKFIELD - check field consistency 9 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 10 Used to check model consistency. 11 Available options: 12 - NaN: 1 if check that there is no NaN 13 - size: [lines cols], NaN for non checked dimensions 14 - >: greater than provided value 15 - >=: greater or equal to provided value 16 - <: smallerthan provided value 17 - <=: smaller or equal to provided value 18 - < vec: smallerthan provided values on each vertex 19 - forcing: 1 if check forcing consistency (size and time) 20 - values: cell of strings or vector of acceptable values 21 - numel: list of acceptable number of elements 22 - cell: 1 if check that is cell 23 - empty: 1 if check that non empty 24 - message: overloaded error message 25 25 26 27 26 Usage: 27 md = checkfield(md,fieldname,options); 28 28 29 30 31 32 29 Example: 30 md = checkfield(md,'mesh.elementonbed','size',[md.mesh.numberofelements 1],'values',[0 1]); 31 md = checkfield(md,'diagnostic.icefront','size',[NaN 4],'NaN',1); 32 md = checkfield(md,'diagnostic.icefront(:,end)','values',[0 1 2]); 33 33 """ 34 34 … … 37 37 38 38 #get field from model 39 field=getattr(md,fieldname) 39 # field=getattr(md,fieldname) 40 exec("field=md.%s" % fieldname) 40 41 41 42 #check empty 42 if 'empty' in options:43 if options.exist('empty'): 43 44 if not field: 44 45 md = md.checkmessage(options.getfieldvalue('message',\ … … 46 47 47 48 #Check size 48 if 'size' in options:49 if options.exist('size'): 49 50 fieldsize=options.getfieldvalue('size') 50 if numpy.isnan(fieldsize[0]):51 if not numpy.size(field,1)==fieldsize[1]:51 if len(fieldsize) == 1: 52 if (not numpy.size(field,0)==fieldsize[0]): 52 53 md = md.checkmessage(options.getfieldvalue('message',\ 53 "field '%s' should have %d columns" % (fieldname,fieldsize[1]))) 54 elif numpy.isnan(fieldsize[1]): 55 if not numpy.size(field,0)==fieldsize[0]: 56 md = md.checkmessage(options.getfieldvalue('message',\ 57 "field '%s' should have %d lines" % (fieldname,fieldsize[0]))) 58 else: 59 if (not numpy.size(field,0)==fieldsize[0]) or (not numpy.size(field,1)==fieldsize[1]): 60 md = md.checkmessage(options.getfieldvalue('message',\ 61 "field '%s' size should be %d x %d" % (fieldname,fieldsize[0],fieldsize[1]))) 54 "field '%s' size should be %d" % (fieldname,fieldsize[0]))) 55 elif len(fieldsize) == 2: 56 if numpy.isnan(fieldsize[0]): 57 if not numpy.size(field,1)==fieldsize[1]: 58 md = md.checkmessage(options.getfieldvalue('message',\ 59 "field '%s' should have %d columns" % (fieldname,fieldsize[1]))) 60 elif numpy.isnan(fieldsize[1]): 61 if not numpy.size(field,0)==fieldsize[0]: 62 md = md.checkmessage(options.getfieldvalue('message',\ 63 "field '%s' should have %d lines" % (fieldname,fieldsize[0]))) 64 else: 65 if (not numpy.size(field,0)==fieldsize[0]) or (not numpy.size(field,1)==fieldsize[1]): 66 md = md.checkmessage(options.getfieldvalue('message',\ 67 "field '%s' size should be %d x %d" % (fieldname,fieldsize[0],fieldsize[1]))) 62 68 63 69 #Check numel 64 if 'numel' in options:70 if options.exist('numel'): 65 71 fieldnumel=options.getfieldvalue('numel') 66 72 if not numpy.size(field) in fieldnumel: … … 88 94 89 95 #check values 90 if 'values' in options:96 if options.exist('values'): 91 97 fieldvalues=options.getfieldvalue('values') 92 98 if False in ismember(field,fieldvalues): … … 102 108 103 109 #check greater 104 if '>=' in options:110 if options.exist('>='): 105 111 lowerbound=options.getfieldvalue('>=') 106 112 if numpy.any(field<lowerbound): 107 113 md = md.checkmessage(options.getfieldvalue('message',\ 108 114 "field '%s' should have values above %d" % (fieldname,lowerbound))) 109 if '>' in options:115 if options.exist('>'): 110 116 lowerbound=options.getfieldvalue('>') 111 117 if numpy.any(field<=lowerbound): … … 114 120 115 121 #check smaller 116 if '<=' in options:122 if options.exist('<='): 117 123 upperbound=options.getfieldvalue('<=') 118 124 if numpy.any(field>upperbound): 119 125 md = md.checkmessage(options.getfieldvalue('message',\ 120 126 "field '%s' should have values below %d" % (fieldname,upperbound))) 121 if '<' in options:127 if options.exist('<'): 122 128 upperbound=options.getfieldvalue('<') 123 129 if numpy.any(field>=upperbound):
Note:
See TracChangeset
for help on using the changeset viewer.