Path: blob/main/test/test_tree_2d_advection.jl
2055 views
module TestExamples2DAdvection12using Test3using Trixi45include("test_trixi.jl")67EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_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"),14# Expected errors are exactly the same as in the parallel test!15l2=[8.311947673061856e-6],16linf=[6.627000273229378e-5])17# Ensure that we do not have excessive memory allocations18# (e.g., from type instabilities)19let20t = sol.t[end]21u_ode = sol.u[end]22du_ode = similar(u_ode)23@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100024end25end2627@trixi_testset "elixir_advection_extended.jl with polydeg=1" begin28@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"),29l2=[0.02134571266411136],30linf=[0.04347734797775926],31polydeg=1)32# Ensure that we do not have excessive memory allocations33# (e.g., from type instabilities)34let35t = sol.t[end]36u_ode = sol.u[end]37du_ode = similar(u_ode)38@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 100039end40end4142@trixi_testset "elixir_advection_implicit_sparse_jacobian.jl" begin43@test_trixi_include(joinpath(EXAMPLES_DIR,44"elixir_advection_implicit_sparse_jacobian.jl"),45l2=[0.003003253325111022], linf=[0.004256250998163846])46# Ensure that we do not have excessive memory allocations47# (e.g., from type instabilities)48let49t = sol.t[end]50u_ode = sol.u[end]51du_ode = similar(u_ode)52@test (@allocated Trixi.rhs!(du_ode, u_ode, semi_float_type, t)) < 100053end54end5556@trixi_testset "elixir_advection_implicit_sparse_jacobian_restart.jl" begin57@test_trixi_include(joinpath(EXAMPLES_DIR,58"elixir_advection_implicit_sparse_jacobian_restart.jl"),59l2=[0.007964280656552015], linf=[0.011267546271397588])60# Ensure that we do not have excessive memory allocations61# (e.g., from type instabilities)62let63t = sol.t[end]64u_ode = sol.u[end]65du_ode = similar(u_ode)66@test (@allocated Trixi.rhs!(du_ode, u_ode, semi_float_type, t)) < 100067end68end6970@trixi_testset "elixir_advection_implicit_sparse_jacobian_restart.jl (no colorvec)" begin71@test_trixi_include(joinpath(EXAMPLES_DIR,72"elixir_advection_implicit_sparse_jacobian_restart.jl"),73colorvec=nothing,74l2=[0.007964280656552015], linf=[0.011267546271397588])75# Ensure that we do not have excessive memory allocations76# (e.g., from type instabilities)77let78t = sol.t[end]79u_ode = sol.u[end]80du_ode = similar(u_ode)81@test (@allocated Trixi.rhs!(du_ode, u_ode, semi_float_type, t)) < 100082end83end8485@trixi_testset "elixir_advection_restart.jl" begin86using OrdinaryDiffEqSSPRK: SSPRK4387println("═"^100)88println(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration_adaptive.jl"))89trixi_include(@__MODULE__,90joinpath(EXAMPLES_DIR,91"elixir_advection_timeintegration_adaptive.jl"),92alg = SSPRK43(), tspan = (0.0, 10.0))93l2_expected, linf_expected = analysis_callback(sol)9495println("═"^100)96println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"))97# Errors are exactly the same as in the elixir_advection_extended.jl98trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),99alg = SSPRK43(),100base_elixir = "elixir_advection_timeintegration_adaptive.jl")101l2_actual, linf_actual = analysis_callback(sol)102103@test l2_actual == l2_expected104@test linf_actual == linf_expected105end106107@trixi_testset "elixir_advection_mortar.jl" begin108@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"),109# Expected errors are exactly the same as in the parallel test!110l2=[0.0015188466707237375],111linf=[0.008446655719187679])112113# Ensure that we do not have excessive memory allocations114# (e.g., from type instabilities)115let116t = sol.t[end]117u_ode = sol.u[end]118du_ode = similar(u_ode)119@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000120end121end122123@trixi_testset "elixir_advection_amr.jl" begin124@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),125# Expected errors are exactly the same as in the parallel test!126l2=[4.913300828257469e-5],127linf=[0.00045263895394385967])128# Ensure that we do not have excessive memory allocations129# (e.g., from type instabilities)130let131t = sol.t[end]132u_ode = sol.u[end]133du_ode = similar(u_ode)134@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000135end136end137138@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin139@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"),140# Expected errors are exactly the same as in the parallel test!141l2=[3.2207388565869075e-5],142linf=[0.0007508059772436404])143# Ensure that we do not have excessive memory allocations144# (e.g., from type instabilities)145let146t = sol.t[end]147u_ode = sol.u[end]148du_ode = similar(u_ode)149@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000150end151end152153@trixi_testset "elixir_advection_amr_solution_independent.jl" begin154@test_trixi_include(joinpath(EXAMPLES_DIR,155"elixir_advection_amr_solution_independent.jl"),156l2=[4.949660644033807e-5],157linf=[0.0004867846262313763])158# Ensure that we do not have excessive memory allocations159# (e.g., from type instabilities)160let161t = sol.t[end]162u_ode = sol.u[end]163du_ode = similar(u_ode)164@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000165end166end167168@trixi_testset "elixir_advection_amr_visualization.jl" begin169# To make CI tests work, disable showing a plot window with the GR backend of the Plots package170# Xref: https://github.com/jheinen/GR.jl/issues/278171# Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103172if !isinteractive()173restore = get(ENV, "GKSwstype", nothing)174ENV["GKSwstype"] = "100"175end176177@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_visualization.jl"),178l2=[0.0007225529919720868],179linf=[0.005954447875428925])180181# Restore GKSwstype to previous value (if it was set)182if !isinteractive()183if isnothing(restore)184delete!(ENV, "GKSwstype")185else186ENV["GKSwstype"] = restore187end188end189end190191@trixi_testset "elixir_advection_timeintegration.jl" begin192@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"),193l2=[2.4976030518356626e-5],194linf=[0.0005531580316338533])195# Ensure that we do not have excessive memory allocations196# (e.g., from type instabilities)197let198t = sol.t[end]199u_ode = sol.u[end]200du_ode = similar(u_ode)201# Larger values for allowed allocations due to usage of custom202# integrator which are not *recorded* for the methods from203# OrdinaryDiffEq.jl204# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877205@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000206end207end208end209210@trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin211@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"),212l2=[2.5314747030031457e-5],213linf=[0.0005437136621948904],214ode_algorithm=Trixi.CarpenterKennedy2N43(),215cfl=1.0)216# Ensure that we do not have excessive memory allocations217# (e.g., from type instabilities)218let219t = sol.t[end]220u_ode = sol.u[end]221du_ode = similar(u_ode)222# Larger values for allowed allocations due to usage of custom223# integrator which are not *recorded* for the methods from224# OrdinaryDiffEq.jl225# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877226@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000227end228end229230@trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin231@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"),232l2=[1.2135350502911197e-5],233linf=[9.999985420537649e-5],234ode_algorithm=Trixi.CarpenterKennedy2N43(),235cfl=1.0,236maxiters=1)237# Ensure that we do not have excessive memory allocations238# (e.g., from type instabilities)239let240t = sol.t[end]241u_ode = sol.u[end]242du_ode = similar(u_ode)243# Larger values for allowed allocations due to usage of custom244# integrator which are not *recorded* for the methods from245# OrdinaryDiffEq.jl246# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877247@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000248end249end250251@trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin252@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"),253l2=[2.4976673477385313e-5],254linf=[0.0005534166916640881],255ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94())256# Ensure that we do not have excessive memory allocations257# (e.g., from type instabilities)258let259t = sol.t[end]260u_ode = sol.u[end]261du_ode = similar(u_ode)262# Larger values for allowed allocations due to usage of custom263# integrator which are not *recorded* for the methods from264# OrdinaryDiffEq.jl265# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877266@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000267end268end269270@trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin271@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"),272l2=[3.667894656471403e-5],273linf=[0.0005799465470165757],274ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(),275cfl=1.0)276# Ensure that we do not have excessive memory allocations277# (e.g., from type instabilities)278let279t = sol.t[end]280u_ode = sol.u[end]281du_ode = similar(u_ode)282# Larger values for allowed allocations due to usage of custom283# integrator which are not *recorded* for the methods from284# OrdinaryDiffEq.jl285# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877286@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000287end288end289290@trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin291@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"),292l2=[1.2198725469737875e-5],293linf=[9.977247740793407e-5],294ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(),295cfl=1.0,296maxiters=1)297# Ensure that we do not have excessive memory allocations298# (e.g., from type instabilities)299let300t = sol.t[end]301u_ode = sol.u[end]302du_ode = similar(u_ode)303# Larger values for allowed allocations due to usage of custom304# integrator which are not *recorded* for the methods from305# OrdinaryDiffEq.jl306# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877307@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000308end309end310311@trixi_testset "elixir_advection_callbacks.jl" begin312@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_callbacks.jl"),313l2=[8.311947673061856e-6],314linf=[6.627000273229378e-5])315# Ensure that we do not have excessive memory allocations316# (e.g., from type instabilities)317let318t = sol.t[end]319u_ode = sol.u[end]320du_ode = similar(u_ode)321@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000322end323end324325# Coverage test for all initial conditions326@testset "Linear scalar advection: Tests for initial conditions" begin327# Linear scalar advection328@trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin329@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"),330l2=[0.0001420618061089383],331linf=[0.0007140570281718439],332maxiters=1,333initial_condition=Trixi.initial_condition_sin_sin)334# Ensure that we do not have excessive memory allocations335# (e.g., from type instabilities)336let337t = sol.t[end]338u_ode = sol.u[end]339du_ode = similar(u_ode)340@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000341end342end343344@trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin345@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"),346l2=[3.8302867746057483e-16],347linf=[1.3322676295501878e-15],348maxiters=1,349initial_condition=initial_condition_constant)350# Ensure that we do not have excessive memory allocations351# (e.g., from type instabilities)352let353t = sol.t[end]354u_ode = sol.u[end]355du_ode = similar(u_ode)356@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000357end358end359360@trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x_y" begin361@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"),362l2=[2.7276160570381226e-16],363linf=[5.10702591327572e-15],364maxiters=1,365initial_condition=Trixi.initial_condition_linear_x_y,366boundary_conditions=Trixi.boundary_condition_linear_x_y,367periodicity=false)368# Ensure that we do not have excessive memory allocations369# (e.g., from type instabilities)370let371t = sol.t[end]372u_ode = sol.u[end]373du_ode = similar(u_ode)374@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000375end376end377378@trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin379@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"),380l2=[1.5121648229368207e-16],381linf=[1.3322676295501878e-15],382maxiters=1,383initial_condition=Trixi.initial_condition_linear_x,384boundary_conditions=Trixi.boundary_condition_linear_x,385periodicity=false)386# Ensure that we do not have excessive memory allocations387# (e.g., from type instabilities)388let389t = sol.t[end]390u_ode = sol.u[end]391du_ode = similar(u_ode)392@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000393end394end395396@trixi_testset "elixir_advection_extended.jl with initial_condition_linear_y" begin397@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"),398l2=[1.714292614252588e-16],399linf=[2.220446049250313e-15],400maxiters=1,401initial_condition=Trixi.initial_condition_linear_y,402boundary_conditions=Trixi.boundary_condition_linear_y,403periodicity=false)404# Ensure that we do not have excessive memory allocations405# (e.g., from type instabilities)406let407t = sol.t[end]408u_ode = sol.u[end]409du_ode = similar(u_ode)410@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000411end412end413end414415end # module416417418