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

Adding quasi 1d shallow water equations #1619

Merged
merged 30 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f3f397f
implementation of quasi shallow water equations 1d.
KrisshChawla Aug 29, 2023
a97dabd
added example elixer for shallow_water_quasi_1d
KrisshChawla Aug 29, 2023
b340a74
changed the names of Quasi1d equations
KrisshChawla Aug 29, 2023
af25d90
including and exported ShallowWaterEquationsQuasi1D
KrisshChawla Aug 29, 2023
5defbf6
exporting flux_chan_etal and flux_chan_nonconservative_etal
jlchan Aug 29, 2023
c045570
minor comment fix
jlchan Aug 29, 2023
09b2e4e
adding tests
jlchan Aug 29, 2023
71fab3e
Apply suggestions from code review
jlchan Aug 29, 2023
3362c04
Apply suggestions from code review
jlchan Aug 29, 2023
09ec421
Update src/equations/shallow_water_quasi_1d.jl
jlchan Aug 29, 2023
2d5c704
formatting
jlchan Aug 29, 2023
70c01ad
Merge remote-tracking branch 'KrisshChawla/quasi_shallow_water_1d' in…
jlchan Aug 29, 2023
d4f58b8
formatting
jlchan Aug 29, 2023
d434e89
forgot comma
jlchan Aug 30, 2023
2a2cb46
Apply suggestions from code review
KrisshChawla Aug 30, 2023
32d0289
renamed example elixir to elixir_shallow_water_quasi_1d_source_terms.jl
KrisshChawla Aug 30, 2023
0bc2e29
Apply suggestions from code review
KrisshChawla Aug 30, 2023
5330cc5
Update test_tree_1d_shallowwater.jl with renamed example elixir
KrisshChawla Aug 30, 2023
682bb76
Merge branch 'main' into quasi_shallow_water_1d
jlchan Aug 30, 2023
875b835
comment fix
KrisshChawla Aug 31, 2023
c2f6c36
comment fix for elixir_shallow_water_quasi_1d_source_terms.jl
KrisshChawla Aug 31, 2023
fe0b699
Merge branch 'main' into quasi_shallow_water_1d
KrisshChawla Sep 6, 2023
3df9255
Added well-balancedness test for shallow_water_quasi_1d
KrisshChawla Sep 8, 2023
baef12d
Added 'max_abs_speeds' function and 'lake_at_rest_error'
KrisshChawla Sep 8, 2023
c70ca5c
Updated test_tree_1d_shallowwater with quasi well-balancedness test
KrisshChawla Sep 8, 2023
edf45e0
File name fix in test_tree_1d_shallowwater
KrisshChawla Sep 8, 2023
ef6503c
Merge branch 'main' into quasi_shallow_water_1d
jlchan Sep 8, 2023
cc4c50b
Update examples/tree_1d_dgsem/elixir_shallowwater_quasi1d_well_balanc…
KrisshChawla Sep 8, 2023
7508ebc
Renamed to "elixir_shallowwater_quasi_1d_well_balanced.jl"
KrisshChawla Sep 8, 2023
cd3f4c1
Merge branch 'main' into quasi_shallow_water_1d
jlchan Sep 13, 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
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
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
2 changes: 2 additions & 0 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export AcousticPerturbationEquations2D,
LatticeBoltzmannEquations2D, LatticeBoltzmannEquations3D,
ShallowWaterEquations1D, ShallowWaterEquations2D,
ShallowWaterTwoLayerEquations1D, ShallowWaterTwoLayerEquations2D,
ShallowWaterEquationsQuasi1D,
LinearizedEulerEquations2D

export LaplaceDiffusion1D, LaplaceDiffusion2D,
Expand All @@ -164,6 +165,7 @@ export flux, flux_central, flux_lax_friedrichs, flux_hll, flux_hllc, flux_hlle,
flux_kennedy_gruber, flux_shima_etal, flux_ec,
flux_fjordholm_etal, flux_nonconservative_fjordholm_etal, flux_es_fjordholm_etal,
flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal,
flux_chan_etal, flux_nonconservative_chan_etal,
hydrostatic_reconstruction_audusse_etal, flux_nonconservative_audusse_etal,
# TODO: TrixiShallowWater: move anything with "chen_noelle" to new file
hydrostatic_reconstruction_chen_noelle, flux_nonconservative_chen_noelle,
Expand Down
1 change: 1 addition & 0 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ include("shallow_water_1d.jl")
include("shallow_water_2d.jl")
include("shallow_water_two_layer_1d.jl")
include("shallow_water_two_layer_2d.jl")
include("shallow_water_quasi_1d.jl")

# CompressibleEulerEquations
abstract type AbstractCompressibleEulerEquations{NDIMS, NVARS} <:
Expand Down
Loading
Loading