From ae538319de00c4cc16ae83e91fdd0fe6434da488 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Sat, 17 Aug 2024 19:15:09 +0200 Subject: [PATCH] add tests for spherical advection in Cartesian coords --- ...xir_euler_spherical_advection_cartesian.jl | 2 + examples/elixir_moist_euler_moist_bubble.jl | 1 + test/runtests.jl | 4 ++ test/test_spherical_advection.jl | 37 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 test/test_spherical_advection.jl diff --git a/examples/elixir_euler_spherical_advection_cartesian.jl b/examples/elixir_euler_spherical_advection_cartesian.jl index 4a3bb4c..9a0e7b5 100644 --- a/examples/elixir_euler_spherical_advection_cartesian.jl +++ b/examples/elixir_euler_spherical_advection_cartesian.jl @@ -6,6 +6,8 @@ using TrixiAtmo ############################################################################### # semidiscretization of the linear advection equation +# We use the Euler equations structure but modify the rhs! function to convert it to a +# variable-coefficient advection equation equations = CompressibleEulerEquations3D(1.4) # Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux diff --git a/examples/elixir_moist_euler_moist_bubble.jl b/examples/elixir_moist_euler_moist_bubble.jl index bdf7b4e..ed633d5 100644 --- a/examples/elixir_moist_euler_moist_bubble.jl +++ b/examples/elixir_moist_euler_moist_bubble.jl @@ -284,6 +284,7 @@ analysis_callback = AnalysisCallback(semi, interval = analysis_interval, alive_callback = AliveCallback(analysis_interval = analysis_interval) save_solution = SaveSolutionCallback(interval = 1000, + output_directory = "moist_bubble", save_initial_solution = true, save_final_solution = true, solution_variables = solution_variables) diff --git a/test/runtests.jl b/test/runtests.jl index c59a4fa..541cfd8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,4 +16,8 @@ const TRIXIATMO_NTHREADS = clamp(Sys.CPU_THREADS, 2, 3) @time if TRIXIATMO_TEST == "all" || TRIXIATMO_TEST == "moist_euler" include("test_2d_moist_euler.jl") end + + @time if TRIXIATMO_TEST == "all" || TRIXIATMO_TEST == "spherical_advection" + include("test_spherical_advection.jl") + end end diff --git a/test/test_spherical_advection.jl b/test/test_spherical_advection.jl new file mode 100644 index 0000000..31f7a29 --- /dev/null +++ b/test/test_spherical_advection.jl @@ -0,0 +1,37 @@ +module TestSphericalAdvection + +using Test +using TrixiAtmo + +include("test_trixiatmo.jl") + +EXAMPLES_DIR = pkgdir(TrixiAtmo, "examples") + +@trixiatmo_testset "elixir_euler_spherical_advection_cartesian" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_spherical_advection_cartesian.jl"), + l2=[ + 8.44505073e-03, + 8.23414117e-03, + 1.84210648e-03, + 0.00000000e+00, + 6.44302430e-02, + ], + linf=[ + 9.48950488e-02, + 9.64811952e-02, + 1.37453400e-02, + 0.00000000e+00, + 4.09322999e-01, + ]) + # 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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100 + end +end + +end # module