Skip to content

Commit

Permalink
Add numerical support of other real types (maxwell) (#2011)
Browse files Browse the repository at this point in the history
* start

* complete

* Apply suggestions from code review

---------

Co-authored-by: Hendrik Ranocha <[email protected]>
  • Loading branch information
huiyuxie and ranocha authored Jul 24, 2024
1 parent e5f4cbe commit 45dfeb4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/equations/maxwell_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions test/test_type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 45dfeb4

Please sign in to comment.