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

Last change on this file since 13023 was 13023, checked in by jschierm, 13 years ago

NEW: Yet another bunch more python checkconsistency and marshall methods for sub-classes (plus other minor changes).

File size: 1.8 KB
RevLine 
[12038]1#module imports
[13023]2import numpy
[12038]3from fielddisplay import fielddisplay
[13023]4from EnumDefinitions import *
5from checkfield import *
6from WriteData import *
[12038]7
[12958]8class steadystate(object):
[13023]9 """
10 STEADYSTATE class definition
11
12 Usage:
13 steadystate=steadystate();
14 """
15
[12038]16 #properties
17 def __init__(self):
18 # {{{ Properties
19 self.reltol = 0
20 self.maxiter = 0
21 self.requested_outputs = float('NaN')
[12123]22
23 #set defaults
24 self.setdefaultparameters()
25
[12038]26 #}}}
[13023]27 def __repr__(self):
[12038]28 # {{{ Display
29 string=' steadystate solution parameters:'
[13023]30 string="%s\n%s"%(string,fielddisplay(self,'reltol','relative tolerance criterion'))
31 string="%s\n%s"%(string,fielddisplay(self,'maxiter','maximum number of iterations'))
32 string="%s\n%s"%(string,fielddisplay(self,'requested_outputs','additional requested outputs'))
[12038]33 return string
34 #}}}
[12123]35
[13023]36 def setdefaultparameters(self):
[12123]37 # {{{setdefaultparameters
38
39 #maximum of steady state iterations
[13023]40 self.maxiter=100
[12123]41
42 #Relative tolerance for the steadystate convertgence
[13023]43 self.reltol=0.01
[12123]44
[13023]45 return self
[12123]46 #}}}
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
57 if numpy.isnan(md.diagnostic.reltol):
58 md.checkmessage("for a steadystate computation, diagnostic.reltol (relative convergence criterion) must be defined!")
59
60 return md
61 # }}}
62
63 def marshall(self,fid): # {{{
64 WriteData(fid,'object',self,'fieldname','reltol','format','Double')
65 WriteData(fid,'object',self,'fieldname','maxiter','format','Integer')
66 WriteData(fid,'object',self,'fieldname','requested_outputs','format','DoubleMat','mattype',3)
67 # }}}
68
Note: See TracBrowser for help on using the repository browser.