-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Covariant formulation of the shallow water equations (#58)
* add additional aux vars * compute christoffel symbols * fix typo in christoffel calculation * covariant SWE weak form runs now * covariant SWE weak form runs now * no longer pass surface_integral into prolong2mortars * bump compat for Trixi from 0.9 to 0.9.9 * add test for spherical SWE * approach to automatically transform to desired coordinate system * added missing aux_vars to prim2cons * both spherical and cartesian works now * add EC formulation * add tests and improve elixirs/docs/cases * more detailed docs * fix typo in docs * improve docs more * add docstring for covariant SWE * sqrtG -> J * fix typo in quadrilaterals * add vorticity calculation for covariant form * improve docs and comments * fix mistake in comment * Rossby-Haurwitz is actually Case 6, not Case 5 * cleanup * reformulate flux differencing * run formatter * a few more comments * add missing h in total energy/entropy calculation * rename source terms * fix comment p -> polydeg * add comments and streamline calculation of contravariant metric * describe the Christoffel symbols * specify in comment that J = sqrtG for analysis in covariant form * fix typo in auxvarnames * comment about possibility to compute Christoffel symbols exactly * replace u_ll_spherical with u_ll_global and likewise for u_rr * run formatter * fix docs * fix another typo in docs * weak form works with central-central * separate split-covariant equations from standard covariant * update geostrophic test values to be for after one day * Apply suggestions from code review Co-authored-by: Andrés Rueda-Ramírez <[email protected]> * revise docstrings and comments --------- Co-authored-by: Andrés Rueda-Ramírez <[email protected]>
- Loading branch information
1 parent
029c14e
commit 2db20a7
Showing
21 changed files
with
1,300 additions
and
144 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
examples/elixir_shallowwater_covariant_geostrophic_balance.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
############################################################################### | ||
# DGSEM for the shallow water equations in covariant form on the cubed sphere | ||
############################################################################### | ||
|
||
using OrdinaryDiffEq, Trixi, TrixiAtmo | ||
|
||
############################################################################### | ||
# Parameters | ||
|
||
initial_condition = initial_condition_geostrophic_balance | ||
polydeg = 3 | ||
cells_per_dimension = 5 | ||
n_saves = 10 | ||
tspan = (0.0, 5.0 * SECONDS_PER_DAY) | ||
|
||
############################################################################### | ||
# Spatial discretization | ||
|
||
mesh = P4estMeshCubedSphere2D(cells_per_dimension, EARTH_RADIUS, polydeg = polydeg, | ||
initial_refinement_level = 0, | ||
element_local_mapping = true) | ||
|
||
equations = CovariantShallowWaterEquations2D(EARTH_GRAVITATIONAL_ACCELERATION, | ||
EARTH_ROTATION_RATE, | ||
global_coordinate_system = GlobalSphericalCoordinates()) | ||
|
||
# Create DG solver with polynomial degree = polydeg | ||
solver = DGSEM(polydeg = polydeg, surface_flux = flux_lax_friedrichs, | ||
volume_integral = VolumeIntegralWeakForm()) | ||
|
||
# Transform the initial condition to the proper set of conservative variables | ||
initial_condition_transformed = transform_initial_condition(initial_condition, equations) | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_transformed, solver, | ||
source_terms = source_terms_geometric_coriolis) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
# Create ODE problem with time span from 0 to T | ||
ode = semidiscretize(semi, tspan) | ||
|
||
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation | ||
# setup and resets the timers | ||
summary_callback = SummaryCallback() | ||
|
||
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the | ||
# results | ||
analysis_callback = AnalysisCallback(semi, interval = 200, | ||
save_analysis = true, | ||
extra_analysis_errors = (:conservation_error,)) | ||
|
||
# The SaveSolutionCallback allows to save the solution to a file in regular intervals | ||
save_solution = SaveSolutionCallback(dt = (tspan[2] - tspan[1]) / n_saves, | ||
solution_variables = cons2cons) | ||
|
||
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step | ||
stepsize_callback = StepsizeCallback(cfl = 0.4) | ||
|
||
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE | ||
# solver | ||
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed | ||
# callbacks | ||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 100.0, save_everystep = false, callback = callbacks); | ||
|
||
# Print the timer summary | ||
summary_callback() |
81 changes: 81 additions & 0 deletions
81
examples/elixir_shallowwater_covariant_rossby_haurwitz_EC.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
############################################################################### | ||
# Entropy-conservative DGSEM for the shallow water equations in covariant form | ||
# on the cubed sphere | ||
############################################################################### | ||
|
||
using OrdinaryDiffEq, Trixi, TrixiAtmo | ||
|
||
############################################################################### | ||
# Parameters | ||
|
||
initial_condition = initial_condition_rossby_haurwitz | ||
polydeg = 3 | ||
cells_per_dimension = 5 | ||
n_saves = 10 | ||
tspan = (0.0, 7.0 * SECONDS_PER_DAY) | ||
|
||
############################################################################### | ||
# Spatial discretization | ||
|
||
mesh = P4estMeshCubedSphere2D(cells_per_dimension, EARTH_RADIUS, polydeg = polydeg, | ||
initial_refinement_level = 0, | ||
element_local_mapping = true) | ||
|
||
equations = SplitCovariantShallowWaterEquations2D(EARTH_GRAVITATIONAL_ACCELERATION, | ||
EARTH_ROTATION_RATE, | ||
global_coordinate_system = GlobalCartesianCoordinates()) | ||
|
||
# Use entropy-conservative two-point fluxes for volume and surface terms | ||
volume_flux = (flux_ec, flux_nonconservative_ec) | ||
surface_flux = (flux_ec, flux_nonconservative_ec) | ||
|
||
# Create DG solver with polynomial degree = polydeg | ||
solver = DGSEM(polydeg = polydeg, surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
# Transform the initial condition to the proper set of conservative variables | ||
initial_condition_transformed = transform_initial_condition(initial_condition, equations) | ||
|
||
# A semidiscretization collects data structures and functions for the spatial discretization | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition_transformed, solver, | ||
source_terms = source_terms_geometric_coriolis) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
# Create ODE problem with time span from 0 to T | ||
ode = semidiscretize(semi, tspan) | ||
|
||
# At the beginning of the main loop, the SummaryCallback prints a summary of the simulation | ||
# setup and resets the timers | ||
summary_callback = SummaryCallback() | ||
|
||
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the | ||
# results. Note that entropy should be conserved at the semi-discrete level. | ||
analysis_callback = AnalysisCallback(semi, interval = 200, | ||
save_analysis = true, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (entropy,)) | ||
|
||
# The SaveSolutionCallback allows to save the solution to a file in regular intervals | ||
save_solution = SaveSolutionCallback(dt = (tspan[2] - tspan[1]) / n_saves, | ||
solution_variables = cons2prim_and_vorticity) | ||
|
||
# The StepsizeCallback handles the re-calculation of the maximum Δt after each time step | ||
stepsize_callback = StepsizeCallback(cfl = 0.4) | ||
|
||
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE | ||
# solver | ||
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# OrdinaryDiffEq's `solve` method evolves the solution in time and executes the passed | ||
# callbacks | ||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 100.0, save_everystep = false, callback = callbacks); | ||
|
||
# Print the timer summary | ||
summary_callback() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.