[25836] | 1 | import numpy as np
|
---|
| 2 |
|
---|
| 3 | from checkfield import checkfield
|
---|
[18757] | 4 | from fielddisplay import fielddisplay
|
---|
[19048] | 5 | from project3d import project3d
|
---|
[18757] | 6 | from WriteData import WriteData
|
---|
| 7 |
|
---|
[24313] | 8 |
|
---|
[18757] | 9 | class calving(object):
|
---|
[25836] | 10 | """CALVING class definition
|
---|
[18757] | 11 |
|
---|
[25836] | 12 | Usage:
|
---|
| 13 | calving = calving()
|
---|
[24313] | 14 | """
|
---|
[18757] | 15 |
|
---|
[24313] | 16 | def __init__(self): # {{{
|
---|
[25836] | 17 | self.calvingrate = np.nan
|
---|
[24313] | 18 | self.setdefaultparameters()
|
---|
[18757] | 19 |
|
---|
[24313] | 20 | #}}}
|
---|
[18757] | 21 |
|
---|
[24313] | 22 | def __repr__(self): # {{{
|
---|
[25836] | 23 | s = ' Calving parameters:'
|
---|
| 24 | s += '{}\n'.format(fielddisplay(self, 'calvingrate', 'calving rate at given location [m / a]'))
|
---|
| 25 | return s
|
---|
[24313] | 26 | #}}}
|
---|
[18757] | 27 |
|
---|
[24313] | 28 | def extrude(self, md): # {{{
|
---|
| 29 | self.calvingrate = project3d(md, 'vector', self.calvingrate, 'type', 'node')
|
---|
| 30 | return self
|
---|
| 31 | #}}}
|
---|
[18757] | 32 |
|
---|
[24313] | 33 | def setdefaultparameters(self): # {{{
|
---|
| 34 | return self
|
---|
| 35 | #}}}
|
---|
[18955] | 36 |
|
---|
[24313] | 37 | def checkconsistency(self, md, solution, analyses): # {{{
|
---|
| 38 | #Early return
|
---|
[25836] | 39 | if solution != 'TransientSolution' or not md.transient.ismovingfront:
|
---|
[24313] | 40 | return md
|
---|
[18757] | 41 |
|
---|
[24313] | 42 | md = checkfield(md, 'fieldname', 'calving.calvingrate', '>=', 0, 'timeseries', 1, 'NaN', 1, 'Inf', 1)
|
---|
[18757] | 43 |
|
---|
[24313] | 44 | return md
|
---|
| 45 | # }}}
|
---|
| 46 |
|
---|
| 47 | def marshall(self, prefix, md, fid): # {{{
|
---|
| 48 | yts = md.constants.yts
|
---|
| 49 |
|
---|
| 50 | WriteData(fid, prefix, 'name', 'md.calving.law', 'data', 1, 'format', 'Integer')
|
---|
| 51 | WriteData(fid, prefix, 'object', self, 'fieldname', 'calvingrate', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', yts, 'scale', 1. / yts)
|
---|
| 52 | # }}}
|
---|