Skip to content
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

Introduce wrappers and separate transport from time discretisations #382

Merged
merged 22 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b3a0642
pull out wrappers into their own object and file
tommbendall Jun 23, 2023
069ebd9
lint fixes
tommbendall Jun 23, 2023
732717a
Merge branch 'main' into wrappers
tommbendall Jun 23, 2023
55eaf41
small fix to where we get idx from for mixed function spaces
tommbendall Jun 23, 2023
795f31b
try to pull out transport scheme into its own object. Not giving sens…
tommbendall Jun 25, 2023
c24af5e
reorganise transport discretisations and start to debug
tommbendall Jun 30, 2023
d704740
reorganisation to try to replicate old order of replace operations
tommbendall Jul 2, 2023
34d873b
transport schemes now working (only one example tried) -- still needs…
tommbendall Jul 2, 2023
0f3d736
rename and reorganise things -- example working
tommbendall Jul 6, 2023
7935f9c
try to get transport-only tests working, still a bug in form used in …
tommbendall Jul 7, 2023
c9fd053
get transport-only tests working properly. Still got to fix SUPG
tommbendall Jul 8, 2023
c4c767d
implement SUPG but there is still a bug
tommbendall Jul 8, 2023
3948d46
make spatial methods general, and roll out changes to integration tes…
tommbendall Jul 8, 2023
40bde26
apply new transport approach to lots of examples. Integration tests f…
tommbendall Jul 11, 2023
485dafc
fix remaining couple of bugs and lint, hopefully mostly working
tommbendall Jul 11, 2023
5481bcf
reorder arguments for PrescribedTransport stepper
tommbendall Jul 12, 2023
1962960
fix linearisations (by restoring them)
tommbendall Jul 12, 2023
71dd858
tie up final set of loose ends. More clearly separate circulation and…
tommbendall Jul 13, 2023
e035286
fix final two failing examples
tommbendall Jul 13, 2023
8dda4aa
improve comments
tommbendall Jul 24, 2023
e817cb1
Merge branch 'main' into wrappers
tommbendall Jul 24, 2023
3c2863a
fix lint
tommbendall Jul 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/compressible/dcmip_3_1_meanflow_quads.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho", subcycles=2),
SSPRK3(domain, "theta", options=SUPGOptions(), subcycles=2)]
transport_methods = [DGUpwind(eqns, field) for field in ["u", "rho", "theta"]]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields, transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
3 changes: 3 additions & 0 deletions examples/compressible/dry_bryan_fritsch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@
SSPRK3(domain, "theta", options=theta_opts),
SSPRK3(domain, "u", options=u_opts)]

transport_methods = [DGUpwind(eqns, field) for field in ["u", "rho", "theta"]]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
3 changes: 3 additions & 0 deletions examples/compressible/moist_bryan_fritsch.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
SSPRK3(domain, "cloud_water", options=EmbeddedDGOptions()),
ImplicitMidpoint(domain, "u")]

transport_methods = [DGUpwind(eqns, field) for field in ["u", "rho", "theta", "water_vapour", "cloud_water"]]

# Linear solver
linear_solver = CompressibleSolver(eqns)

Expand All @@ -72,6 +74,7 @@

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver,
physics_schemes=physics_schemes)

Expand Down
4 changes: 4 additions & 0 deletions examples/compressible/mountain_hydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho"),
SSPRK3(domain, "theta", options=theta_opts)]
transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "rho"),
DGUpwind(eqns, "theta", ibp=theta_opts.ibp)]

# Linear solver
params = {'mat_type': 'matfree',
Expand All @@ -100,6 +103,7 @@

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver,
alpha=alpha)

Expand Down
4 changes: 4 additions & 0 deletions examples/compressible/mountain_nonhydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho"),
SSPRK3(domain, "theta", options=theta_opts)]
transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "rho"),
DGUpwind(eqns, "theta", ibp=theta_opts.ibp)]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
12 changes: 8 additions & 4 deletions examples/compressible/robert_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@

# Transport schemes
theta_opts = EmbeddedDGOptions()
transported_fields = []
transported_fields.append(ImplicitMidpoint(domain, "u"))
transported_fields.append(SSPRK3(domain, "rho"))
transported_fields.append(SSPRK3(domain, "theta", options=theta_opts))
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho"),
SSPRK3(domain, "theta", options=theta_opts)]

transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "rho"),
DGUpwind(eqns, "theta")]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
13 changes: 9 additions & 4 deletions examples/compressible/skamarock_klemp_hydrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,21 @@
io = IO(domain, output, diagnostic_fields=diagnostic_fields)

# Transport schemes
transported_fields = []
transported_fields.append(ImplicitMidpoint(domain, "u"))
transported_fields.append(SSPRK3(domain, "rho"))
transported_fields.append(SSPRK3(domain, "theta", options=SUPGOptions()))
theta_opts = SUPGOptions()
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho"),
SSPRK3(domain, "theta", options=theta_opts)]

transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "rho"),
DGUpwind(eqns, "theta", ibp=theta_opts.ibp)]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
4 changes: 4 additions & 0 deletions examples/compressible/skamarock_klemp_nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho"),
SSPRK3(domain, "theta", options=theta_opts)]
transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "rho"),
DGUpwind(eqns, "theta", ibp=theta_opts.ibp)]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
12 changes: 9 additions & 3 deletions examples/compressible/straka_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@

