Skip to content

Rename gravity_constant to gravity in the equations constructor #2357

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ used in the Julia ecosystem. Notable changes will be documented in this file
for human readability.


## Changes when updating to v0.12 from v0.11.x

#### Added

#### Changed

- The keyword argument `gravity_constant` has been changed to `gravity` for the `ShallowWaterEquations1D`,
`ShallowWaterEquations2D`, and `ShallowWaterEquationsQuasi1D`.

#### Deprecated

#### Removed

## Changes in the v0.11 lifecycle

#### Added
Expand Down
2 changes: 1 addition & 1 deletion examples/dgmulti_1d/elixir_shallow_water_quasi_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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)
equations = ShallowWaterEquationsQuasi1D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
2 changes: 1 addition & 1 deletion examples/dgmulti_2d/elixir_shallowwater_source_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test # MMS EOC test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function (set in the initial conditions)

equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.0)
equations = ShallowWaterEquations2D(gravity = 9.81, H0 = 3.0)

# An initial condition with constant total water height and zero velocities to test well-balancedness.
# Note, this routine is used to compute errors in the analysis callback but the initialization is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations.

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test # MMS EOC test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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)
equations = ShallowWaterEquationsQuasi1D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
2 changes: 1 addition & 1 deletion examples/tree_1d_dgsem/elixir_shallowwater_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# Semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations1D(gravity_constant = 9.81)
equations = ShallowWaterEquations1D(gravity = 9.81)

# Initial condition with a truly discontinuous water height, velocity, and bottom
# topography function as an academic testcase for entropy conservation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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)
equations = ShallowWaterEquationsQuasi1D(gravity = 9.81)

function initial_condition_discontinuity(x, t, equations::ShallowWaterEquationsQuasi1D)
RealT = eltype(x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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)
equations = ShallowWaterEquationsQuasi1D(gravity = 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations1D(gravity_constant = 9.812, H0 = 1.75)
equations = ShallowWaterEquations1D(gravity = 9.812, H0 = 1.75)

# Initial condition with a truly discontinuous velocity and bottom topography.
# Works as intended for TreeMesh1D with `initial_refinement_level=3`. If the mesh
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_1d_dgsem/elixir_shallowwater_source_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations1D(gravity_constant = 9.81)
equations = ShallowWaterEquations1D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations1D(gravity_constant = 9.81)
equations = ShallowWaterEquations1D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations1D(gravity_constant = 9.81, H0 = 3.25)
equations = ShallowWaterEquations1D(gravity = 9.81, H0 = 3.25)

# Setup a truly discontinuous bottom topography function for this academic
# testcase of well-balancedness. The errors from the analysis callback are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations1D(gravity_constant = 1.0, H0 = 3.0)
equations = ShallowWaterEquations1D(gravity = 1.0, H0 = 3.0)

# An initial condition with constant total water height and zero velocities to test well-balancedness.
function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations1D)
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_shallowwater_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

# Note, this initial condition is used to compute errors in the analysis callback but the initialization is
# overwritten by `initial_condition_ec_discontinuous_bottom` below.
Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_shallowwater_source_terms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test # MMS EOC test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
2 changes: 1 addition & 1 deletion examples/tree_2d_dgsem/elixir_shallowwater_wall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Trixi
###############################################################################
# Semidiscretization of the shallow water equations

equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25)
equations = ShallowWaterEquations2D(gravity = 9.81, H0 = 3.25)

# An initial condition with a bottom topography and a perturbation in the waterheight to test
# boundary_condition_slip_wall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25)
equations = ShallowWaterEquations2D(gravity = 9.81, H0 = 3.25)

# An initial condition with constant total water height and zero velocities to test well-balancedness.
# Note, this routine is used to compute errors in the analysis callback but the initialization is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.25)
equations = ShallowWaterEquations2D(gravity = 9.81, H0 = 3.25)

# An initial condition with constant total water height and zero velocities to test well-balancedness.
# Note, this routine is used to compute errors in the analysis callback but the initialization is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a continuous
# bottom topography function (set in the initial conditions)

equations = ShallowWaterEquations2D(gravity_constant = 1.0, H0 = 3.0)
equations = ShallowWaterEquations2D(gravity = 1.0, H0 = 3.0)

# An initial condition with constant total water height and zero velocities to test well-balancedness.
function initial_condition_well_balancedness(x, t, equations::ShallowWaterEquations2D)
Expand Down
2 changes: 1 addition & 1 deletion examples/unstructured_2d_dgsem/elixir_shallowwater_ec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

# Note, this initial condition is used to compute errors in the analysis callback but the initialization is
# overwritten by `initial_condition_ec_discontinuous_bottom` below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.81f0)
equations = ShallowWaterEquations2D(gravity = 9.81f0)

# Note, this initial condition is used to compute errors in the analysis callback but the initialization is
# overwritten by `initial_condition_ec_discontinuous_bottom` below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

# Note, this initial condition is used to compute errors in the analysis callback but the initialization is
# overwritten by `initial_condition_ec_discontinuous_bottom` below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a periodic
# bottom topography function (set in the initial conditions)

equations = ShallowWaterEquations2D(gravity_constant = 9.81)
equations = ShallowWaterEquations2D(gravity = 9.81)

