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

[WIP] Wet/dry capabilities for 2D shallow water equations #1340

Merged
merged 145 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
9f4cfbf
HR of Chen and Noelle (1D) and edit SWE struct
svengoldberg Jan 20, 2023
529fe9e
Overload limiter (SWE 1D) to cut off waterheight
svengoldberg Jan 20, 2023
e87dbf2
New indicatorHG (SWE 1D) to apply FV on dry cells
svengoldberg Jan 20, 2023
fac5972
Threshold in rhs! before calculation (SWE 1D)
svengoldberg Jan 20, 2023
2443b8d
New lake_at_rest_error for SWE 1D
svengoldberg Jan 20, 2023
0decdaf
New wet/dry elixirs for testing scheme for SWE 1D
svengoldberg Jan 20, 2023
698185b
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-1d
svengoldberg Jan 20, 2023
15ae272
HR of Chen and Noelle (2D) and edit SWE struct
svengoldberg Jan 21, 2023
beca28a
Overload limiter (SWE 2D) to cut off waterheight
svengoldberg Jan 21, 2023
fc88648
New indicatorHG (SWE 2D) to apply FV on dry cells
svengoldberg Jan 21, 2023
43bf89a
Threshold in rhs! before calculation (SWE 2D)
svengoldberg Jan 21, 2023
7fafa29
New lake_at_rest_error for SWE 2D
svengoldberg Jan 21, 2023
0b31095
New wet/dry elixirs for testing scheme for SWE 2D
svengoldberg Jan 21, 2023
df5b1e9
Elixir SWE 2D: 3 mounds, problem with boundaries
svengoldberg Jan 21, 2023
62c7265
Fixed MethodError; apply_thresholds! too strict
svengoldberg Jan 21, 2023
92a51b1
Fixed MethodError; apply_thresholds! too strict
svengoldberg Jan 21, 2023
36517d2
Move threshold on volume integral in stage_limiter
svengoldberg Feb 9, 2023
71501c3
Indentation, spacing and comments adjustment
svengoldberg Feb 9, 2023
bbb3f8c
Renaming numerical HLL type flux (SWE 1D)
svengoldberg Feb 9, 2023
3a08116
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-1d
svengoldberg Feb 9, 2023
8c4dccd
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-2d
svengoldberg Feb 9, 2023
1b7c28d
Move threshold on volume integral in stage_limiter
svengoldberg Feb 9, 2023
99e67a2
Renaming numerical HLL type flux (SWE 2D)
svengoldberg Feb 9, 2023
304428a
Indentation, spacing and comments adjustment
svengoldberg Feb 10, 2023
a231148
Describing docs for Chen and Noelle HR (SWE 1D)
svengoldberg Feb 11, 2023
3bb0447
Edit SWE 1D elixirs, error-based solver and docs
svengoldberg Feb 11, 2023
449af84
Including tests on new SWE 1D elixirs
svengoldberg Feb 11, 2023
d5d9570
Describing docs for Chen and Noelle HR (SWE 2D)
svengoldberg Feb 11, 2023
4c306e8
Edit SWE 2D elixirs, error-based solver and docs
svengoldberg Feb 11, 2023
00621da
Including tests on new SWE 2D elixirs
svengoldberg Feb 11, 2023
2e2d2c2
New/reorganize positivity limiter (SWE 2D)
svengoldberg Feb 23, 2023
15930b1
New/reorganize positivity limiter (SWE 1D)
svengoldberg Feb 23, 2023
b0bb88d
Editing docs SWE 1D
svengoldberg Mar 2, 2023
648f7eb
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-1d
svengoldberg Mar 2, 2023
d9f1af6
Merge branch 'sg/wet-dry-swe-1d' of https://github.com/svengoldberg/T…
svengoldberg Mar 2, 2023
71c0452
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-2d
svengoldberg Mar 2, 2023
d614ec2
Editing docs SWE 2D
svengoldberg Mar 2, 2023
ef0e6e6
Rearrange cut off at interfaces, edit tests SWE 1D
svengoldberg Mar 3, 2023
022e0ee
Edit docs, add Ref
svengoldberg Mar 3, 2023
871567c
Edit docs and indenting (SWE 2D)
svengoldberg Mar 3, 2023
7dcb931
Rearrange cut off at interfaces, edit tests SWE 2D
svengoldberg Mar 3, 2023
7855926
Remove tree/structured mesh elixir from repo SWE2D
svengoldberg Mar 3, 2023
6eb44f4
Create unstructured mesh elixir SWE 2D
svengoldberg Mar 3, 2023
03a7095
Add 1D lake-at-rest-error logic to pass 1D tests
svengoldberg Mar 3, 2023
0bcf93f
Add 2D lake-at-rest-error logic to pass 2D tests
svengoldberg Mar 3, 2023
6906fc6
Fixed typo. Confusing name, but correct math
svengoldberg Apr 19, 2023
5bfd23c
Correction of comments and docstrings
svengoldberg Apr 25, 2023
aa5216e
Correction of comments and docstrings
svengoldberg Apr 25, 2023
9ede947
Rename mesh file in elixir for UnstructuredMesh
svengoldberg Apr 25, 2023
caa7f6f
Merge branch 'main' into sg/wet-dry-swe-2d
andrewwinters5000 Apr 26, 2023
b91bb6d
Update test_unstructured_2d.jl
andrewwinters5000 Apr 26, 2023
20b0cae
Merge branch 'main' into sg/wet-dry-swe-2d
andrewwinters5000 May 1, 2023
3a4db71
Fixing typos
svengoldberg May 1, 2023
3080aca
Merge branch 'sg/wet-dry-swe-2d' of https://github.com/svengoldberg/T…
svengoldberg May 1, 2023
66adf3e
fix dispatching error on new lake-at-rest error calculation. See if t…
andrewwinters5000 May 2, 2023
f089eef
Editing initial condition in parabolic bowl elixir
svengoldberg May 2, 2023
d4854fd
Merge branch 'sg/wet-dry-swe-2d' of https://github.com/svengoldberg/T…
svengoldberg May 2, 2023
30b3229
Delete unnecessary variable in elixir
svengoldberg May 2, 2023
76ca4c7
Merge branch 'main' into sg/wet-dry-swe-2d
andrewwinters5000 May 3, 2023
bc18814
adjust lake-at-rest error computation strategy. move specialized vers…
andrewwinters5000 May 3, 2023
b94c128
Merge branch 'sg/wet-dry-swe-2d' of github.com:svengoldberg/Trixi.jl …
andrewwinters5000 May 3, 2023
4b6d067
update structured mesh version of the wet-dry well-balancedness test
andrewwinters5000 May 3, 2023
d41ca0c
fix typos
andrewwinters5000 May 3, 2023
03a79a8
update values in parabolic bowl test on StructuredMesh
andrewwinters5000 May 4, 2023
e581469
update parabolic bowl test on TreeMesh
andrewwinters5000 May 4, 2023
b9ec599
revert the 1D computation of the lake-at-rest error to the standard w…
andrewwinters5000 May 4, 2023
444d81f
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-1d
svengoldberg May 4, 2023
4a500fb
Reset lake-at-rest error computation strategy.
svengoldberg May 4, 2023
5c1ac38
Fix typo
svengoldberg May 4, 2023
cdc86c1
Shorten test run for parabolic bowl 1D
svengoldberg May 4, 2023
af9f8cb
Choose lower resolution for parabolic bowl
svengoldberg May 4, 2023
d8a5bdb
Further reduce resolution for parabolic bowl
svengoldberg May 5, 2023
a108d59
adjust special initial conditions and well-balancedness error routine…
andrewwinters5000 May 6, 2023
7595ac2
Remove MPI from well-balanced test
svengoldberg May 10, 2023
e156bc2
simplify workaround to set discontinuous initial data
andrewwinters5000 May 10, 2023
4d4c570
Merge branch 'main' into sg/wet-dry-swe-2d
andrewwinters5000 May 10, 2023
a73060f
Merge branch 'main' into sg/wet-dry-swe-2d
andrewwinters5000 May 12, 2023
ae55a5c
Simplify workaround to set discontinuity
svengoldberg May 12, 2023
a423b82
Merge branch 'main' into sg/wet-dry-swe-2d
sloede May 14, 2023
5f92288
Change structure of Chen&Noelle flux
svengoldberg May 16, 2023
6974c39
Merge branch 'sg/wet-dry-swe-2d' of https://github.com/svengoldberg/T…
svengoldberg May 16, 2023
5cf5e94
Fix typos and indenting
svengoldberg May 16, 2023
1402eeb
Adjust call of solve and use ode_default_options
svengoldberg May 16, 2023
3506b29
Edit docstring
svengoldberg May 16, 2023
e9df987
Replace boolean with if, remove set_node_vars
svengoldberg May 18, 2023
ca4ca18
Change structure of Chen&Noelle flux
svengoldberg May 18, 2023
1a734af
Fix typos and indenting
svengoldberg May 18, 2023
b1b9fb1
Adjust call of solve and use ode_default_options
svengoldberg May 18, 2023
f579a72
Edit docstring
svengoldberg May 18, 2023
03daf4f
Replace boolean with if, remove set_node_vars
svengoldberg May 18, 2023
56d5195
Merge branch 'main' into sg/wet-dry-swe-1d
svengoldberg May 18, 2023
b406109
Merge branch 'sg/wet-dry-swe-1d' of https://github.com/svengoldberg/T…
svengoldberg May 18, 2023
4816eac
Update comment regarding H0 for lake-at-rest error
svengoldberg May 19, 2023
a593a71
Add the original source to the parabolic bowl test
svengoldberg May 19, 2023
bdc8c72
Update comment regarding H0 for lake-at-rest error
svengoldberg May 19, 2023
ef094ef
Add the original source to the parabolic bowl test
svengoldberg May 19, 2023
5be46c2
New sc indicator especially for SWE
svengoldberg May 19, 2023
744faa5
Remove threshold parameter from SWE limiter call
svengoldberg May 19, 2023
822bdcb
Merge branch 'main' into sg/wet-dry-swe-2d
andrewwinters5000 May 29, 2023
4aa5ff5
Merge branch 'dev' into sg/wet-dry-swe-2d
andrewwinters5000 Jun 2, 2023
052fce5
update some docstrings
andrewwinters5000 Jun 2, 2023
29ba920
remove type instability in positivty limiter
andrewwinters5000 Jun 2, 2023
aa04c1a
typo fix
andrewwinters5000 Jun 2, 2023
747767a
move safety check for dry state in the new positivity limiter into th…
andrewwinters5000 Jun 2, 2023
d415a5d
more docstring updates
andrewwinters5000 Jun 2, 2023
8590711
remove dummy comment added in the dev initial commit
andrewwinters5000 Jun 2, 2023
7494ff2
adjust default threshold values to be precision agnostic
andrewwinters5000 Jun 2, 2023
f2b94cb
update comment on the default threshold value in the new TreeMesh eli…
andrewwinters5000 Jun 2, 2023
3de76fe
update comments for the three new TreeMesh examples
andrewwinters5000 Jun 2, 2023
1578672
update IC comment for three mound test
andrewwinters5000 Jun 2, 2023
9bbcd6f
update IC comments for new StructuredMesh2D tests
andrewwinters5000 Jun 2, 2023
537a934
update comment on shallow water constructor
andrewwinters5000 Jun 2, 2023
e2a6a69
adjust comments in the shallow_water_2d file
andrewwinters5000 Jun 2, 2023
7260cd1
adjust comment regarding threshold_limiter in the new elixirs
andrewwinters5000 Jun 2, 2023
225220c
fix typos found by SpellCheck
andrewwinters5000 Jun 2, 2023
00c088e
Edit docs
svengoldberg Jun 5, 2023
4861503
Import Printf macros for printing wb error
svengoldberg Jun 5, 2023
1bd8b31
Remove type instability in Chen & Noelle HR
svengoldberg Jun 5, 2023
303e459
Change logic for setting SC indicator to one
svengoldberg Jun 5, 2023
71d563c
Change logic for default values of SWE struct
svengoldberg Jun 5, 2023
199d264
Merge branch 'trixi-framework:main' into sg/wet-dry-swe-1d
svengoldberg Jun 15, 2023
f99b016
Outsource HG shock capturing indicator for SWE
svengoldberg Jun 15, 2023
abade12
Move limiterthreshold into function & edit docs
svengoldberg Jun 15, 2023
3c306b1
Move new limiter safety check in same element loop
svengoldberg Jun 15, 2023
096d58e
Adjust default threshold values
svengoldberg Jun 15, 2023
eeb4dc4
Remove type instability
svengoldberg Jun 15, 2023
ac14ca3
Import Printf package for terminal output
svengoldberg Jun 15, 2023
a10e65d
Edit docs
svengoldberg Jun 15, 2023
10e5012
Add Printf package to the test/Project.toml
svengoldberg Jun 20, 2023
5a6dae4
Add Printf package to the test/Project.toml
svengoldberg Jun 20, 2023
724dc01
Merge branch 'dev' into sg/wet-dry-swe-2d
andrewwinters5000 Jun 20, 2023
a12a815
Typo fix in elixir_shallowwater_well_balanced_wet_dry.jl
andrewwinters5000 Jun 20, 2023
7b58582
Typo fix in elixir_shallowwater_well_balanced_wet_dry.jl
andrewwinters5000 Jun 20, 2023
56cbd05
unify new code with required formatting
andrewwinters5000 Jun 30, 2023
a5b128f
Merge branch 'dev' into sg/wet-dry-swe-2d
andrewwinters5000 Jun 30, 2023
a2c12ad
fix weird formatting and add 'format: noindent' where missing. fix cr…
andrewwinters5000 Jul 5, 2023
94c6494
add unit test for new show routine
andrewwinters5000 Jul 5, 2023
afd89ea
Merge branch 'dev' into sg/wet-dry-swe-2d
andrewwinters5000 Jul 5, 2023
eddb8cc
Merge branch 'sg/wet-dry-swe-2d' into sg/wet-dry-swe-1d
andrewwinters5000 Jul 6, 2023
d8e45c8
apply JuliaFormatter
andrewwinters5000 Jul 6, 2023
0792bd3
simplify elixir as we can set discontinuous ICs in 1D. Also update be…
andrewwinters5000 Jul 6, 2023
a2821f6
dummy commit to check push access
andrewwinters5000 Jul 6, 2023
675c154
remove dummy comment
andrewwinters5000 Jul 6, 2023
0cbf94d
Merge branch 'sg/wet-dry-swe-1d' into sg/wet-dry-swe-2d
andrewwinters5000 Jul 6, 2023
5eb4a00
typo fix
andrewwinters5000 Jul 6, 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
112 changes: 112 additions & 0 deletions examples/structured_2d_dgsem/elixir_shallowwater_conical_island.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant=9.81, H0=1.4)

