Skip to content

Commit

Permalink
update unit tests, comment wave speed estimates
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickersing committed Dec 19, 2023
1 parent b58e902 commit d0eb6dd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 48 deletions.
70 changes: 39 additions & 31 deletions src/equations/shallow_water_wet_dry_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
# """
Expand Down Expand Up @@ -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,
Expand Down
36 changes: 19 additions & 17 deletions test/test_unit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

0 comments on commit d0eb6dd

Please sign in to comment.