# Equation
parameters = CompressibleParameters()
diffusion_options = [
("u", DiffusionParameters(kappa=75., mu=10./delta)),
("theta", DiffusionParameters(kappa=75., mu=10./delta))]
u_diffusion_opts = DiffusionParameters(kappa=75., mu=10./delta)
theta_diffusion_opts = DiffusionParameters(kappa=75., mu=10./delta)
diffusion_options = [("u", u_diffusion_opts), ("theta", theta_diffusion_opts)]
eqns = CompressibleEulerEquations(domain, parameters,
diffusion_options=diffusion_options)

Expand All @@ -65,16 +65,22 @@
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "rho"),
SSPRK3(domain, "theta", options=theta_opts)]
transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "rho"),
DGUpwind(eqns, "theta", ibp=theta_opts.ibp)]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Diffusion schemes
diffusion_schemes = [BackwardEuler(domain, "u"),
BackwardEuler(domain, "theta")]
diffusion_methods = [InteriorPenaltyDiffusion(eqns, "u", u_diffusion_opts),
InteriorPenaltyDiffusion(eqns, "theta", theta_diffusion_opts)]

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
spatial_methods=transport_methods+diffusion_methods,
linear_solver=linear_solver,
diffusion_schemes=diffusion_schemes)

Expand Down
6 changes: 5 additions & 1 deletion examples/compressible/unsaturated_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,22 @@
SSPRK3(domain, "cloud_water", options=theta_opts, limiter=limiter),
SSPRK3(domain, "rain", options=theta_opts, limiter=limiter)]

transport_methods = [DGUpwind(eqns, field) for field in ["u", "rho", "theta", "water_vapour", "cloud_water", "rain"]]

# Linear solver
linear_solver = CompressibleSolver(eqns)

# Physics schemes
# NB: to use wrapper options with Fallout, need to pass field name to time discretisation
physics_schemes = [(Fallout(eqns, 'rain', domain), SSPRK3(domain, field_name='rain', options=theta_opts, limiter=limiter)),
rainfall_method = DGUpwind(eqns, 'rain', outflow=True)
physics_schemes = [(Fallout(eqns, 'rain', domain, rainfall_method), SSPRK3(domain, field_name='rain', options=theta_opts, limiter=limiter)),
(Coalescence(eqns), ForwardEuler(domain)),
(EvaporationOfRain(eqns), ForwardEuler(domain)),
(SaturationAdjustment(eqns), ForwardEuler(domain))]

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver,
physics_schemes=physics_schemes)

Expand Down
2 changes: 2 additions & 0 deletions examples/incompressible/skamarock_klemp_incompressible.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@
b_opts = SUPGOptions()
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "b", options=b_opts)]
transport_methods = [DGUpwind(eqns, "u"), DGUpwind(eqns, "b", ibp=b_opts.ibp)]

# Linear solver
linear_solver = IncompressibleSolver(eqns)

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)

# ---------------------------------------------------------------------------- #
Expand Down
3 changes: 2 additions & 1 deletion examples/shallow_water/linear_williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@

# Transport schemes
transport_schemes = [ForwardEuler(domain, "D")]
transport_methods = [DGUpwind(eqns, "D")]

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transport_schemes)
stepper = SemiImplicitQuasiNewton(eqns, io, transport_schemes, transport_methods)

# ---------------------------------------------------------------------------- #
# Initial conditions
Expand Down
5 changes: 4 additions & 1 deletion examples/shallow_water/thermal_williamson2.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@
ShallowWaterPotentialEnstrophy(),
SteadyStateError('u'), SteadyStateError('D')]
io = IO(domain, output, diagnostic_fields=diagnostic_fields)
transport_methods = [DGUpwind(eqns, "u"),
DGUpwind(eqns, "D"),
DGUpwind(eqns, "b")]

# Time stepper
stepper = Timestepper(eqns, RK4(domain), io)
stepper = Timestepper(eqns, RK4(domain), io, spatial_methods=transport_methods)

# ----------------------------------------------------------------- #
# Initial conditions
Expand Down
3 changes: 2 additions & 1 deletion examples/shallow_water/williamson_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@
# Transport schemes
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "D", subcycles=2)]
transport_methods = [DGUpwind(eqns, "u"), DGUpwind(eqns, "D")]

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields)
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields, transport_methods)

# ------------------------------------------------------------------------ #
# Initial conditions
Expand Down
3 changes: 2 additions & 1 deletion examples/shallow_water/williamson_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@
# Transport schemes
transported_fields = [ImplicitMidpoint(domain, "u"),
SSPRK3(domain, "D")]
transport_methods = [DGUpwind(eqns, "u"), DGUpwind(eqns, "D")]

# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields)
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields, transport_methods)

# ------------------------------------------------------------------------ #
# Initial conditions
Expand Down
7 changes: 5 additions & 2 deletions gusto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from gusto.active_tracers import * # noqa
from gusto.common_forms import * # noqa
from gusto.configuration import * # noqa
from gusto.domain import * # noqa
from gusto.diagnostics import * # noqa
from gusto.diffusion import * # noqa
from gusto.diffusion_methods import * # noqa
from gusto.equations import * # noqa
from gusto.fml import * # noqa
from gusto.forcing import * # noqa
Expand All @@ -15,6 +16,8 @@
from gusto.physics import * # noqa
from gusto.preconditioners import * # noqa
from gusto.recovery import * # noqa
from gusto.spatial_methods import * # noqa
from gusto.time_discretisation import * # noqa
from gusto.timeloop import * # noqa
from gusto.transport_forms import * # noqa
from gusto.transport_methods import * # noqa
from gusto.wrappers import * # noqa
Loading
Loading