Skip to content

Commit 71fbfa6

Browse files
patrickersingranochaandrewwinters5000
authored
Move SWEs from Trixi.jl to TrixiShallowWater.jl (#96)
* move SWEs from Trixi.jl * switch to trixi version from separationPR for testing * switch to Trixi.jl version from PR for testing * try alternative way to test with PR version * update ci.yml * include workaround for test without coverage * add dgmulti and t8code testing * add ci workaround to documenter.yml * fix dostring references * apply formatter * update documenter.yml * update documenter.yml * fix comments * add debug statement to documenter.yml * update documenter.yml * remove debug statements * with external references in docs * rename SWE_WetDry to SWE * update docstrings * fix documenter.yml to julia v1.10 * add news.md entry * fix wavespeed estimates for SWE1D * adjust test tolerances to the floating-point format * Update examples/unstructured_2d_dgsem/elixir_shallowwater_ec_float32.jl Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> * Update elixir_shallowwater_perturbation_wet_dry_amr.jl Mistakenly merged conflict resolution with wrong equation name. * adjust equation name in new coarsen/refine routines * run formatter * Apply suggestions from code review Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> * rename swe files * uncomment type tests and remove experimental warning * apply suggestion from code review * Update src/equations/equations.jl Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se> * remove code highlighting for package names * test against Trixi/main * allow Trixi.jl v0.12 for docs * update version * update docstring reference for FluxHydrostaticReconstruction --------- Co-authored-by: Hendrik Ranocha <ranocha@users.noreply.github.com> Co-authored-by: Andrew Winters <andrew.ross.winters@liu.se>
1 parent dd51a30 commit 71fbfa6

File tree

83 files changed

+3225
-720
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3225
-720
lines changed

.github/workflows/Documenter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
- uses: julia-actions/setup-julia@v2
3333
with:
34-
version: '1'
34+
version: '1.10'
3535
show-versioninfo: true
3636
- uses: julia-actions/cache@v2
3737
- uses: julia-actions/julia-buildpkg@v1

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
- tree_2d
5252
- structured_2d
5353
- unstructured_2d
54+
- t8code_2d
55+
- dgmulti
5456
- p4est_2d
5557
- unit
5658
- upstream
@@ -99,6 +101,8 @@ jobs:
99101
- tree_2d
100102
- structured_2d
101103
- unstructured_2d
104+
- t8code_2d
105+
- dgmulti
102106
- p4est_2d
103107
- unit
104108
steps:

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ TrixiShallowWater.jl follows the interpretation of
55
used in the Julia ecosystem. Notable changes will be documented in this file
66
for human readability.
77

8+
## Changes when updating to v0.2 from v0.1.x
9+
10+
#### Added
11+
- New equation `ShallowWaterEquationsQuasi1D` and functions `FluxHydrostaticReconstruction`,
12+
`flux_nonconservative_audusse_etal`, and `hydrostatic_reconstruction_audusse_etal` are now available
13+
through TrixiShallowWater.jl instead of Trixi.jl. ([#96])
14+
15+
#### Changed
16+
- `ShallowWaterEquationsWetDry` have been renamed to `ShallowWaterEquations`. The source code
17+
for these equations is now implemented directly in TrixiShallowWater.jl ([#96]).
18+
19+
#### Deprecated
20+
21+
#### Removed
822

923
## Changes in the v0.1 lifecycle
1024

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "TrixiShallowWater"
22
uuid = "804cb1fc-5b08-4398-a671-a789bfe091b3"
33
authors = ["Andrew R. Winters <andrew.ross.winters@liu.se>", "Michael Schlottke-Lakemper <michael@sloede.com>"]
4-
version = "0.1.1-DEV"
4+
version = "0.2.0"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -19,5 +19,5 @@ Printf = "1"
1919
Roots = "2.1.6"
2020
Static = "1.1.1"
2121
StaticArrays = "1.9"
22-
Trixi = "0.11.10"
23-
julia = "1.10"
22+
Trixi = "0.12"
23+
julia = "1.10"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ HOHQMesh = "0.2"
2525
Literate = "2.20"
2626
OrdinaryDiffEqLowStorageRK = "1.3"
2727
OrdinaryDiffEqSSPRK = "1.2"
28-
Trixi = "0.11.10"
28+
Trixi = "0.12"
2929
Trixi2Vtk = "0.3.16"
3030
TrixiBottomTopography = "0.1"

docs/src/tutorials/elixir_shallowwater_dam_break_triangular.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# - Set up a SWE solver for wet/dry transitions
1414
# - Create custom initial conditions and source terms
1515
# - Save solution data at gauge points
16-
# - Visualization with [`Makie.jl`](https://docs.makie.org/dev/)
16+
# - Visualization with [Makie.jl](https://docs.makie.org/dev/)
1717

1818
# ## Load required packages
1919
# Before we start, we need to load the required packages. Besides TrixiShallowWater.jl, we require
20-
# [`Trixi.jl`](@extref Trixi.jl) for the spatial discretization and [`OrdinaryDiffEqSSPRK.jl`](https://docs.sciml.ai/OrdinaryDiffEq/stable/) for time integration.
21-
# In addition to that [`CairoMakie.jl`](https://docs.makie.org/dev/) is used for visualization and [`CSV.jl`](https://csv.juliadata.org/stable/) and [`DataFrames.jl`](https://dataframes.juliadata.org/stable/) will
20+
# [Trixi.jl](@extref Trixi.jl) for the spatial discretization and [OrdinaryDiffEqSSPRK.jl](https://docs.sciml.ai/OrdinaryDiffEq/stable/) for time integration.
21+
# In addition to that [CairoMakie.jl](https://docs.makie.org/dev/) is used for visualization and [CSV.jl](https://csv.juliadata.org/stable/) and [DataFrames.jl](https://dataframes.juliadata.org/stable/) will
2222
# be used to load the experimental data.
2323

2424
# Standard packages
@@ -33,16 +33,16 @@ using CSV
3333
# ## Prepare and run the problem setup
3434

3535
# In the first step we will set up the equation system. In this example we want to solve the
36-
# one-dimensional shallow water equations, so we will use the [`ShallowWaterEquationsWetDry1D`](@ref ShallowWaterEquationsWetDry1D)
36+
# one-dimensional shallow water equations, so we will use the [`ShallowWaterEquations1D`](@ref)
3737
# and specify the gravitational acceleration to `gravity = 9.812`. In contrast to the
38-
# [`Trixi.ShallowWaterEquations1D`](@extref Trixi.ShallowWaterEquations1D) type, this equation type
38+
# [`ShallowWaterEquations1D`](@ref) type, this equation type
3939
# contains additional parameters and methods that are needed to handle wetting and drying.
40-
equations = ShallowWaterEquationsWetDry1D(gravity = 9.812)
40+
equations = ShallowWaterEquations1D(gravity = 9.812)
4141

4242
# We then create a function to supply the initial condition for the simulation. Note, in the last
4343
# step of this function the water height needs to be shifted by a small value to avoid division by zero.
4444
function initial_condition_dam_break_triangular(x, t,
45-
equations::ShallowWaterEquationsWetDry1D)
45+
equations::ShallowWaterEquations1D)
4646
b = 0.0 # Bottom topography
4747
h = 0.0 # Water height
4848
v = 0.0 # Velocity
@@ -75,7 +75,7 @@ initial_condition = initial_condition_dam_break_triangular;
7575
# As we want to compare the results to experimental data, we also need to account for bottom friction.
7676
# For this we create a new source term, which adds a Manning friction term to the momentum equation.
7777
@inline function source_term_manning_friction(u, x, t,
78-
equations::ShallowWaterEquationsWetDry1D)
78+
equations::ShallowWaterEquations1D)
7979
h, hv, _ = u
8080

8181
n = 0.0125 # friction coefficient

docs/src/tutorials/elixir_shallowwater_monai_tsunami.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030

3131
# ## Load required packages
3232
# The core solver component is TrixiShallowWater.jl,
33-
# which requires [`Trixi.jl`](@extref Trixi.jl) for the underlying spatial discretization
34-
# and `OrdinaryDiffEqSSPRK.jl` for time integration.
35-
# `HOHQMesh.jl` is needed to generate an unstructured mesh for this problem.
36-
# `TrixiBottomTopography.jl` is needed to create a bathymetry approximation that is directly
33+
# which requires [Trixi.jl](@extref Trixi.jl) for the underlying spatial discretization
34+
# and OrdinaryDiffEqSSPRK.jl for time integration.
35+
# HOHQMesh.jl is needed to generate an unstructured mesh for this problem.
36+
# TrixiBottomTopography.jl is needed to create a bathymetry approximation that is directly
3737
# usable by Trixi.jl.
38-
# Finally, we include [`CairoMakie.jl`](https://docs.makie.org/stable/) for insitu visualization and `Trixi2Vtk.jl` for postprocessing.
38+
# Finally, we include [CairoMakie.jl](https://docs.makie.org/stable/) for insitu visualization and Trixi2Vtk.jl for postprocessing.
3939
using HOHQMesh
4040
using OrdinaryDiffEqSSPRK
4141
using Trixi
@@ -152,12 +152,12 @@ generate_mesh(monai);
152152
# for the tsunami runup problem.
153153

154154
# For this example we solve the two-dimensional shallow water equations,
155-
# so we use the [`ShallowWaterEquationsWetDry2D`](@ref ShallowWaterEquationsWetDry2D)
155+
# so we use the [`ShallowWaterEquations2D`](@ref)
156156
# and specify the gravitational acceleration to `gravity = 9.812`
157157
# as well as a background water height `H0 = 0.0`.
158-
# In contrast to the [`Trixi.ShallowWaterEquations2D`](@extref Trixi.ShallowWaterEquations2D) type,
159-
# this equation type contains additional parameters and methods needed to handle wetting and drying.
160-
equations = ShallowWaterEquationsWetDry2D(gravity = 9.81, H0 = 0.0)
158+
# In contrast to the [`ShallowWaterEquations2D`](@ref) type,
159+
# this equation type allows contains additional parameters and methods needed to handle wetting and drying.
160+
equations = ShallowWaterEquations2D(gravity = 9.81, H0 = 0.0)
161161

162162
# Next, we construct an approximation to the bathymetry with TrixiBottomTopography.jl using
163163
# a [`BicubicBSpline`](https://trixi-framework.github.io/TrixiBottomTopography.jl/stable/reference/#TrixiBottomTopography.BicubicBSpline)
@@ -176,7 +176,7 @@ bathymetry(x::Float64, y::Float64) = spline_interpolation(bath_spline_struct, x,
176176

177177
# We then create a function to supply the initial condition for the simulation.
178178
@inline function initial_condition_monai_tsunami(x, t,
179-
equations::ShallowWaterEquationsWetDry2D)
179+
equations::ShallowWaterEquations2D)
180180
## Initially water is at rest
181181
v1 = 0.0
182182
v2 = 0.0
@@ -221,7 +221,7 @@ H_from_wave_maker(t::Float64) = spline_interpolation(h_spline_struct, t);
221221
# wave maker.
222222
@inline function boundary_condition_wave_maker(u_inner, normal_direction::AbstractVector,
223223
x, t, surface_flux_functions,
224-
equations::ShallowWaterEquationsWetDry2D)
224+
equations::ShallowWaterEquations2D)
225225
## Extract the numerical flux functions to compute the conservative and nonconservative
226226
## pieces of the approximation
227227
surface_flux_function, nonconservative_flux_function = surface_flux_functions
@@ -263,7 +263,7 @@ boundary_condition = Dict(:Bottom => boundary_condition_slip_wall,
263263
# For this application, we also need to model the bottom friction.
264264
# Thus, we create a new source term, which adds a Manning friction term to the momentum equations.
265265
@inline function source_terms_manning_friction(u, x, t,
266-
equations::ShallowWaterEquationsWetDry2D)
266+
equations::ShallowWaterEquations2D)
267267
h, hv_1, hv_2, _ = u
268268

269269
n = 0.001 # friction coefficient
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK
2+
using Trixi
3+
using TrixiShallowWater
4+
5+
###############################################################################
6+
# Semidiscretization of the quasi 1d shallow water equations
7+
# See Chan et al. https://doi.org/10.48550/arXiv.2307.12089 for details
8+
9+
equations = ShallowWaterEquationsQuasi1D(gravity = 9.81)
10+
11+
initial_condition = initial_condition_convergence_test
12+
13+
volume_flux = (flux_chan_etal, flux_nonconservative_chan_etal)
14+
surface_flux = (FluxPlusDissipation(flux_chan_etal, DissipationLocalLaxFriedrichs()),
15+
flux_nonconservative_chan_etal)
16+
17+
dg = DGMulti(polydeg = 4, element_type = Line(), approximation_type = SBP(),
18+
surface_integral = SurfaceIntegralWeakForm(surface_flux),
19+
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
20+
21+
cells_per_dimension = (8,)
22+
mesh = DGMultiMesh(dg, cells_per_dimension,
23+
coordinates_min = (0.0,), coordinates_max = (sqrt(2),),
24+
periodicity = true)
25+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg;
26+
source_terms = source_terms_convergence_test)
27+
28+
###############################################################################
29+
# ODE solvers, callbacks etc.
30+
31+
tspan = (0.0, 1.0)
32+
ode = semidiscretize(semi, tspan)
33+
34+
summary_callback = SummaryCallback()
35+
36+
analysis_interval = 100
37+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
38+
39+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
40+
41+
callbacks = CallbackSet(summary_callback,
42+
analysis_callback,
43+
alive_callback)
44+
45+
###############################################################################
46+
# run the simulation
47+
48+
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-8, reltol = 1.0e-8,
49+
ode_default_options()..., callback = callbacks)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using OrdinaryDiffEqSSPRK, OrdinaryDiffEqLowStorageRK
2+
using Trixi
3+
using TrixiShallowWater
4+
5+
###############################################################################
6+
# semidiscretization of the shallow water equations
7+
8+
equations = ShallowWaterEquations2D(gravity = 9.81)
9+
10+
initial_condition = initial_condition_convergence_test
11+
12+
volume_flux = (flux_wintermeyer_etal, flux_nonconservative_wintermeyer_etal)
13+
surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal)
14+
dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = SBP(),
15+
surface_integral = SurfaceIntegralWeakForm(surface_flux),
16+
volume_integral = VolumeIntegralFluxDifferencing(volume_flux))
17+
18+
cells_per_dimension = (8, 8)
19+
mesh = DGMultiMesh(dg, cells_per_dimension,
20+
coordinates_min = (0.0, 0.0), coordinates_max = (sqrt(2), sqrt(2)),
21+
periodicity = true)
22+
23+
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, dg;
24+
source_terms = source_terms_convergence_test)
25+
26+
###############################################################################
27+
# ODE solvers, callbacks etc.
28+
29+
tspan = (0.0, 0.4)
30+
ode = semidiscretize(semi, tspan)
31+
32+
summary_callback = SummaryCallback()
33+
34+
analysis_interval = 100
35+
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
36+
alive_callback = AliveCallback(analysis_interval = analysis_interval)
37+
38+
callbacks = CallbackSet(summary_callback,
39+
analysis_callback,
40+
alive_callback)
41+
42+
###############################################################################
43+
# run the simulation
44+
45+
sol = solve(ode, RDPK3SpFSAL49(); abstol = 1.0e-7, reltol = 1.0e-7,
46+
ode_default_options()..., callback = callbacks);

examples/p4est_2d_dgsem/elixir_shallowwater_perturbation_amr.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ using TrixiShallowWater
77
# semidiscretization of the shallow water equations with a continuous
88
# bottom topography function and a perturbation in the water height
99

10-
equations = ShallowWaterEquationsWetDry2D(gravity = 9.812, H0 = 2.1)
10+
equations = ShallowWaterEquations2D(gravity = 9.812, H0 = 2.1)
1111

12-
function initial_condition_perturbation(x, t, equations::ShallowWaterEquationsWetDry2D)
12+
function initial_condition_perturbation(x, t, equations::ShallowWaterEquations2D)
1313
# Calculate primitive variables
1414
H = equations.H0
1515
v1 = 0.0
@@ -111,7 +111,7 @@ save_solution = SaveSolutionCallback(dt = 0.04,
111111
save_final_solution = true)
112112

113113
# Define the perturbation of water height as a variable to use in the AMR indicator
114-
@inline function waterheight_total(u, equations::ShallowWaterEquationsWetDry2D)
114+
@inline function waterheight_total(u, equations::ShallowWaterEquations2D)
115115
return u[1] + u[4]
116116
end
117117

0 commit comments

Comments
 (0)