-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
variable bathymetry Serre-Green-Naghdi equations (#135)
* variable bathymetry Serre-Green-Naghdi equations * Dingemans * format * various fixes * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * move function waterheight * bathymetry -> bathymetry_type * add bathymetry_type to elixirs and well-balanced test * move comments * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * format * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * Update src/equations/serre_green_naghdi_1d.jl Co-authored-by: Joshua Lampert <[email protected]> * use D1 for SBP op. * (h + b) -> eta * explain mild slope * -= * format * update Dingemans test values * fix bug * add new test used for benchmarks * fix typo * Apply suggestions from code review Co-authored-by: Joshua Lampert <[email protected]> * Update examples/serre_green_naghdi_1d/serre_green_naghdi_well_balanced.jl Co-authored-by: Joshua Lampert <[email protected]> * assemble_system_matrix! * solve_system_matrix! * Update src/equations/serre_green_naghdi_1d.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * update Dingemans * Update src/equations/serre_green_naghdi_1d.jl Co-authored-by: Joshua Lampert <[email protected]> * Update src/equations/serre_green_naghdi_1d.jl Co-authored-by: Joshua Lampert <[email protected]> * fix docstring of energy_total_modified * adapt tolerances for macOS CI * not only integrals --------- Co-authored-by: Joshua Lampert <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8fcba88
commit 935081c
Showing
16 changed files
with
1,041 additions
and
186 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ out*/ | |
/docs/build/ | ||
run | ||
run/* | ||
**/*.code-workspace |
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
69 changes: 69 additions & 0 deletions
69
examples/serre_green_naghdi_1d/serre_green_naghdi_conservation.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,69 @@ | ||
# This elixir contains an artificial setup that can be used to check the | ||
# conservation properties of the equations and numerical methods as well as | ||
# a possible directional bias (if the velocity is set to zero). See | ||
# - Hendrik Ranocha and Mario Ricchiuto (2024) | ||
# Structure-preserving approximations of the Serre-Green-Naghdi | ||
# equations in standard and hyperbolic form | ||
# [arXiv: 2408.02665](https://arxiv.org/abs/2408.02665) | ||
|
||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
bathymetry_type = bathymetry_variable # or bathymetry_mild_slope | ||
equations = SerreGreenNaghdiEquations1D(bathymetry_type; | ||
gravity_constant = 9.81, | ||
eta0 = 1.0) | ||
|
||
function initial_condition_conservation_test(x, t, | ||
equations::SerreGreenNaghdiEquations1D, | ||
mesh) | ||
eta = 1 + exp(-x^2) | ||
v = 1.0e-2 # set this to zero to test a directional bias | ||
b = 0.25 * cospi(x / 75) | ||
|
||
D = equations.eta0 - b | ||
return SVector(eta, v, D) | ||
end | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -150.0 | ||
coordinates_max = +150.0 | ||
N = 1_000 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with periodic SBP operators of accuracy order 2 | ||
accuracy_order = 2 | ||
solver = Solver(mesh, accuracy_order) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, | ||
initial_condition_conservation_test, solver; | ||
boundary_conditions = boundary_condition_periodic) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, 35.0) | ||
ode = semidiscretize(semi, tspan) | ||
|
||
# The callbacks support an additional `io` argument to write output to a file | ||
# or any other IO stream. The default is stdout. We use this here to enable | ||
# setting it to `devnull` to benchmark the full simulation including the time | ||
# to compute the errors etc. but without the time to write the output to the | ||
# terminal. | ||
io = stdout | ||
summary_callback = SummaryCallback(io) | ||
analysis_callback = AnalysisCallback(semi; interval = 10, io, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
momentum, | ||
entropy, | ||
entropy_modified)) | ||
|
||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
sol = solve(ode, Tsit5(); | ||
save_everystep = false, callback = callbacks) |
49 changes: 49 additions & 0 deletions
49
examples/serre_green_naghdi_1d/serre_green_naghdi_dingemans.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,49 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
bathymetry_type = bathymetry_variable # or bathymetry_mild_slope | ||
equations = SerreGreenNaghdiEquations1D(bathymetry_type; | ||
gravity_constant = 9.81) | ||
|
||
initial_condition = initial_condition_dingemans | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -138.0 | ||
coordinates_max = 46.0 | ||
N = 512 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with periodic upwind SBP operators of accuracy order 4 | ||
# (note that only central-type with even order are used) | ||
D1 = upwind_operators(periodic_derivative_operator; | ||
derivative_order = 1, accuracy_order = 3, | ||
xmin = xmin(mesh), xmax = xmax(mesh), | ||
N = nnodes(mesh)) | ||
solver = Solver(D1, nothing) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, 70.0) | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 10, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
momentum, | ||
entropy, | ||
entropy_modified)) | ||
|
||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
saveat = range(tspan..., length = 500) | ||
sol = solve(ode, Tsit5(), abstol = 1e-7, reltol = 1e-7, | ||
save_everystep = false, callback = callbacks, saveat = saveat) |
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
66 changes: 66 additions & 0 deletions
66
examples/serre_green_naghdi_1d/serre_green_naghdi_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,66 @@ | ||
using OrdinaryDiffEq | ||
using DispersiveShallowWater | ||
using SummationByPartsOperators: upwind_operators, periodic_derivative_operator | ||
|
||
############################################################################### | ||
# Semidiscretization of the Serre-Green-Naghdi equations | ||
|
||
bathymetry_type = bathymetry_variable # or bathymetry_mild_slope | ||
equations = SerreGreenNaghdiEquations1D(bathymetry_type; | ||
gravity_constant = 1.0, eta0 = 2.0) | ||
|
||
# Setup a truly discontinuous bottom topography function 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 | ||
# `∫|η-η₀|` should be around machine roundoff. | ||
function initial_condition_discontinuous_well_balancedness(x, t, | ||
equations::SerreGreenNaghdiEquations1D, | ||
mesh) | ||
# Set the background values | ||
eta = equations.eta0 | ||
v = 0.0 | ||
D = equations.eta0 - 1.0 | ||
|
||
# Setup a discontinuous bottom topography | ||
if x >= 0.5 && x <= 0.75 | ||
D = equations.eta0 - 1.5 - 0.5 * sinpi(2.0 * x) | ||
end | ||
|
||
return SVector(eta, v, D) | ||
end | ||
|
||
initial_condition = initial_condition_discontinuous_well_balancedness | ||
boundary_conditions = boundary_condition_periodic | ||
|
||
# create homogeneous mesh | ||
coordinates_min = -1.0 | ||
coordinates_max = 1.0 | ||
N = 512 | ||
mesh = Mesh1D(coordinates_min, coordinates_max, N) | ||
|
||
# create solver with periodic upwind SBP operators | ||
D1 = upwind_operators(periodic_derivative_operator, | ||
derivative_order = 1, | ||
accuracy_order = 3, # the resulting central operators have order 4 | ||
xmin = xmin(mesh), xmax = xmax(mesh), | ||
N = nnodes(mesh)) | ||
solver = Solver(D1, nothing) | ||
|
||
# semidiscretization holds all the necessary data structures for the spatial discretization | ||
semi = Semidiscretization(mesh, equations, initial_condition, solver, | ||
boundary_conditions = boundary_conditions) | ||
|
||
############################################################################### | ||
# Create `ODEProblem` and run the simulation | ||
tspan = (0.0, 30.0) | ||
ode = semidiscretize(semi, tspan) | ||
summary_callback = SummaryCallback() | ||
analysis_callback = AnalysisCallback(semi; interval = 10, | ||
extra_analysis_errors = (:conservation_error,), | ||
extra_analysis_integrals = (waterheight_total, | ||
momentum, | ||
entropy_modified, | ||
lake_at_rest_error)) | ||
callbacks = CallbackSet(analysis_callback, summary_callback) | ||
|
||
sol = solve(ode, Tsit5(), dt = 0.5, adaptive = false, callback = callbacks) |
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.