Path: blob/main/test/test_tree_1d_advection.jl
2055 views
module TestExamples1DAdvection12using Test3using Trixi45include("test_trixi.jl")67EXAMPLES_DIR = joinpath(examples_dir(), "tree_1d_dgsem")89@testset "Linear scalar advection" begin10#! format: noindent1112@trixi_testset "elixir_advection_basic.jl" begin13@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),14l2=[6.0388296447998465e-6],15linf=[3.217887726258972e-5])16# Ensure that we do not have excessive memory allocations17# (e.g., from type instabilities)18let19t = sol.t[end]20u_ode = sol.u[end]21du_ode = similar(u_ode)22@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100023end24end2526@trixi_testset "elixir_advection_basic.jl (max_abs_speed)" begin27@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),28surface_flux=FluxLaxFriedrichs(max_abs_speed),29l2=[6.0388296447998465e-6],30linf=[3.217887726258972e-5])31# Ensure that we do not have excessive memory allocations32# (e.g., from type instabilities)33let34t = sol.t[end]35u_ode = sol.u[end]36du_ode = similar(u_ode)37@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100038end39end4041@trixi_testset "elixir_advection_amr.jl" begin42@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),43l2=[0.3540206249507417],44linf=[0.9999896603382347])45# Ensure that we do not have excessive memory allocations46# (e.g., from type instabilities)47let48t = sol.t[end]49u_ode = sol.u[end]50du_ode = similar(u_ode)51@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100052end53end5455@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin56@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"),57l2=[4.283508859843524e-6],58linf=[3.235356127918171e-5])59# Ensure that we do not have excessive memory allocations60# (e.g., from type instabilities)61let62t = sol.t[end]63u_ode = sol.u[end]64du_ode = similar(u_ode)65@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100066end67end6869@trixi_testset "elixir_advection_basic.jl (No errors)" begin70@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),71analysis_callback=AnalysisCallback(semi, interval = 42,72analysis_errors = Symbol[]))73# Ensure that we do not have excessive memory allocations74# (e.g., from type instabilities)75let76t = sol.t[end]77u_ode = sol.u[end]78du_ode = similar(u_ode)79@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100080end81end8283@trixi_testset "elixir_advection_finite_volume.jl" begin84@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"),85l2=[0.011662300515980219],86linf=[0.01647256923710194])87# Ensure that we do not have excessive memory allocations88# (e.g., from type instabilities)89let90t = sol.t[end]91u_ode = sol.u[end]92du_ode = similar(u_ode)93@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100094end95end9697@trixi_testset "elixir_advection_perk2.jl" begin98@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2.jl"),99l2=[0.011288030389423475],100linf=[0.01596735472556976])101# Ensure that we do not have excessive memory allocations102# (e.g., from type instabilities)103let104t = sol.t[end]105u_ode = sol.u[end]106du_ode = similar(u_ode)107# Larger values for allowed allocations due to usage of custom108# integrator which are not *recorded* for the methods from109# OrdinaryDiffEq.jl110# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877111@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 8000112end113end114115# Testing the second-order paired explicit Runge-Kutta (PERK) method without stepsize callback116@trixi_testset "elixir_advection_perk2.jl(fixed time step)" begin117@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2.jl"),118dt=2.0e-3,119tspan=(0.0, 20.0),120save_solution=SaveSolutionCallback(dt = 0.1 + 1.0e-8),121callbacks=CallbackSet(summary_callback, save_solution,122analysis_callback, alive_callback),123l2=[9.886271430207691e-6],124linf=[3.729460413781638e-5])125# Ensure that we do not have excessive memory allocations126# (e.g., from type instabilities)127let128t = sol.t[end]129u_ode = sol.u[end]130du_ode = similar(u_ode)131# Larger values for allowed allocations due to usage of custom132# integrator which are not *recorded* for the methods from133# OrdinaryDiffEq.jl134# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877135@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 8000136end137end138139# Testing the second-order paired explicit Runge-Kutta (PERK) method with the optimal CFL number140@trixi_testset "elixir_advection_perk2_optimal_cfl.jl" begin141@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2_optimal_cfl.jl"),142l2=[0.0009700887119146429],143linf=[0.00137209242077041])144# Ensure that we do not have excessive memory allocations145# (e.g., from type instabilities)146let147t = sol.t[end]148u_ode = sol.u[end]149du_ode = similar(u_ode)150# Larger values for allowed allocations due to usage of custom151# integrator which are not *recorded* for the methods from152# OrdinaryDiffEq.jl153# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877154@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 8000155end156end157158@trixi_testset "elixir_advection_doublefloat.jl" begin159using DoubleFloats: Double64160@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_doublefloat.jl"),161l2=Double64[6.80895929885700039832943251427357703e-11],162linf=Double64[5.82834770064525291688100323411704252e-10])163# Ensure that we do not have excessive memory allocations164# (e.g., from type instabilities)165let166t = sol.t[end]167u_ode = sol.u[end]168du_ode = similar(u_ode)169@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000170end171end172end173174end # module175176177