source: issm/trunk/src/m/classes/mask.py@ 16137

Last change on this file since 16137 was 16137, checked in by Mathieu Morlighem, 12 years ago

merged trunk-jpl and trunk for revision 16135

File size: 1.4 KB
RevLine 
[12038]1from fielddisplay import fielddisplay
[13395]2from EnumDefinitions import *
3from checkfield import *
4from WriteData import *
[12038]5
[13395]6class mask(object):
7 """
8 MASK class definition
9
10 Usage:
11 mask=mask();
12 """
13
[15396]14 def __init__(self): # {{{
[16137]15 self.ice_levelset = float('NaN')
16 self.groundedice_levelset = float('NaN')
[12123]17
18 #set defaults
19 self.setdefaultparameters()
20
[12038]21 #}}}
[15396]22 def __repr__(self): # {{{
[14310]23 string=" masks:"
[12038]24
[16137]25 string="%s\n%s"%(string,fielddisplay(self,"groundedice_levelset","is ice grounded ? grounded ice if > 0, grounding line position if = 0, floating ice if < 0"))
26 string="%s\n%s"%(string,fielddisplay(self,"ice_levelset","presence of ice if > 0, icefront position if = 0, no ice if < 0"))
[12038]27 return string
28 #}}}
[15396]29 def setdefaultparameters(self): # {{{
[13395]30 return self
[12123]31 #}}}
[13395]32 def checkconsistency(self,md,solution,analyses): # {{{
33
[16137]34 md = checkfield(md,'mask.ice_levelset' ,'size',[md.mesh.numberofvertices])
35 isice=numpy.array(md.mask.ice_levelset>0,int)
36 totallyicefree=(numpy.sum(isice[md.mesh.elements-1],axis=1)==0).astype(int)
37 if any(totallyicefree):
38 raise TypeError("elements with no ice not implemented yet, each element should have at least one vertex with md.mask.ice_levelset > 0")
[13395]39
40 return md
41 # }}}
[15396]42 def marshall(self,md,fid): # {{{
[16137]43 WriteData(fid,'object',self,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1)
44 WriteData(fid,'object',self,'fieldname','ice_levelset','format','DoubleMat','mattype',1)
[13395]45 # }}}
Note: See TracBrowser for help on using the repository browser.