source: issm/trunk-jpl/src/m/classes/steadystate.py@ 16471

Last change on this file since 16471 was 16471, checked in by Mathieu Morlighem, 11 years ago

CHG: removing debuging print

File size: 2.2 KB
RevLine 
[13023]1import numpy
[12038]2from fielddisplay import fielddisplay
[13023]3from EnumDefinitions import *
4from checkfield import *
5from WriteData import *
[12038]6
[12958]7class steadystate(object):
[13023]8 """
9 STEADYSTATE class definition
10
11 Usage:
12 steadystate=steadystate();
13 """
14
[14640]15 def __init__(self): # {{{
[12038]16 self.reltol = 0
17 self.maxiter = 0
[16363]18 self.requested_outputs = []
[12123]19
20 #set defaults
21 self.setdefaultparameters()
22
[12038]23 #}}}
[14640]24 def __repr__(self): # {{{
[12038]25 string=' steadystate solution parameters:'
[13023]26 string="%s\n%s"%(string,fielddisplay(self,'reltol','relative tolerance criterion'))
27 string="%s\n%s"%(string,fielddisplay(self,'maxiter','maximum number of iterations'))
28 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional requested outputs'))
[12038]29 return string
30 #}}}
[16470]31 def defaultoutputs(self,md): # {{{
32
33 return md.stressbalance.defaultoutputs(md)+md.thermal.defaultoutputs(md)
34
35 #}}}
[14640]36 def setdefaultparameters(self): # {{{
[12123]37
38 #maximum of steady state iterations
[13023]39 self.maxiter=100
[12123]40
41 #Relative tolerance for the steadystate convertgence
[13023]42 self.reltol=0.01
[12123]43
[16470]44 #default output
45 self.requested_outputs=['default']
[13023]46 return self
[12123]47 #}}}
[13023]48 def checkconsistency(self,md,solution,analyses): # {{{
49
50 #Early return
51 if not solution==SteadystateSolutionEnum():
52 return md
53
54 if not md.timestepping.time_step==0:
55 md.checkmessage("for a steadystate computation, timestepping.time_step must be zero.")
56
[15771]57 if numpy.isnan(md.stressbalance.reltol):
58 md.checkmessage("for a steadystate computation, stressbalance.reltol (relative convergence criterion) must be defined!")
[13023]59
[16458]60 md = checkfield(md,'steadystate.requested_outputs','stringrow',1)
[16385]61
[13023]62 return md
63 # }}}
[15131]64 def marshall(self,md,fid): # {{{
[13023]65 WriteData(fid,'object',self,'fieldname','reltol','format','Double')
66 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer')
[16470]67
68 #process requested outputs
69 outputs = self.requested_outputs
70 indices = [i for i, x in enumerate(outputs) if x == 'default']
71 if len(indices) > 0:
72 outputscopy=outputs[0:max(0,indices[0]-1)]+self.defaultoutputs(md)+outputs[indices[0]+1:]
73 outputs =outputscopy
74 WriteData(fid,'data',outputs,'enum',SteadystateRequestedOutputsEnum(),'format','StringArray')
[13023]75 # }}}
Note: See TracBrowser for help on using the repository browser.