Skip to content

Commit

Permalink
complete 2D
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyuxie committed Jul 19, 2024
1 parent 9a97dac commit a7670a7
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/equations/shallow_water_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ A weak blast wave discontinuity useful for testing, e.g., total energy conservat
Note for the shallow water equations to the total energy acts as a mathematical entropy function.
"""
function initial_condition_weak_blast_wave(x, t, equations::ShallowWaterEquations2D)
RealT = eltype(x)
# Set up polar coordinates
RealT = eltype(x)
inicenter = SVector(convert(RealT, 0.7), convert(RealT, 0.7))
x_norm = x[1] - inicenter[1]
y_norm = x[2] - inicenter[2]
Expand Down
146 changes: 144 additions & 2 deletions test/test_type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1957,14 +1957,156 @@ isdir(outdir) && rm(outdir, recursive = true)
x = SVector(zero(RealT), zero(RealT))
t = zero(RealT)
u = u_ll = u_rr = u_inner = cons = SVector(one(RealT), one(RealT), one(RealT),
one(RealT), one(RealT), one(RealT))
one(RealT))
orientations = [1, 2]
directions = [1, 2, 3, 4]
normal_direction = SVector(one(RealT), zero(RealT))
normal_direction = normal_direction_ll = normal_direction_average = SVector(one(RealT),
zero(RealT))

surface_flux_function = flux_lax_friedrichs
dissipation = DissipationLocalLaxFriedrichs()
numflux = FluxHLL()

@test eltype(@inferred initial_condition_convergence_test(x, t, equations)) ==
RealT
@test eltype(@inferred source_terms_convergence_test(u, x, t, equations)) ==
RealT
@test eltype(@inferred initial_condition_weak_blast_wave(x, t, equations)) ==
RealT

if RealT == Float32
# check `surface_flux_function` (test broken)
@test_broken eltype(@inferred boundary_condition_slip_wall(u_inner,
normal_direction,
x, t,
surface_flux_function,
equations)) ==
RealT
else
@test eltype(@inferred boundary_condition_slip_wall(u_inner,
normal_direction,
x, t,
surface_flux_function,
equations)) == RealT
end
@test eltype(@inferred flux(u, normal_direction, equations)) == RealT
@test eltype(@inferred flux_nonconservative_wintermeyer_etal(u_ll, u_rr,
normal_direction_ll,
normal_direction_average,
equations)) ==
RealT
@test eltype(@inferred flux_nonconservative_fjordholm_etal(u_ll, u_rr,
normal_direction_ll,
normal_direction_average,
equations)) == RealT
@test eltype(@inferred flux_nonconservative_audusse_etal(u_ll, u_rr,
normal_direction_ll,
normal_direction_average,
equations)) == RealT
@test eltype(@inferred flux_nonconservative_ersing_etal(u_ll, u_rr,
normal_direction_ll,
normal_direction_average,
equations)) == RealT
@test eltype(@inferred flux_fjordholm_etal(u_ll, u_rr, normal_direction,
equations)) == RealT
@test eltype(@inferred flux_wintermeyer_etal(u_ll, u_rr, normal_direction,
equations)) == RealT

@test typeof(@inferred max_abs_speed_naive(u_ll, u_rr, normal_direction,
equations)) ==
RealT
@test eltype(@inferred dissipation(u_ll, u_rr, normal_direction, equations)) ==
RealT
@test eltype(@inferred numflux(u_ll, u_rr, normal_direction, equations)) ==
RealT
@test eltype(@inferred min_max_speed_naive(u_ll, u_rr, normal_direction,
equations)) == RealT
@test eltype(@inferred min_max_speed_davis(u_ll, u_rr, normal_direction,
equations)) == RealT
@test eltype(@inferred min_max_speed_einfeldt(u_ll, u_rr, normal_direction,
equations)) == RealT
@test eltype(@inferred Trixi.calc_wavespeed_roe(u_ll, u_rr, normal_direction,
equations)) == RealT

for orientation in orientations
for direction in directions
if RealT == Float32
# check `surface_flux_function` (test broken)
@test_broken eltype(@inferred boundary_condition_slip_wall(u_inner,
orientation,
direction,
x, t,
surface_flux_function,
equations)) ==
RealT
else
@test eltype(@inferred boundary_condition_slip_wall(u_inner,
orientation,
direction, x, t,
surface_flux_function,
equations)) ==
RealT
end
end

@test eltype(@inferred flux(u, orientation, equations)) == RealT
@test eltype(@inferred flux_nonconservative_wintermeyer_etal(u_ll, u_rr,
orientation,
equations)) ==
RealT
@test eltype(@inferred flux_nonconservative_fjordholm_etal(u_ll, u_rr,
orientation,
equations)) ==
RealT
@test eltype(@inferred flux_nonconservative_audusse_etal(u_ll, u_rr,
orientation,
equations)) ==
RealT
@test eltype(eltype(@inferred flux_nonconservative_ersing_etal(u_ll, u_rr,
orientation,
equations))) ==
RealT
@test eltype(@inferred flux_fjordholm_etal(u_ll, u_rr, orientation,
equations)) == RealT
@test eltype(@inferred flux_wintermeyer_etal(u_ll, u_rr, orientation,
equations)) == RealT

@test typeof(@inferred max_abs_speed_naive(u_ll, u_rr, orientation,
equations)) ==
RealT
@test eltype(@inferred dissipation(u_ll, u_rr, orientation, equations)) ==
RealT
@test eltype(@inferred numflux(u_ll, u_rr, orientation, 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 min_max_speed_einfeldt(u_ll, u_rr, orientation,
equations)) == RealT
@test eltype(@inferred Trixi.calc_wavespeed_roe(u_ll, u_rr, orientation,
equations)) == RealT
end

@test eltype(eltype(@inferred hydrostatic_reconstruction_audusse_etal(u_ll,
u_rr,
equations))) ==
RealT

@test eltype(@inferred Trixi.max_abs_speeds(u, equations)) == RealT
@test eltype(@inferred velocity(u, equations)) == RealT
@test eltype(@inferred cons2prim(u, equations)) == RealT
@test eltype(@inferred prim2cons(u, equations)) == RealT
@test eltype(@inferred cons2entropy(u, equations)) == RealT
@test eltype(@inferred entropy2cons(u, equations)) == RealT
@test typeof(@inferred Trixi.waterheight(u, equations)) == RealT
@test typeof(@inferred pressure(u, equations)) == RealT
@test typeof(@inferred waterheight_pressure(u, equations)) == RealT

@test typeof(@inferred entropy(cons, equations)) == RealT
@test typeof(@inferred energy_total(cons, equations)) == RealT
@test typeof(@inferred energy_kinetic(u, equations)) == RealT
@test typeof(@inferred energy_internal(cons, equations)) == RealT
@test typeof(@inferred lake_at_rest_error(u, equations)) == RealT
end
end
end
Expand Down

0 comments on commit a7670a7

Please sign in to comment.