-
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.
* add hyperbolic_serre_green_naghdi_conservation.jl * use FastBroadcast.jl for hyperbolic SGN * minor performance tuning of hyperbolic SGN * use FastBroadcast.jl for standard SGN * relax FastBroadcast.jl compat to 0.3 * allow FastBroadcast 0.2.8 Co-authored-by: Joshua Lampert <[email protected]> --------- Co-authored-by: Joshua Lampert <[email protected]>
- Loading branch information
1 parent
36c8f28
commit 99583ab
Showing
7 changed files
with
261 additions
and
161 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
75 changes: 75 additions & 0 deletions
75
examples/hyperbolic_serre_green_naghdi_1d/hyperbolic_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,75 @@ | ||
# 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 | ||
|
||
############################################################################### | ||
# Semidiscretization of the hyperbolic Serre-Green-Naghdi equations | ||
|
||
bathymetry_type = bathymetry_mild_slope | ||
equations = HyperbolicSerreGreenNaghdiEquations1D(bathymetry_type; | ||
lambda = 500.0, | ||
gravity_constant = 9.81, | ||
eta0 = 1.0) | ||
|
||
function initial_condition_conservation_test(x, t, | ||
equations::HyperbolicSerreGreenNaghdiEquations1D, | ||
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) | ||
|
||
# We use the feature that we can only return the physical variables | ||
# used by the `hyperbolic_approximation_limit`, i.e., the | ||
# `SerreGreenNaghdiEquations1D.` | ||
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) | ||
|
||
# optimized time integration methods like this one are much more efficient | ||
# for stiff problems (λ big) than standard methods like Tsit5() | ||
alg = RDPK3SpFSAL35() | ||
sol = solve(ode, alg; | ||
save_everystep = 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
Oops, something went wrong.