| 1 | import numpy as np
|
|---|
| 2 |
|
|---|
| 3 | from checkfield import checkfield
|
|---|
| 4 | from fielddisplay import fielddisplay
|
|---|
| 5 | from project3d import project3d
|
|---|
| 6 | from structtoobj import structtoobj
|
|---|
| 7 | from WriteData import WriteData
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | class frictionshakti(object):
|
|---|
| 11 | """FRICTIONSHAKTI class definition
|
|---|
| 12 |
|
|---|
| 13 | Usage:
|
|---|
| 14 | friction = frictionshakti()
|
|---|
| 15 | """
|
|---|
| 16 |
|
|---|
| 17 | def __init__(self, *args): # {{{
|
|---|
| 18 | self.coefficient = np.nan
|
|---|
| 19 |
|
|---|
| 20 | nargs = len(args)
|
|---|
| 21 | if nargs == 0:
|
|---|
| 22 | self.setdefaultparameters()
|
|---|
| 23 | elif nargs == 1:
|
|---|
| 24 | self = structtoobj(self, args[0])
|
|---|
| 25 | # }}}
|
|---|
| 26 |
|
|---|
| 27 | def __repr__(self): # {{{
|
|---|
| 28 | s = 'Basal shear stress parameters: Sigma_b = coefficient^2 * Neff * u_b\n'
|
|---|
| 29 | s += '(effective stress Neff = rho_ice * g * thickness + rho_water * g * (head - b))\n'
|
|---|
| 30 | s += '{}\n'.format(fielddisplay(self, 'coefficient', 'friction coefficient [SI]'))
|
|---|
| 31 | return s
|
|---|
| 32 | # }}}
|
|---|
| 33 |
|
|---|
| 34 | def setdefaultparameters(self): # {{{
|
|---|
| 35 | return self
|
|---|
| 36 | # }}}
|
|---|
| 37 |
|
|---|
| 38 | def extrude(self, md): # {{{
|
|---|
| 39 | self.coefficient = project3d(md, 'vector', self.coefficient, 'type', 'node', 'layer', 1)
|
|---|
| 40 | return self
|
|---|
| 41 | # }}}
|
|---|
| 42 |
|
|---|
| 43 | def checkconsistency(self, md, solution, analyses): # {{{
|
|---|
| 44 | # Early return
|
|---|
| 45 | if 'StressbalanceAnalysis' not in analyses and 'ThermalAnalysis' not in analyses:
|
|---|
| 46 | return md
|
|---|
| 47 | md = checkfield(md, 'fieldname', 'friction.coefficient', 'timeseries', 1, 'NaN', 1, 'Inf', 1)
|
|---|
| 48 | return md
|
|---|
| 49 | # }}}
|
|---|
| 50 |
|
|---|
| 51 | def marshall(self, prefix, md, fid): # {{{
|
|---|
| 52 | WriteData(fid, prefix, 'name', 'md.friction.law', 'data', 8, 'format', 'Integer')
|
|---|
| 53 | WriteData(fid, prefix, 'object', self, 'fieldname', 'coefficient', 'format', 'DoubleMat', 'mattype', 1, 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
|
|---|
| 54 | # }}}
|
|---|