"""
initial_condition_conical_island(x, t, equations::ShallowWaterEquations2D)

Initial condition for the [`ShallowWaterEquations2D`](@ref) to test the [`hydrostatic_reconstruction_chen_noelle`](@ref)
and its handling of discontinuous water heights at the start in combination with wetting and
drying. The bottom topography is given by a conical island in the middle of the domain. Around that
island, there is a cylindrical water column at t=0 and the rest of the domain is dry. This
discontinuous water height is smoothed by a logistic function. This simulation uses periodic
boundary conditions.
"""
function initial_condition_conical_island(x, t, equations::ShallowWaterEquations2D)
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
# Set the background values

v1 = 0.0
v2 = 0.0

x1, x2 = x
b = max(0.1, 1.0 - 4.0 * sqrt(x1^2 + x2^2))

# use a logistic function to transfer water height value smoothly
L = equations.H0 # maximum of function
x0 = 0.3 # center point of function
k = -25.0 # sharpness of transfer

H = max(b, L/(1.0 + exp(-k*(sqrt(x1^2+x2^2) - x0))))

# It is mandatory to shift the water level at dry areas to make sure the water height h
# stays positive. The system would not be stable for h set to a hard 0 due to division by h in
# the computation of velocity, e.g., (h v1) / h. Therefore, a small dry state threshold
# with a default value of 500*eps() ≈ 1e-13 in double precision, is set in the constructor above
# for the ShallowWaterEquations and added to the initial condition if h = 0.
# This default value can be changed within the constructor call depending on the simulation setup.
H = max(H, b + equations.threshold_limiter)
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
return prim2cons(SVector(H, v1, v2, b), equations)
end

