-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split State into Domain and IO #320
Conversation
…ughout most of the model
c06f1d7
to
e4f5952
Compare
gusto/equations.py
Outdated
@@ -954,7 +954,7 @@ def __init__(self, domain, parameters, Omega=None, sponge=None, | |||
muexpr = conditional(z <= zc, | |||
0.0, | |||
mubar*sin((pi/2.)*(z-zc)/(H-zc))**2) | |||
self.mu = Function(W_DG).interpolate(muexpr) | |||
self.mu = self.prescribed_fields("coriolis", W_DG).interpolate(muexpr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the sponge function on the Coriolis space? Do we need to change the name of the space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that's a typo! Sorry, that should be the string "sponge"
for the name of the field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extensively discussed offline - looks great, thanks Tom!
This PR splits apart the
state
object -- at the moment this is a bit of a random bag of various different things. The idea is to make this into coherent objects which should then interact in a way that really captures what is going on in the model.The separation of things is as follows:
Spaces
SpaceCreator
is now in its own file (function_spaces.py
).Domain
mesh
, thespaces
and other things related to the geometry (e.g. thek
vector, theperp
operator andis_spherical
)dt
IO
Equation
parameters
for the equationTimestepper
fields
To make this work, there are several other parts of the model that have to change:
Fields
StateFields
object has been extended -- it is now initialised from aTimeLevelFields
object and existing fields can be added to it. This isintended so that the fields in the
StateFields
object can be pointers, andso at the start/end of time steps, prognostic fields don't need copying into/
out of this object.
StateFields
point to thetimestepper.x.np1
fieldsStateFields
object has a type (prognostic, prescribed,diagnostic or derived) which can help determine how that field is treated.
equation
unfortunately may need to see some other fields (for instancethe shallow-water equation needs Coriolis and topography fields). To address
this I have created a
PrescribedFields
object which is stored in theequation. See below for more discussion.
Diagnostics
StateFields
are now held by the time stepper, the interface to settingup the diagnostics must change, since the diagnostics need to see this object
(both to search for fields in it and also to store the diagnostics themselves).
A lot of the diagnostic code has then been reorganised.
__init__
contains an interface to specify whichfunction space the diagnostic field should be computed in, and what method
should be used to compute it (interpolation, projection, etc.)
setup
routine creates an object for evaluating thediagnostic, i.e. an
Interpolator
or aProjector
. This avoids us repeatedlycalling
.project
within the time loop.setup
routine must create aself.expr
correspondingto the diagnostic field. Then, the super
setup
method is called to create theevaluator object.
compute
method from base class,which simply calls the evaluator.
steady_state_errors
andperturbations
are no longer special cases and donot need special handling, so these have been removed from the
output_parameters
Linear Solver
two fields from the
_setup_solver
method to thesolve
method. This isbecause these pre-computations involve the reference profiles, which will not
have been set up when the solver is initialised. However it means these
computations are happening every time the solver is called, so we need to find
a way to avoid this.
moisture
argument from thelinear_solver
. Thisinformation can now be obtained from the active tracers.
Initialisation
Thus we have a clean separation in the code between: (a) building the model's
objects, (b) specifying the initial conditions, and (c) running the model. I
think this will make easy to create a
Model
object.Reference Profiles
linear solver.
haven't been initialised.
Miscellaneous