From 2d8c833a5cc00f95cba4a08bf251f31e8645eabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Tue, 10 Dec 2024 17:26:37 +0100 Subject: [PATCH] Use a single elixir to test EC and EC+LLF --- .../elixir_mhdmultiion_ec+llf.jl | 62 ------------------- test/test_tree_2d_mhdmultiion.jl | 23 ++++++- 2 files changed, 20 insertions(+), 65 deletions(-) delete mode 100644 examples/tree_2d_dgsem/elixir_mhdmultiion_ec+llf.jl diff --git a/examples/tree_2d_dgsem/elixir_mhdmultiion_ec+llf.jl b/examples/tree_2d_dgsem/elixir_mhdmultiion_ec+llf.jl deleted file mode 100644 index 9be4e5e249..0000000000 --- a/examples/tree_2d_dgsem/elixir_mhdmultiion_ec+llf.jl +++ /dev/null @@ -1,62 +0,0 @@ - -using OrdinaryDiffEq -using Trixi - -############################################################################### -# semidiscretization of the ideal MHD equations -equations = IdealGlmMhdMultiIonEquations2D(gammas = (1.4, 1.667), - charge_to_mass = (1.0, 2.0)) - -initial_condition = initial_condition_weak_blast_wave - -volume_flux = (flux_ruedaramirez_etal, flux_nonconservative_ruedaramirez_etal) -surface_flux = (flux_lax_friedrichs, flux_nonconservative_central) - -solver = DGSEM(polydeg = 3, surface_flux = surface_flux, - volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) - -coordinates_min = (-2.0, -2.0) -coordinates_max = (2.0, 2.0) -mesh = TreeMesh(coordinates_min, coordinates_max, - initial_refinement_level = 4, - n_cells_max = 10_000) - -semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - source_terms = source_terms_lorentz) - -############################################################################### -# ODE solvers, callbacks etc. - -tspan = (0.0, 0.4) -ode = semidiscretize(semi, tspan) - -summary_callback = SummaryCallback() - -analysis_interval = 10 -analysis_callback = AnalysisCallback(semi, interval = analysis_interval) -alive_callback = AliveCallback(analysis_interval = analysis_interval) - -save_solution = SaveSolutionCallback(dt = 0.1, # interval=100, - save_initial_solution = true, - save_final_solution = true, - solution_variables = cons2prim) - -cfl = 0.5 - -stepsize_callback = StepsizeCallback(cfl = cfl) - -glm_speed_callback = GlmSpeedCallback(glm_scale = 0.5, cfl = cfl) - -callbacks = CallbackSet(summary_callback, - analysis_callback, alive_callback, - save_solution, - stepsize_callback, - glm_speed_callback) - -############################################################################### -# run the simulation - -sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), - dt = 1.0, # solve needs some value here but it will be overwritten by the stepsize_callback - save_everystep = false, callback = callbacks); -summary_callback() # print the timer summary diff --git a/test/test_tree_2d_mhdmultiion.jl b/test/test_tree_2d_mhdmultiion.jl index ac91c47a33..69de4eb683 100644 --- a/test/test_tree_2d_mhdmultiion.jl +++ b/test/test_tree_2d_mhdmultiion.jl @@ -45,10 +45,18 @@ EXAMPLES_DIR = joinpath(pathof(Trixi) |> dirname |> dirname, "examples", "tree_2 0.6078381519649727, 0.00673110606965085 ]) + # 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 "elixir_mhdmultiion_ec+llf.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_ec+llf.jl"), +@trixi_testset "elixir_mhdmultiion_ec.jl with local Lax-Friedrichs at the surface" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmultiion_ec.jl"), l2=[ 0.017668026737187294, 0.017797845988889206, @@ -80,7 +88,16 @@ end 0.08694877996306204, 0.49493751138636366, 0.003287414714660175 - ]) + ], + surface_flux=(flux_lax_friedrichs, flux_nonconservative_central)) + # 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