Ignore:
Timestamp:
12/22/21 10:39:44 (3 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 26742

Location:
issm/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src

  • issm/trunk/src/m/classes/solidearth.py

    r25836 r26744  
    44from fielddisplay import fielddisplay
    55from lovenumbers import lovenumbers
     6from MatlabFuncs import *
    67from planetradius import planetradius
    78from project3d import project3d
    89from rotational import rotational
    910from solidearthsettings import solidearthsettings
    10 from surfaceload import surfaceload
     11from solidearthsolution import solidearthsolution
    1112from WriteData import WriteData
    1213
     
    1718    Usage:
    1819        solidearth = solidearth()
     20        solidearth = solidearth('earth')
     21
     22    TODO:
     23    - Update translation from solidearth.m
    1924    """
    2025
    21     def __init__(self, *args):  #{{{
    22         self.initialsealevel    = np.nan
     26    def __init__(self, *args):  # {{{
    2327        self.settings           = solidearthsettings()
    24         self.external           = []
    25         self.surfaceload        = surfaceload()
     28        self.external           = None
    2629        self.lovenumbers        = lovenumbers()
    2730        self.rotational         = rotational()
     
    3134        self.partitionice       = []
    3235        self.partitionhydro     = []
     36        self.partitionocean     = []
    3337
    3438        nargs = len(args)
    35 
    3639        if nargs == 0:
    3740            self.setdefaultparameters('earth')
     
    4043        else:
    4144            raise Exception('solidearth constructor error message: zero or one argument only!')
    42     #}}}
    43 
     45    # }}}
    4446    def __repr__(self):  # {{{
    4547        s = '   solidearthinputs, forcings and settings:\n'
    46         s += '{}\n'.format(fielddisplay(self, 'initialsealevel', 'sea level at the start of computation [m]'))
    4748        s += '{}\n'.format(fielddisplay(self, 'planetradius', 'planet radius [m]'))
    4849        s += '{}\n'.format(fielddisplay(self, 'transitions', 'indices into parts of the mesh that will be icecaps'))
     
    5051        s += '{}\n'.format(fielddisplay(self, 'partitionice', 'ice partition vector for barystatic contribution'))
    5152        s += '{}\n'.format(fielddisplay(self, 'partitionhydro', 'hydro partition vector for barystatic contribution'))
     53        s += '{}\n'.format(fielddisplay(self, 'partitionocean', 'ocean partition vector for barystatic contribution'))
    5254        if not self.external:
    5355            s += '{}\n'.format(fielddisplay(self, 'external', 'external solution, of the type solidearthsolution'))
    5456        print(self.settings)
    55         print(self.surfaceload)
    5657        print(self.lovenumbers)
    5758        print(self.rotational)
    58         if self.external:
     59        if len(self.external):
    5960            print(self.external)
    6061        return s
    61     #}}}
    62 
     62    # }}}
    6363    def setdefaultparameters(self, planet):  # {{{
    64         # Default output
     64        # Output default
    6565        self.requested_outputs = ['default']
    6666
     
    7171        self.partitionice = []
    7272        self.partitionhydro = []
     73        self.partitionocean = []
    7374
    74         # No external solutions by defalt
    75         self.external = []
     75        # No external solutions by default
     76        self.external = None
    7677
    77         # Earth radius
     78        # Planet radius
    7879        self.planetradius = planetradius(planet)
    79     #}}}
     80    # }}}
     81    def checkconsistency(self, md, solution, analyses):  # {{{
     82        if ('SealevelchangeAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslc):
     83            return md
    8084
    81     def checkconsistency(self, md, solution, analyses):  # {{{
    82         if ('SealevelriseAnalysis' not in analyses) or (solution == 'TransientSolution' and not md.transient.isslr):
    83             return md
    84         md = checkfield(md, 'fieldname', 'solidearth.initialsealevel', 'NaN', 1, 'Inf', 1, 'size', [md.mesh.numberofvertices])
    8585        md = checkfield(md, 'fieldname', 'solidearth.requested_outputs', 'stringrow', 1)
    8686
    8787        self.settings.checkconsistency(md, solution, analyses)
    88         self.surfaceload.checkconsistency(md, solution, analyses)
    8988        self.lovenumbers.checkconsistency(md, solution, analyses)
    9089        self.rotational.checkconsistency(md, solution, analyses)
    9190        if self.external:
    92             if not isinstance(self.external,'solidearthsolution'):
     91            if not isa(self.external, solidearthsolution):
    9392                raise Exception('solidearth consistency check: external field should be a solidearthsolution')
    94             end
    95             self.external.checkconsistency(md,solution,analyses)
     93            self.external.checkconsistency(md, solution, analyses)
    9694        return md
    97     #}}}
    98 
    99     def defaultoutputs(self, md):  #{{{
     95    # }}}
     96    def defaultoutputs(self, md):  # {{{
    10097        return ['Sealevel']
    101     #}}}
    102 
    103     def marshall(self, prefix, md, fid):  #{{{
    104         WriteData(fid, prefix, 'object', self, 'fieldname', 'initialsealevel', 'mattype', 1, 'format', 'DoubleMat', 'timeserieslength', md.mesh.numberofvertices + 1, 'yts', md.constants.yts)
     98    # }}}
     99    def marshall(self, prefix, md, fid):  # {{{
    105100        WriteData(fid, prefix, 'object', self, 'fieldname', 'planetradius', 'format', 'Double')
    106101        WriteData(fid, prefix, 'object', self, 'fieldname', 'transitions', 'format', 'MatArray')
     
    116111            nparthydro = 0
    117112
     113        if len(self.partitionocean):
     114            npartocean = np.max(self.partitionocean) + 2
     115        else:
     116            npartocean = 0
     117
    118118        WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionice', 'mattype', 1, 'format', 'DoubleMat');
    119119        WriteData(fid, prefix, 'data', npartice, 'format', 'Integer', 'name', 'md.solidearth.npartice');
    120120        WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionhydro', 'mattype', 1, 'format', 'DoubleMat');
    121121        WriteData(fid, prefix, 'data', nparthydro,'format', 'Integer', 'name','md.solidearth.nparthydro');
     122        WriteData(fid, prefix, 'object', self, 'fieldname', 'partitionocean', 'mattype', 1, 'format', 'DoubleMat');
     123        WriteData(fid, prefix, 'data', npartocean,'format', 'Integer', 'name','md.solidearth.npartocean');
    122124
    123125        self.settings.marshall(prefix, md, fid)
    124         self.surfaceload.marshall(prefix, md, fid)
    125126        self.lovenumbers.marshall(prefix, md, fid)
    126127        self.rotational.marshall(prefix, md, fid)
    127128        if self.external:
     129            WriteData(fid, prefix, 'data', 1, 'format', 'Integer', 'name', 'md.solidearth.isexternal')
    128130            self.external.marshall(prefix, md, fid)
     131        else:
     132            WriteData(fid, prefix, 'data', 0, 'format', 'Integer', 'name', 'md.solidearth.isexternal')
    129133
    130         #process requested outputs
     134        # Process requested outputs
    131135        outputs = self.requested_outputs
    132136        pos = np.where(np.asarray(outputs) == 'default')[0]
    133137        if len(pos):
    134             outputs = np.delete(outputs, pos)  #remove 'default' from outputs
    135             outputs = np.append(outputs, self.defaultoutputs(md))  #add defaults
     138            outputs = np.delete(outputs, pos) # remove 'default' from outputs
     139            outputs = np.append(outputs, self.defaultoutputs(md)) # add defaults
    136140        WriteData(fid, prefix, 'data', outputs, 'name', 'md.solidearth.requested_outputs', 'format', 'StringArray')
    137     #}}}
    138 
    139     def extrude(self, md): #{{{
    140         self.initialsealevel = project3d(md, 'vector', self.initialsealevel, 'type', 'node')
     141    # }}}
     142    def extrude(self, md):  # {{{
    141143        return self
    142     #}}}
     144    # }}}
Note: See TracChangeset for help on using the changeset viewer.