From d0eb6dd7eeed1e223c9fffc9b9b8c9f800a02a39 Mon Sep 17 00:00:00 2001 From: patrickersing Date: Tue, 19 Dec 2023 13:05:32 +0100 Subject: [PATCH] update unit tests, comment wave speed estimates --- src/equations/shallow_water_wet_dry_1d.jl | 70 +++++++++++++---------- test/test_unit.jl | 36 ++++++------ 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/equations/shallow_water_wet_dry_1d.jl b/src/equations/shallow_water_wet_dry_1d.jl index 04bba57..fc22649 100644 --- a/src/equations/shallow_water_wet_dry_1d.jl +++ b/src/equations/shallow_water_wet_dry_1d.jl @@ -474,15 +474,17 @@ end # return u_ll_star, u_rr_star # end -# Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the -# maximum velocity magnitude plus the maximum speed of sound -@inline function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquationsWetDry1D) - return Trixi.max_abs_speed_naive(u_ll, u_rr, orientation, - Trixi.ShallowWaterEquations1D(equations.gravity, - equations.H0, eps(), - eps())) -end +# TODO: Probably can be removed. Since we dispatch to ShallowWaterEquations1D we don't need +# equation specific wave speed estimates. +# # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation as the +# # maximum velocity magnitude plus the maximum speed of sound +# @inline function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, +# equations::ShallowWaterEquationsWetDry1D) +# return Trixi.max_abs_speed_naive(u_ll, u_rr, orientation, +# Trixi.ShallowWaterEquations1D(equations.gravity, +# equations.H0, eps(), +# eps())) +# end # Specialized `DissipationLocalLaxFriedrichs` to avoid spurious dissipation in the bottom topography @inline function (dissipation::Trixi.DissipationLocalLaxFriedrichs)(u_ll, u_rr, @@ -505,14 +507,16 @@ end eps())) end -# Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes -@inline function Trixi.min_max_speed_naive(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquationsWetDry1D) - return Trixi.min_max_speed_naive(u_ll, u_rr, orientation, - Trixi.ShallowWaterEquations1D(equations.gravity, - equations.H0, eps(), - eps())) -end +# TODO: Probably can be removed. Since we dispatch to ShallowWaterEquations1D we don't need +# equation specific wave speed estimates. +# # Calculate estimate for minimum and maximum wave speeds for HLL-type fluxes +# @inline function Trixi.min_max_speed_naive(u_ll, u_rr, orientation::Integer, +# equations::ShallowWaterEquationsWetDry1D) +# return Trixi.min_max_speed_naive(u_ll, u_rr, orientation, +# Trixi.ShallowWaterEquations1D(equations.gravity, +# equations.H0, eps(), +# eps())) +# end # TODO: This function is currently exported by Trixi.jl. Needs to be uncommented when removed from Trixi.jl # """ @@ -547,22 +551,26 @@ end # return λ_min, λ_max # end +# TODO: Probably can be removed. Since we dispatch to ShallowWaterEquations1D we don't need +# equation specific wave speed estimates. # More refined estimates for minimum and maximum wave speeds for HLL-type fluxes -@inline function Trixi.min_max_speed_davis(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquationsWetDry1D) - return Trixi.min_max_speed_davis(u_ll, u_rr, orientation, - Trixi.ShallowWaterEquations1D(equations.gravity, - equations.H0, eps(), - eps())) -end +# @inline function Trixi.min_max_speed_davis(u_ll, u_rr, orientation::Integer, +# equations::ShallowWaterEquationsWetDry1D) +# return Trixi.min_max_speed_davis(u_ll, u_rr, orientation, +# Trixi.ShallowWaterEquations1D(equations.gravity, +# equations.H0, eps(), +# eps())) +# end -@inline function Trixi.min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, - equations::ShallowWaterEquationsWetDry1D) - return Trixi.min_max_speed_einfeldt(u_ll, u_rr, orientation, - Trixi.ShallowWaterEquations1D(equations.gravity, - equations.H0, - eps(), eps())) -end +# TODO: Probably can be removed. Since we dispatch to ShallowWaterEquations1D we don't need +# equation specific wave speed estimates. +# @inline function Trixi.min_max_speed_einfeldt(u_ll, u_rr, orientation::Integer, +# equations::ShallowWaterEquationsWetDry1D) +# return Trixi.min_max_speed_einfeldt(u_ll, u_rr, orientation, +# Trixi.ShallowWaterEquations1D(equations.gravity, +# equations.H0, +# eps(), eps())) +# end @inline function Trixi.max_abs_speeds(u, equations::ShallowWaterEquationsWetDry1D) return Trixi.max_abs_speeds(u, diff --git a/test/test_unit.jl b/test/test_unit.jl index 195e3bf..a1474e3 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -17,7 +17,7 @@ isdir(outdir) && rm(outdir, recursive = true) @timed_testset "Shallow water conversion between conservative/entropy variables" begin H, v, b = 3.5, 0.25, 0.4 - let equations = ShallowWaterEquations1D(gravity_constant = 9.8) + let equations = ShallowWaterEquationsWetDry1D(gravity_constant = 9.8) cons_vars = Trixi.prim2cons(SVector(H, v, b), equations) entropy_vars = Trixi.cons2entropy(cons_vars, equations) @test cons_vars ≈ Trixi.entropy2cons(entropy_vars, equations) @@ -32,22 +32,24 @@ isdir(outdir) && rm(outdir, recursive = true) end end -@timed_testset "Connectivity with Trixi.jl" begin - u = SVector(SVector(1, 0.5, 0.0)) - orientation = 1 - equations = ShallowWaterEquationsWetDry1D(gravity_constant = 9.81) - equations_trixi = ShallowWaterEquations1D(gravity_constant = 9.81) - - # We only need to check equivalence between the equation systems. The functionality is tested in - # Trixi.jl. We choose these specific ones to improve code coverage, as they are not tested in - # any elixirs. - @test min_max_speed_einfeldt(u, u, orientation, equations) == - min_max_speed_einfeldt(u, u, orientation, equations_trixi) - @test min_max_speed_davis(u, u, orientation, equations) == - min_max_speed_davis(u, u, orientation, equations_trixi) - @test max_abs_speed_naive(u, u, orientation, equations) == - max_abs_speed_naive(u, u, orientation, equations_trixi) -end +# TODO: Probably can be removed. Since we dispatch to ShallowWaterEquations1D we don't need +# equation specific wave speed estimates. +# @timed_testset "Connectivity with Trixi.jl" begin +# u = SVector(SVector(1, 0.5, 0.0)) +# orientation = 1 +# equations = ShallowWaterEquationsWetDry1D(gravity_constant = 9.81) +# equations_trixi = ShallowWaterEquations1D(gravity_constant = 9.81) + +# # We only need to check equivalence between the equation systems. The functionality is tested in +# # Trixi.jl. We choose these specific ones to improve code coverage, as they are not tested in +# # any elixirs. +# @test min_max_speed_einfeldt(u, u, orientation, equations) == +# min_max_speed_einfeldt(u, u, orientation, equations_trixi) +# @test min_max_speed_davis(u, u, orientation, equations) == +# min_max_speed_davis(u, u, orientation, equations_trixi) +# @test max_abs_speed_naive(u, u, orientation, equations) == +# max_abs_speed_naive(u, u, orientation, equations_trixi) +# end end end # module