-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding quasi 1d shallow water equations (#1619)
* implementation of quasi shallow water equations 1d. * added example elixer for shallow_water_quasi_1d * changed the names of Quasi1d equations * including and exported ShallowWaterEquationsQuasi1D * exporting flux_chan_etal and flux_chan_nonconservative_etal * minor comment fix * adding tests * Apply suggestions from code review * Apply suggestions from code review * Update src/equations/shallow_water_quasi_1d.jl * formatting * formatting * forgot comma * Apply suggestions from code review Co-authored-by: Hendrik Ranocha <[email protected]> * renamed example elixir to elixir_shallow_water_quasi_1d_source_terms.jl * Apply suggestions from code review Co-authored-by: Andrew Winters <[email protected]> * Update test_tree_1d_shallowwater.jl with renamed example elixir * comment fix * comment fix for elixir_shallow_water_quasi_1d_source_terms.jl * Added well-balancedness test for shallow_water_quasi_1d The initial condition in the elixir is intended to test a discontinuous channel width 'a(x)' and bottom topography 'b(x)' on a periodic mesh. * Added 'max_abs_speeds' function and 'lake_at_rest_error' * Updated test_tree_1d_shallowwater with quasi well-balancedness test * File name fix in test_tree_1d_shallowwater * Update examples/tree_1d_dgsem/elixir_shallowwater_quasi1d_well_balanced.jl Co-authored-by: Jesse Chan <[email protected]> * Renamed to "elixir_shallowwater_quasi_1d_well_balanced.jl" --------- Co-authored-by: Jesse Chan <[email protected]> Co-authored-by: Jesse Chan <[email protected]> Co-authored-by: Hendrik Ranocha <[email protected]> Co-authored-by: Andrew Winters <[email protected]>
- Loading branch information
1 parent
32d837b
commit b942775
Showing
6 changed files
with
484 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
examples/tree_1d_dgsem/elixir_shallow_water_quasi_1d_source_terms.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,60 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# Semidiscretization of the quasi 1d shallow water equations | ||
# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details | ||
|
||
equations = ShallowWaterEquationsQuasi1D(gravity_constant = 9.81) | ||
|
||
initial_condition = initial_condition_convergence_test | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_chan_etal, flux_nonconservative_chan_etal) | ||
surface_flux = (FluxPlusDissipation(flux_chan_etal, DissipationLocalLaxFriedrichs()), | ||
flux_nonconservative_chan_etal) | ||
solver = DGSEM(polydeg = 3, surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = 0.0 | ||
coordinates_max = sqrt(2.0) | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 3, | ||
n_cells_max = 10_000, | ||
periodicity = true) | ||
|
||
# create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, | ||
source_terms = source_terms_convergence_test) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 1.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 500 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 200, | ||
save_initial_solution = true, | ||
save_final_solution = true) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
# use a Runge-Kutta method with automatic (error based) time step size control | ||
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8, | ||
ode_default_options()..., callback = callbacks); | ||
summary_callback() # print the timer summary |
84 changes: 84 additions & 0 deletions
84
examples/tree_1d_dgsem/elixir_shallowwater_quasi_1d_well_balanced.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,84 @@ | ||
using OrdinaryDiffEq | ||
using Trixi | ||
|
||
############################################################################### | ||
# semidiscretization of the shallow water equations with a discontinuous | ||
# bottom topography function and channel width function | ||
|
||
equations = ShallowWaterEquationsQuasi1D(gravity_constant = 9.81, H0 = 2.0) | ||
|
||
# Setup a truly discontinuous bottom topography function and channel width for | ||
# this academic testcase of well-balancedness. The errors from the analysis | ||
# callback are not important but the error for this lake-at-rest test case | ||
# `∑|H0-(h+b)|` should be around machine roundoff. | ||
# Works as intended for TreeMesh1D with `initial_refinement_level=3`. If the mesh | ||
# refinement level is changed the initial condition below may need changed as well to | ||
# ensure that the discontinuities lie on an element interface. | ||
function initial_condition_discontinuous_well_balancedness(x, t, | ||
equations::ShallowWaterEquationsQuasi1D) | ||
H = equations.H0 | ||
v = 0.0 | ||
|
||
# for a periodic domain, this choice of `b` and `a` mimic | ||
# discontinuity across the periodic boundary. | ||
b = 0.5 * (x[1] + 1) | ||
a = 2 + x[1] | ||
|
||
return prim2cons(SVector(H, v, b, a), equations) | ||
end | ||
|
||
initial_condition = initial_condition_discontinuous_well_balancedness | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_chan_etal, flux_nonconservative_chan_etal) | ||
surface_flux = volume_flux | ||
solver = DGSEM(polydeg = 4, surface_flux = surface_flux, | ||
volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) | ||
|
||
############################################################################### | ||
# Get the TreeMesh and setup a periodic mesh | ||
|
||
coordinates_min = -1.0 | ||
coordinates_max = 1.0 | ||
mesh = TreeMesh(coordinates_min, coordinates_max, | ||
initial_refinement_level = 3, | ||
n_cells_max = 10_000) | ||
|
||
# Create the semi discretization object | ||
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) | ||
|
||
############################################################################### | ||
# ODE solver | ||
|
||
tspan = (0.0, 100.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
############################################################################### | ||
# Callbacks | ||
|
||
summary_callback = SummaryCallback() | ||
|
||
analysis_interval = 1000 | ||
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, | ||
extra_analysis_integrals = (lake_at_rest_error,)) | ||
|
||
alive_callback = AliveCallback(analysis_interval = analysis_interval) | ||
|
||
save_solution = SaveSolutionCallback(interval = 1000, | ||
save_initial_solution = true, | ||
save_final_solution = true) | ||
|
||
stepsize_callback = StepsizeCallback(cfl = 3.0) | ||
|
||
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution, | ||
stepsize_callback) | ||
|
||
############################################################################### | ||
# run the simulation | ||
|
||
sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), | ||
dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback | ||
save_everystep = false, callback = callbacks); | ||
summary_callback() # print the timer summary |
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.