From 1aae05901ff132492cde1f51f9287115424332d5 Mon Sep 17 00:00:00 2001 From: bennibolm Date: Wed, 8 Jan 2025 14:26:10 +0100 Subject: [PATCH] Add tests --- examples/t8code_2d_fv/elixir_advection_amr.jl | 6 ++-- test/test_t8code_fv_2d.jl | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/examples/t8code_2d_fv/elixir_advection_amr.jl b/examples/t8code_2d_fv/elixir_advection_amr.jl index c0fd5cf7c2c..152f30b42fc 100644 --- a/examples/t8code_2d_fv/elixir_advection_amr.jl +++ b/examples/t8code_2d_fv/elixir_advection_amr.jl @@ -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() @@ -39,7 +39,7 @@ 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), @@ -47,7 +47,7 @@ amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first) 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) diff --git a/test/test_t8code_fv_2d.jl b/test/test_t8code_fv_2d.jl index 279e70951e6..127f2cda914 100644 --- a/test/test_t8code_fv_2d.jl +++ b/test/test_t8code_fv_2d.jl @@ -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"),