-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix flux (remove non-conservative part) * add test * formatting --------- Co-authored-by: Hendrik Ranocha <[email protected]>
- Loading branch information
Showing
3 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
examples/tree_1d_dgsem/elixir_shallowwater_quasi_1d_discontinuous.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,73 @@ | ||
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) | ||
|
||
function initial_condition_discontinuity(x, t, equations::ShallowWaterEquationsQuasi1D) | ||
H = 2 + 0.1 * exp(-25 * x[1]^2) | ||
v = 0.0 | ||
|
||
if x[1] > 0 | ||
b = 0.1 | ||
a = 1.0 | ||
else | ||
b = 0.0 | ||
a = 1.1 | ||
end | ||
|
||
return prim2cons(SVector(H, v, b, a), equations) | ||
end | ||
|
||
initial_condition = initial_condition_discontinuity | ||
|
||
############################################################################### | ||
# Get the DG approximation space | ||
|
||
volume_flux = (flux_chan_etal, flux_nonconservative_chan_etal) | ||
surface_flux = (flux_lax_friedrichs, 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.5 | ||
coordinates_max = 0.5 | ||
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) | ||
|
||
############################################################################### | ||
# ODE solvers, callbacks etc. | ||
|
||
tspan = (0.0, 0.25) | ||
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 |
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