Changeset 20225


Ignore:
Timestamp:
02/21/16 23:25:36 (9 years ago)
Author:
dlcheng
Message:

ADD: maskpsl and gmtmask python versions. CHG: mesh3dsurface.py checkfield corrections

Location:
issm/trunk-jpl/src/m
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/mesh3dsurface.py

    r20223 r20225  
    33from EnumDefinitions import *
    44from numpy import *
     5from fielddisplay import fielddisplay
     6from checkfield import checkfield
     7from WriteData import WriteData
    58
    69class mesh3dsurface(object):
     
    3336                self.extractedelements           = NaN
    3437               
    35                 if len(args)==0:
     38                if not len(args):
    3639                        self.setdefaultparameters()
    3740                elif len(args)==1:
     
    4649                        raise RuntimeError('constructor not supported')
    4750
    48                 #set defaults
    49                 self.setdefaultparameters()
    50         #}}}
     51        # }}}
    5152        def __repr__(self): # {{{
    5253                string='   2D tria Mesh (horizontal):'
     54               
    5355                string+='\n      Elements and vertices:'
    5456                string="%s\n%s"%(string,fielddisplay(self,'numberofelements','number of elements'))
     
    7678                string="%s\n%s"%(string,fielddisplay(self,'extractedvertices','vertices extracted from the model()'))
    7779                string="%s\n%s"%(string,fielddisplay(self,'extractedelements','elements extracted from the model()'))
    78                 # }}}
     80               
     81                return string
     82        # }}}
    7983        def loadobj(self): # {{{
    8084                # This def is directly called by matlab when a model() selfect is
     
    9296                                else:
    9397                                        self.epsg=3031
    94                 # }}}
     98                return self
     99        # }}}
    95100        def setdefaultparameters(self): # {{{
    96101
     
    102107                self.average_vertex_connectivity=25
    103108                return self
    104                 # }}}
     109        # }}}
    105110        def checkconsistency(self,md,solution,analyses): # {{{
    106111
    107                 md = checkfield(md,'fieldname','mesh.x','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices,1])
    108                 md = checkfield(md,'fieldname','mesh.y','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices,1])
    109                 md = checkfield(md,'fieldname','mesh.z','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices,1])
    110                 md = checkfield(md,'fieldname','mesh.lat','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices,1])
    111                 md = checkfield(md,'fieldname','mesh.long','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices,1])
    112                 md = checkfield(md,'fieldname','mesh.r','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices,1])
    113                 md = checkfield(md,'fieldname','mesh.elements','NaN',1,'Inf',1,'>',0,'values',[md.mesh.numberofvertices])
     112                md = checkfield(md,'fieldname','mesh.x','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     113                md = checkfield(md,'fieldname','mesh.y','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     114                md = checkfield(md,'fieldname','mesh.z','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     115                md = checkfield(md,'fieldname','mesh.lat','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     116                md = checkfield(md,'fieldname','mesh.long','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     117                md = checkfield(md,'fieldname','mesh.r','NaN',1,'Inf',1,'size',[md.mesh.numberofvertices])
     118                md = checkfield(md,'fieldname','mesh.elements','NaN',1,'Inf',1,'>',0,'values',arange(1,md.mesh.numberofvertices+1))
    114119                md = checkfield(md,'fieldname','mesh.elements','size',[md.mesh.numberofelements,3])
    115120                if any(not ismember([md.mesh.numberofvertices],sort(unique(md.mesh.elements)))):
     
    124129                       
    125130                return md
    126                 # }}}
     131        # }}}
    127132        def marshall(self,md,fid): # {{{
    128                 WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain', domaintype(obj)]),'format','Integer')
    129                 WriteData(fid,'enum',DomainDimensionEnum(),'data',dimension(obj),'format','Integer')
    130                 WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(elementtype(obj)),'format','Integer')
     133                WriteData(fid,'enum',DomainTypeEnum(),'data',StringToEnum(['Domain', self.domaintype()]),'format','Integer')
     134                WriteData(fid,'enum',DomainDimensionEnum(),'data',self.dimension(),'format','Integer')
     135                WriteData(fid,'enum',MeshElementtypeEnum(),'data',StringToEnum(self.elementtype()),'format','Integer')
    131136                WriteData(fid,'object',obj,'class','mesh','fieldname','x','format','DoubleMat','mattype',1)
    132137                WriteData(fid,'object',obj,'class','mesh','fieldname','y','format','DoubleMat','mattype',1)
    133138                WriteData(fid,'object',obj,'class','mesh','fieldname','z','format','DoubleMat','mattype',1)
    134                 WriteData(fid,'enum',MeshLatEnum(),'data',obj.lat,'format','DoubleMat','mattype',1)
    135                 WriteData(fid,'enum',MeshLongEnum(),'data',obj.long,'format','DoubleMat','mattype',1)
     139                WriteData(fid,'enum',MeshLatEnum(),'data',md.mesh.lat,'format','DoubleMat','mattype',1)
     140                WriteData(fid,'enum',MeshLongEnum(),'data',md.mesh.long,'format','DoubleMat','mattype',1)
    136141                WriteData(fid,'object',obj,'class','mesh','fieldname','r','format','DoubleMat','mattype',1)
    137                 WriteData(fid,'enum',MeshZEnum(),'data',zeros(obj.numberofvertices,1),'format','DoubleMat','mattype',1)
     142                WriteData(fid,'enum',MeshZEnum(),'data',zeros(md.mesh.numberofvertices,1),'format','DoubleMat','mattype',1)
    138143                WriteData(fid,'object',obj,'class','mesh','fieldname','elements','format','DoubleMat','mattype',2)
    139144                WriteData(fid,'object',obj,'class','mesh','fieldname','numberofelements','format','Integer')
     
    141146                WriteData(fid,'object',obj,'class','mesh','fieldname','average_vertex_connectivity','format','Integer')
    142147                WriteData(fid,'object',obj,'class','mesh','fieldname','vertexonboundary','format','DoubleMat','mattype',1)
    143                 # }}}
     148        # }}}
    144149        def domaintype(self): # {{{
    145150                return '3Dsurface'
    146                 # }}}
     151        # }}}
    147152        def dimension(self): # {{{
    148153                return 2
    149                 # }}}
     154        # }}}
    150155        def elementtype(self): # {{{
    151156                return 'Tria'
    152                 # }}}
     157        # }}}
    153158        def processmesh(self,options): # {{{
    154159       
     
    161166                z        = self.z
    162167                return [x, y, z, elements, is2d, isplanet]
    163                 # }}}
     168        # }}}
    164169        def savemodeljs(self,fid,modelname): # {{{
    165170       
     
    185190                writejs1Darray(fid,[modelname, '.mesh.extractedelements'],self.extractedelements)
    186191
    187                 # }}}
     192        # }}}
    188193       
Note: See TracChangeset for help on using the changeset viewer.