From 45dfeb4fac809fd01d15a2d75b6b01b62d8da009 Mon Sep 17 00:00:00 2001 From: Huiyu Xie Date: Wed, 24 Jul 2024 01:31:33 -1000 Subject: [PATCH] Add numerical support of other real types (`maxwell`) (#2011) * start * complete * Apply suggestions from code review --------- Co-authored-by: Hendrik Ranocha --- src/equations/maxwell_1d.jl | 2 +- test/test_type.jl | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/equations/maxwell_1d.jl b/src/equations/maxwell_1d.jl index 838e4e7b81..096fe3946c 100644 --- a/src/equations/maxwell_1d.jl +++ b/src/equations/maxwell_1d.jl @@ -58,7 +58,7 @@ function initial_condition_convergence_test(x, t, equations::MaxwellEquations1D) c = equations.speed_of_light char_pos = c * t + x[1] - sin_char_pos = sin(2 * pi * char_pos) + sin_char_pos = sinpi(2 * char_pos) E = -c * sin_char_pos B = sin_char_pos diff --git a/test/test_type.jl b/test/test_type.jl index a3e50b81cf..34fef14fee 100644 --- a/test/test_type.jl +++ b/test/test_type.jl @@ -1853,6 +1853,34 @@ isdir(outdir) && rm(outdir, recursive = true) end end + @timed_testset "Maxwell 1D" begin + for RealT in (Float32, Float64) + c = RealT(299_792_458) + equations = @inferred MaxwellEquations1D(c) + + x = SVector(zero(RealT)) + t = zero(RealT) + u = u_ll = u_rr = SVector(one(RealT), one(RealT)) + orientation = 1 + + @test eltype(@inferred initial_condition_convergence_test(x, t, equations)) == + RealT + + @test eltype(@inferred flux(u, orientation, equations)) == RealT + + @test typeof(@inferred max_abs_speed_naive(u_ll, u_rr, orientation, equations)) == + RealT + @test eltype(@inferred Trixi.max_abs_speeds(equations)) == + RealT + @test eltype(@inferred min_max_speed_naive(u_ll, u_rr, orientation, equations)) == + RealT + @test eltype(@inferred min_max_speed_davis(u_ll, u_rr, orientation, equations)) == + RealT + @test eltype(@inferred cons2prim(u, equations)) == RealT + @test eltype(@inferred cons2entropy(u, equations)) == RealT + end + end + @timed_testset "Shallow Water 1D" begin for RealT in (Float32, Float64) equations = @inferred ShallowWaterEquations1D(gravity_constant = RealT(9.81))