initial_condition = initial_condition_conical_island

###############################################################################
# Get the DG approximation space

volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal)
surface_flux = (FluxHydrostaticReconstruction(flux_hll_chen_noelle, hydrostatic_reconstruction_chen_noelle),
flux_nonconservative_chen_noelle)

basis = LobattoLegendreBasis(4)

indicator_sc = IndicatorHennemannGassnerShallowWater(equations, basis,
alpha_max=0.5,
alpha_min=0.001,
alpha_smooth=true,
variable=waterheight_pressure)
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
volume_flux_dg=volume_flux,
volume_flux_fv=surface_flux)

solver = DGSEM(basis, surface_flux, volume_integral)

###############################################################################
# Get the StructuredMesh and setup a periodic mesh

coordinates_min = (-1.0, -1.0)
coordinates_max = (1.0, 1.0)

cells_per_dimension = (16, 16)

mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max)

# Create the semi discretization object
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

###############################################################################
# ODE solver

tspan = (0.0, 10.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=100,
save_initial_solution=true,
save_final_solution=true)

callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)

###############################################################################
# run the simulation

stage_limiter! = PositivityPreservingLimiterShallowWater(variables=(Trixi.waterheight,))

sol = solve(ode, SSPRK43(stage_limiter!);
ode_default_options()..., callback=callbacks);

