[21341] | 1 | import numpy as np
|
---|
[12038] | 2 | from fielddisplay import fielddisplay
|
---|
[19105] | 3 | from project3d import project3d
|
---|
[17806] | 4 | from checkfield import checkfield
|
---|
| 5 | from WriteData import WriteData
|
---|
[20500] | 6 | import MatlabFuncs as m
|
---|
[12038] | 7 |
|
---|
[13395] | 8 | class mask(object):
|
---|
| 9 | """
|
---|
| 10 | MASK class definition
|
---|
| 11 |
|
---|
| 12 | Usage:
|
---|
| 13 | mask=mask();
|
---|
| 14 | """
|
---|
| 15 |
|
---|
[15396] | 16 | def __init__(self): # {{{
|
---|
[16137] | 17 | self.ice_levelset = float('NaN')
|
---|
| 18 | self.groundedice_levelset = float('NaN')
|
---|
[12123] | 19 |
|
---|
| 20 | #set defaults
|
---|
| 21 | self.setdefaultparameters()
|
---|
| 22 |
|
---|
[12038] | 23 | #}}}
|
---|
[15396] | 24 | def __repr__(self): # {{{
|
---|
[14310] | 25 | string=" masks:"
|
---|
[12038] | 26 |
|
---|
[16137] | 27 | 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"))
|
---|
[17806] | 28 | string="%s\n%s"%(string,fielddisplay(self,"ice_levelset","presence of ice if < 0, icefront position if = 0, no ice if > 0"))
|
---|
[12038] | 29 | return string
|
---|
| 30 | #}}}
|
---|
[19105] | 31 | def extrude(self,md): # {{{
|
---|
| 32 | self.ice_levelset=project3d(md,'vector',self.ice_levelset,'type','node')
|
---|
| 33 | self.groundedice_levelset=project3d(md,'vector',self.groundedice_levelset,'type','node')
|
---|
| 34 | return self
|
---|
| 35 | #}}}
|
---|
[15396] | 36 | def setdefaultparameters(self): # {{{
|
---|
[13395] | 37 | return self
|
---|
[12123] | 38 | #}}}
|
---|
[13395] | 39 | def checkconsistency(self,md,solution,analyses): # {{{
|
---|
[22758] | 40 | if(solution=='LoveSolution'):
|
---|
| 41 | return
|
---|
[13395] | 42 |
|
---|
[17806] | 43 | md = checkfield(md,'fieldname','mask.ice_levelset' ,'size',[md.mesh.numberofvertices])
|
---|
[21341] | 44 | isice=np.array(md.mask.ice_levelset<=0,int)
|
---|
| 45 | if np.sum(isice)==0:
|
---|
[18301] | 46 | raise TypeError("no ice present in the domain")
|
---|
[13395] | 47 |
|
---|
| 48 | return md
|
---|
| 49 | # }}}
|
---|
[21341] | 50 | def marshall(self,prefix,md,fid): # {{{
|
---|
| 51 | WriteData(fid,prefix,'object',self,'fieldname','groundedice_levelset','format','DoubleMat','mattype',1)
|
---|
| 52 | WriteData(fid,prefix,'object',self,'fieldname','ice_levelset','format','DoubleMat','mattype',1)
|
---|
[13395] | 53 | # }}}
|
---|