Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Jan 8, 2025
1 parent b018441 commit 1aae059
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/t8code_2d_fv/elixir_advection_amr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mesh = T8codeMesh(trees_per_dimension, element_class,

semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)

tspan = (0.0, 5.0)
tspan = (0.0, 1.0)
ode = semidiscretize(semi, tspan)

summary_callback = SummaryCallback()
Expand All @@ -39,15 +39,15 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval,

alive_callback = AliveCallback(analysis_interval = analysis_interval)

save_solution = SaveSolutionCallback(interval = 1,
save_solution = SaveSolutionCallback(interval = 10,
solution_variables = cons2prim)

amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),
base_level = 1,
med_level = 3, med_threshold = 0.1,
max_level = 5, max_threshold = 0.6)
amr_callback = AMRCallback(semi, amr_controller,
interval = 1,
interval = 5,
adapt_initial_condition = true,
adapt_initial_condition_only_refine = true)

Expand Down
32 changes: 32 additions & 0 deletions test/test_t8code_fv_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,38 @@ end
end
end

@trixi_testset "elixir_advection_amr.jl" begin
@trixi_testset "first-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_amr.jl"),
order=1,
l2=[0.0449818455360287],
linf=[0.12473470922146587])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
@trixi_testset "second-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR,
"elixir_advection_amr.jl"),
l2=[0.02512215868291359],
linf=[0.1037808063352261])
# Ensure that we do not have excessive memory allocations
# (e.g., from type instabilities)
let
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
end
end
end

@trixi_testset "elixir_advection_basic_hybrid.jl" begin
@trixi_testset "first-order FV" begin
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_hybrid.jl"),
Expand Down

0 comments on commit 1aae059

Please sign in to comment.