summary_callback() # print the timer summary
117 changes: 117 additions & 0 deletions examples/structured_2d_dgsem/elixir_shallowwater_parabolic_bowl.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@

using OrdinaryDiffEq
using Trixi

###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant=9.81)

"""
initial_condition_parabolic_bowl(x, t, equations:: ShallowWaterEquations2D)

Well-known initial condition to test the [`hydrostatic_reconstruction_chen_noelle`](@ref) and its
wet-dry mechanics. This test has an analytical solution. The initial condition is defined by the
analytical solution at time t=0. The bottom topography defines a bowl and the water level is given
by an oscillating lake.
The original test and its analytical solution were first presented in
- William C. Thacker (1981)
Some exact solutions to the nonlinear shallow-water wave equations
[DOI: 10.1017/S0022112081001882](https://doi.org/10.1017/S0022112081001882).

The particular setup below is taken from Section 6.2 of
- Niklas Wintermeyer, Andrew R. Winters, Gregor J. Gassner and Timothy Warburton (2018)
An entropy stable discontinuous Galerkin method for the shallow water equations on
curvilinear meshes with wet/dry fronts accelerated by GPUs
[DOI: 10.1016/j.jcp.2018.08.038](https://doi.org/10.1016/j.jcp.2018.08.038).
"""
function initial_condition_parabolic_bowl(x, t, equations:: ShallowWaterEquations2D)
a = 1.0
h_0 = 0.1
sigma = 0.5
ω = sqrt(2 * equations.gravity * h_0) / a