initial_condition = initial_condition_convergence_test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a continuous
# bottom topography function

equations = ShallowWaterEquations2D(gravity_constant = 9.812, H0 = 2.0)
equations = ShallowWaterEquations2D(gravity = 9.812, H0 = 2.0)

function initial_condition_stone_throw(x, t, equations::ShallowWaterEquations2D)
# Set up polar coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Trixi
# semidiscretization of the shallow water equations with a discontinuous
# bottom topography function (set in the initial conditions)

equations = ShallowWaterEquations2D(gravity_constant = 9.81, H0 = 3.0)
equations = ShallowWaterEquations2D(gravity = 9.81, H0 = 3.0)

# An initial condition with constant total water height and zero velocities to test well-balancedness.
# Note, this routine is used to compute errors in the analysis callback but the initialization is
Expand Down
14 changes: 7 additions & 7 deletions src/equations/shallow_water_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#! format: noindent

@doc raw"""
ShallowWaterEquations1D(; gravity_constant, H0 = 0)
ShallowWaterEquations1D(; gravity, H0 = 0)

Shallow water equations (SWE) in one space dimension. The equations are given by
```math
Expand All @@ -17,7 +17,7 @@ Shallow water equations (SWE) in one space dimension. The equations are given by
\end{aligned}
```
The unknown quantities of the SWE are the water height ``h`` and the velocity ``v``.
The gravitational constant is denoted by `g` and the (possibly) variable bottom topography function ``b(x)``.
The gravitational acceleration is denoted by `g` and the (possibly) variable bottom topography function ``b(x)``.
Conservative variable water height ``h`` is measured from the bottom topography ``b``, therefore one
also defines the total water height as ``H = h + b``.

Expand Down Expand Up @@ -45,16 +45,16 @@ References for the SWE are many but a good introduction is available in Chapter
[DOI: 10.1017/CBO9780511791253](https://doi.org/10.1017/CBO9780511791253)
"""
struct ShallowWaterEquations1D{RealT <: Real} <: AbstractShallowWaterEquations{1, 3}
gravity::RealT # gravitational constant
gravity::RealT # gravitational acceleration
H0::RealT # constant "lake-at-rest" total water height
end

# Allow for flexibility to set the gravitational constant within an elixir depending on the
# application where `gravity_constant=1.0` or `gravity_constant=9.81` are common values.
# Allow for flexibility to set the gravitational acceleration within an elixir depending on the
# application where `gravity=1.0` or `gravity=9.81` are common values.
# The reference total water height H0 defaults to 0.0 but is used for the "lake-at-rest"
# well-balancedness test cases.
function ShallowWaterEquations1D(; gravity_constant, H0 = zero(gravity_constant))
ShallowWaterEquations1D(gravity_constant, H0)
function ShallowWaterEquations1D(; gravity, H0 = zero(gravity))
ShallowWaterEquations1D(gravity, H0)
end

have_nonconservative_terms(::ShallowWaterEquations1D) = True()
Expand Down
14 changes: 7 additions & 7 deletions src/equations/shallow_water_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#! format: noindent

@doc raw"""
ShallowWaterEquations2D(; gravity_constant, H0 = 0)
ShallowWaterEquations2D(; gravity, H0 = 0)

Shallow water equations (SWE) in two space dimensions. The equations are given by
```math
Expand All @@ -20,7 +20,7 @@ Shallow water equations (SWE) in two space dimensions. The equations are given b
\end{aligned}
```
The unknown quantities of the SWE are the water height ``h`` and the velocities ``\mathbf{v} = (v_1, v_2)^T``.
The gravitational constant is denoted by `g` and the (possibly) variable bottom topography function ``b(x,y)``.
The gravitational acceleration is denoted by `g` and the (possibly) variable bottom topography function ``b(x,y)``.
Conservative variable water height ``h`` is measured from the bottom topography ``b``, therefore one
also defines the total water height as ``H = h + b``.

Expand Down Expand Up @@ -48,17 +48,17 @@ References for the SWE are many but a good introduction is available in Chapter
[DOI: 10.1017/CBO9780511791253](https://doi.org/10.1017/CBO9780511791253)
"""
struct ShallowWaterEquations2D{RealT <: Real} <: AbstractShallowWaterEquations{2, 4}
gravity::RealT # gravitational constant
gravity::RealT # gravitational acceleration
H0::RealT # constant "lake-at-rest" total water height
end

# Allow for flexibility to set the gravitational constant within an elixir depending on the
# application where `gravity_constant=1.0` or `gravity_constant=9.81` are common values.
# Allow for flexibility to set the gravitational acceleration within an elixir depending on the
# application where `gravity=1.0` or `gravity=9.81` are common values.
# The reference total water height H0 defaults to 0.0 but is used for the "lake-at-rest"
# well-balancedness test cases.
# Strict default values for thresholds that performed well in many numerical experiments
function ShallowWaterEquations2D(; gravity_constant, H0 = zero(gravity_constant))
ShallowWaterEquations2D(gravity_constant, H0)
function ShallowWaterEquations2D(; gravity, H0 = zero(gravity))
ShallowWaterEquations2D(gravity, H0)
end

have_nonconservative_terms(::ShallowWaterEquations2D) = True()
Expand Down
Loading
Loading