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

breaking changes for Trixi.jl v0.5 #1302

Merged
merged 19 commits into from
Dec 24, 2022
Merged
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
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ Trixi.jl follows the interpretation of [semantic versioning (semver)](https://ju
used in the Julia ecosystem. Notable changes will be documented in this file
for human readability.

## Changes when updating to v0.5 from v0.4.x

#### Added

#### Changed

- Compile-time boolean indicators have been changed from `Val{true}`/`Val{false}`
to `Trixi.True`/`Trixi.False`. This affects user code only if new equations
with nonconservative terms are created. Change
`Trixi.has_nonconservative_terms(::YourEquations) = Val{true}()` to
`Trixi.has_nonconservative_terms(::YourEquations) = Trixi.True()`.
- The (non-exported) DGSEM function `split_form_kernel!` has been renamed to `flux_differencing_kernel!`
sloede marked this conversation as resolved.
Show resolved Hide resolved

ranocha marked this conversation as resolved.
Show resolved Hide resolved
#### Deprecated

- The signature of the `DGMultiMesh` constructors has changed - the `dg::DGMulti`
argument now comes first.
- The undocumented and unused
`DGMultiMesh(triangulateIO, rd::RefElemData{2, Tri}, boundary_dict::Dict{Symbol, Int})`
constructor was removed.

#### Removed

- Everything deprecated in Trixi.jl v0.4.x has been removed.


## Changes in the v0.4 lifecycle

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Trixi"
uuid = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Gregor Gassner <[email protected]>", "Hendrik Ranocha <[email protected]>", "Andrew R. Winters <[email protected]>", "Jesse Chan <[email protected]>"]
version = "0.4.60-pre"
version = "0.5.0-pre"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
Expand Down
4 changes: 2 additions & 2 deletions docs/literate/src/files/adding_nonconservative_equation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end


## We use nonconservative terms
have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Val(true)
have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True()

## This "nonconservative numerical flux" implements the nonconservative terms.
## In general, nonconservative terms can be written in the form
Expand Down Expand Up @@ -219,7 +219,7 @@ end


## We use nonconservative terms
have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Val(true)
have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True()

## This "nonconservative numerical flux" implements the nonconservative terms.
## In general, nonconservative terms can be written in the form
Expand Down
2 changes: 1 addition & 1 deletion examples/dgmulti_2d/elixir_euler_bilinear.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for i in eachindex(vertex_coordinates[1])
setindex!.(vertex_coordinates, mapping(vx, vy), i)
end

mesh = DGMultiMesh(vertex_coordinates, EToV, dg, is_on_boundary=is_on_boundary)
mesh = DGMultiMesh(dg, vertex_coordinates, EToV, is_on_boundary=is_on_boundary)

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :top => boundary_condition_convergence_test,
Expand Down
2 changes: 1 addition & 1 deletion examples/dgmulti_2d/elixir_euler_triangulate_pkg_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ meshIO = StartUpDG.triangulate_domain(StartUpDG.RectangularDomainWithHole())

# the pre-defined Triangulate geometry in StartUpDG has integer boundary tags. this routine
# assigns boundary faces based on these integer boundary tags.
mesh = DGMultiMesh(meshIO, dg, Dict(:outer_boundary=>1, :inner_boundary=>2))
mesh = DGMultiMesh(dg, meshIO, Dict(:outer_boundary=>1, :inner_boundary=>2))

boundary_condition_convergence_test = BoundaryConditionDirichlet(initial_condition)
boundary_conditions = (; :outer_boundary => boundary_condition_convergence_test,
Expand Down
3 changes: 1 addition & 2 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using P4est
using Setfield: @set
using RecipesBase: RecipesBase
using Requires: @require
using Static: Static, One
using Static: Static, One, True, False
sloede marked this conversation as resolved.
Show resolved Hide resolved
@reexport using StaticArrays: SVector
using StaticArrays: StaticArrays, MVector, MArray, SMatrix, @SMatrix
using StrideArrays: PtrArray, StrideArray, StaticInt
Expand Down Expand Up @@ -235,7 +235,6 @@ export ode_norm, ode_unstable_check
export convergence_test, jacobian_fd, jacobian_ad_forward, linear_structure

export DGMulti, estimate_dt, DGMultiMesh, GaussSBP
export VertexMappedMesh # TODO: DGMulti, v0.5. Remove deprecated VertexMappedMesh in next release

export ViscousFormulationBassiRebay1, ViscousFormulationLocalDG

Expand Down
10 changes: 8 additions & 2 deletions src/auxiliary/mpi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ const MPI_IS_ROOT = Ref(true)

# This is not type-stable but that's okay since we want to get rid of it anyway
# and it's not used in performance-critical parts. The alternative we used before,
# calling something like `eval(:(mpi_parallel() = Val(true)))` in `init_mpi()`,
# calling something like `eval(:(mpi_parallel() = True()))` in `init_mpi()`,
# causes invalidations and slows down the first call to Trixi.
mpi_parallel()::Union{Val{true}, Val{false}} = Val(mpi_isparallel())
function mpi_parallel()
if mpi_isparallel()
return True()
else
return False()
end
end

@inline mpi_isroot() = MPI_IS_ROOT[]

Expand Down
8 changes: 4 additions & 4 deletions src/callbacks_step/stepsize_dg1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


function max_dt(u, t, mesh::TreeMesh{1},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -27,7 +27,7 @@ end


function max_dt(u, t, mesh::TreeMesh{1},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -43,7 +43,7 @@ end


function max_dt(u, t, mesh::StructuredMesh{1},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -68,7 +68,7 @@ end


function max_dt(u, t, mesh::StructuredMesh{1},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand Down
16 changes: 8 additions & 8 deletions src/callbacks_step/stepsize_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


function max_dt(u, t, mesh::TreeMesh{2},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -28,7 +28,7 @@ end


function max_dt(u, t, mesh::TreeMesh{2},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -44,7 +44,7 @@ end


function max_dt(u, t, mesh::ParallelTreeMesh{2},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# call the method accepting a general `mesh::TreeMesh{2}`
# TODO: MPI, we should improve this; maybe we should dispatch on `u`
# and create some MPI array type, overloading broadcasting and mapreduce etc.
Expand All @@ -60,7 +60,7 @@ end


function max_dt(u, t, mesh::ParallelTreeMesh{2},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# call the method accepting a general `mesh::TreeMesh{2}`
# TODO: MPI, we should improve this; maybe we should dispatch on `u`
# and create some MPI array type, overloading broadcasting and mapreduce etc.
Expand All @@ -76,7 +76,7 @@ end


function max_dt(u, t, mesh::Union{StructuredMesh{2}, UnstructuredMesh2D, P4estMesh{2}},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand Down Expand Up @@ -109,7 +109,7 @@ end


function max_dt(u, t, mesh::Union{StructuredMesh{2}, UnstructuredMesh2D, P4estMesh{2}},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
@unpack contravariant_vectors, inverse_jacobian = cache.elements

# to avoid a division by zero if the speed vanishes everywhere,
Expand All @@ -136,7 +136,7 @@ end


function max_dt(u, t, mesh::ParallelP4estMesh{2},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# call the method accepting a general `mesh::P4estMesh{2}`
# TODO: MPI, we should improve this; maybe we should dispatch on `u`
# and create some MPI array type, overloading broadcasting and mapreduce etc.
Expand All @@ -152,7 +152,7 @@ end


function max_dt(u, t, mesh::ParallelP4estMesh{2},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# call the method accepting a general `mesh::P4estMesh{2}`
# TODO: MPI, we should improve this; maybe we should dispatch on `u`
# and create some MPI array type, overloading broadcasting and mapreduce etc.
Expand Down
12 changes: 6 additions & 6 deletions src/callbacks_step/stepsize_dg3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


function max_dt(u, t, mesh::TreeMesh{3},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -29,7 +29,7 @@ end


function max_dt(u, t, mesh::TreeMesh{3},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand All @@ -45,7 +45,7 @@ end


function max_dt(u, t, mesh::Union{StructuredMesh{3}, P4estMesh{3}},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand Down Expand Up @@ -80,7 +80,7 @@ end


function max_dt(u, t, mesh::Union{StructuredMesh{3}, P4estMesh{3}},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# to avoid a division by zero if the speed vanishes everywhere,
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))
Expand Down Expand Up @@ -110,7 +110,7 @@ end


function max_dt(u, t, mesh::ParallelP4estMesh{3},
constant_speed::Val{false}, equations, dg::DG, cache)
constant_speed::False, equations, dg::DG, cache)
# call the method accepting a general `mesh::P4estMesh{3}`
# TODO: MPI, we should improve this; maybe we should dispatch on `u`
# and create some MPI array type, overloading broadcasting and mapreduce etc.
Expand All @@ -126,7 +126,7 @@ end


function max_dt(u, t, mesh::ParallelP4estMesh{3},
constant_speed::Val{true}, equations, dg::DG, cache)
constant_speed::True, equations, dg::DG, cache)
# call the method accepting a general `mesh::P4estMesh{3}`
# TODO: MPI, we should improve this; maybe we should dispatch on `u`
# and create some MPI array type, overloading broadcasting and mapreduce etc.
Expand Down
2 changes: 1 addition & 1 deletion src/equations/acoustic_perturbation_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ end
end


@inline have_constant_speed(::AcousticPerturbationEquations2D) = Val(false)
@inline have_constant_speed(::AcousticPerturbationEquations2D) = False()

@inline function max_abs_speeds(u, equations::AcousticPerturbationEquations2D)
v1_mean = u[4]
Expand Down
8 changes: 4 additions & 4 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ with or without nonconservative terms. Classical conservation laws such as the
[`CompressibleEulerEquations2D`](@ref) do not have nonconservative terms. The
[`ShallowWaterEquations2D`](@ref) with non-constant bottom topography are an
example of equations with nonconservative terms.
The return value will be `Val(true)` or `Val(false)` to allow dispatching on the return type.
The return value will be `True()` or `False()` to allow dispatching on the return type.
"""
have_nonconservative_terms(::AbstractEquations) = Val(false)
have_constant_speed(::AbstractEquations) = Val(false)
have_nonconservative_terms(::AbstractEquations) = False()
have_constant_speed(::AbstractEquations) = False()

default_analysis_errors(::AbstractEquations) = (:l2_error, :linf_error)
"""
Expand All @@ -225,7 +225,7 @@ Return the conserved variables `u`. While this function is as trivial as `identi
it is also as useful.
"""
@inline cons2cons(u, ::AbstractEquations) = u

@inline Base.first(u, ::AbstractEquations) = first(u)

"""
Expand Down
2 changes: 1 addition & 1 deletion src/equations/hyperbolic_diffusion_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ end
end


@inline have_constant_speed(::HyperbolicDiffusionEquations1D) = Val(true)
@inline have_constant_speed(::HyperbolicDiffusionEquations1D) = True()

@inline function max_abs_speeds(eq::HyperbolicDiffusionEquations1D)
return sqrt(eq.nu * eq.inv_Tr)
Expand Down
2 changes: 1 addition & 1 deletion src/equations/hyperbolic_diffusion_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ end



@inline have_constant_speed(::HyperbolicDiffusionEquations2D) = Val(true)
@inline have_constant_speed(::HyperbolicDiffusionEquations2D) = True()

@inline function max_abs_speeds(eq::HyperbolicDiffusionEquations2D)
λ = sqrt(eq.nu * eq.inv_Tr)
Expand Down
2 changes: 1 addition & 1 deletion src/equations/hyperbolic_diffusion_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ end



@inline have_constant_speed(::HyperbolicDiffusionEquations3D) = Val(true)
@inline have_constant_speed(::HyperbolicDiffusionEquations3D) = True()

@inline function max_abs_speeds(eq::HyperbolicDiffusionEquations3D)
λ = sqrt(eq.nu * eq.inv_Tr)
Expand Down
2 changes: 1 addition & 1 deletion src/equations/ideal_glm_mhd_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct IdealGlmMhdEquations1D{RealT<:Real} <: AbstractIdealGlmMhdEquations{1, 8}
end
end

have_nonconservative_terms(::IdealGlmMhdEquations1D) = Val(false)
have_nonconservative_terms(::IdealGlmMhdEquations1D) = False()
varnames(::typeof(cons2cons), ::IdealGlmMhdEquations1D) = ("rho", "rho_v1", "rho_v2", "rho_v3", "rho_e", "B1", "B2", "B3")
varnames(::typeof(cons2prim), ::IdealGlmMhdEquations1D) = ("rho", "v1", "v2", "v3", "p", "B1", "B2", "B3")
default_analysis_integrals(::IdealGlmMhdEquations1D) = (entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
Expand Down
2 changes: 1 addition & 1 deletion src/equations/ideal_glm_mhd_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function IdealGlmMhdEquations2D(gamma; initial_c_h=convert(typeof(gamma), NaN))
end


have_nonconservative_terms(::IdealGlmMhdEquations2D) = Val(true)
have_nonconservative_terms(::IdealGlmMhdEquations2D) = True()
varnames(::typeof(cons2cons), ::IdealGlmMhdEquations2D) = ("rho", "rho_v1", "rho_v2", "rho_v3", "rho_e", "B1", "B2", "B3", "psi")
varnames(::typeof(cons2prim), ::IdealGlmMhdEquations2D) = ("rho", "v1", "v2", "v3", "p", "B1", "B2", "B3", "psi")
default_analysis_integrals(::IdealGlmMhdEquations2D) = (entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
Expand Down
2 changes: 1 addition & 1 deletion src/equations/ideal_glm_mhd_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function IdealGlmMhdEquations3D(gamma; initial_c_h=convert(typeof(gamma), NaN))
end


have_nonconservative_terms(::IdealGlmMhdEquations3D) = Val(true)
have_nonconservative_terms(::IdealGlmMhdEquations3D) = True()
varnames(::typeof(cons2cons), ::IdealGlmMhdEquations3D) = ("rho", "rho_v1", "rho_v2", "rho_v3", "rho_e", "B1", "B2", "B3", "psi")
varnames(::typeof(cons2prim), ::IdealGlmMhdEquations3D) = ("rho", "v1", "v2", "v3", "p", "B1", "B2", "B3", "psi")
default_analysis_integrals(::IdealGlmMhdEquations3D) = (entropy_timederivative, Val(:l2_divb), Val(:linf_divb))
Expand Down
2 changes: 1 addition & 1 deletion src/equations/ideal_glm_mhd_multicomponent_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

@inline Base.real(::IdealGlmMhdMulticomponentEquations1D{NVARS, NCOMP, RealT}) where {NVARS, NCOMP, RealT} = RealT

have_nonconservative_terms(::IdealGlmMhdMulticomponentEquations1D) = Val(false)
have_nonconservative_terms(::IdealGlmMhdMulticomponentEquations1D) = False()

function varnames(::typeof(cons2cons), equations::IdealGlmMhdMulticomponentEquations1D)

Expand Down
2 changes: 1 addition & 1 deletion src/equations/ideal_glm_mhd_multicomponent_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end

@inline Base.real(::IdealGlmMhdMulticomponentEquations2D{NVARS, NCOMP, RealT}) where {NVARS, NCOMP, RealT} = RealT

have_nonconservative_terms(::IdealGlmMhdMulticomponentEquations2D) = Val(true)
have_nonconservative_terms(::IdealGlmMhdMulticomponentEquations2D) = True()

function varnames(::typeof(cons2cons), equations::IdealGlmMhdMulticomponentEquations2D)

Expand Down
2 changes: 1 addition & 1 deletion src/equations/lattice_boltzmann_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ end



@inline have_constant_speed(::LatticeBoltzmannEquations2D) = Val(true)
@inline have_constant_speed(::LatticeBoltzmannEquations2D) = True()

@inline function max_abs_speeds(equations::LatticeBoltzmannEquations2D)
@unpack c = equations
Expand Down
2 changes: 1 addition & 1 deletion src/equations/lattice_boltzmann_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ end



@inline have_constant_speed(::LatticeBoltzmannEquations3D) = Val(true)
@inline have_constant_speed(::LatticeBoltzmannEquations3D) = True()

@inline function max_abs_speeds(equations::LatticeBoltzmannEquations3D)
@unpack c = equations
Expand Down
Loading