v1 = -sigma * ω * sin(ω * t)
v2 = sigma * ω * cos(ω * t)

b = h_0 * ((x[1])^2 + (x[2])^2) / a^2

H = sigma * h_0 / a^2 * (2 * x[1] * cos(ω * t) + 2 * x[2] * sin(ω * t) - sigma) + h_0

# It is mandatory to shift the water level at dry areas to make sure the water height h
# stays positive. The system would not be stable for h set to a hard 0 due to division by h in
# the computation of velocity, e.g., (h v1) / h. Therefore, a small dry state threshold
# with a default value of 500*eps() ≈ 1e-13 in double precision, is set in the constructor above
# for the ShallowWaterEquations and added to the initial condition if h = 0.
# This default value can be changed within the constructor call depending on the simulation setup.
H = max(H, b + equations.threshold_limiter)
svengoldberg marked this conversation as resolved.
Show resolved Hide resolved
return prim2cons(SVector(H, v1, v2, b), equations)
end

initial_condition = initial_condition_parabolic_bowl


###############################################################################
# Get the DG approximation space

volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal)
surface_flux = (FluxHydrostaticReconstruction(flux_hll_chen_noelle, hydrostatic_reconstruction_chen_noelle),
flux_nonconservative_chen_noelle)

basis = LobattoLegendreBasis(4)

indicator_sc = IndicatorHennemannGassnerShallowWater(equations, basis,
alpha_max=0.6,
alpha_min=0.001,
alpha_smooth=true,
variable=waterheight_pressure)
volume_integral = VolumeIntegralShockCapturingHG(indicator_sc;
volume_flux_dg=volume_flux,
volume_flux_fv=surface_flux)

solver = DGSEM(basis, surface_flux, volume_integral)


###############################################################################

coordinates_min = (-2.0, -2.0)
coordinates_max = (2.0, 2.0)

cells_per_dimension = (150, 150)

mesh = StructuredMesh(cells_per_dimension, coordinates_min, coordinates_max)

# create the semi discretization object
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

###############################################################################
# ODE solvers, callbacks etc.

tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()

analysis_interval = 1000
analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=false,
extra_analysis_integrals=(energy_kinetic,
energy_internal,
lake_at_rest_error))

alive_callback = AliveCallback(analysis_interval=analysis_interval)

save_solution = SaveSolutionCallback(interval=100,
save_initial_solution=true,
save_final_solution=true)

callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, save_solution)

stage_limiter! = PositivityPreservingLimiterShallowWater(variables=(Trixi.waterheight,))

###############################################################################
# run the simulation

sol = solve(ode, SSPRK43(stage_limiter!);
ode_default_options()..., callback=callbacks);

summary_callback() # print the timer summary
Loading