diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index ce46360b832..81d18f4105e 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -30,7 +30,7 @@ jobs: # format(".") run: | julia -e 'using Pkg; Pkg.add(PackageSpec(name = "JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(["benchmark", "ext", "src", "utils"])' + julia -e 'using JuliaFormatter; format(["benchmark", "ext", "src", "test", "utils"])' - name: Format check run: | julia -e ' diff --git a/test/coverage/coverage.jl b/test/coverage/coverage.jl index fbe89acf702..5f1ae8af8fc 100644 --- a/test/coverage/coverage.jl +++ b/test/coverage/coverage.jl @@ -9,28 +9,28 @@ const lcov_info_file = "lcov.info" # Change path to root directory cd(joinpath(@__DIR__, "..", "..")) do - # Process coverage files - processed = process_folder("src") - - # Uncomment the following line once Codecov support is enabled - # Codecov.submit_local(processed) - - # Calculate coverage - covered_lines, total_lines = get_summary(processed) - percentage = covered_lines / total_lines * 100 - - # Print coverage in a format that can be easily parsed - println("($(percentage)%) covered") - - # Try to generate a coverage report - isdir(report_dir) || mkdir(report_dir) - tracefile = joinpath(report_dir, lcov_info_file) - Coverage.LCOV.writefile(tracefile, processed) - branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) - commit = strip(read(`git rev-parse --short HEAD`, String)) - title = "commit $(commit) on branch $(branch)" - run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`) - - # Clean up .cov files - clean_folder("src") + # Process coverage files + processed = process_folder("src") + + # Uncomment the following line once Codecov support is enabled + # Codecov.submit_local(processed) + + # Calculate coverage + covered_lines, total_lines = get_summary(processed) + percentage = covered_lines / total_lines * 100 + + # Print coverage in a format that can be easily parsed + println("($(percentage)%) covered") + + # Try to generate a coverage report + isdir(report_dir) || mkdir(report_dir) + tracefile = joinpath(report_dir, lcov_info_file) + Coverage.LCOV.writefile(tracefile, processed) + branch = strip(read(`git rev-parse --abbrev-ref HEAD`, String)) + commit = strip(read(`git rev-parse --short HEAD`, String)) + title = "commit $(commit) on branch $(branch)" + run(`genhtml -t $(title) -o $(report_dir) $(tracefile)`) + + # Clean up .cov files + clean_folder("src") end diff --git a/test/test_aqua.jl b/test/test_aqua.jl index f7ab4f545d0..9f57791406f 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -12,7 +12,7 @@ include("test_trixi.jl") # exceptions necessary for adding a new method `StartUpDG.estimate_h` # in src/solvers/dgmulti/sbp.jl piracy = (treat_as_own = [Trixi.StartUpDG.RefElemData, - Trixi.StartUpDG.MeshData],)) + Trixi.StartUpDG.MeshData],)) end end #module diff --git a/test/test_dgmulti_1d.jl b/test/test_dgmulti_1d.jl index 180838158ea..79ad64075b4 100644 --- a/test/test_dgmulti_1d.jl +++ b/test/test_dgmulti_1d.jl @@ -9,126 +9,162 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_1d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "DGMulti 1D" begin +#! format: noindent - @trixi_testset "elixir_advection_gauss_sbp.jl " begin +@trixi_testset "elixir_advection_gauss_sbp.jl " begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_sbp.jl"), - cells_per_dimension = (8,), - l2 = [2.9953644500009865e-5], - linf = [4.467840577382365e-5] - ) - # 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 + cells_per_dimension=(8,), + l2=[2.9953644500009865e-5], + linf=[4.467840577382365e-5]) + # 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_euler_flux_diff.jl " begin +@trixi_testset "elixir_euler_flux_diff.jl " begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension = (16,), - # division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain - l2 = [7.853842541289665e-7, 9.609905503440606e-7, 2.832322219966481e-6] ./ sqrt(2.0), - linf = [1.5003758788711963e-6, 1.802998748523521e-6, 4.83599270806323e-6] - ) - # 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 + cells_per_dimension=(16,), + # division by sqrt(2.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 7.853842541289665e-7, + 9.609905503440606e-7, + 2.832322219966481e-6, + ] ./ sqrt(2.0), + linf=[ + 1.5003758788711963e-6, + 1.802998748523521e-6, + 4.83599270806323e-6, + ]) + # 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_euler_flux_diff.jl (convergence)" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), 3) - @test isapprox(mean_convergence[:l2], [4.1558759698638434, 3.977911306037128, 4.041421206468769], rtol=0.05) - # 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 +@trixi_testset "elixir_euler_flux_diff.jl (convergence)" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "elixir_euler_flux_diff.jl"), 3) + @test isapprox(mean_convergence[:l2], + [4.1558759698638434, 3.977911306037128, 4.041421206468769], + rtol = 0.05) + # 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_euler_flux_diff.jl (SBP) " begin +@trixi_testset "elixir_euler_flux_diff.jl (SBP) " begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension = (16,), - approximation_type = SBP(), - l2 = [6.437827414849647e-6, 2.1840558851820947e-6, 1.3245669629438228e-5], - linf = [2.0715843751295537e-5, 8.519520630301258e-6, 4.2642194098885255e-5] - ) - # 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 + cells_per_dimension=(16,), + approximation_type=SBP(), + l2=[ + 6.437827414849647e-6, + 2.1840558851820947e-6, + 1.3245669629438228e-5, + ], + linf=[ + 2.0715843751295537e-5, + 8.519520630301258e-6, + 4.2642194098885255e-5, + ]) + # 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_euler_flux_diff.jl (FD SBP)" begin +@trixi_testset "elixir_euler_flux_diff.jl (FD SBP)" begin + global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 16) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_flux_diff.jl"), - cells_per_dimension = (4,), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=16), - l2 = [1.8684509287853788e-5, 1.0641411823379635e-5, 5.178010291876143e-5], - linf = [6.933493585936645e-5, 3.0277366229292113e-5, 0.0002220020568932668] - ) + cells_per_dimension=(4,), + approximation_type=D, + l2=[ + 1.8684509287853788e-5, + 1.0641411823379635e-5, + 5.178010291876143e-5, + ], + linf=[ + 6.933493585936645e-5, + 3.0277366229292113e-5, + 0.0002220020568932668, + ]) show(stdout, semi.solver.basis) show(stdout, MIME"text/plain"(), semi.solver.basis) - # 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 + # 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_euler_fdsbp_periodic.jl" begin +@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2 = [9.146929180585711e-7, 1.8997616878017292e-6, 3.991417702211889e-6], - linf = [1.7321089884614338e-6, 3.3252888855805907e-6, 6.5252787737613005e-6] - ) + l2=[ + 9.146929180585711e-7, + 1.8997616878017292e-6, + 3.991417702211889e-6, + ], + linf=[ + 1.7321089884614338e-6, + 3.3252888855805907e-6, + 6.5252787737613005e-6, + ]) show(stdout, semi.solver.basis) show(stdout, MIME"text/plain"(), semi.solver.basis) - # 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 + # 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 "DGMulti with periodic SBP unit test" begin +@trixi_testset "DGMulti with periodic SBP unit test" begin # see https://github.com/trixi-framework/Trixi.jl/pull/1013 - dg = DGMulti(element_type = Line(), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=-5.0, xmax=10.0, N=50)) + global D = periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = -5.0, + xmax = 10.0, N = 50) + dg = DGMulti(element_type = Line(), approximation_type = D) mesh = DGMultiMesh(dg) @test mapreduce(isapprox, &, mesh.md.xyz, dg.basis.rst) # check to make sure nodes are rescaled to [-1, 1] @test minimum(dg.basis.rst[1]) ≈ -1 - @test maximum(dg.basis.rst[1]) ≈ 1 atol=0.35 - end + @test maximum(dg.basis.rst[1])≈1 atol=0.35 +end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_dgmulti_2d.jl b/test/test_dgmulti_2d.jl index 861e30045ce..8fd00df72ea 100644 --- a/test/test_dgmulti_2d.jl +++ b/test/test_dgmulti_2d.jl @@ -9,357 +9,680 @@ EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_2d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "DGMulti 2D" begin +#! format: noindent - @trixi_testset "elixir_euler_weakform.jl" begin +@trixi_testset "elixir_euler_weakform.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0013536930300254945, 0.0014315603442106193, 0.001431560344211359, 0.0047393341007602625] ./ 2.0, - linf = [0.001514260921466004, 0.0020623991944839215, 0.002062399194485476, 0.004897700392503701] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (SBP)" begin + cells_per_dimension=(4, 4), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0013536930300254945, + 0.0014315603442106193, + 0.001431560344211359, + 0.0047393341007602625, + ] ./ 2.0, + linf=[ + 0.001514260921466004, + 0.0020623991944839215, + 0.002062399194485476, + 0.004897700392503701, + ]) +end + +@trixi_testset "elixir_euler_weakform.jl (SBP)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - approximation_type = SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0074706882014934735, 0.005306220583603261, 0.005306220583613591, 0.014724842607716771] ./ 2.0, - linf = [0.021563604940952885, 0.01359397832530762, 0.013593978324845324, 0.03270995869587523] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin + cells_per_dimension=(4, 4), + approximation_type=SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0074706882014934735, + 0.005306220583603261, + 0.005306220583613591, + 0.014724842607716771, + ] ./ 2.0, + linf=[ + 0.021563604940952885, + 0.01359397832530762, + 0.013593978324845324, + 0.03270995869587523, + ]) +end + +@trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - element_type = Quad(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.00031892254415307093, 0.00033637562986771894, 0.0003363756298680649, 0.0011100259064243145] ./ 2.0, - linf = [0.001073298211445639, 0.0013568139808282087, 0.0013568139808290969, 0.0032249020004324613] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (EC) " begin + cells_per_dimension=(4, 4), + element_type=Quad(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.00031892254415307093, + 0.00033637562986771894, + 0.0003363756298680649, + 0.0011100259064243145, + ] ./ 2.0, + linf=[ + 0.001073298211445639, + 0.0013568139808282087, + 0.0013568139808290969, + 0.0032249020004324613, + ]) +end + +@trixi_testset "elixir_euler_weakform.jl (EC) " begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.007801417730672109, 0.00708583561714128, 0.0070858356171393, 0.015217574294198809] ./ 2.0, - linf = [0.011572828457858897, 0.013965298735070686, 0.01396529873508534, 0.04227683691807904] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin + cells_per_dimension=(4, 4), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.007801417730672109, + 0.00708583561714128, + 0.0070858356171393, + 0.015217574294198809, + ] ./ 2.0, + linf=[ + 0.011572828457858897, + 0.013965298735070686, + 0.01396529873508534, + 0.04227683691807904, + ]) +end + +@trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.01280067571168776, 0.010607599608273302, 0.010607599608239775, 0.026408338014056548] ./ 2.0, - linf = [0.037983023185674814, 0.05321027922533417, 0.05321027922608157, 0.13392025411844033] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin + cells_per_dimension=(4, 4), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.01280067571168776, + 0.010607599608273302, + 0.010607599608239775, + 0.026408338014056548, + ] ./ 2.0, + linf=[ + 0.037983023185674814, + 0.05321027922533417, + 0.05321027922608157, + 0.13392025411844033, + ]) +end + +@trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - element_type = Quad(), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0029373718090697975, 0.0030629360605489465, 0.003062936060545615, 0.0068486089344859755] ./ 2.0, - linf = [0.01360165305316885, 0.01267402847925303, 0.012674028479251254, 0.02210545278615017] - ) - end - - @trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin + cells_per_dimension=(4, 4), + element_type=Quad(), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0029373718090697975, + 0.0030629360605489465, + 0.003062936060545615, + 0.0068486089344859755, + ] ./ 2.0, + linf=[ + 0.01360165305316885, + 0.01267402847925303, + 0.012674028479251254, + 0.02210545278615017, + ]) +end + +@trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_bilinear.jl"), - l2 = [1.0259435706215337e-5, 9.014090233720625e-6, 9.014090233223014e-6, 2.738953587401793e-5], - linf = [7.362609083649829e-5, 6.874188055272512e-5, 6.874188052830021e-5, 0.0001912435192696904] - ) - end + l2=[ + 1.0259435706215337e-5, + 9.014090233720625e-6, + 9.014090233223014e-6, + 2.738953587401793e-5, + ], + linf=[ + 7.362609083649829e-5, + 6.874188055272512e-5, + 6.874188052830021e-5, + 0.0001912435192696904, + ]) +end - @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin +@trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - l2 = [1.720476068165337e-5, 1.592168205710526e-5, 1.592168205812963e-5, 4.894094865697305e-5], - linf = [0.00010525416930584619, 0.00010003778091061122, 0.00010003778085621029, 0.00036426282101720275] - ) - end + l2=[ + 1.720476068165337e-5, + 1.592168205710526e-5, + 1.592168205812963e-5, + 4.894094865697305e-5, + ], + linf=[ + 0.00010525416930584619, + 0.00010003778091061122, + 0.00010003778085621029, + 0.00036426282101720275, + ]) +end - @trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin +@trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - approximation_type = GaussSBP(), - l2 = [3.4666312079259457e-6, 3.4392774480368986e-6, 3.439277447953705e-6, 1.0965598424665836e-5], - linf = [1.1327280377004811e-5, 1.1343911926253725e-5, 1.1343911906935844e-5, 3.679582619220412e-5], - rtol = 2 * sqrt(eps()) - ) - end - - @trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin + approximation_type=GaussSBP(), + l2=[ + 3.4666312079259457e-6, + 3.4392774480368986e-6, + 3.439277447953705e-6, + 1.0965598424665836e-5, + ], + linf=[ + 1.1327280377004811e-5, + 1.1343911926253725e-5, + 1.1343911906935844e-5, + 3.679582619220412e-5, + ], + rtol=2 * sqrt(eps())) +end + +@trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - element_type = Tri(), approximation_type = Polynomial(), volume_integral = VolumeIntegralWeakForm(), - l2 = [7.905498158659466e-6, 8.731690809663625e-6, 8.731690811576996e-6, 2.9113296018693953e-5], - linf = [3.298811230090237e-5, 4.032272476939269e-5, 4.032272526011127e-5, 0.00012013725458537294] - ) - end + element_type=Tri(), approximation_type=Polynomial(), + volume_integral=VolumeIntegralWeakForm(), + l2=[ + 7.905498158659466e-6, + 8.731690809663625e-6, + 8.731690811576996e-6, + 2.9113296018693953e-5, + ], + linf=[ + 3.298811230090237e-5, + 4.032272476939269e-5, + 4.032272526011127e-5, + 0.00012013725458537294, + ]) +end - @trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin +@trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_hohqmesh.jl"), - l2 = [0.0008153911341517156, 0.0007768159701964676, 0.00047902606811690694, 0.0015551846076348535], - linf = [0.0029301131365355726, 0.0034427051471457304, 0.0028721569841545502, 0.011125365074589944] - ) - end + l2=[ + 0.0008153911341517156, + 0.0007768159701964676, + 0.00047902606811690694, + 0.0015551846076348535, + ], + linf=[ + 0.0029301131365355726, + 0.0034427051471457304, + 0.0028721569841545502, + 0.011125365074589944, + ]) +end - @trixi_testset "elixir_euler_weakform.jl (convergence)" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), 2) - @test isapprox(mean_convergence[:l2], [4.243843382379403, 4.128314378833922, 4.128314378397532, 4.081366752807379], rtol=0.05) - end +@trixi_testset "elixir_euler_weakform.jl (convergence)" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "elixir_euler_weakform.jl"), 2) + @test isapprox(mean_convergence[:l2], + [ + 4.243843382379403, + 4.128314378833922, + 4.128314378397532, + 4.081366752807379, + ], rtol = 0.05) +end - @trixi_testset "elixir_euler_weakform_periodic.jl" begin +@trixi_testset "elixir_euler_weakform_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0014986508075708323, 0.001528523420746786, 0.0015285234207473158, 0.004846505183839211] ./ 2.0, - linf = [0.0015062108658376872, 0.0019373508504645365, 0.0019373508504538783, 0.004742686826709086] - ) - end + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0014986508075708323, + 0.001528523420746786, + 0.0015285234207473158, + 0.004846505183839211, + ] ./ 2.0, + linf=[ + 0.0015062108658376872, + 0.0019373508504645365, + 0.0019373508504538783, + 0.004742686826709086, + ]) +end - @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin +@trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_triangulate_pkg_mesh.jl"), - l2 = [2.344080455438114e-6, 1.8610038753097983e-6, 2.4095165666095305e-6, 6.373308158814308e-6], - linf = [2.5099852761334418e-5, 2.2683684021362893e-5, 2.6180448559287584e-5, 5.5752932611508044e-5] - ) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - cells_per_dimension = (32, 32), tspan = (0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.11140378947116614, 0.06598161188703612, 0.10448953167839563, 0.16023209181809595] ./ 2.0, - linf = [0.24033843177853664, 0.1659992245272325, 0.1235468309508845, 0.26911424973147735] - ) - end - - @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - cells_per_dimension = (32, 32), element_type = Quad(), approximation_type=GaussSBP(), tspan = (0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.11141270656347146, 0.06598888014584121, 0.1044902203749932, 0.16023037364774995] ./ 2.0, - linf = [0.2414760062126462, 0.1662111846065654, 0.12344140473946856, 0.26978428189564774] - ) - end - - @trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_rayleigh_taylor_instability.jl"), - cells_per_dimension = (8, 8), tspan = (0.0, 0.2), - l2 = [0.0709665896982514, 0.005182828752164663, 0.013832655585206478, 0.03247013800580221], - linf = [0.4783963902824797, 0.022527207050681054, 0.040307056293369226, 0.0852365428206836] - ) - end - - @trixi_testset "elixir_euler_brown_minion_vortex.jl" begin + l2=[ + 2.344080455438114e-6, + 1.8610038753097983e-6, + 2.4095165666095305e-6, + 6.373308158814308e-6, + ], + linf=[ + 2.5099852761334418e-5, + 2.2683684021362893e-5, + 2.6180448559287584e-5, + 5.5752932611508044e-5, + ]) +end + +@trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + cells_per_dimension=(32, 32), tspan=(0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.11140378947116614, + 0.06598161188703612, + 0.10448953167839563, + 0.16023209181809595, + ] ./ 2.0, + linf=[ + 0.24033843177853664, + 0.1659992245272325, + 0.1235468309508845, + 0.26911424973147735, + ]) +end + +@trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + cells_per_dimension=(32, 32), element_type=Quad(), + approximation_type=GaussSBP(), tspan=(0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.11141270656347146, + 0.06598888014584121, + 0.1044902203749932, + 0.16023037364774995, + ] ./ 2.0, + linf=[ + 0.2414760062126462, + 0.1662111846065654, + 0.12344140473946856, + 0.26978428189564774, + ]) +end + +@trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_rayleigh_taylor_instability.jl"), + cells_per_dimension=(8, 8), tspan=(0.0, 0.2), + l2=[ + 0.0709665896982514, + 0.005182828752164663, + 0.013832655585206478, + 0.03247013800580221, + ], + linf=[ + 0.4783963902824797, + 0.022527207050681054, + 0.040307056293369226, + 0.0852365428206836, + ]) +end + +@trixi_testset "elixir_euler_brown_minion_vortex.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_brown_minion_vortex.jl"), - cells_per_dimension = 4, tspan = (0.0, 0.1), - l2 = [0.006680001611078062, 0.02151676347585447, 0.010696524235364626, 0.15052841129694647], - linf = [0.01544756362800248, 0.09517304772476806, 0.021957154972646383, 0.33773439650806303] - ) - end + cells_per_dimension=4, tspan=(0.0, 0.1), + l2=[ + 0.006680001611078062, + 0.02151676347585447, + 0.010696524235364626, + 0.15052841129694647, + ], + linf=[ + 0.01544756362800248, + 0.09517304772476806, + 0.021957154972646383, + 0.33773439650806303, + ]) +end - @trixi_testset "elixir_euler_shockcapturing.jl" begin +@trixi_testset "elixir_euler_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - cells_per_dimension = 4, tspan = (0.0, 0.1), - l2 = [0.05685148333985476, 0.04308122135907089, 0.043081221359070915, 0.21098131003847664], - linf = [0.2360672306096051, 0.16684417686971842, 0.1668441768697189, 0.8572572782118661] - ) - end + cells_per_dimension=4, tspan=(0.0, 0.1), + l2=[ + 0.05685148333985476, + 0.04308122135907089, + 0.043081221359070915, + 0.21098131003847664, + ], + linf=[ + 0.2360672306096051, + 0.16684417686971842, + 0.1668441768697189, + 0.8572572782118661, + ]) +end - @trixi_testset "elixir_euler_shockcapturing_curved.jl" begin +@trixi_testset "elixir_euler_shockcapturing_curved.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_curved.jl"), - cells_per_dimension = 4, tspan = (0.0, 0.1), - l2 = [0.05565849298766252, 0.042322816017256494, 0.042322816017256466, 0.2064212098324083], - linf = [0.23633287875008924, 0.16930148707515683, 0.16930148707515688, 0.8587706761131937] - ) - end - + cells_per_dimension=4, tspan=(0.0, 0.1), + l2=[ + 0.05565849298766252, + 0.042322816017256494, + 0.042322816017256466, + 0.2064212098324083, + ], + linf=[ + 0.23633287875008924, + 0.16930148707515683, + 0.16930148707515688, + 0.8587706761131937, + ]) +end - @trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin +@trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin + global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 12) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (2, 2), - element_type = Quad(), - cfl = 1.0, - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=12), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0008966318978421226, 0.0011418826379110242, 0.001141882637910878, 0.0030918374335671393] ./ 2.0, - linf = [0.0015281525343109337, 0.00162430960401716, 0.0016243096040242655, 0.004447503691245913] - ) - end - - @trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin + cells_per_dimension=(2, 2), + element_type=Quad(), + cfl=1.0, + approximation_type=D, + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0008966318978421226, + 0.0011418826379110242, + 0.001141882637910878, + 0.0030918374335671393, + ] ./ 2.0, + linf=[ + 0.0015281525343109337, + 0.00162430960401716, + 0.0016243096040242655, + 0.004447503691245913, + ]) +end + +@trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin + global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 12) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - cells_per_dimension = (2, 2), - element_type = Quad(), - cfl = 1.0, - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=12), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.0014018725496871129, 0.0015887007320868913, 0.001588700732086329, 0.003870926821031202] ./ 2.0, - linf = [0.0029541996523780867, 0.0034520465226108854, 0.003452046522624652, 0.007677153211004928] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin + cells_per_dimension=(2, 2), + element_type=Quad(), + cfl=1.0, + approximation_type=D, + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0014018725496871129, + 0.0015887007320868913, + 0.001588700732086329, + 0.003870926821031202, + ] ./ 2.0, + linf=[ + 0.0029541996523780867, + 0.0034520465226108854, + 0.003452046522624652, + 0.007677153211004928, + ]) +end + +@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2 = [1.3333320340010056e-6, 2.044834627970641e-6, 2.044834627855601e-6, 5.282189803559564e-6], - linf = [2.7000151718858945e-6, 3.988595028259212e-6, 3.9885950273710336e-6, 8.848583042286862e-6] - ) - end + l2=[ + 1.3333320340010056e-6, + 2.044834627970641e-6, + 2.044834627855601e-6, + 5.282189803559564e-6, + ], + linf=[ + 2.7000151718858945e-6, + 3.988595028259212e-6, + 3.9885950273710336e-6, + 8.848583042286862e-6, + ]) +end - @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin +@trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - xmin=-200.0, xmax=100.0 #= parameters for reference interval =#, - l2 = [1.333332034149886e-6, 2.0448346280892024e-6, 2.0448346279766305e-6, 5.282189803510037e-6], - linf = [2.700015170553627e-6, 3.988595024262409e-6, 3.988595024928543e-6, 8.84858303740188e-6] - ) - end + xmin=-200.0, xmax=100.0, #= parameters for reference interval =# + l2=[ + 1.333332034149886e-6, + 2.0448346280892024e-6, + 2.0448346279766305e-6, + 5.282189803510037e-6, + ], + linf=[ + 2.700015170553627e-6, + 3.988595024262409e-6, + 3.988595024928543e-6, + 8.84858303740188e-6, + ]) +end - @trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin +@trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin + global D = periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = -200.0, + xmax = 100.0, + N = 100) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - approximation_type = periodic_derivative_operator( - derivative_order=1, accuracy_order=4, xmin=-200.0, xmax=100.0, N=100), - coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0), - l2 = [0.07318831033918516, 0.10039910610067465, 0.1003991061006748, 0.2642450566234564], - linf = [0.36081081739439735, 0.5244468027020845, 0.5244468027020814, 1.2210130256735705] - ) - end - - @trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin + approximation_type=D, + coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0), + l2=[ + 0.07318831033918516, + 0.10039910610067465, + 0.1003991061006748, + 0.2642450566234564, + ], + linf=[ + 0.36081081739439735, + 0.5244468027020845, + 0.5244468027020814, + 1.2210130256735705, + ]) +end + +@trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin + D_local = SummationByPartsOperators.legendre_derivative_operator(xmin = 0.0, + xmax = 1.0, + N = 4) + mesh_local = SummationByPartsOperators.UniformPeriodicMesh1D(xmin = -1.0, + xmax = 1.0, + Nx = 10) + global D = SummationByPartsOperators.couple_continuously(D_local, mesh_local) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - approximation_type = SummationByPartsOperators.couple_continuously( - SummationByPartsOperators.legendre_derivative_operator(xmin=0.0, xmax=1.0, N=4), - SummationByPartsOperators.UniformPeriodicMesh1D(xmin=-1.0, xmax=1.0, Nx=10)), - l2 = [1.5440402410017893e-5, 1.4913189903083485e-5, 1.4913189902797073e-5, 2.6104615985156992e-5], - linf = [4.16334345412217e-5, 5.067812788173143e-5, 5.067812786885284e-5, 9.887976803746312e-5] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin + approximation_type=D, + l2=[ + 1.5440402410017893e-5, + 1.4913189903083485e-5, + 1.4913189902797073e-5, + 2.6104615985156992e-5, + ], + linf=[ + 4.16334345412217e-5, + 5.067812788173143e-5, + 5.067812786885284e-5, + 9.887976803746312e-5, + ]) +end + +@trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), - cells_per_dimension = 4, - l2 = [0.03906769915509508, 0.04923079758984701, 0.049230797589847136, 0.02660348840973283, - 0.18054907061740028, 0.019195256934309846, 0.019195256934310016, 0.027856113419468087, - 0.0016567799774264065], - linf = [0.16447597822733662, 0.244157345789029, 0.24415734578903472, 0.11982440036793476, - 0.7450328339751362, 0.06357382685763713, 0.0635738268576378, 0.1058830287485999, - 0.005740591170062146] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin + cells_per_dimension=4, + l2=[0.03906769915509508, 0.04923079758984701, + 0.049230797589847136, 0.02660348840973283, + 0.18054907061740028, 0.019195256934309846, + 0.019195256934310016, 0.027856113419468087, + 0.0016567799774264065], + linf=[0.16447597822733662, 0.244157345789029, + 0.24415734578903472, 0.11982440036793476, + 0.7450328339751362, 0.06357382685763713, 0.0635738268576378, + 0.1058830287485999, + 0.005740591170062146]) +end + +@trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"), - cells_per_dimension = 4, element_type = Tri(), - l2 = [0.03372468091254386, 0.03971626483409167, 0.03971626483409208, 0.021427571421535722, - 0.15079331840847413, 0.015716300366650286, 0.015716300366652128, 0.022365252076279075, - 0.0009232971979900358], - linf = [0.16290247390873458, 0.2256891306641319, 0.2256891306641336, 0.09476017042552534, - 0.6906308908961734, 0.05349939593012487, 0.05349939593013042, 0.08830587480616725, - 0.0029551359803035027] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin + cells_per_dimension=4, element_type=Tri(), + l2=[0.03372468091254386, 0.03971626483409167, + 0.03971626483409208, 0.021427571421535722, + 0.15079331840847413, 0.015716300366650286, + 0.015716300366652128, 0.022365252076279075, + 0.0009232971979900358], + linf=[0.16290247390873458, 0.2256891306641319, + 0.2256891306641336, 0.09476017042552534, + 0.6906308908961734, 0.05349939593012487, + 0.05349939593013042, 0.08830587480616725, + 0.0029551359803035027]) +end + +@trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin # These setups do not pass CI reliably, see # https://github.com/trixi-framework/Trixi.jl/pull/880 and # https://github.com/trixi-framework/Trixi.jl/issues/881 - @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave_SBP.jl"), - cells_per_dimension = 4, - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.15825983698241494, 0.19897219694837923, 0.19784182473275247, 0.10482833997417325, - 0.7310752391255246, 0.07374056714564853, 0.07371172293240634, 0.10782032253431281, - 0.004921676235111545] ./ 2.0, - linf = [0.1765644464978685, 0.2627803272865769, 0.26358136695848144, 0.12347681727447984, - 0.7733289736898254, 0.06695360844467957, 0.06650382120802623, 0.10885097000919097, - 0.007212567638078835] - ) - end - - @trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin + @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_mhd_weak_blast_wave_SBP.jl"), + cells_per_dimension=4, + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[0.15825983698241494, 0.19897219694837923, + 0.19784182473275247, 0.10482833997417325, + 0.7310752391255246, 0.07374056714564853, + 0.07371172293240634, 0.10782032253431281, + 0.004921676235111545] ./ 2.0, + linf=[0.1765644464978685, 0.2627803272865769, + 0.26358136695848144, 0.12347681727447984, + 0.7733289736898254, 0.06695360844467957, + 0.06650382120802623, 0.10885097000919097, + 0.007212567638078835]) +end + +@trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin # These setups do not pass CI reliably, see # https://github.com/trixi-framework/Trixi.jl/pull/880 and # https://github.com/trixi-framework/Trixi.jl/issues/881 - @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave_SBP.jl"), - cells_per_dimension = 4, element_type=Tri(), tspan = (0.0, 0.2), - # division by 2.0 corresponds to normalization by the square root of the size of the domain - l2 = [0.13825044764021147, 0.15472815448314997, 0.1549093274293255, 0.053103596213755405, - 0.7246162776815603, 0.07730777596615901, 0.07733438386480523, 0.109893463921706, - 0.00617678167062838] ./ 2.0, - linf = [0.22701306227317952, 0.2905255794821543, 0.2912409425436937, 0.08051361477962096, - 1.0842974228656006, 0.07866000368926784, 0.0786646354518149, 0.1614896380292925, - 0.010358210347485542] - ) - end - - @trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin + @test_skip @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_mhd_weak_blast_wave_SBP.jl"), + cells_per_dimension=4, element_type=Tri(), + tspan=(0.0, 0.2), + # division by 2.0 corresponds to normalization by the square root of the size of the domain + l2=[0.13825044764021147, 0.15472815448314997, + 0.1549093274293255, 0.053103596213755405, + 0.7246162776815603, 0.07730777596615901, + 0.07733438386480523, 0.109893463921706, + 0.00617678167062838] ./ 2.0, + linf=[0.22701306227317952, 0.2905255794821543, + 0.2912409425436937, 0.08051361477962096, + 1.0842974228656006, 0.07866000368926784, + 0.0786646354518149, 0.1614896380292925, + 0.010358210347485542]) +end + +@trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_reflective_wall.jl"), - cells_per_dimension = 4, - l2 = [0.0036019536614619687, 0.001734097206958611, 0.008375221008997178, 0.0, 0.028596796602124414, 0.0018573693138866614, 0.0020807798141551166, 0.0, 5.301188920230166e-5], - linf = [0.01692601228199253, 0.009369662298436778, 0.04145169295835428, 0.0, 0.11569908670112738, 0.00984964453299233, 0.01141708032148614, 0.0, 0.0002992631411931389] - ) - end + cells_per_dimension=4, + l2=[ + 0.0036019536614619687, + 0.001734097206958611, + 0.008375221008997178, + 0.0, + 0.028596796602124414, + 0.0018573693138866614, + 0.0020807798141551166, + 0.0, + 5.301188920230166e-5, + ], + linf=[ + 0.01692601228199253, + 0.009369662298436778, + 0.04145169295835428, + 0.0, + 0.11569908670112738, + 0.00984964453299233, + 0.01141708032148614, + 0.0, + 0.0002992631411931389, + ]) +end - @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, SBP)" begin +@trixi_testset "elixir_shallowwater_source_terms.jl (Quad, SBP)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Quad(), approximation_type = SBP(), - l2 = [0.0020316462913319046, 0.023669019044882247, 0.03446194752754684, 1.9333465252381796e-15], - linf = [0.010385010095182778, 0.08750628939565086, 0.12088392994348407, 9.325873406851315e-15] - ) - end + cells_per_dimension=8, element_type=Quad(), + approximation_type=SBP(), + l2=[ + 0.0020316462913319046, + 0.023669019044882247, + 0.03446194752754684, + 1.9333465252381796e-15, + ], + linf=[ + 0.010385010095182778, + 0.08750628939565086, + 0.12088392994348407, + 9.325873406851315e-15, + ]) +end - @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin +@trixi_testset "elixir_shallowwater_source_terms.jl (Tri, SBP)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Tri(), approximation_type = SBP(), - l2 = [0.004180680322490383, 0.07026192411558974, 0.11815151697006446, 2.329788936151192e-15], - linf = [0.02076003852980346, 0.29169601664914424, 0.5674183379872275, 1.1546319456101628e-14] - ) - end + cells_per_dimension=8, element_type=Tri(), + approximation_type=SBP(), + l2=[ + 0.004180680322490383, + 0.07026192411558974, + 0.11815151697006446, + 2.329788936151192e-15, + ], + linf=[ + 0.02076003852980346, + 0.29169601664914424, + 0.5674183379872275, + 1.1546319456101628e-14, + ]) +end - @trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin +@trixi_testset "elixir_shallowwater_source_terms.jl (Tri, Polynomial)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Tri(), approximation_type = Polynomial(), - # The last l2, linf error are the L2 projection error in approximating `b`, so they are not - # zero for general non-collocated quadrature rules (e.g., for `element_type=Tri()`, `polydeg > 2`). - l2 = [0.0008309356912456799, 0.01522451288799231, 0.016033969387208476, 1.2820247308150876e-5], - linf = [0.001888045014140971, 0.05466838692127718, 0.06345885709961152, 3.3989933098554914e-5] - ) - end - - @trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - cells_per_dimension = 8, element_type = Quad(), approximation_type = Polynomial(), - # The last l2, linf error are the L2 projection error in approximating `b`. However, this is zero - # for `Quad()` elements with `Polynomial()` approximations because the quadrature rule defaults to - # a `(polydeg + 1)`-point Gauss quadrature rule in each coordinate (in general, StartUpDG.jl defaults - # to the quadrature rule with the fewest number of points which exactly integrates the mass matrix). - l2 = [7.460461950323111e-5, 0.003685589808444905, 0.0039101604749887785, 2.0636891126652983e-15], - linf = [0.000259995400729629, 0.0072236204211630906, 0.010364675200833062, 1.021405182655144e-14] - ) - end - + cells_per_dimension=8, element_type=Tri(), + approximation_type=Polynomial(), + # The last l2, linf error are the L2 projection error in approximating `b`, so they are not + # zero for general non-collocated quadrature rules (e.g., for `element_type=Tri()`, `polydeg > 2`). + l2=[ + 0.0008309356912456799, + 0.01522451288799231, + 0.016033969387208476, + 1.2820247308150876e-5, + ], + linf=[ + 0.001888045014140971, + 0.05466838692127718, + 0.06345885709961152, + 3.3989933098554914e-5, + ]) +end +@trixi_testset "elixir_shallowwater_source_terms.jl (Quad, Polynomial)" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + cells_per_dimension=8, element_type=Quad(), + approximation_type=Polynomial(), + # The last l2, linf error are the L2 projection error in approximating `b`. However, this is zero + # for `Quad()` elements with `Polynomial()` approximations because the quadrature rule defaults to + # a `(polydeg + 1)`-point Gauss quadrature rule in each coordinate (in general, StartUpDG.jl defaults + # to the quadrature rule with the fewest number of points which exactly integrates the mass matrix). + l2=[ + 7.460461950323111e-5, + 0.003685589808444905, + 0.0039101604749887785, + 2.0636891126652983e-15, + ], + linf=[ + 0.000259995400729629, + 0.0072236204211630906, + 0.010364675200833062, + 1.021405182655144e-14, + ]) +end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_dgmulti_3d.jl b/test/test_dgmulti_3d.jl index d2556ae434b..3a1db255484 100644 --- a/test/test_dgmulti_3d.jl +++ b/test/test_dgmulti_3d.jl @@ -9,252 +9,402 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "dgmulti_3d") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "DGMulti 3D" begin - # 3d tet/hex tests - @trixi_testset "elixir_euler_weakform.jl" begin +#! format: noindent + +# 3d tet/hex tests +@trixi_testset "elixir_euler_weakform.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.0010029534292051608, 0.0011682205957721673, 0.001072975385793516, 0.000997247778892257, 0.0039364354651358294] ./ sqrt(8), - linf = [0.003660737033303718, 0.005625620600749226, 0.0030566354814669516, 0.0041580358824311325, 0.019326660236036464] - ) - # 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 + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0010029534292051608, + 0.0011682205957721673, + 0.001072975385793516, + 0.000997247778892257, + 0.0039364354651358294, + ] ./ sqrt(8), + linf=[ + 0.003660737033303718, + 0.005625620600749226, + 0.0030566354814669516, + 0.0041580358824311325, + 0.019326660236036464, + ]) + # 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_euler_weakform.jl (EC)" begin +@trixi_testset "elixir_euler_weakform.jl (EC)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.014932088450136542, 0.017080219613061526, 0.016589517840793006, 0.015905000907070196, 0.03903416208587798] ./ sqrt(8), - linf = [0.06856547797256729, 0.08225664880340489, 0.06925055630951782, 0.06913016119820181, 0.19161418499621874] - ) - # 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 + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.014932088450136542, + 0.017080219613061526, + 0.016589517840793006, + 0.015905000907070196, + 0.03903416208587798, + ] ./ sqrt(8), + linf=[ + 0.06856547797256729, + 0.08225664880340489, + 0.06925055630951782, + 0.06913016119820181, + 0.19161418499621874, + ]) + # 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_euler_weakform.jl (Hexahedral elements)" begin +@trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"), - element_type = Hex(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.00030580190715769566, 0.00040146357607439464, 0.00040146357607564597, 0.000401463576075708, 0.0015749412434154315] ./ sqrt(8), - linf = [0.00036910287847780054, 0.00042659774184228283, 0.0004265977427213574, 0.00042659774250686233, 0.00143803344597071] - ) - # 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 + element_type=Hex(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.00030580190715769566, + 0.00040146357607439464, + 0.00040146357607564597, + 0.000401463576075708, + 0.0015749412434154315, + ] ./ sqrt(8), + linf=[ + 0.00036910287847780054, + 0.00042659774184228283, + 0.0004265977427213574, + 0.00042659774250686233, + 0.00143803344597071, + ]) + # 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_euler_curved.jl (Hex elements, SBP, flux differencing)" begin +@trixi_testset "elixir_euler_curved.jl (Hex elements, SBP, flux differencing)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - l2 = [0.018354883045936066, 0.024412704052042846, 0.024408520416087945, 0.01816314570880129, 0.039342805507972006], - linf = [0.14862225990775757, 0.28952368161864683, 0.2912054484817035, 0.1456603133854122, 0.3315354586775472] - ) - # 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 + l2=[ + 0.018354883045936066, + 0.024412704052042846, + 0.024408520416087945, + 0.01816314570880129, + 0.039342805507972006, + ], + linf=[ + 0.14862225990775757, + 0.28952368161864683, + 0.2912054484817035, + 0.1456603133854122, + 0.3315354586775472, + ]) + # 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_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin +@trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"), - approximation_type=GaussSBP(), - l2 = [0.002631131519508634, 0.0029144224044954105, 0.002913889110662827, 0.002615140832314194, 0.006881528610614373], - linf = [0.020996114874140215, 0.021314522450134543, 0.021288322783006297, 0.020273381695435244, 0.052598740390024545] - ) - # 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 + approximation_type=GaussSBP(), + l2=[ + 0.002631131519508634, + 0.0029144224044954105, + 0.002913889110662827, + 0.002615140832314194, + 0.006881528610614373, + ], + linf=[ + 0.020996114874140215, + 0.021314522450134543, + 0.021288322783006297, + 0.020273381695435244, + 0.052598740390024545, + ]) + # 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_euler_weakform_periodic.jl" begin +@trixi_testset "elixir_euler_weakform_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.0010317074322517949, 0.0012277090547035293, 0.0011273991123913515, 0.0010418496196130177, 0.004058878478404962] ./ sqrt(8), - linf = [0.003227752881827861, 0.005620317864620361, 0.0030514833972379307, 0.003987027618439498, 0.019282224709831652] - ) - # 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 + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.0010317074322517949, + 0.0012277090547035293, + 0.0011273991123913515, + 0.0010418496196130177, + 0.004058878478404962, + ] ./ sqrt(8), + linf=[ + 0.003227752881827861, + 0.005620317864620361, + 0.0030514833972379307, + 0.003987027618439498, + 0.019282224709831652, + ]) + # 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_euler_weakform_periodic.jl (Hexahedral elements)" begin +@trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.00034230612468547436, 0.00044397204714598747, 0.0004439720471461567, 0.0004439720471464591, 0.0016639410646990126] ./ sqrt(8), - linf = [0.0003674374460325147, 0.0004253921341716982, 0.0004253921340786615, 0.0004253921340831024, 0.0014333414071048267] - ) - # 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 + element_type=Hex(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.00034230612468547436, + 0.00044397204714598747, + 0.0004439720471461567, + 0.0004439720471464591, + 0.0016639410646990126, + ] ./ sqrt(8), + linf=[ + 0.0003674374460325147, + 0.0004253921341716982, + 0.0004253921340786615, + 0.0004253921340831024, + 0.0014333414071048267, + ]) + # 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_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin +@trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain - l2 = [0.001712443468716032, 0.002491315550718859, 0.0024913155507195303, 0.002491315550720031, 0.008585818982343299] ./ sqrt(8), - linf = [0.003810078279323559, 0.004998778644230928, 0.004998778643986235, 0.0049987786444081195, 0.016455044373650196] - ) - # 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 + element_type=Hex(), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + # division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain + l2=[ + 0.001712443468716032, + 0.002491315550718859, + 0.0024913155507195303, + 0.002491315550720031, + 0.008585818982343299, + ] ./ sqrt(8), + linf=[ + 0.003810078279323559, + 0.004998778644230928, + 0.004998778643986235, + 0.0049987786444081195, + 0.016455044373650196, + ]) + # 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_euler_taylor_green_vortex.jl" begin +@trixi_testset "elixir_euler_taylor_green_vortex.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - polydeg = 3, tspan = (0.0, 1.0), cells_per_dimension = (2, 2, 2), - l2 = [0.0003612827827560599, 0.06219350883951729, 0.062193508839503864, 0.08121963221634831, 0.07082703570808184], - linf = [0.0007893509649821162, 0.1481953939988877, 0.14819539399791176, 0.14847291108358926, 0.21313533492212855] - ) - # 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 + polydeg=3, tspan=(0.0, 1.0), cells_per_dimension=(2, 2, 2), + l2=[ + 0.0003612827827560599, + 0.06219350883951729, + 0.062193508839503864, + 0.08121963221634831, + 0.07082703570808184, + ], + linf=[ + 0.0007893509649821162, + 0.1481953939988877, + 0.14819539399791176, + 0.14847291108358926, + 0.21313533492212855, + ]) + # 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_euler_taylor_green_vortex.jl (GaussSBP)" begin +@trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - polydeg = 3, approximation_type = GaussSBP(), tspan = (0.0, 1.0), cells_per_dimension = (2, 2, 2), - l2 = [0.00036128278275524326, 0.062193508839511434, 0.06219350883949677, 0.08121963221635205, 0.07082703570765223], - linf = [0.000789350964946367, 0.14819539399525805, 0.14819539399590542, 0.14847291107658706, 0.21313533492059378] - ) - # 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 + polydeg=3, approximation_type=GaussSBP(), tspan=(0.0, 1.0), + cells_per_dimension=(2, 2, 2), + l2=[ + 0.00036128278275524326, + 0.062193508839511434, + 0.06219350883949677, + 0.08121963221635205, + 0.07082703570765223, + ], + linf=[ + 0.000789350964946367, + 0.14819539399525805, + 0.14819539399590542, + 0.14847291107658706, + 0.21313533492059378, + ]) + # 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_euler_weakform_periodic.jl (FD SBP)" begin +@trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin + global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 2, + xmin = 0.0, xmax = 1.0, + N = 8) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - cells_per_dimension = (2, 2, 2), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=8), - l2 = [0.0024092707138829925, 0.003318758964118284, 0.0033187589641182386, 0.003318758964118252, 0.012689348410504253], - linf = [0.006118565824207778, 0.008486456080185167, 0.008486456080180282, 0.008486456080185611, 0.035113544599208346] - ) - # 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 + element_type=Hex(), + cells_per_dimension=(2, 2, 2), + approximation_type=D, + l2=[ + 0.0024092707138829925, + 0.003318758964118284, + 0.0033187589641182386, + 0.003318758964118252, + 0.012689348410504253, + ], + linf=[ + 0.006118565824207778, + 0.008486456080185167, + 0.008486456080180282, + 0.008486456080185611, + 0.035113544599208346, + ]) + # 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_euler_weakform_periodic.jl (FD SBP, EC)" begin +@trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin + global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 2, + xmin = 0.0, xmax = 1.0, + N = 8) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"), - element_type = Hex(), - cells_per_dimension = (2, 2, 2), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=2, - xmin=0.0, xmax=1.0, N=8), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - l2 = [0.0034543609010604407, 0.004944363692625066, 0.0049443636926250435, 0.004944363692625037, 0.01788695279620914], - linf = [0.013861851418853988, 0.02126572106620328, 0.021265721066209053, 0.021265721066210386, 0.0771455289446683] - ) - # 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 + element_type=Hex(), + cells_per_dimension=(2, 2, 2), + approximation_type=D, + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + l2=[ + 0.0034543609010604407, + 0.004944363692625066, + 0.0049443636926250435, + 0.004944363692625037, + 0.01788695279620914, + ], + linf=[ + 0.013861851418853988, + 0.02126572106620328, + 0.021265721066209053, + 0.021265721066210386, + 0.0771455289446683, + ]) + # 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_euler_fdsbp_periodic.jl" begin +@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"), - l2 = [7.561896970325353e-5, 6.884047859361093e-5, 6.884047859363204e-5, 6.884047859361148e-5, 0.000201107274617457], - linf = [0.0001337520020225913, 0.00011571467799287305, 0.0001157146779990903, 0.00011571467799376123, 0.0003446082308800058] - ) - # 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 + l2=[ + 7.561896970325353e-5, + 6.884047859361093e-5, + 6.884047859363204e-5, + 6.884047859361148e-5, + 0.000201107274617457, + ], + linf=[ + 0.0001337520020225913, + 0.00011571467799287305, + 0.0001157146779990903, + 0.00011571467799376123, + 0.0003446082308800058, + ]) + # 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_tensor_wedge.jl" begin +@trixi_testset "elixir_advection_tensor_wedge.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"), - l2 = [2.30487910e-04] , - linf = [6.31795281e-04] ) - # 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 + l2=[2.30487910e-04], + linf=[6.31795281e-04]) + # 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 end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_mpi.jl b/test/test_mpi.jl index 34febf7e268..ad1ba4e835d 100644 --- a/test/test_mpi.jl +++ b/test/test_mpi.jl @@ -7,7 +7,7 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) +Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) # CI with MPI and some tests fails often on Windows. Thus, we check whether this # is the case here. We use GitHub Actions, so we can check whether we run CI @@ -16,33 +16,32 @@ Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @testset "MPI" begin - # TreeMesh tests - include("test_mpi_tree.jl") - - # P4estMesh tests - include("test_mpi_p4est_2d.jl") - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` above - include("test_mpi_p4est_3d.jl") - end + # TreeMesh tests + include("test_mpi_tree.jl") + + # P4estMesh tests + include("test_mpi_p4est_2d.jl") + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` above + include("test_mpi_p4est_3d.jl") + end end # MPI - @trixi_testset "MPI supporting functionality" begin - using OrdinaryDiffEq - - t = 0.5 - let u = 1.0 - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end - let u = [1.0, -2.0] - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end - let u = [SVector(1.0, -2.0), SVector(0.5, -0.1)] - @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) - end + using OrdinaryDiffEq + + t = 0.5 + let u = 1.0 + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end + let u = [1.0, -2.0] + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end + let u = [SVector(1.0, -2.0), SVector(0.5, -0.1)] + @test ode_norm(u, t) ≈ OrdinaryDiffEq.ODE_DEFAULT_NORM(u, t) + end end # MPI supporting functionality # Clean up afterwards: delete Trixi.jl output directory -Trixi.mpi_isroot() && @test_nowarn rm(outdir, recursive=true) +Trixi.mpi_isroot() && @test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_mpi_p4est_2d.jl b/test/test_mpi_p4est_2d.jl index 4023997eaf3..1edbce8f6c8 100644 --- a/test/test_mpi_p4est_2d.jl +++ b/test/test_mpi_p4est_2d.jl @@ -8,70 +8,87 @@ include("test_trixi.jl") const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_2d_dgsem") @testset "P4estMesh MPI 2D" begin +#! format: noindent # Run basic tests @testset "Examples 2D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && println("elixir_advection_basic.jl with error-based step size control") + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && + println("elixir_advection_basic.jl with error-based step size control") - sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, - ode_default_options()..., callback=callbacks); summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2 ≈ [3.3022040342579066e-5] rtol=1.0e-4 - @test errors.linf ≈ [0.00011787417954578494] rtol=1.0e-4 - end + sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, + ode_default_options()..., callback = callbacks) + summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2≈[3.3022040342579066e-5] rtol=1.0e-4 + @test errors.linf≈[0.00011787417954578494] rtol=1.0e-4 + end + end end - end - @trixi_testset "elixir_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), - l2 = [3.198940059144588e-5], - linf = [0.00030636069494005547]) - end + @trixi_testset "elixir_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonconforming_flag.jl"), + l2=[3.198940059144588e-5], + linf=[0.00030636069494005547]) + end - @trixi_testset "elixir_advection_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), - l2 = [0.0005379687442422346], - linf = [0.007438525029884735]) - end + @trixi_testset "elixir_advection_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_unstructured_flag.jl"), + l2=[0.0005379687442422346], + linf=[0.007438525029884735]) + end - @trixi_testset "elixir_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [4.949660644033807e-5], - linf = [0.0004867846262313763], - coverage_override = (maxiters=6,)) - end + @trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + end - @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_flag.jl"), - l2 = [0.0012766060609964525], - linf = [0.01750280631586159], - coverage_override = (maxiters=6,)) - end + @trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_flag.jl"), + l2=[0.0012766060609964525], + linf=[0.01750280631586159], + coverage_override=(maxiters = 6,)) + end - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [4.507575525876275e-6], - linf = [6.21489667023134e-5]) - end + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[4.507575525876275e-6], + linf=[6.21489667023134e-5]) + end - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) - end + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) + end end - end # P4estMesh MPI end # module diff --git a/test/test_mpi_p4est_3d.jl b/test/test_mpi_p4est_3d.jl index f92feb1eed9..8082930b3b4 100644 --- a/test/test_mpi_p4est_3d.jl +++ b/test/test_mpi_p4est_3d.jl @@ -8,90 +8,150 @@ include("test_trixi.jl") const EXAMPLES_DIR = pkgdir(Trixi, "examples", "p4est_3d_dgsem") @testset "P4estMesh MPI 3D" begin +#! format: noindent # Run basic tests @testset "Examples 3D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && println("elixir_advection_basic.jl with error-based step size control") - - sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, - ode_default_options()..., callback=callbacks); summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2 ≈ [0.00016800412839949264] rtol=1.0e-4 - @test errors.linf ≈ [0.0014548839020096516] rtol=1.0e-4 - end + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && + println("elixir_advection_basic.jl with error-based step size control") + + sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, + ode_default_options()..., callback = callbacks) + summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2≈[0.00016800412839949264] rtol=1.0e-4 + @test errors.linf≈[0.0014548839020096516] rtol=1.0e-4 + end + end + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[9.773852895157622e-6], + linf=[0.0005853874124926162], + # override values are different from the serial tests to ensure each process holds at least + # one element, otherwise OrdinaryDiffEq fails during initialization + coverage_override=(maxiters = 6, + initial_refinement_level = 2, + base_level = 2, med_level = 3, + max_level = 4)) + end + + @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_curved.jl"), + l2=[1.6236411810065552e-5], + linf=[0.0010554006923731395], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6, + initial_refinement_level = 0, + base_level = 0, med_level = 1, + max_level = 2)) + end + + @trixi_testset "elixir_advection_restart.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + l2=[0.002590388934758452], + linf=[0.01840757696885409]) + end + + @trixi_testset "elixir_advection_cubed_sphere.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), + l2=[0.002006918015656413], + linf=[0.027655117058380085]) end - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [9.773852895157622e-6], - linf = [0.0005853874124926162], - # override values are different from the serial tests to ensure each process holds at least - # one element, otherwise OrdinaryDiffEq fails during initialization - coverage_override = (maxiters=6, initial_refinement_level=2, base_level=2, med_level=3, max_level=4)) - end - - @trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_curved.jl"), - l2 = [1.6236411810065552e-5], - linf = [0.0010554006923731395], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=1, max_level=2)) - end - - @trixi_testset "elixir_advection_restart.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.002590388934758452], - linf = [0.01840757696885409]) - end - - @trixi_testset "elixir_advection_cubed_sphere.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), - l2 = [0.002006918015656413], - linf = [0.027655117058380085]) - end - - # Compressible Euler - @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), - l2 = [4.070355207909268e-5, 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, 0.00019986264001630542], - linf = [0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, 0.008526972236273522], - tspan = (0.0, 0.01)) - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [0.0015106060984283647, 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, 0.0028149479453087093], - linf = [0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, 0.01562861968368434], - tspan = (0.0, 1.0)) - end - - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.010380390326164493, 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, 0.02628875593094754], - linf = [0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, 0.8099577682187109], - tspan = (0.0, 0.2), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - end - - @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), - l2 = [0.0042023406458005464, 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, 0.007389845952982495], - linf = [0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, 0.1154589758186293]) - end -end + # Compressible Euler + @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), + l2=[ + 4.070355207909268e-5, + 4.4993257426833716e-5, + 5.10588457841744e-5, + 5.102840924036687e-5, + 0.00019986264001630542, + ], + linf=[ + 0.0016987332417202072, + 0.003622956808262634, + 0.002029576258317789, + 0.0024206977281964193, + 0.008526972236273522, + ], + tspan=(0.0, 0.01)) + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 0.0015106060984283647, + 0.0014733349038567685, + 0.00147333490385685, + 0.001473334903856929, + 0.0028149479453087093, + ], + linf=[ + 0.008070806335238156, + 0.009007245083113125, + 0.009007245083121784, + 0.009007245083102688, + 0.01562861968368434, + ], + tspan=(0.0, 1.0)) + end + + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.010380390326164493, + 0.006192950051354618, + 0.005970674274073704, + 0.005965831290564327, + 0.02628875593094754, + ], + linf=[ + 0.3326911600075694, + 0.2824952141320467, + 0.41401037398065543, + 0.45574161423218573, + 0.8099577682187109, + ], + tspan=(0.0, 0.2), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + end + + @trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), + l2=[ + 0.0042023406458005464, + 0.004122532789279737, + 0.0042448149597303616, + 0.0036361316700401765, + 0.007389845952982495, + ], + linf=[ + 0.04530610539892499, + 0.02765695110527666, + 0.05670295599308606, + 0.048396544302230504, + 0.1154589758186293, + ]) + end +end end # P4estMesh MPI end # module diff --git a/test/test_mpi_tree.jl b/test/test_mpi_tree.jl index 8f08a9d72e7..0831f6a1313 100644 --- a/test/test_mpi_tree.jl +++ b/test/test_mpi_tree.jl @@ -11,198 +11,334 @@ const EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows() @testset "TreeMesh MPI" begin +#! format: noindent # Run basic tests @testset "Examples 2D" begin - # Linear scalar advection - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - end - - @trixi_testset "elixir_advection_restart.jl" begin - using OrdinaryDiffEq: RDPK3SpFSAL49 - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl")) - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - alg = RDPK3SpFSAL49(), tspan = (0.0, 10.0)) - l2_expected, linf_expected = analysis_callback(sol) - - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl")) - # Errors are exactly the same as in the elixir_advection_extended.jl - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - alg = RDPK3SpFSAL49()) - l2_actual, linf_actual = analysis_callback(sol) - - Trixi.mpi_isroot() && @test l2_actual == l2_expected - Trixi.mpi_isroot() && @test linf_actual == linf_expected - end - - @trixi_testset "elixir_advection_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [0.0015188466707237375], - linf = [0.008446655719187679]) - end - - @trixi_testset "elixir_advection_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [4.913300828257469e-5], - linf = [0.00045263895394385967], - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [3.2207388565869075e-5], - linf = [0.0007508059772436404], - coverage_override = (maxiters=6,)) - end - - # Linear scalar advection with AMR - # These example files are only for testing purposes and have no practical use - @trixi_testset "elixir_advection_amr_refine_twice.jl" begin - # Here, we also test that SaveSolutionCallback prints multiple mesh files with AMR - # Start with a clean environment: remove Trixi.jl output directory if it exists - outdir = "out" - isdir(outdir) && rm(outdir, recursive=true) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_refine_twice.jl"), - l2 = [0.00020547512522578292], - linf = [0.007831753383083506], - coverage_override = (maxiters=6,)) - meshfiles = filter(file -> endswith(file,".h5") && startswith(file,"mesh"), readdir(outdir)) - @test length(meshfiles) > 1 - end - - @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_coarsen_twice.jl"), - l2 = [0.0014321062757891826], - linf = [0.0253454486893413], - coverage_override = (maxiters=6,)) - end - - # Hyperbolic diffusion - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2 = [0.00015687751816056159, 0.001025986772217084, 0.0010259867722169909], - linf = [0.0011986956416591976, 0.006423873516411049, 0.006423873516411049]) - end - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [8.61813235543625e-8, 5.619399844542781e-7, 5.6193998447443e-7], - linf = [1.124861862180196e-6, 8.622436471039663e-6, 8.622436470151484e-6]) - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [8.523077653955306e-6, 2.8779323653065056e-5, 5.4549427691297846e-5], - linf = [5.5227409524905013e-5, 0.0001454489597927185, 0.00032396328684569653]) - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_hypdiff_godunov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), - l2 = [5.868147556427088e-6, 3.80517927324465e-5, 3.805179273249344e-5], - linf = [3.701965498725812e-5, 0.0002122422943138247, 0.00021224229431116015], - atol = 2.0e-12 #= required for CI on macOS =#) - end - end - - - # Compressible Euler - # Note: Some tests here have manually increased relative tolerances since reduction via MPI can - # slightly change the L2 error norms (different floating point truncation errors) - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], - rtol = 2000*sqrt(eps())) - end - end - - # This example file is only for testing purposes and has no practical use - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_amr_refine_coarsen.jl"), - l2 = [4.8226610349853444e-5, 4.117706709270575e-5, 4.1177067092959676e-5, 0.00012205252427437389], - linf = [0.0003543874851490436, 0.0002973166773747593, 0.0002973166773760916, 0.001154106793870291], - # Let this test run until the end to cover the time-dependent lines - # of the indicator and the MPI-specific AMR code. - coverage_override = (maxiters=10^5,)) - end - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], - linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5], - rtol = 0.001) - end - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], - linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) - - @testset "error-based step size control" begin - Trixi.mpi_isroot() && println("-"^100) - Trixi.mpi_isroot() && println("elixir_euler_ec.jl with error-based step size control") - - sol = solve(ode, RDPK3SpFSAL35(); abstol=1.0e-4, reltol=1.0e-4, - ode_default_options()..., callback=callbacks); summary_callback() - errors = analysis_callback(sol) - if Trixi.mpi_isroot() - @test errors.l2 ≈ [0.061653630426688116, 0.05006930431098764, 0.05007694316484242, 0.22550689872331683] rtol=1.0e-4 - @test errors.linf ≈ [0.28516937484583693, 0.2983633696512788, 0.297812036335975, 1.027368795517512] rtol=1.0e-4 + # Linear scalar advection + @trixi_testset "elixir_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + end + + @trixi_testset "elixir_advection_restart.jl" begin + using OrdinaryDiffEq: RDPK3SpFSAL49 + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && + println(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl")) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + alg = RDPK3SpFSAL49(), tspan = (0.0, 10.0)) + l2_expected, linf_expected = analysis_callback(sol) + + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && + println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl")) + # Errors are exactly the same as in the elixir_advection_extended.jl + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), + alg = RDPK3SpFSAL49()) + l2_actual, linf_actual = analysis_callback(sol) + + Trixi.mpi_isroot() && @test l2_actual == l2_expected + Trixi.mpi_isroot() && @test linf_actual == linf_expected + end + + @trixi_testset "elixir_advection_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[0.0015188466707237375], + linf=[0.008446655719187679]) + end + + @trixi_testset "elixir_advection_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[4.913300828257469e-5], + linf=[0.00045263895394385967], + coverage_override=(maxiters = 6,)) + end + + @trixi_testset "elixir_advection_amr_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_nonperiodic.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[3.2207388565869075e-5], + linf=[0.0007508059772436404], + coverage_override=(maxiters = 6,)) + end + + # Linear scalar advection with AMR + # These example files are only for testing purposes and have no practical use + @trixi_testset "elixir_advection_amr_refine_twice.jl" begin + # Here, we also test that SaveSolutionCallback prints multiple mesh files with AMR + # Start with a clean environment: remove Trixi.jl output directory if it exists + outdir = "out" + isdir(outdir) && rm(outdir, recursive = true) + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_refine_twice.jl"), + l2=[0.00020547512522578292], + linf=[0.007831753383083506], + coverage_override=(maxiters = 6,)) + meshfiles = filter(file -> endswith(file, ".h5") && startswith(file, "mesh"), + readdir(outdir)) + @test length(meshfiles) > 1 + end + + @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_coarsen_twice.jl"), + l2=[0.0014321062757891826], + linf=[0.0253454486893413], + coverage_override=(maxiters = 6,)) + end + + # Hyperbolic diffusion + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_lax_friedrichs.jl"), + l2=[ + 0.00015687751816056159, + 0.001025986772217084, + 0.0010259867722169909, + ], + linf=[ + 0.0011986956416591976, + 0.006423873516411049, + 0.006423873516411049, + ]) end - end - end - end - - @trixi_testset "elixir_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [0.00013492249515826863, 0.006615696236378061, 0.006782108219800376, 0.016393831451740604], - linf = [0.0020782600954247776, 0.08150078921935999, 0.08663621974991986, 0.2829930622010579], - rtol = 0.001) - end - - @trixi_testset "elixir_euler_vortex_mortar.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [0.0017208369388227673, 0.09628684992237334, 0.09620157717330868, 0.1758809552387432], - linf = [0.021869936355319086, 0.9956698009442038, 1.0002507727219028, 2.223249697515648]) - end - - @trixi_testset "elixir_euler_vortex_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), - # Expected errors are exactly the same as in the serial test! - l2 = [5.051719943432265e-5, 0.0022574259317084747, 0.0021755998463189713, 0.004346492398617521], - linf = [0.0012880114865917447, 0.03857193149447702, 0.031090457959835893, 0.12125130332971423], - coverage_override = (maxiters=6,)) - end - - if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` - @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), - l2 = [0.0017158367642679273, 0.09619888722871434, 0.09616432767924141, 0.17553381166255197], - linf = [0.021853862449723982, 0.9878047229255944, 0.9880191167111795, 2.2154030488035588], - rtol = 0.001) - end - end -end + end + + @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[ + 8.61813235543625e-8, + 5.619399844542781e-7, + 5.6193998447443e-7, + ], + linf=[ + 1.124861862180196e-6, + 8.622436471039663e-6, + 8.622436470151484e-6, + ]) + end + + @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), + l2=[ + 8.523077653955306e-6, + 2.8779323653065056e-5, + 5.4549427691297846e-5, + ], + linf=[ + 5.5227409524905013e-5, + 0.0001454489597927185, + 0.00032396328684569653, + ]) + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_hypdiff_godunov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), + l2=[ + 5.868147556427088e-6, + 3.80517927324465e-5, + 3.805179273249344e-5, + ], + linf=[ + 3.701965498725812e-5, + 0.0002122422943138247, + 0.00021224229431116015, + ], + atol=2.0e-12) #= required for CI on macOS =# + end + end + + # Compressible Euler + # Note: Some tests here have manually increased relative tolerances since reduction via MPI can + # slightly change the L2 error norms (different floating point truncation errors) + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ], + rtol=2000 * sqrt(eps())) + end + end + + # This example file is only for testing purposes and has no practical use + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_amr_refine_coarsen.jl"), + l2=[ + 4.8226610349853444e-5, + 4.117706709270575e-5, + 4.1177067092959676e-5, + 0.00012205252427437389, + ], + linf=[ + 0.0003543874851490436, + 0.0002973166773747593, + 0.0002973166773760916, + 0.001154106793870291, + ], + # Let this test run until the end to cover the time-dependent lines + # of the indicator and the MPI-specific AMR code. + coverage_override=(maxiters = 10^5,)) + end + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511766445e-6, + 2.318888155713922e-6, + 2.3188881557894307e-6, + 6.3327863238858925e-6, + ], + linf=[ + 1.498738264560373e-5, + 1.9182011928187137e-5, + 1.918201192685487e-5, + 6.0526717141407005e-5, + ], + rtol=0.001) + end + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), + l2=[ + 0.061751715597716854, + 0.05018223615408711, + 0.05018989446443463, + 0.225871559730513, + ], + linf=[ + 0.29347582879608825, + 0.31081249232844693, + 0.3107380389947736, + 1.0540358049885143, + ]) + + @testset "error-based step size control" begin + Trixi.mpi_isroot() && println("-"^100) + Trixi.mpi_isroot() && + println("elixir_euler_ec.jl with error-based step size control") + sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4, + ode_default_options()..., callback = callbacks) + summary_callback() + errors = analysis_callback(sol) + if Trixi.mpi_isroot() + @test errors.l2≈[ + 0.061653630426688116, + 0.05006930431098764, + 0.05007694316484242, + 0.22550689872331683, + ] rtol=1.0e-4 + @test errors.linf≈[ + 0.28516937484583693, + 0.2983633696512788, + 0.297812036335975, + 1.027368795517512, + ] rtol=1.0e-4 + end + end + end + end + + @trixi_testset "elixir_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 0.00013492249515826863, + 0.006615696236378061, + 0.006782108219800376, + 0.016393831451740604, + ], + linf=[ + 0.0020782600954247776, + 0.08150078921935999, + 0.08663621974991986, + 0.2829930622010579, + ], + rtol=0.001) + end + + @trixi_testset "elixir_euler_vortex_mortar.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[ + 0.0017208369388227673, + 0.09628684992237334, + 0.09620157717330868, + 0.1758809552387432, + ], + linf=[ + 0.021869936355319086, + 0.9956698009442038, + 1.0002507727219028, + 2.223249697515648, + ]) + end + + @trixi_testset "elixir_euler_vortex_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), + # Expected errors are exactly the same as in the serial test! + l2=[ + 5.051719943432265e-5, + 0.0022574259317084747, + 0.0021755998463189713, + 0.004346492398617521, + ], + linf=[ + 0.0012880114865917447, + 0.03857193149447702, + 0.031090457959835893, + 0.12125130332971423, + ], + coverage_override=(maxiters = 6,)) + end + + if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl` + @trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_vortex_shockcapturing.jl"), + l2=[ + 0.0017158367642679273, + 0.09619888722871434, + 0.09616432767924141, + 0.17553381166255197, + ], + linf=[ + 0.021853862449723982, + 0.9878047229255944, + 0.9880191167111795, + 2.2154030488035588, + ], + rtol=0.001) + end + end +end end # TreeMesh MPI end # module diff --git a/test/test_p4est_2d.jl b/test/test_p4est_2d.jl index 5baa090c8d7..cf7250b246b 100644 --- a/test/test_p4est_2d.jl +++ b/test/test_p4est_2d.jl @@ -9,326 +9,455 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "P4estMesh2D" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - # 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 + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + # 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_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming_flag.jl"), - l2 = [3.198940059144588e-5], - linf = [0.00030636069494005547]) - # 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_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonconforming_flag.jl"), + l2=[3.198940059144588e-5], + linf=[0.00030636069494005547]) + # 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_advection_unstructured_flag.jl" begin +@trixi_testset "elixir_advection_unstructured_flag.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), - l2 = [0.0005379687442422346], - linf = [0.007438525029884735]) - # 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 + l2=[0.0005379687442422346], + linf=[0.007438525029884735]) + # 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_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with StructuredMesh! - l2 = [4.949660644033807e-5], - linf = [0.0004867846262313763], - coverage_override = (maxiters=6,)) - # 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_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with StructuredMesh! + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + # 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_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_flag.jl"), - l2 = [0.0012766060609964525], - linf = [0.01750280631586159], - coverage_override = (maxiters=6,)) - # 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_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_flag.jl"), + l2=[0.0012766060609964525], + linf=[0.01750280631586159], + coverage_override=(maxiters = 6,)) + # 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_advection_restart.jl" begin +@trixi_testset "elixir_advection_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [4.507575525876275e-6], - linf = [6.21489667023134e-5]) - # 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 + l2=[4.507575525876275e-6], + linf=[6.21489667023134e-5]) + # 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_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) - # 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 +@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) + # 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_euler_free_stream.jl" begin +@trixi_testset "elixir_euler_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], - linf = [1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], - atol = 2.0e-12, # required to make CI tests pass on macOS - ) - # 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 + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], + atol=2.0e-12,) + # 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_euler_shockcapturing_ec.jl" begin +@trixi_testset "elixir_euler_shockcapturing_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), - l2 = [9.53984675e-02, 1.05633455e-01, 1.05636158e-01, 3.50747237e-01], - linf = [2.94357464e-01, 4.07893014e-01, 3.97334516e-01, 1.08142520e+00], - tspan = (0.0, 1.0)) - # 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 + l2=[ + 9.53984675e-02, + 1.05633455e-01, + 1.05636158e-01, + 3.50747237e-01, + ], + linf=[ + 2.94357464e-01, + 4.07893014e-01, + 3.97334516e-01, + 1.08142520e+00, + ], + tspan=(0.0, 1.0)) + # 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_euler_sedov.jl" begin +@trixi_testset "elixir_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [3.76149952e-01, 2.46970327e-01, 2.46970327e-01, 1.28889042e+00], - linf = [1.22139001e+00, 1.17742626e+00, 1.17742626e+00, 6.20638482e+00], - tspan = (0.0, 0.3)) - # 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 + l2=[ + 3.76149952e-01, + 2.46970327e-01, + 2.46970327e-01, + 1.28889042e+00, + ], + linf=[ + 1.22139001e+00, + 1.17742626e+00, + 1.17742626e+00, + 6.20638482e+00, + ], + tspan=(0.0, 0.3)) + # 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_euler_blast_wave_amr.jl" begin +@trixi_testset "elixir_euler_blast_wave_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), - l2 = [6.32183914e-01, 3.86914231e-01, 3.86869171e-01, 1.06575688e+00], - linf = [2.76020890e+00, 2.32659890e+00, 2.32580837e+00, 2.15778188e+00], - tspan = (0.0, 0.3), - coverage_override = (maxiters=6,)) - # 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 + l2=[ + 6.32183914e-01, + 3.86914231e-01, + 3.86869171e-01, + 1.06575688e+00, + ], + linf=[ + 2.76020890e+00, + 2.32659890e+00, + 2.32580837e+00, + 2.15778188e+00, + ], + tspan=(0.0, 0.3), + coverage_override=(maxiters = 6,)) + # 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_euler_wall_bc_amr.jl" begin +@trixi_testset "elixir_euler_wall_bc_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"), - l2 = [0.020291447969983396, 0.017479614254319948, 0.011387644425613437, 0.0514420126021293], - linf = [0.3582779022370579, 0.32073537890751663, 0.221818049107692, 0.9209559420400415], - tspan = (0.0, 0.15)) - # 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 + l2=[ + 0.020291447969983396, + 0.017479614254319948, + 0.011387644425613437, + 0.0514420126021293, + ], + linf=[ + 0.3582779022370579, + 0.32073537890751663, + 0.221818049107692, + 0.9209559420400415, + ], + tspan=(0.0, 0.15)) + # 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_euler_forward_step_amr.jl" begin +@trixi_testset "elixir_euler_forward_step_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_forward_step_amr.jl"), - l2 = [0.004194875320833303, 0.003785140699353966, 0.0013696609105790351, 0.03265268616046424], - linf = [2.0585399781442852, 2.213428805506876, 3.862362410419163, 17.75187237459251], - tspan = (0.0, 0.0001), - rtol = 1.0e-7, - skip_coverage=true) - if @isdefined sol # Skipped in coverage run - # 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 + l2=[ + 0.004194875320833303, + 0.003785140699353966, + 0.0013696609105790351, + 0.03265268616046424, + ], + linf=[ + 2.0585399781442852, + 2.213428805506876, + 3.862362410419163, + 17.75187237459251, + ], + tspan=(0.0, 0.0001), + rtol=1.0e-7, + skip_coverage=true) + if @isdefined sol # Skipped in coverage run + # 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 + end +end - @trixi_testset "elixir_euler_double_mach_amr.jl" begin +@trixi_testset "elixir_euler_double_mach_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_double_mach_amr.jl"), - l2 = [0.051359355290192046, 0.4266034859911273, 0.2438304855475594, 4.11487176105527], - linf = [6.902000373057003, 53.95714139820832, 24.241610279839758, 561.0630401858057], - tspan = (0.0, 0.0001), - skip_coverage=true) - if @isdefined sol # Skipped in coverage run - # 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 + l2=[ + 0.051359355290192046, + 0.4266034859911273, + 0.2438304855475594, + 4.11487176105527, + ], + linf=[ + 6.902000373057003, + 53.95714139820832, + 24.241610279839758, + 561.0630401858057, + ], + tspan=(0.0, 0.0001), + skip_coverage=true) + if @isdefined sol # Skipped in coverage run + # 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 + end +end - @trixi_testset "elixir_euler_supersonic_cylinder.jl" begin +@trixi_testset "elixir_euler_supersonic_cylinder.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_supersonic_cylinder.jl"), - l2 = [0.026798021911954406, 0.05118546368109259, 0.03206703583774831, 0.19680026567208672], - linf = [3.653905721692421, 4.285035711361009, 6.8544353186357645, 31.748244912257533], - tspan = (0.0, 0.001), - skip_coverage=true) - if @isdefined sol # Skipped in coverage run - # 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 + l2=[ + 0.026798021911954406, + 0.05118546368109259, + 0.03206703583774831, + 0.19680026567208672, + ], + linf=[ + 3.653905721692421, + 4.285035711361009, + 6.8544353186357645, + 31.748244912257533, + ], + tspan=(0.0, 0.001), + skip_coverage=true) + if @isdefined sol # Skipped in coverage run + # 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 + end +end - @trixi_testset "elixir_eulergravity_convergence.jl" begin +@trixi_testset "elixir_eulergravity_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) - # 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 + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) + # 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_shallowwater_source_terms.jl" begin +@trixi_testset "elixir_shallowwater_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [9.168126407325352e-5, 0.0009795410115453788, 0.002546408320320785, 3.941189812642317e-6], - linf = [0.0009903782521019089, 0.0059752684687262025, 0.010941106525454103, 1.2129488214718265e-5], - tspan = (0.0, 0.1)) - # 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 + l2=[ + 9.168126407325352e-5, + 0.0009795410115453788, + 0.002546408320320785, + 3.941189812642317e-6, + ], + linf=[ + 0.0009903782521019089, + 0.0059752684687262025, + 0.010941106525454103, + 1.2129488214718265e-5, + ], + tspan=(0.0, 0.1)) + # 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_mhd_alfven_wave.jl" begin +@trixi_testset "elixir_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.0513414461545583e-5, 1.0517900957166411e-6, 1.0517900957304043e-6, 1.511816606372376e-6, - 1.0443997728645063e-6, 7.879639064990798e-7, 7.879639065049896e-7, 1.0628631669056271e-6, - 4.3382328912336153e-7], - linf = [4.255466285174592e-5, 1.0029706745823264e-5, 1.0029706747467781e-5, 1.2122265939010224e-5, - 5.4791097160444835e-6, 5.18922042269665e-6, 5.189220422141538e-6, 9.552667261422676e-6, - 1.4237578427628152e-6]) - # 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 + l2=[1.0513414461545583e-5, 1.0517900957166411e-6, + 1.0517900957304043e-6, 1.511816606372376e-6, + 1.0443997728645063e-6, 7.879639064990798e-7, + 7.879639065049896e-7, 1.0628631669056271e-6, + 4.3382328912336153e-7], + linf=[4.255466285174592e-5, 1.0029706745823264e-5, + 1.0029706747467781e-5, 1.2122265939010224e-5, + 5.4791097160444835e-6, 5.18922042269665e-6, + 5.189220422141538e-6, 9.552667261422676e-6, + 1.4237578427628152e-6]) + # 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_mhd_rotor.jl" begin +@trixi_testset "elixir_mhd_rotor.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2 = [0.4552084651735862, 0.8918048264575757, 0.832471223081887, 0.0, - 0.9801264164951583, 0.10475690769435382, 0.1555132409149897, 0.0, - 2.0597079362763556e-5], - linf = [10.194181233788775, 18.25472397868819, 10.031307436191334, 0.0, - 19.647239392277378, 1.3938810140985936, 1.8724965294853084, 0.0, - 0.0016290067532561904], - tspan = (0.0, 0.02)) - # 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 + l2=[0.4552084651735862, 0.8918048264575757, 0.832471223081887, + 0.0, + 0.9801264164951583, 0.10475690769435382, 0.1555132409149897, + 0.0, + 2.0597079362763556e-5], + linf=[10.194181233788775, 18.25472397868819, 10.031307436191334, + 0.0, + 19.647239392277378, 1.3938810140985936, 1.8724965294853084, + 0.0, + 0.0016290067532561904], + tspan=(0.0, 0.02)) + # 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_linearizedeuler_gaussian_source.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_gaussian_source.jl"), - l2 = [0.006047938590548741, 0.0040953286019907035, 0.004222698522497298, 0.006269492499336128], - linf = [0.06386175207349379, 0.0378926444850457, 0.041759728067967065, 0.06430136016259067]) - # 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_linearizedeuler_gaussian_source.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_linearizedeuler_gaussian_source.jl"), + l2=[ + 0.006047938590548741, + 0.0040953286019907035, + 0.004222698522497298, + 0.006269492499336128, + ], + linf=[ + 0.06386175207349379, + 0.0378926444850457, + 0.041759728067967065, + 0.06430136016259067, + ]) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_p4est_3d.jl b/test/test_p4est_3d.jl index 370f864b5aa..63077deb436 100644 --- a/test/test_p4est_3d.jl +++ b/test/test_p4est_3d.jl @@ -9,311 +9,453 @@ EXAMPLES_DIR = joinpath(examples_dir(), "p4est_3d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "P4estMesh3D" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - # 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 + # Expected errors are exactly the same as with TreeMesh! + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + # 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_advection_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_curved.jl"), - l2 = [0.0004750004258546538], - linf = [0.026527551737137167]) - # 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_advection_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_unstructured_curved.jl"), + l2=[0.0004750004258546538], + linf=[0.026527551737137167]) + # 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_advection_nonconforming.jl" begin +@trixi_testset "elixir_advection_nonconforming.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"), - l2 = [0.00253595715323843], - linf = [0.016486952252155795]) - # 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 + l2=[0.00253595715323843], + linf=[0.016486952252155795]) + # 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_advection_amr.jl" begin +@trixi_testset "elixir_advection_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [9.773852895157622e-6], - linf = [0.0005853874124926162], - coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, med_level=2, max_level=3)) - # 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 + # Expected errors are exactly the same as with TreeMesh! + l2=[9.773852895157622e-6], + linf=[0.0005853874124926162], + coverage_override=(maxiters = 6, initial_refinement_level = 1, + base_level = 1, med_level = 2, max_level = 3)) + # 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_advection_amr_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_unstructured_curved.jl"), - l2 = [1.6236411810065552e-5], - linf = [0.0010554006923731395], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=1, max_level=2)) - # 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_advection_amr_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_curved.jl"), + l2=[1.6236411810065552e-5], + linf=[0.0010554006923731395], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6, initial_refinement_level = 0, + base_level = 0, med_level = 1, max_level = 2)) + # 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_advection_cubed_sphere.jl" begin +@trixi_testset "elixir_advection_cubed_sphere.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"), - l2 = [0.002006918015656413], - linf = [0.027655117058380085]) - # 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 + l2=[0.002006918015656413], + linf=[0.027655117058380085]) + # 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_advection_restart.jl" begin +@trixi_testset "elixir_advection_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.002590388934758452], - linf = [0.01840757696885409]) - # 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 + l2=[0.002590388934758452], + linf=[0.01840757696885409]) + # 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_euler_source_terms_nonconforming_unstructured_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), - l2 = [4.070355207909268e-5, 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, 0.00019986264001630542], - linf = [0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, 0.008526972236273522], - tspan = (0.0, 0.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 Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end - end +@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_curved.jl"), + l2=[ + 4.070355207909268e-5, + 4.4993257426833716e-5, + 5.10588457841744e-5, + 5.102840924036687e-5, + 0.00019986264001630542, + ], + linf=[ + 0.0016987332417202072, + 0.003622956808262634, + 0.002029576258317789, + 0.0024206977281964193, + 0.008526972236273522, + ], + tspan=(0.0, 0.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 Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end +end - @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [0.0015106060984283647, 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, 0.0028149479453087093], - linf = [0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, 0.01562861968368434], - tspan = (0.0, 1.0)) - # 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_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 0.0015106060984283647, + 0.0014733349038567685, + 0.00147333490385685, + 0.001473334903856929, + 0.0028149479453087093, + ], + linf=[ + 0.008070806335238156, + 0.009007245083113125, + 0.009007245083121784, + 0.009007245083102688, + 0.01562861968368434, + ], + tspan=(0.0, 1.0)) + # 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_euler_free_stream.jl" begin +@trixi_testset "elixir_euler_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [5.162664597942288e-15, 1.941857343642486e-14, 2.0232366394187278e-14, 2.3381518645408552e-14, 7.083114561232324e-14], - linf = [7.269740365245525e-13, 3.289868377720495e-12, 4.440087186807773e-12, 3.8686831516088205e-12, 9.412914891981927e-12], - tspan = (0.0, 0.03)) - # 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 + l2=[ + 5.162664597942288e-15, + 1.941857343642486e-14, + 2.0232366394187278e-14, + 2.3381518645408552e-14, + 7.083114561232324e-14, + ], + linf=[ + 7.269740365245525e-13, + 3.289868377720495e-12, + 4.440087186807773e-12, + 3.8686831516088205e-12, + 9.412914891981927e-12, + ], + tspan=(0.0, 0.03)) + # 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_euler_free_stream_extruded.jl" begin +@trixi_testset "elixir_euler_free_stream_extruded.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream_extruded.jl"), - l2 = [8.444868392439035e-16, 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, 1.1356712092620279e-14], - linf = [7.749356711883593e-14, 2.8792246364872653e-13, 1.1121659149182506e-13, 3.3228975127030935e-13, 9.592326932761353e-13], - tspan=(0.0, 0.1)) - # 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 + l2=[ + 8.444868392439035e-16, + 4.889826056731442e-15, + 2.2921260987087585e-15, + 4.268460455702414e-15, + 1.1356712092620279e-14, + ], + linf=[ + 7.749356711883593e-14, + 2.8792246364872653e-13, + 1.1121659149182506e-13, + 3.3228975127030935e-13, + 9.592326932761353e-13, + ], + tspan=(0.0, 0.1)) + # 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_euler_ec.jl" begin +@trixi_testset "elixir_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.010380390326164493, 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, 0.02628875593094754], - linf = [0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, 0.8099577682187109], - tspan = (0.0, 0.2), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - # 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 + l2=[ + 0.010380390326164493, + 0.006192950051354618, + 0.005970674274073704, + 0.005965831290564327, + 0.02628875593094754, + ], + linf=[ + 0.3326911600075694, + 0.2824952141320467, + 0.41401037398065543, + 0.45574161423218573, + 0.8099577682187109, + ], + tspan=(0.0, 0.2), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + # 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_euler_sedov.jl" begin +@trixi_testset "elixir_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [7.82070951e-02, 4.33260474e-02, 4.33260474e-02, 4.33260474e-02, 3.75260911e-01], - linf = [7.45329845e-01, 3.21754792e-01, 3.21754792e-01, 3.21754792e-01, 4.76151527e+00], - tspan = (0.0, 0.3), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - # 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 + l2=[ + 7.82070951e-02, + 4.33260474e-02, + 4.33260474e-02, + 4.33260474e-02, + 3.75260911e-01, + ], + linf=[ + 7.45329845e-01, + 3.21754792e-01, + 3.21754792e-01, + 3.21754792e-01, + 4.76151527e+00, + ], + tspan=(0.0, 0.3), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + # 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_euler_source_terms_nonconforming_earth.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonconforming_earth.jl"), - l2 = [6.040180337738628e-6, 5.4254175153621895e-6, 5.677698851333843e-6, 5.8017136892469794e-6, 1.3637854615117974e-5], - linf = [0.00013996924184311865, 0.00013681539559939893, 0.00013681539539733834, 0.00013681539541021692, 0.00016833038543762058], - # Decrease tolerance of adaptive time stepping to get similar results across different systems - abstol=1.0e-11, reltol=1.0e-11, - coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI - # 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_euler_source_terms_nonconforming_earth.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_earth.jl"), + l2=[ + 6.040180337738628e-6, + 5.4254175153621895e-6, + 5.677698851333843e-6, + 5.8017136892469794e-6, + 1.3637854615117974e-5, + ], + linf=[ + 0.00013996924184311865, + 0.00013681539559939893, + 0.00013681539539733834, + 0.00013681539541021692, + 0.00016833038543762058, + ], + # Decrease tolerance of adaptive time stepping to get similar results across different systems + abstol=1.0e-11, reltol=1.0e-11, + coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI + # 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_euler_circular_wind_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_circular_wind_nonconforming.jl"), - l2 = [1.573832094977477e-7, 3.863090659429634e-5, 3.867293305754584e-5, 3.686550296950078e-5, 0.05508968493733932], - linf = [2.2695202613887133e-6, 0.0005314968179916946, 0.0005314969614147458, 0.0005130280733059617, 0.7944959432352334], - tspan = (0.0, 2e2), - coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI - # 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_euler_circular_wind_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_circular_wind_nonconforming.jl"), + l2=[ + 1.573832094977477e-7, + 3.863090659429634e-5, + 3.867293305754584e-5, + 3.686550296950078e-5, + 0.05508968493733932, + ], + linf=[ + 2.2695202613887133e-6, + 0.0005314968179916946, + 0.0005314969614147458, + 0.0005130280733059617, + 0.7944959432352334, + ], + tspan=(0.0, 2e2), + coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI + # 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_euler_baroclinic_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_baroclinic_instability.jl"), - l2 = [6.725065410642336e-7, 0.00021710117340245454, 0.000438679759422352, 0.00020836356588024185, 0.07602006689579247], - linf = [1.9101671995258585e-5, 0.029803626911022396, 0.04847630924006063, 0.022001371349740104, 4.847761006938526], - tspan = (0.0, 1e2), - # Decrease tolerance of adaptive time stepping to get similar results across different systems - abstol=1.0e-9, reltol=1.0e-9, - coverage_override = (trees_per_cube_face=(1, 1), polydeg=3)) # Prevent long compile time in CI - # 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_euler_baroclinic_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_baroclinic_instability.jl"), + l2=[ + 6.725065410642336e-7, + 0.00021710117340245454, + 0.000438679759422352, + 0.00020836356588024185, + 0.07602006689579247, + ], + linf=[ + 1.9101671995258585e-5, + 0.029803626911022396, + 0.04847630924006063, + 0.022001371349740104, + 4.847761006938526, + ], + tspan=(0.0, 1e2), + # Decrease tolerance of adaptive time stepping to get similar results across different systems + abstol=1.0e-9, reltol=1.0e-9, + coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI + # 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_euler_source_terms_nonperiodic_hohqmesh.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), - l2 = [0.0042023406458005464, 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, 0.007389845952982495], - linf = [0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, 0.1154589758186293]) - # 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_euler_source_terms_nonperiodic_hohqmesh.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic_hohqmesh.jl"), + l2=[ + 0.0042023406458005464, + 0.004122532789279737, + 0.0042448149597303616, + 0.0036361316700401765, + 0.007389845952982495, + ], + linf=[ + 0.04530610539892499, + 0.02765695110527666, + 0.05670295599308606, + 0.048396544302230504, + 0.1154589758186293, + ]) + # 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_mhd_alfven_wave_nonconforming.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_nonconforming.jl"), - l2 = [0.00019018725889431733, 0.0006523517707148006, 0.0002401595437705759, 0.0007796920661427565, - 0.0007095787460334334, 0.0006558819731628876, 0.0003565026134076906, 0.0007904654548841712, - 9.437300326448332e-7], - linf = [0.0012482306861187897, 0.006408776208178299, 0.0016845452099629663, 0.0068711236542984555, - 0.004626581522263695, 0.006614624811393632, 0.0030068344747734566, 0.008277825749754025, - 1.3475027166309006e-5], - tspan = (0.0, 0.25), - coverage_override = (trees_per_dimension=(1, 1, 1),)) - # 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_mhd_alfven_wave_nonconforming.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_mhd_alfven_wave_nonconforming.jl"), + l2=[0.00019018725889431733, 0.0006523517707148006, + 0.0002401595437705759, 0.0007796920661427565, + 0.0007095787460334334, 0.0006558819731628876, + 0.0003565026134076906, 0.0007904654548841712, + 9.437300326448332e-7], + linf=[0.0012482306861187897, 0.006408776208178299, + 0.0016845452099629663, 0.0068711236542984555, + 0.004626581522263695, 0.006614624811393632, + 0.0030068344747734566, 0.008277825749754025, + 1.3475027166309006e-5], + tspan=(0.0, 0.25), + coverage_override=(trees_per_dimension = (1, 1, 1),)) + # 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_mhd_shockcapturing_amr.jl" begin +@trixi_testset "elixir_mhd_shockcapturing_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shockcapturing_amr.jl"), - l2 = [0.006298541670176575, 0.0064368506652601265, 0.007108729762852636, 0.006530420607206385, - 0.02061185869237284, 0.005562033787605515, 0.007571716276627825, 0.005571862660453231, - 3.909755063709152e-6], - linf = [0.20904054009050665, 0.18622917151105936, 0.2347957890323218, 0.19432508025509926, - 0.6858860133405615, 0.15172116633332622, 0.22432820727833747, 0.16805989780225183, - 0.000535219040687628], - tspan = (0.0, 0.04), - coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, max_level=2)) - # 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 + l2=[0.006298541670176575, 0.0064368506652601265, + 0.007108729762852636, 0.006530420607206385, + 0.02061185869237284, 0.005562033787605515, + 0.007571716276627825, 0.005571862660453231, + 3.909755063709152e-6], + linf=[0.20904054009050665, 0.18622917151105936, + 0.2347957890323218, 0.19432508025509926, + 0.6858860133405615, 0.15172116633332622, + 0.22432820727833747, 0.16805989780225183, + 0.000535219040687628], + tspan=(0.0, 0.04), + coverage_override=(maxiters = 6, initial_refinement_level = 1, + base_level = 1, max_level = 2)) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_paper_self_gravitating_gas_dynamics.jl b/test/test_paper_self_gravitating_gas_dynamics.jl index 68aa2992601..10b4f93ad74 100644 --- a/test/test_paper_self_gravitating_gas_dynamics.jl +++ b/test/test_paper_self_gravitating_gas_dynamics.jl @@ -7,231 +7,352 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) const EXAMPLES_DIR = pkgdir(Trixi, "examples", "paper_self_gravitating_gas_dynamics") # Numerical examples from the Euler-gravity paper @testset "paper_self_gravitating_gas_dynamics" begin - @trixi_testset "elixir_euler_convergence.jl" begin +#! format: noindent + +@trixi_testset "elixir_euler_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [0.0001740977055972079, 0.0003369355182519592, 0.0003369355182518708, 0.0006099171220334989], - linf = [0.001079347149189669, 0.0018836938381321389, 0.001883693838132583, 0.003971575376718217]) - # 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_euler_convergence.jl with polydeg=4" begin + l2=[ + 0.0001740977055972079, + 0.0003369355182519592, + 0.0003369355182518708, + 0.0006099171220334989, + ], + linf=[ + 0.001079347149189669, + 0.0018836938381321389, + 0.001883693838132583, + 0.003971575376718217, + ]) + # 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_euler_convergence.jl with polydeg=4" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [1.7187201161597772e-5, 2.678065111772951e-5, 2.678065111783027e-5, 4.952504160091526e-5], - linf = [0.0001501749544159381, 0.00016549482504535362, 0.00016549482504601976, 0.0004372960291432193], - polydeg = 4) - # 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_hypdiff_convergence.jl" begin + l2=[ + 1.7187201161597772e-5, + 2.678065111772951e-5, + 2.678065111783027e-5, + 4.952504160091526e-5, + ], + linf=[ + 0.0001501749544159381, + 0.00016549482504535362, + 0.00016549482504601976, + 0.0004372960291432193, + ], + polydeg=4) + # 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_hypdiff_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), - l2 = [0.003154024896093942, 0.012394432074951856, 0.02185973823794725], - linf = [0.01731850928579215, 0.07843510773347553, 0.11242300176349201]) - # 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_hypdiff_convergence.jl with polydeg=4" begin + l2=[ + 0.003154024896093942, + 0.012394432074951856, + 0.02185973823794725, + ], + linf=[ + 0.01731850928579215, + 0.07843510773347553, + 0.11242300176349201, + ]) + # 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_hypdiff_convergence.jl with polydeg=4" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_convergence.jl"), - l2 = [0.0002511283012128458, 0.0008808243846610255, 0.0016313343228567005], - linf = [0.0017290715087938668, 0.003129184465704738, 0.01000728849316701], - polydeg = 4) - # 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_eulergravity_convergence.jl" begin + l2=[ + 0.0002511283012128458, + 0.0008808243846610255, + 0.0016313343228567005, + ], + linf=[ + 0.0017290715087938668, + 0.003129184465704738, + 0.01000728849316701, + ], + polydeg=4) + # 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_eulergravity_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) - # 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_eulergravity_convergence.jl with polydeg=4" begin + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) + # 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_eulergravity_convergence.jl with polydeg=4" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [1.9537712148648045e-5, 2.7564396197947587e-5, 2.7564396197967635e-5, 5.688838772067586e-5], - linf = [0.00012335710672761735, 0.00020086268350816283, 0.00020086268350727465, 0.0004962155455632278], - tspan = (0.0, 0.1), polydeg = 4) - # 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_eulergravity_convergence.jl with 1st order RK3S*" begin + l2=[ + 1.9537712148648045e-5, + 2.7564396197947587e-5, + 2.7564396197967635e-5, + 5.688838772067586e-5, + ], + linf=[ + 0.00012335710672761735, + 0.00020086268350816283, + 0.00020086268350727465, + 0.0004962155455632278, + ], + tspan=(0.0, 0.1), polydeg=4) + # 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_eulergravity_convergence.jl with 1st order RK3S*" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138959434, 0.000337007710281087, 0.0003370077102811394, 0.0007231525515231289], - linf = [0.0015813032941613958, 0.002049428843978518, 0.0020494288439798503, 0.004793821198143977], - tspan = (0.0, 0.1), timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!) - # 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_eulergravity_convergence.jl with 3rd order RK3S*" begin + l2=[ + 0.00024871265138959434, + 0.000337007710281087, + 0.0003370077102811394, + 0.0007231525515231289, + ], + linf=[ + 0.0015813032941613958, + 0.002049428843978518, + 0.0020494288439798503, + 0.004793821198143977, + ], + tspan=(0.0, 0.1), + timestep_gravity=Trixi.timestep_gravity_erk51_3Sstar!) + # 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_eulergravity_convergence.jl with 3rd order RK3S*" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.0002487126513894034, 0.00033700771023049785, 0.00033700771023048245, 0.0007231525514158737], - linf = [0.0015813032943847727, 0.002049428842844314, 0.0020494288428452023, 0.004793821195971937], - tspan = (0.0, 0.1), timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!) - # 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_eulergravity_jeans_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), - l2 = [10733.63378538114, 13356.780607423452, 1.6722844879795038e-6, 26834.076821148774], - linf = [15194.296424901113, 18881.481685044182, 6.809726988008751e-6, 37972.99700513482], - tspan = (0.0, 0.1), - atol = 4.0e-6 # the background field is reatively large, so this corresponds to our usual atol - ) - # 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_eulergravity_jeans_instability.jl with RK3S*" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), - l2 = [10734.598193238024, 13358.217234481384, 1.911011743371934e-6, 26836.487841241516], - linf = [15195.661004798487, 18883.512035906537, 7.867948710816926e-6, 37976.408478975296], - tspan = (0.0, 0.1), - atol = 4.0e-6, # the background field is reatively large, so this corresponds to our usual atol - parameters=ParametersEulerGravity(background_density=1.5e7, - gravitational_constant=6.674e-8, - cfl=2.4, - resid_tol=1.0e-4, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!)) - # 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 "Printing" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_jeans_instability.jl"), - tspan = (0.0, 1.0e-5), - parameters=ParametersEulerGravity(background_density=1.5e7, - gravitational_constant=6.674e-8, - cfl=2.4, - resid_tol=1.0e-4, - n_iterations_max=1000, - timestep_gravity=timestep_gravity_erk52_3Sstar!)) + l2=[ + 0.0002487126513894034, + 0.00033700771023049785, + 0.00033700771023048245, + 0.0007231525514158737, + ], + linf=[ + 0.0015813032943847727, + 0.002049428842844314, + 0.0020494288428452023, + 0.004793821195971937, + ], + tspan=(0.0, 0.1), + timestep_gravity=Trixi.timestep_gravity_erk53_3Sstar!) + # 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_eulergravity_jeans_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_jeans_instability.jl"), + l2=[ + 10733.63378538114, + 13356.780607423452, + 1.6722844879795038e-6, + 26834.076821148774, + ], + linf=[ + 15194.296424901113, + 18881.481685044182, + 6.809726988008751e-6, + 37972.99700513482, + ], + tspan=(0.0, 0.1), + atol=4.0e-6) + # 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_eulergravity_jeans_instability.jl with RK3S*" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_jeans_instability.jl"), + l2=[ + 10734.598193238024, + 13358.217234481384, + 1.911011743371934e-6, + 26836.487841241516, + ], + linf=[ + 15195.661004798487, + 18883.512035906537, + 7.867948710816926e-6, + 37976.408478975296, + ], + tspan=(0.0, 0.1), + atol=4.0e-6, # the background field is reatively large, so this corresponds to our usual atol + parameters=ParametersEulerGravity(background_density = 1.5e7, + gravitational_constant = 6.674e-8, + cfl = 2.4, + resid_tol = 1.0e-4, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!)) + # 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 "Printing" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_jeans_instability.jl"), + tspan=(0.0, 1.0e-5), + parameters=ParametersEulerGravity(background_density = 1.5e7, + gravitational_constant = 6.674e-8, + cfl = 2.4, + resid_tol = 1.0e-4, + n_iterations_max = 1000, + timestep_gravity = timestep_gravity_erk52_3Sstar!)) show(stdout, parameters) show(stdout, semi) show(stdout, semi_euler.boundary_conditions) show(stdout, TrivialCallback()) show(stdout, equations_euler) - # 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 + # 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_eulergravity_sedov_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_sedov_blast_wave.jl"), + l2=[ + 0.046315994852653024, + 0.0650818006233669, + 0.06508180062336677, + 0.4896707211656037, + ], + linf=[ + 2.3874843337593776, + 4.07876384374792, + 4.07876384374792, + 16.23914384809855, + ], + tspan=(0.0, 0.05), + coverage_override=(maxiters = 2,)) + # 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_eulergravity_sedov_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_sedov_blast_wave.jl"), - l2 = [0.046315994852653024, 0.0650818006233669, 0.06508180062336677, 0.4896707211656037], - linf = [2.3874843337593776, 4.07876384374792, 4.07876384374792, 16.23914384809855], - tspan = (0.0, 0.05), - coverage_override = (maxiters=2,)) - # 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_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_sedov_blast_wave.jl"), - l2 = [0.00289222135995042, 0.013724813590853825, 0.013724813590853832, 0.05822904710548214], - linf = [0.26361780693997594, 1.3908873830688688, 1.3908873830688688, 4.066701303607613], - tspan = (0.0, 0.005), initial_refinement_level=8, amr_callback=TrivialCallback()) - # 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_eulergravity_sedov_blast_wave.jl with ref-level=8 and no AMR" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulergravity_sedov_blast_wave.jl"), + l2=[ + 0.00289222135995042, + 0.013724813590853825, + 0.013724813590853832, + 0.05822904710548214, + ], + linf=[ + 0.26361780693997594, + 1.3908873830688688, + 1.3908873830688688, + 4.066701303607613, + ], + tspan=(0.0, 0.005), initial_refinement_level=8, + amr_callback=TrivialCallback()) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_parabolic_1d.jl b/test/test_parabolic_1d.jl index d1f8b4d8057..c1cfec052fe 100644 --- a/test/test_parabolic_1d.jl +++ b/test/test_parabolic_1d.jl @@ -5,162 +5,217 @@ using Trixi include("test_trixi.jl") - # Start with a clean environment: remove Trixi output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "SemidiscretizationHyperbolicParabolic (1D)" begin - - @trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_advection_diffusion.jl"), - initial_refinement_level = 4, tspan=(0.0, 0.4), polydeg=3, - l2 = [8.389498188525518e-06], - linf = [2.847421658558336e-05] - ) - # 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 +#! format: noindent + +@trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_advection_diffusion.jl"), + initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3, + l2=[8.389498188525518e-06], + linf=[2.847421658558336e-05]) + # 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 "TreeMesh1D: elixir_advection_diffusion.jl (AMR)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_advection_diffusion.jl"), - tspan=(0.0, 0.0), initial_refinement_level = 5) - tspan=(0.0, 1.0) - ode = semidiscretize(semi, tspan) - amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable=first), - base_level=4, - med_level=5, med_threshold=0.1, - max_level=6, max_threshold=0.6) - amr_callback = AMRCallback(semi, amr_controller, - interval=5, - adapt_initial_condition=true) +end - # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver - callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, amr_callback) - sol = solve(ode, KenCarp4(autodiff=false), abstol=time_abs_tol, reltol=time_int_tol, - save_everystep=false, callback=callbacks) - l2_error, linf_error = analysis_callback(sol) - @test l2_error ≈ [6.4878111416468355e-6] - @test linf_error ≈ [3.258075790424364e-5] - # 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 "TreeMesh1D: elixir_advection_diffusion.jl (AMR)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_advection_diffusion.jl"), + tspan=(0.0, 0.0), initial_refinement_level=5) + tspan = (0.0, 1.0) + ode = semidiscretize(semi, tspan) + amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first), + base_level = 4, + med_level = 5, med_threshold = 0.1, + max_level = 6, max_threshold = 0.6) + amr_callback = AMRCallback(semi, amr_controller, + interval = 5, + adapt_initial_condition = true) + + # Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver + callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback, + amr_callback) + sol = solve(ode, KenCarp4(autodiff = false), abstol = time_abs_tol, + reltol = time_int_tol, + save_everystep = false, callback = callbacks) + l2_error, linf_error = analysis_callback(sol) + @test l2_error ≈ [6.4878111416468355e-6] + @test linf_error ≈ [3.258075790424364e-5] + # 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 "TreeMesh1D: elixir_navierstokes_convergence_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_navierstokes_convergence_periodic.jl"), - l2 = [0.0001133835907077494, 6.226282245610444e-5, 0.0002820171699999139], - linf = [0.0006255102377159538, 0.00036195501456059986, 0.0016147729485886941] - ) - # 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 +@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_navierstokes_convergence_periodic.jl"), + l2=[ + 0.0001133835907077494, + 6.226282245610444e-5, + 0.0002820171699999139, + ], + linf=[ + 0.0006255102377159538, + 0.00036195501456059986, + 0.0016147729485886941, + ]) + # 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 "TreeMesh1D: elixir_navierstokes_convergence_periodic.jl: GradientVariablesEntropy" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_navierstokes_convergence_periodic.jl"), - equations_parabolic = CompressibleNavierStokesDiffusion1D(equations, mu=mu(), - Prandtl=prandtl_number(), - gradient_variables = GradientVariablesEntropy()), - l2 = [0.00011310615871043463, 6.216495207074201e-5, 0.00028195843110817814], - linf = [0.0006240837363233886, 0.0003616694320713876, 0.0016147339542413874] - ) - # 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 +@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_periodic.jl: GradientVariablesEntropy" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_navierstokes_convergence_periodic.jl"), + equations_parabolic=CompressibleNavierStokesDiffusion1D(equations, + mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesEntropy()), + l2=[ + 0.00011310615871043463, + 6.216495207074201e-5, + 0.00028195843110817814, + ], + linf=[ + 0.0006240837363233886, + 0.0003616694320713876, + 0.0016147339542413874, + ]) + # 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 "TreeMesh1D: elixir_navierstokes_convergence_walls.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_navierstokes_convergence_walls.jl"), - l2 = [0.00047023310868269237, 0.00032181736027057234, 0.0014966266486095025], - linf = [0.002996375101363302, 0.002863904256059634, 0.012691132946258676] - ) - # 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 +@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_navierstokes_convergence_walls.jl"), + l2=[ + 0.00047023310868269237, + 0.00032181736027057234, + 0.0014966266486095025, + ], + linf=[ + 0.002996375101363302, + 0.002863904256059634, + 0.012691132946258676, + ]) + # 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 "TreeMesh1D: elixir_navierstokes_convergence_walls.jl: GradientVariablesEntropy" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_navierstokes_convergence_walls.jl"), - equations_parabolic = CompressibleNavierStokesDiffusion1D(equations, mu=mu(), - Prandtl=prandtl_number(), - gradient_variables = GradientVariablesEntropy()), - l2 = [0.0004608500483647771, 0.00032431091222851285, 0.0015159733360626845], - linf = [0.002754803146635787, 0.0028567714697580906, 0.012941794048176192] - ) - # 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 +@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls.jl: GradientVariablesEntropy" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_navierstokes_convergence_walls.jl"), + equations_parabolic=CompressibleNavierStokesDiffusion1D(equations, + mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesEntropy()), + l2=[ + 0.0004608500483647771, + 0.00032431091222851285, + 0.0015159733360626845, + ], + linf=[ + 0.002754803146635787, + 0.0028567714697580906, + 0.012941794048176192, + ]) + # 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 "TreeMesh1D: elixir_navierstokes_convergence_walls_amr.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_navierstokes_convergence_walls_amr.jl"), - equations_parabolic = CompressibleNavierStokesDiffusion1D(equations, mu=mu(), - Prandtl=prandtl_number()), - l2 = [2.5278824700860636e-5, 2.5540078777006958e-5, 0.00012118655083858043], - linf = [0.0001466387075579334, 0.00019422427462629705, 0.0009556446847707178] - ) - # 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 +@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls_amr.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_navierstokes_convergence_walls_amr.jl"), + equations_parabolic=CompressibleNavierStokesDiffusion1D(equations, + mu = mu(), + Prandtl = prandtl_number()), + l2=[ + 2.5278824700860636e-5, + 2.5540078777006958e-5, + 0.00012118655083858043, + ], + linf=[ + 0.0001466387075579334, + 0.00019422427462629705, + 0.0009556446847707178, + ]) + # 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 "TreeMesh1D: elixir_navierstokes_convergence_walls_amr.jl: GradientVariablesEntropy" begin - @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_navierstokes_convergence_walls_amr.jl"), - equations_parabolic = CompressibleNavierStokesDiffusion1D(equations, mu=mu(), - Prandtl=prandtl_number(), - gradient_variables = GradientVariablesEntropy()), - l2 = [2.459359632523962e-5, 2.3928390718460263e-5, 0.00011252414117082376], - linf = [0.0001185052018830568, 0.00018987717854305393, 0.0009597503607920999] - ) - # 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 +@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls_amr.jl: GradientVariablesEntropy" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_navierstokes_convergence_walls_amr.jl"), + equations_parabolic=CompressibleNavierStokesDiffusion1D(equations, + mu = mu(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesEntropy()), + l2=[ + 2.459359632523962e-5, + 2.3928390718460263e-5, + 0.00011252414117082376, + ], + linf=[ + 0.0001185052018830568, + 0.00018987717854305393, + 0.0009597503607920999, + ]) + # 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 end # Clean up afterwards: delete Trixi output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index a57462ef7ea..22a5a8b4e31 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -5,19 +5,18 @@ using Trixi include("test_trixi.jl") - # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "SemidiscretizationHyperbolicParabolic (2D)" begin +#! format: noindent - @trixi_testset "DGMulti 2D rhs_parabolic!" begin - +@trixi_testset "DGMulti 2D rhs_parabolic!" begin dg = DGMulti(polydeg = 2, element_type = Quad(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_central), volume_integral = VolumeIntegralWeakForm()) - mesh = DGMultiMesh(dg, cells_per_dimension=(2, 2)) + mesh = DGMultiMesh(dg, cells_per_dimension = (2, 2)) # test with polynomial initial condition x^2 * y # test if we recover the exact second derivative @@ -26,7 +25,8 @@ isdir(outdir) && rm(outdir, recursive=true) equations = LinearScalarAdvectionEquation2D(1.0, 1.0) equations_parabolic = LaplaceDiffusion2D(1.0, equations) - semi = SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabolic, initial_condition, dg) + semi = SemidiscretizationHyperbolicParabolic(mesh, equations, equations_parabolic, + initial_condition, dg) @test_nowarn_mod show(stdout, semi) @test_nowarn_mod show(stdout, MIME"text/plain"(), semi) @test_nowarn_mod show(stdout, boundary_condition_do_nothing) @@ -46,8 +46,8 @@ isdir(outdir) && rm(outdir, recursive=true) @unpack cache, cache_parabolic, equations_parabolic = semi @unpack gradients = cache_parabolic for dim in eachindex(gradients) - fill!(gradients[dim], zero(eltype(gradients[dim]))) - end + fill!(gradients[dim], zero(eltype(gradients[dim]))) + end t = 0.0 # pass in `boundary_condition_periodic` to skip boundary flux/integral evaluation @@ -55,7 +55,7 @@ isdir(outdir) && rm(outdir, recursive=true) boundary_condition_periodic, dg, cache, cache_parabolic) @unpack x, y, xq, yq = mesh.md @test getindex.(gradients[1], 1) ≈ 2 * xq .* yq - @test getindex.(gradients[2], 1) ≈ xq.^2 + @test getindex.(gradients[2], 1) ≈ xq .^ 2 u_flux = similar.(gradients) Trixi.calc_viscous_fluxes!(u_flux, ode.u0, gradients, mesh, equations_parabolic, @@ -64,425 +64,579 @@ isdir(outdir) && rm(outdir, recursive=true) @test u_flux[2] ≈ gradients[2] du = similar(ode.u0) - Trixi.calc_divergence!(du, ode.u0, t, u_flux, mesh, equations_parabolic, boundary_condition_periodic, + Trixi.calc_divergence!(du, ode.u0, t, u_flux, mesh, equations_parabolic, + boundary_condition_periodic, dg, semi.solver_parabolic, cache, cache_parabolic) @test getindex.(du, 1) ≈ 2 * y - end - - @trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.2485803335154642], - linf = [1.079606969242132] - ) - # 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 + +@trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_advection_diffusion.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[0.2485803335154642], + linf=[1.079606969242132]) + # 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 "DGMulti: elixir_advection_diffusion_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion_periodic.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.03180371984888462], - linf = [0.2136821621370909] - ) - # 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 + +@trixi_testset "DGMulti: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_advection_diffusion_periodic.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[0.03180371984888462], + linf=[0.2136821621370909]) + # 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 "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_advection_diffusion_nonperiodic.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.002123168335604323], - linf = [0.00963640423513712] - ) - # 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 + +@trixi_testset "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_advection_diffusion_nonperiodic.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[0.002123168335604323], + linf=[0.00963640423513712]) + # 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 "DGMulti: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_convergence.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.0015355076812510957, 0.0033843168272696756, 0.0036531858107443434, 0.009948436427519214], - linf = [0.005522560467190019, 0.013425258500730508, 0.013962115643482154, 0.027483102120502423] - ) - # 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 + +@trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_navierstokes_convergence.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[ + 0.0015355076812510957, + 0.0033843168272696756, + 0.0036531858107443434, + 0.009948436427519214, + ], + linf=[ + 0.005522560467190019, + 0.013425258500730508, + 0.013962115643482154, + 0.027483102120502423, + ]) + # 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 "DGMulti: elixir_navierstokes_convergence_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_convergence_curved.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.1), - l2 = [0.004255101916146187, 0.011118488923215765, 0.011281831283462686, 0.03573656447388509], - linf = [0.015071710669706473, 0.04103132025858458, 0.03990424085750277, 0.1309401718598764], - ) - # 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 + +@trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_navierstokes_convergence_curved.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.1), + l2=[ + 0.004255101916146187, + 0.011118488923215765, + 0.011281831283462686, + 0.03573656447388509, + ], + linf=[ + 0.015071710669706473, + 0.04103132025858458, + 0.03990424085750277, + 0.1309401718598764, + ],) + # 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 "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_navierstokes_lid_driven_cavity.jl"), - cells_per_dimension = (4, 4), tspan=(0.0, 0.5), - l2 = [0.00022156125227115747, 0.028318325921401, 0.009509168701070296, 0.028267900513550506], - linf = [0.001562278941298234, 0.14886653390744856, 0.0716323565533752, 0.19472785105241996] - ) - # 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 + +@trixi_testset "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_navierstokes_lid_driven_cavity.jl"), + cells_per_dimension=(4, 4), tspan=(0.0, 0.5), + l2=[ + 0.00022156125227115747, + 0.028318325921401, + 0.009509168701070296, + 0.028267900513550506, + ], + linf=[ + 0.001562278941298234, + 0.14886653390744856, + 0.0716323565533752, + 0.19472785105241996, + ]) + # 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 "TreeMesh2D: elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.4), polydeg=5, - l2 = [4.0915532997994255e-6], - linf = [2.3040850347877395e-5] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_diffusion.jl"), + initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5, + l2=[4.0915532997994255e-6], + linf=[2.3040850347877395e-5]) + # 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 "TreeMesh2D: elixir_advection_diffusion.jl (Refined mesh)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), - tspan=(0.0, 0.0)) - LLID = Trixi.local_leaf_cells(mesh.tree) - num_leafs = length(LLID) - @assert num_leafs % 8 == 0 - Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs/8)]) - tspan=(0.0, 1.5) - semi = SemidiscretizationHyperbolicParabolic(mesh, - (equations, equations_parabolic), - initial_condition, solver; - boundary_conditions=(boundary_conditions, +end + +@trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl (Refined mesh)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_diffusion.jl"), + tspan=(0.0, 0.0)) + LLID = Trixi.local_leaf_cells(mesh.tree) + num_leafs = length(LLID) + @assert num_leafs % 8 == 0 + Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs / 8)]) + tspan = (0.0, 1.5) + semi = SemidiscretizationHyperbolicParabolic(mesh, + (equations, equations_parabolic), + initial_condition, solver; + boundary_conditions = (boundary_conditions, boundary_conditions_parabolic)) - ode = semidiscretize(semi, tspan) - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) - sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, - ode_default_options()..., callback=callbacks) - l2_error, linf_error = analysis_callback(sol) - @test l2_error ≈ [1.67452550744728e-6] - @test linf_error ≈ [7.905059166368744e-6] - - # 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) + ode = semidiscretize(semi, tspan) + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) + sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + ode_default_options()..., callback = callbacks) + l2_error, linf_error = analysis_callback(sol) + @test l2_error ≈ [1.67452550744728e-6] + @test linf_error ≈ [7.905059166368744e-6] + + # 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)) < 100 @test (@allocated Trixi.rhs_parabolic!(du_ode, u_ode, semi, t)) < 100 end - end - - @trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion_nonperiodic.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - l2 = [0.007646800618485118], - linf = [0.10067621050468958] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_diffusion_nonperiodic.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + l2=[0.007646800618485118], + linf=[0.10067621050468958]) + # 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 "TreeMesh2D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - analysis_callback = AnalysisCallback(semi, interval=analysis_interval, - extra_analysis_integrals=(energy_kinetic, - energy_internal, - enstrophy)), - l2 = [0.002111672530658797, 0.0034322351490857846, 0.0038742528195910416, 0.012469246082568561], - linf = [0.012006418939223495, 0.035520871209746126, 0.024512747492231427, 0.11191122588756564] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + analysis_callback=AnalysisCallback(semi, + interval = analysis_interval, + extra_analysis_integrals = (energy_kinetic, + energy_internal, + enstrophy)), + l2=[ + 0.002111672530658797, + 0.0034322351490857846, + 0.0038742528195910416, + 0.012469246082568561, + ], + linf=[ + 0.012006418939223495, + 0.035520871209746126, + 0.024512747492231427, + 0.11191122588756564, + ]) + # 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 "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.002103629650383915, 0.003435843933396454, 0.00386735987813341, 0.012670355349235728], - linf = [0.012006261793147788, 0.03550212518982032, 0.025107947319661185, 0.11647078036571124] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.002103629650383915, + 0.003435843933396454, + 0.00386735987813341, + 0.012670355349235728, + ], + linf=[ + 0.012006261793147788, + 0.03550212518982032, + 0.025107947319661185, + 0.11647078036571124, + ]) + # 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 "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - l2 = [0.0021403742517389513, 0.0034258287094908572, 0.0038915122886898517, 0.012506862343013842], - linf = [0.012244412004628336, 0.03507559186162224, 0.024580892345558894, 0.11425600758350107] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + l2=[ + 0.0021403742517389513, + 0.0034258287094908572, + 0.0038915122886898517, + 0.012506862343013842, + ], + linf=[ + 0.012244412004628336, + 0.03507559186162224, + 0.024580892345558894, + 0.11425600758350107, + ]) + # 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 "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.0021349737347844907, 0.0034301388278203033, 0.0038928324474291572, 0.012693611436230873], - linf = [0.01224423627586213, 0.035054066314102905, 0.025099598504931965, 0.11795616324751634] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.0021349737347844907, + 0.0034301388278203033, + 0.0038928324474291572, + 0.012693611436230873, + ], + linf=[ + 0.01224423627586213, + 0.035054066314102905, + 0.025099598504931965, + 0.11795616324751634, + ]) + # 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 "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - volume_integral=VolumeIntegralFluxDifferencing(flux_central), - l2 = [0.0021116725306633594, 0.0034322351490827557, 0.0038742528196093542, 0.012469246082526909], - linf = [0.012006418939291663, 0.035520871209594115, 0.024512747491801577, 0.11191122588591007] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + volume_integral=VolumeIntegralFluxDifferencing(flux_central), + l2=[ + 0.0021116725306633594, + 0.0034322351490827557, + 0.0038742528196093542, + 0.012469246082526909, + ], + linf=[ + 0.012006418939291663, + 0.035520871209594115, + 0.024512747491801577, + 0.11191122588591007, + ]) + # 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 "TreeMesh2D: elixir_navierstokes_convergence.jl (Refined mesh)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_convergence.jl"), - tspan=(0.0, 0.0), initial_refinement_level=3) - LLID = Trixi.local_leaf_cells(mesh.tree) - num_leafs = length(LLID) - @assert num_leafs % 4 == 0 - Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs/4)]) - tspan=(0.0, 0.5) - semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) - ode = semidiscretize(semi, tspan) - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) - sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, dt = 1e-5, - ode_default_options()..., callback=callbacks) - l2_error, linf_error = analysis_callback(sol) - @test l2_error ≈ [0.00024296959173852447; 0.0002093263158670915; 0.0005390572390977262; 0.00026753561392341537] - @test linf_error ≈ [0.0016210102053424436; 0.002593287648655501; 0.002953907343823712; 0.002077119120180271] - # 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 "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_lid_driven_cavity.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.00015144571529699053, 0.018766076072331623, 0.007065070765652574, 0.0208399005734258], - linf = [0.0014523369373669048, 0.12366779944955864, 0.05532450997115432, 0.16099927805328207] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Refined mesh)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + tspan=(0.0, 0.0), initial_refinement_level=3) + LLID = Trixi.local_leaf_cells(mesh.tree) + num_leafs = length(LLID) + @assert num_leafs % 4 == 0 + Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs / 4)]) + tspan = (0.0, 0.5) + semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, solver; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) + ode = semidiscretize(semi, tspan) + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) + sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + dt = 1e-5, + ode_default_options()..., callback = callbacks) + l2_error, linf_error = analysis_callback(sol) + @test l2_error ≈ + [0.00024296959173852447; 0.0002093263158670915; 0.0005390572390977262; + 0.00026753561392341537] + @test linf_error ≈ + [0.0016210102053424436; 0.002593287648655501; 0.002953907343823712; + 0.002077119120180271] + # 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 "TreeMesh2D: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), - l2 = [0.0009279657228109691, 0.012454661988687185, 0.012454661988689886, 0.030487112728612178], - linf = [0.002435582543096171, 0.024824039368199546, 0.024824039368212758, 0.06731583711777489] - ) - # 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 + +@trixi_testset "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_lid_driven_cavity.jl"), + initial_refinement_level=2, tspan=(0.0, 0.5), + l2=[ + 0.00015144571529699053, + 0.018766076072331623, + 0.007065070765652574, + 0.0208399005734258, + ], + linf=[ + 0.0014523369373669048, + 0.12366779944955864, + 0.05532450997115432, + 0.16099927805328207, + ]) + # 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 "TreeMesh2D: elixir_navierstokes_shearlayer_amr.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_navierstokes_shearlayer_amr.jl"), + l2=[ + 0.00526017743452336, + 0.4130430692895672, + 0.4310996183791349, + 1.1544344171604635, + ], + linf=[ + 0.03492185879198495, + 1.392635891671335, + 1.357551616406459, + 8.713760873018146, + ], + tspan=(0.0, 0.7)) +end + +@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_advection_diffusion_periodic.jl"), + trees_per_dimension=(1, 1), initial_refinement_level=2, + tspan=(0.0, 0.5), + l2=[0.0023754695605828443], + linf=[0.008154128363741964]) + # 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 "TreeMesh2D: elixir_navierstokes_shearlayer_amr.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_navierstokes_shearlayer_amr.jl"), - l2 = [0.00526017743452336, 0.4130430692895672, 0.4310996183791349, 1.1544344171604635], - linf = [0.03492185879198495, 1.392635891671335, 1.357551616406459, 8.713760873018146], - tspan = (0.0, 0.7) - ) - end - - @trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic.jl"), - trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.0023754695605828443], - linf = [0.008154128363741964] - ) - # 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 + +@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_advection_diffusion_periodic.jl"), + trees_per_dimension=(1, 1), initial_refinement_level=2, + tspan=(0.0, 0.5), + l2=[0.0023754695605828443], + linf=[0.008154128363741964]) + # 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 "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_periodic_curved.jl"), - trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.006708147442490916], - linf = [0.04807038397976693] - ) - # 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 + +@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_advection_diffusion_periodic_curved.jl"), + trees_per_dimension=(1, 1), initial_refinement_level=2, + tspan=(0.0, 0.5), + l2=[0.006708147442490916], + linf=[0.04807038397976693]) + # 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 "P4estMesh2D: elixir_advection_diffusion_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_advection_diffusion_nonperiodic_curved.jl"), - trees_per_dimension = (1, 1), initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.00919917034843865], - linf = [0.14186297438393505] - ) - # 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 + +@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_advection_diffusion_nonperiodic_curved.jl"), + trees_per_dimension=(1, 1), initial_refinement_level=2, + tspan=(0.0, 0.5), + l2=[0.00919917034843865], + linf=[0.14186297438393505]) + # 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 "P4estMesh2D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 1, tspan=(0.0, 0.2), - l2 = [0.0003811978985836709, 0.0005874314969169538, 0.0009142898787923481, 0.0011613918899727263], - linf = [0.0021633623982135752, 0.009484348274135372, 0.004231572066492217, 0.011661660275365193] - ) - # 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 + +@trixi_testset "P4estMesh2D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=1, tspan=(0.0, 0.2), + l2=[ + 0.0003811978985836709, + 0.0005874314969169538, + 0.0009142898787923481, + 0.0011613918899727263, + ], + linf=[ + 0.0021633623982135752, + 0.009484348274135372, + 0.004231572066492217, + 0.011661660275365193, + ]) + # 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 "P4estMesh2D: elixir_navierstokes_convergence_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_convergence_nonperiodic.jl"), - initial_refinement_level = 1, tspan=(0.0, 0.2), - l2 = [0.00040364962558511795, 0.0005869762481506936, 0.00091488537427274, 0.0011984191566376762], - linf = [0.0024993634941723464, 0.009487866203944725, 0.004505829506628117, 0.011634902776245681] - ) - # 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 + +@trixi_testset "P4estMesh2D: elixir_navierstokes_convergence_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_navierstokes_convergence_nonperiodic.jl"), + initial_refinement_level=1, tspan=(0.0, 0.2), + l2=[ + 0.00040364962558511795, + 0.0005869762481506936, + 0.00091488537427274, + 0.0011984191566376762, + ], + linf=[ + 0.0024993634941723464, + 0.009487866203944725, + 0.004505829506628117, + 0.011634902776245681, + ]) + # 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 "P4estMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_lid_driven_cavity.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.5), - l2 = [0.00028716166408816073, 0.08101204560401647, 0.02099595625377768, 0.05008149754143295], - linf = [0.014804500261322406, 0.9513271652357098, 0.7223919625994717, 1.4846907331004786] - ) - # 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 + +@trixi_testset "P4estMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_navierstokes_lid_driven_cavity.jl"), + initial_refinement_level=2, tspan=(0.0, 0.5), + l2=[ + 0.00028716166408816073, + 0.08101204560401647, + 0.02099595625377768, + 0.05008149754143295, + ], + linf=[ + 0.014804500261322406, + 0.9513271652357098, + 0.7223919625994717, + 1.4846907331004786, + ]) + # 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 end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) end # module diff --git a/test/test_parabolic_3d.jl b/test/test_parabolic_3d.jl index 276e37518ee..d6c720cf0d9 100644 --- a/test/test_parabolic_3d.jl +++ b/test/test_parabolic_3d.jl @@ -7,268 +7,439 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "SemidiscretizationHyperbolicParabolic (3D)" begin +#! format: noindent - @trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_convergence.jl"), - cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.1), - l2 = [0.0005532847115849239, 0.000659263490965341, 0.0007776436127362806, 0.0006592634909662951, 0.0038073628897809185], - linf = [0.0017039861523615585, 0.002628561703560073, 0.003531057425112172, 0.0026285617036090336, 0.015587829540351095] - ) - # 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 +@trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", + "elixir_navierstokes_convergence.jl"), + cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1), + l2=[ + 0.0005532847115849239, + 0.000659263490965341, + 0.0007776436127362806, + 0.0006592634909662951, + 0.0038073628897809185, + ], + linf=[ + 0.0017039861523615585, + 0.002628561703560073, + 0.003531057425112172, + 0.0026285617036090336, + 0.015587829540351095, + ]) + # 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 "DGMulti: elixir_navierstokes_convergence_curved.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_convergence_curved.jl"), - cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.1), - l2 = [0.0014027227251207474, 0.0021322235533273513, 0.0027873741447455194, 0.0024587473070627423, 0.00997836818019202], - linf = [0.006341750402837576, 0.010306014252246865, 0.01520740250924979, 0.010968264045485565, 0.047454389831591115] - ) - # 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 +@trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", + "elixir_navierstokes_convergence_curved.jl"), + cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1), + l2=[ + 0.0014027227251207474, + 0.0021322235533273513, + 0.0027873741447455194, + 0.0024587473070627423, + 0.00997836818019202, + ], + linf=[ + 0.006341750402837576, + 0.010306014252246865, + 0.01520740250924979, + 0.010968264045485565, + 0.047454389831591115, + ]) + # 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 "DGMulti: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", "elixir_navierstokes_taylor_green_vortex.jl"), - cells_per_dimension = (4, 4, 4), tspan=(0.0, 0.25), - l2 = [0.0001825713444029892, 0.015589736382772248, 0.015589736382771884, 0.021943924667273653, 0.01927370280244222], - linf = [0.0006268463584697681, 0.03218881662749007, 0.03218881662697948, 0.053872495395614256, 0.05183822000984151] - ) - # 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 +@trixi_testset "DGMulti: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "dgmulti_3d", + "elixir_navierstokes_taylor_green_vortex.jl"), + cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.25), + l2=[ + 0.0001825713444029892, + 0.015589736382772248, + 0.015589736382771884, + 0.021943924667273653, + 0.01927370280244222, + ], + linf=[ + 0.0006268463584697681, + 0.03218881662749007, + 0.03218881662697948, + 0.053872495395614256, + 0.05183822000984151, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - l2 = [0.0019582188528512257, 0.002653449504302844, 0.002898264205184629, 0.002653449504302853, 0.009511572365085706], - linf = [0.013680656759085918, 0.0356910450154318, 0.023526343547736236, 0.035691045015431855, 0.11482570604041165] - ) - # 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 +@trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + l2=[ + 0.0019582188528512257, + 0.002653449504302844, + 0.002898264205184629, + 0.002653449504302853, + 0.009511572365085706, + ], + linf=[ + 0.013680656759085918, + 0.0356910450154318, + 0.023526343547736236, + 0.035691045015431855, + 0.11482570604041165, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl (isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.00195468651965362, 0.0026554367897028506, 0.002892730402724066, 0.002655436789702817, 0.009596351796609566], - linf = [0.013680508110645473, 0.035673446359424356, 0.024024936779729028, 0.03567344635942474, 0.11839497110809383] - ) - # 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 +@trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.00195468651965362, + 0.0026554367897028506, + 0.002892730402724066, + 0.002655436789702817, + 0.009596351796609566, + ], + linf=[ + 0.013680508110645473, + 0.035673446359424356, + 0.024024936779729028, + 0.03567344635942474, + 0.11839497110809383, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - l2 = [0.0019770444875099307, 0.0026524750946399327, 0.00290860030832445, 0.0026524750946399396, 0.009509568981439294], - linf = [0.01387936112914212, 0.03526260609304053, 0.023554197097368997, 0.035262606093040896, 0.11719963716509518] - ) - # 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 +@trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + l2=[ + 0.0019770444875099307, + 0.0026524750946399327, + 0.00290860030832445, + 0.0026524750946399396, + 0.009509568981439294, + ], + linf=[ + 0.01387936112914212, + 0.03526260609304053, + 0.023554197097368997, + 0.035262606093040896, + 0.11719963716509518, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level=2, tspan=(0.0, 0.1), gradient_variables=GradientVariablesEntropy(), - heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, t, equations), equations)), - l2 = [0.001974631423398113, 0.002654768259143932, 0.002907031063651286, 0.002654768259143901, 0.009587792882971452], - linf = [0.01387919380137137, 0.035244084526358944, 0.02398614622061363, 0.03524408452635828, 0.12005056512506407] - ) - # 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 +@trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + gradient_variables=GradientVariablesEntropy(), + heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x, + t, + equations), + equations)), + l2=[ + 0.001974631423398113, + 0.002654768259143932, + 0.002907031063651286, + 0.002654768259143901, + 0.009587792882971452, + ], + linf=[ + 0.01387919380137137, + 0.035244084526358944, + 0.02398614622061363, + 0.03524408452635828, + 0.12005056512506407, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl (flux differencing)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - volume_integral=VolumeIntegralFluxDifferencing(flux_central), - l2 = [0.0019582188528180213, 0.002653449504301736, 0.0028982642051960006, 0.0026534495043017384, 0.009511572364811033], - linf = [0.013680656758949583, 0.035691045015224444, 0.02352634354676752, 0.035691045015223424, 0.11482570603751441] - ) - # 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 +@trixi_testset "TreeMesh3D: elixir_navierstokes_convergence.jl (flux differencing)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + volume_integral=VolumeIntegralFluxDifferencing(flux_central), + l2=[ + 0.0019582188528180213, + 0.002653449504301736, + 0.0028982642051960006, + 0.0026534495043017384, + 0.009511572364811033, + ], + linf=[ + 0.013680656758949583, + 0.035691045015224444, + 0.02352634354676752, + 0.035691045015223424, + 0.11482570603751441, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl (Refined mesh)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_convergence.jl"), - tspan=(0.0, 0.0)) - LLID = Trixi.local_leaf_cells(mesh.tree) - num_leafs = length(LLID) - @assert num_leafs % 16 == 0 - Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs/16)]) - tspan=(0.0, 0.25) - semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, solver; - boundary_conditions=(boundary_conditions, boundary_conditions_parabolic), - source_terms=source_terms_navier_stokes_convergence_test) - ode = semidiscretize(semi, tspan) - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) - sol = solve(ode, RDPK3SpFSAL49(); abstol=time_int_tol, reltol=time_int_tol, dt = 1e-5, - ode_default_options()..., callback=callbacks) - l2_error, linf_error = analysis_callback(sol) - @test l2_error ≈ [0.0003109336253407314, 0.0006473493036803503, 0.0007705277238213672, 0.0006280517917198335, 0.000903927789884075] - @test linf_error ≈ [0.0023694155365339142, 0.010634932622402863, 0.006772070862236412, 0.010640551561726901, 0.019256819038719897] - # 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 "TreeMesh3D: elixir_navierstokes_convergence.jl (Refined mesh)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + tspan=(0.0, 0.0)) + LLID = Trixi.local_leaf_cells(mesh.tree) + num_leafs = length(LLID) + @assert num_leafs % 16 == 0 + Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs / 16)]) + tspan = (0.0, 0.25) + semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, solver; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic), + source_terms = source_terms_navier_stokes_convergence_test) + ode = semidiscretize(semi, tspan) + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) + sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol, + dt = 1e-5, + ode_default_options()..., callback = callbacks) + l2_error, linf_error = analysis_callback(sol) + @test l2_error ≈ [ + 0.0003109336253407314, + 0.0006473493036803503, + 0.0007705277238213672, + 0.0006280517917198335, + 0.000903927789884075, + ] + @test linf_error ≈ [ + 0.0023694155365339142, + 0.010634932622402863, + 0.006772070862236412, + 0.010640551561726901, + 0.019256819038719897, + ] + # 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 "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.25), - l2 = [0.00024173250389635442, 0.015684268393762454, 0.01568426839376248, 0.021991909545192333, 0.02825413672911425], - linf = [0.0008410587892853094, 0.04740176181772552, 0.04740176181772507, 0.07483494924031157, 0.150181591534448] - ) - # 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 +@trixi_testset "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_taylor_green_vortex.jl"), + initial_refinement_level=2, tspan=(0.0, 0.25), + l2=[ + 0.00024173250389635442, + 0.015684268393762454, + 0.01568426839376248, + 0.021991909545192333, + 0.02825413672911425, + ], + linf=[ + 0.0008410587892853094, + 0.04740176181772552, + 0.04740176181772507, + 0.07483494924031157, + 0.150181591534448, + ]) + # 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 "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl (Refined mesh)" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), - tspan=(0.0, 0.0)) - LLID = Trixi.local_leaf_cells(mesh.tree) - num_leafs = length(LLID) - @assert num_leafs % 32 == 0 - Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs/32)]) - tspan=(0.0, 0.1) - semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), - initial_condition, solver) - ode = semidiscretize(semi, tspan) - analysis_callback = AnalysisCallback(semi, interval=analysis_interval, save_analysis=true, - extra_analysis_integrals=(energy_kinetic, +@trixi_testset "TreeMesh3D: elixir_navierstokes_taylor_green_vortex.jl (Refined mesh)" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_navierstokes_taylor_green_vortex.jl"), + tspan=(0.0, 0.0)) + LLID = Trixi.local_leaf_cells(mesh.tree) + num_leafs = length(LLID) + @assert num_leafs % 32 == 0 + Trixi.refine!(mesh.tree, LLID[1:Int(num_leafs / 32)]) + tspan = (0.0, 0.1) + semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, solver) + ode = semidiscretize(semi, tspan) + analysis_callback = AnalysisCallback(semi, interval = analysis_interval, + save_analysis = true, + extra_analysis_integrals = (energy_kinetic, energy_internal, enstrophy)) - callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) - # Use CarpenterKennedy2N54 since `RDPK3SpFSAL49` gives slightly different results on different machines - sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), - dt=5e-3, - save_everystep=false, callback=callbacks); - l2_error, linf_error = analysis_callback(sol) - @test l2_error ≈ [7.314319856736271e-5, 0.006266480163542894, 0.006266489911815533, 0.008829222305770226, 0.0032859166842329228] - @test linf_error ≈ [0.0002943968186086554, 0.013876261980614757, 0.013883619864959451, 0.025201279960491936, 0.018679364985388247] - # 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) + callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) + # Use CarpenterKennedy2N54 since `RDPK3SpFSAL49` gives slightly different results on different machines + sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + dt = 5e-3, + save_everystep = false, callback = callbacks) + l2_error, linf_error = analysis_callback(sol) + @test l2_error ≈ [ + 7.314319856736271e-5, + 0.006266480163542894, + 0.006266489911815533, + 0.008829222305770226, + 0.0032859166842329228, + ] + @test linf_error ≈ [ + 0.0002943968186086554, + 0.013876261980614757, + 0.013883619864959451, + 0.025201279960491936, + 0.018679364985388247, + ] + # 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)) < 100 @test (@allocated Trixi.rhs_parabolic!(du_ode, u_ode, semi, t)) < 100 end - end +end - @trixi_testset "P4estMesh3D: elixir_navierstokes_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_3d_dgsem", "elixir_navierstokes_convergence.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.1), - l2 = [0.00026599105554982194, 0.000461877794472316, 0.0005424899076052261, 0.0004618777944723191, 0.0015846392581126832], - linf = [0.0025241668929956163, 0.006308461681816373, 0.004334939663169113, 0.006308461681804009, 0.03176343480493493] - ) - # 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 +@trixi_testset "P4estMesh3D: elixir_navierstokes_convergence.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_3d_dgsem", + "elixir_navierstokes_convergence.jl"), + initial_refinement_level=2, tspan=(0.0, 0.1), + l2=[ + 0.00026599105554982194, + 0.000461877794472316, + 0.0005424899076052261, + 0.0004618777944723191, + 0.0015846392581126832, + ], + linf=[ + 0.0025241668929956163, + 0.006308461681816373, + 0.004334939663169113, + 0.006308461681804009, + 0.03176343480493493, + ]) + # 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 "P4estMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_3d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), - initial_refinement_level = 2, tspan=(0.0, 0.25), - l2 = [0.0001547509861140407, 0.015637861347119624, 0.015637861347119687, 0.022024699158522523, 0.009711013505930812], - linf = [0.0006696415247340326, 0.03442565722527785, 0.03442565722577423, 0.06295407168705314, 0.032857472756916195] - ) - # 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 +@trixi_testset "P4estMesh3D: elixir_navierstokes_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_3d_dgsem", + "elixir_navierstokes_taylor_green_vortex.jl"), + initial_refinement_level=2, tspan=(0.0, 0.25), + l2=[ + 0.0001547509861140407, + 0.015637861347119624, + 0.015637861347119687, + 0.022024699158522523, + 0.009711013505930812, + ], + linf=[ + 0.0006696415247340326, + 0.03442565722527785, + 0.03442565722577423, + 0.06295407168705314, + 0.032857472756916195, + ]) + # 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 "TreeMesh3D: elixir_advection_diffusion_amr.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_advection_diffusion_amr.jl"), - l2 = [0.000355780485397024], - linf = [0.0010810770271614256] - ) - end +@trixi_testset "TreeMesh3D: elixir_advection_diffusion_amr.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_advection_diffusion_amr.jl"), + l2=[0.000355780485397024], + linf=[0.0010810770271614256]) +end - @trixi_testset "TreeMesh3D: elixir_advection_diffusion_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_advection_diffusion_nonperiodic.jl"), - l2 = [0.0009808996243280868], - linf = [0.01732621559135459] - ) - end +@trixi_testset "TreeMesh3D: elixir_advection_diffusion_nonperiodic.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_advection_diffusion_nonperiodic.jl"), + l2=[0.0009808996243280868], + linf=[0.01732621559135459]) +end end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn isdir(outdir) && rm(outdir, recursive=true) +@test_nowarn isdir(outdir) && rm(outdir, recursive = true) -end # module \ No newline at end of file +end # module diff --git a/test/test_performance_specializations_2d.jl b/test/test_performance_specializations_2d.jl index eaf2a66e84f..4fd39c78f64 100644 --- a/test/test_performance_specializations_2d.jl +++ b/test/test_performance_specializations_2d.jl @@ -7,169 +7,171 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) - +isdir(outdir) && rm(outdir, recursive = true) @testset "Performance specializations 2D" begin - @timed_testset "TreeMesh2D, flux_shima_etal_turbo" begin +#! format: noindent + +@timed_testset "TreeMesh2D, flux_shima_etal_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - end +end - @timed_testset "TreeMesh2D, flux_ranocha_turbo" begin +@timed_testset "TreeMesh2D, flux_ranocha_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - end +end - @timed_testset "StructuredMesh2D, flux_shima_etal_turbo" begin +@timed_testset "StructuredMesh2D, flux_shima_etal_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - end +end - @timed_testset "StructuredMesh2D, flux_ranocha_turbo" begin +@timed_testset "StructuredMesh2D, flux_ranocha_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + joinpath(examples_dir(), "structured_2d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, 1] + + @test du_specialized ≈ du_baseline end - end end - +end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_performance_specializations_3d.jl b/test/test_performance_specializations_3d.jl index f767930996a..929fc7e3621 100644 --- a/test/test_performance_specializations_3d.jl +++ b/test/test_performance_specializations_3d.jl @@ -7,169 +7,171 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) - +isdir(outdir) && rm(outdir, recursive = true) @testset "Performance specializations 3D" begin - @timed_testset "TreeMesh3D, flux_shima_etal_turbo" begin +#! format: noindent + +@timed_testset "TreeMesh3D, flux_shima_etal_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - end +end - @timed_testset "TreeMesh3D, flux_ranocha_turbo" begin +@timed_testset "TreeMesh3D, flux_ranocha_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), - initial_refinement_level=0, tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + joinpath(examples_dir(), "tree_3d_dgsem", "elixir_euler_ec.jl"), + initial_refinement_level = 0, tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - end +end - @timed_testset "StructuredMesh3D, flux_shima_etal_turbo" begin +@timed_testset "StructuredMesh3D, flux_shima_etal_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_shima_etal_turbo, surface_flux=flux_shima_etal_turbo) + joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_shima_etal_turbo, + surface_flux = flux_shima_etal_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - end +end - @timed_testset "StructuredMesh3D, flux_ranocha_turbo" begin +@timed_testset "StructuredMesh3D, flux_ranocha_turbo" begin trixi_include(@__MODULE__, - joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), - cells_per_dimension=(1, 1, 1), tspan=(0.0, 0.0), polydeg=3, - volume_flux=flux_ranocha_turbo, surface_flux=flux_ranocha_turbo) + joinpath(examples_dir(), "structured_3d_dgsem", "elixir_euler_ec.jl"), + cells_per_dimension = (1, 1, 1), tspan = (0.0, 0.0), polydeg = 3, + volume_flux = flux_ranocha_turbo, surface_flux = flux_ranocha_turbo) u_ode = copy(sol.u[end]) du_ode = zero(u_ode) # Preserve original memory since it will be `unsafe_wrap`ped and might # thus otherwise be garbage collected GC.@preserve u_ode du_ode begin - u = Trixi.wrap_array(u_ode, semi) - du = Trixi.wrap_array(du_ode, semi) - nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) - - # Call the optimized default version - du .= 0 - Trixi.flux_differencing_kernel!( - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_specialized = du[:, :, :, :, 1] - - # Call the plain version - note the argument type `Function` of - # `semi.solver.volume_integral.volume_flux` - du .= 0 - invoke(Trixi.flux_differencing_kernel!, - Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), - typeof(nonconservative_terms), typeof(semi.equations), - Function, typeof(semi.solver), typeof(semi.cache), Bool}, - du, u, 1, semi.mesh, - nonconservative_terms, semi.equations, - semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) - du_baseline = du[:, :, :, :, 1] - - @test du_specialized ≈ du_baseline + u = Trixi.wrap_array(u_ode, semi) + du = Trixi.wrap_array(du_ode, semi) + nonconservative_terms = Trixi.have_nonconservative_terms(semi.equations) + + # Call the optimized default version + du .= 0 + Trixi.flux_differencing_kernel!(du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, + semi.solver, semi.cache, true) + du_specialized = du[:, :, :, :, 1] + + # Call the plain version - note the argument type `Function` of + # `semi.solver.volume_integral.volume_flux` + du .= 0 + invoke(Trixi.flux_differencing_kernel!, + Tuple{typeof(du), typeof(u), Integer, typeof(semi.mesh), + typeof(nonconservative_terms), typeof(semi.equations), + Function, typeof(semi.solver), typeof(semi.cache), Bool}, + du, u, 1, semi.mesh, + nonconservative_terms, semi.equations, + semi.solver.volume_integral.volume_flux, semi.solver, semi.cache, true) + du_baseline = du[:, :, :, :, 1] + + @test du_specialized ≈ du_baseline end - end end - +end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_special_elixirs.jl b/test/test_special_elixirs.jl index c05dfbdfca1..4f42414ccbf 100644 --- a/test/test_special_elixirs.jl +++ b/test/test_special_elixirs.jl @@ -10,7 +10,7 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) const EXAMPLES_DIR = pkgdir(Trixi, "examples") @@ -18,66 +18,116 @@ cmd = string(Base.julia_cmd()) coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) @testset "Special elixirs" begin - @testset "Convergence test" begin +#! format: noindent + +@testset "Convergence test" begin if !coverage - @timed_testset "tree_2d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), 3, initial_refinement_level=2) - @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) - end - - @timed_testset "structured_2d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_extended.jl"), 3, cells_per_dimension=(5, 9)) - @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) - end - - @timed_testset "structured_2d_dgsem coupled" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_coupled.jl"), 3) - @test isapprox(mean_convergence[1][:l2], [4.0], rtol=0.05) - @test isapprox(mean_convergence[2][:l2], [4.0], rtol=0.05) - end - - @timed_testset "p4est_2d_dgsem" begin - # Run convergence test on unrefined mesh - no_refine = @cfunction((p4est, which_tree, quadrant) -> Cint(0), Cint, (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, Ptr{Trixi.p4est_quadrant_t})) - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), 2, refine_fn_c=no_refine) - @test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol=0.05) - end - - @timed_testset "structured_3d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_3d_dgsem", "elixir_advection_basic.jl"), 2, cells_per_dimension=(7, 4, 5)) - @test isapprox(mean_convergence[:l2], [4.0], rtol=0.05) - end - - @timed_testset "p4est_3d_dgsem" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "p4est_3d_dgsem", "elixir_advection_unstructured_curved.jl"), 2, initial_refinement_level=0) - @test isapprox(mean_convergence[:l2], [2.7], rtol=0.05) - end - - @timed_testset "paper_self_gravitating_gas_dynamics" begin - mean_convergence = convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "paper_self_gravitating_gas_dynamics", "elixir_eulergravity_convergence.jl"), 2, tspan=(0.0, 0.25), initial_refinement_level=1) - @test isapprox(mean_convergence[:l2], 4 * ones(4), atol=0.4) - end + @timed_testset "tree_2d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), + 3, initial_refinement_level = 2) + @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) + end + + @timed_testset "structured_2d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "structured_2d_dgsem", + "elixir_advection_extended.jl"), + 3, cells_per_dimension = (5, 9)) + @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) + end + + @timed_testset "structured_2d_dgsem coupled" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "structured_2d_dgsem", + "elixir_advection_coupled.jl"), + 3) + @test isapprox(mean_convergence[1][:l2], [4.0], rtol = 0.05) + @test isapprox(mean_convergence[2][:l2], [4.0], rtol = 0.05) + end + + @timed_testset "p4est_2d_dgsem" begin + # Run convergence test on unrefined mesh + no_refine = @cfunction((p4est, which_tree, quadrant)->Cint(0), Cint, + (Ptr{Trixi.p4est_t}, Ptr{Trixi.p4est_topidx_t}, + Ptr{Trixi.p4est_quadrant_t})) + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "p4est_2d_dgsem", + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + 2, refine_fn_c = no_refine) + @test isapprox(mean_convergence[:linf], [3.2, 3.2, 4.0, 3.7], rtol = 0.05) + end + + @timed_testset "structured_3d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "structured_3d_dgsem", + "elixir_advection_basic.jl"), + 2, cells_per_dimension = (7, 4, 5)) + @test isapprox(mean_convergence[:l2], [4.0], rtol = 0.05) + end + + @timed_testset "p4est_3d_dgsem" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "p4est_3d_dgsem", + "elixir_advection_unstructured_curved.jl"), + 2, initial_refinement_level = 0) + @test isapprox(mean_convergence[:l2], [2.7], rtol = 0.05) + end + + @timed_testset "paper_self_gravitating_gas_dynamics" begin + mean_convergence = convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, + "paper_self_gravitating_gas_dynamics", + "elixir_eulergravity_convergence.jl"), + 2, tspan = (0.0, 0.25), + initial_refinement_level = 1) + @test isapprox(mean_convergence[:l2], 4 * ones(4), atol = 0.4) + end else - # Without coverage, just run simple convergence tests to cover - # the convergence test logic - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_basic.jl"), 2, tspan=(0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), 2, initial_refinement_level=0, tspan=(0.0, 0.1)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_basic.jl"), 2, tspan=(0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_coupled.jl"), 2, tspan=(0.0, 0.01)) - @test_nowarn_mod convergence_test(@__MODULE__, joinpath(EXAMPLES_DIR, "structured_2d_dgsem", "elixir_advection_extended.jl"), 2, cells_per_dimension=(1, 1), tspan=(0.0, 0.1)) + # Without coverage, just run simple convergence tests to cover + # the convergence test logic + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_basic.jl"), 2, + tspan = (0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), 2, + initial_refinement_level = 0, + tspan = (0.0, 0.1)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "structured_2d_dgsem", + "elixir_advection_basic.jl"), 2, + tspan = (0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "structured_2d_dgsem", + "elixir_advection_coupled.jl"), 2, + tspan = (0.0, 0.01)) + @test_nowarn_mod convergence_test(@__MODULE__, + joinpath(EXAMPLES_DIR, "structured_2d_dgsem", + "elixir_advection_extended.jl"), 2, + cells_per_dimension = (1, 1), + tspan = (0.0, 0.1)) end - end - +end - @timed_testset "Test linear structure (2D)" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) +@timed_testset "Test linear structure (2D)" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) A, b = linear_structure(semi) λ = eigvals(Matrix(A)) @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_hypdiff_lax_friedrichs.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_hypdiff_lax_friedrichs.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) A, b = linear_structure(semi) λ = eigvals(Matrix(A)) @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) @@ -87,122 +137,141 @@ coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", Ax = A * x @. b = 2 * b + x @test A * x ≈ Ax - end - +end - @testset "Test Jacobian of DG (2D)" begin +@testset "Test Jacobian of DG (2D)" begin @timed_testset "Linear advection" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) - A, _ = linear_structure(semi) - - J = jacobian_ad_forward(semi) - @test Matrix(A) ≈ J - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - - J = jacobian_fd(semi) - @test Matrix(A) ≈ J - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) + A, _ = linear_structure(semi) + + J = jacobian_ad_forward(semi) + @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + + J = jacobian_fd(semi) + @test Matrix(A) ≈ J + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) end @timed_testset "Linear advection-diffusion" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_advection_diffusion.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_advection_diffusion.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) end @timed_testset "Compressible Euler equations" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_euler_density_wave.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_euler_density_wave.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - - J = jacobian_fd(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-3 + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 - # This does not work yet because of the indicators... - @test_skip begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_euler_shockcapturing.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) - jacobian_ad_forward(semi) - end + J = jacobian_fd(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-3 + + # This does not work yet because of the indicators... + @test_skip begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_euler_shockcapturing.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) + jacobian_ad_forward(semi) + end - @timed_testset "DGMulti (weak form)" begin - gamma = 1.4 - equations = CompressibleEulerEquations2D(gamma) - initial_condition = initial_condition_density_wave + @timed_testset "DGMulti (weak form)" begin + gamma = 1.4 + equations = CompressibleEulerEquations2D(gamma) + initial_condition = initial_condition_density_wave - solver = DGMulti(polydeg = 5, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralWeakForm()) + solver = DGMulti(polydeg = 5, element_type = Quad(), + approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralWeakForm()) - # DGMultiMesh is on [-1, 1]^ndims by default - mesh = DGMultiMesh(solver, cells_per_dimension=(2, 2), periodicity=(true, true)) + # DGMultiMesh is on [-1, 1]^ndims by default + mesh = DGMultiMesh(solver, cells_per_dimension = (2, 2), + periodicity = (true, true)) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver) - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - end + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + end - @timed_testset "DGMulti (SBP, flux differencing)" begin - gamma = 1.4 - equations = CompressibleEulerEquations2D(gamma) - initial_condition = initial_condition_density_wave + @timed_testset "DGMulti (SBP, flux differencing)" begin + gamma = 1.4 + equations = CompressibleEulerEquations2D(gamma) + initial_condition = initial_condition_density_wave - solver = DGMulti(polydeg = 5, element_type = Quad(), approximation_type = SBP(), - surface_integral = SurfaceIntegralWeakForm(flux_central), - volume_integral = VolumeIntegralFluxDifferencing(flux_central)) + solver = DGMulti(polydeg = 5, element_type = Quad(), + approximation_type = SBP(), + surface_integral = SurfaceIntegralWeakForm(flux_central), + volume_integral = VolumeIntegralFluxDifferencing(flux_central)) - # DGMultiMesh is on [-1, 1]^ndims by default - mesh = DGMultiMesh(solver, cells_per_dimension=(2, 2), periodicity=(true, true)) + # DGMultiMesh is on [-1, 1]^ndims by default + mesh = DGMultiMesh(solver, cells_per_dimension = (2, 2), + periodicity = (true, true)) - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver) + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver) - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 7.0e-7 - end + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 7.0e-7 + end end @timed_testset "Navier-Stokes" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_navierstokes_taylor_green_vortex.jl"), - tspan=(0.0, 0.0), initial_refinement_level=2) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_navierstokes_taylor_green_vortex.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 2) - J = jacobian_ad_forward(semi) - λ = eigvals(J) - @test maximum(real, λ) < 0.2 + J = jacobian_ad_forward(semi) + λ = eigvals(J) + @test maximum(real, λ) < 0.2 end @timed_testset "MHD" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_2d_dgsem", "elixir_mhd_alfven_wave.jl"), - tspan=(0.0, 0.0), initial_refinement_level=0) - @test_nowarn jacobian_ad_forward(semi) + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_2d_dgsem", + "elixir_mhd_alfven_wave.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 0) + @test_nowarn jacobian_ad_forward(semi) end - end - +end - @timed_testset "Test linear structure (3D)" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_3d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) +@timed_testset "Test linear structure (3D)" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_3d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) A, b = linear_structure(semi) λ = eigvals(Matrix(A)) @test maximum(real, λ) < 10 * sqrt(eps(real(semi))) - end - +end - @timed_testset "Test Jacobian of DG (3D)" begin - trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "tree_3d_dgsem", "elixir_advection_extended.jl"), - tspan=(0.0, 0.0), initial_refinement_level=1) +@timed_testset "Test Jacobian of DG (3D)" begin + trixi_include(@__MODULE__, + joinpath(EXAMPLES_DIR, "tree_3d_dgsem", + "elixir_advection_extended.jl"), + tspan = (0.0, 0.0), initial_refinement_level = 1) A, _ = linear_structure(semi) J = jacobian_ad_forward(semi) @@ -210,76 +279,77 @@ coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", J = jacobian_fd(semi) @test Matrix(A) ≈ J - end - +end - @testset "AD using ForwardDiff" begin +@testset "AD using ForwardDiff" begin @timed_testset "Euler equations 1D" begin - function entropy_at_final_time(k) # k is the wave number of the initial condition - equations = CompressibleEulerEquations1D(1.4) - mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level=3, n_cells_max=10^4) - solver = DGSEM(3, flux_hll, VolumeIntegralFluxDifferencing(flux_ranocha)) - initial_condition = (x, t, equations) -> begin - rho = 2 + sinpi(k * sum(x)) - v1 = 0.1 - p = 10.0 - return prim2cons(SVector(rho, v1, p), equations) + function entropy_at_final_time(k) # k is the wave number of the initial condition + equations = CompressibleEulerEquations1D(1.4) + mesh = TreeMesh((-1.0,), (1.0,), initial_refinement_level = 3, + n_cells_max = 10^4) + solver = DGSEM(3, flux_hll, VolumeIntegralFluxDifferencing(flux_ranocha)) + initial_condition = (x, t, equations) -> begin + rho = 2 + sinpi(k * sum(x)) + v1 = 0.1 + p = 10.0 + return prim2cons(SVector(rho, v1, p), equations) + end + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver, + uEltype = typeof(k)) + ode = semidiscretize(semi, (0.0, 1.0)) + summary_callback = SummaryCallback() + analysis_interval = 100 + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + alive_callback = AliveCallback(analysis_interval = analysis_interval) + callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback) + sol = solve(ode, SSPRK43(), callback = callbacks) + Trixi.integrate(entropy, sol.u[end], semi) end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)) - ode = semidiscretize(semi, (0.0, 1.0)) - summary_callback = SummaryCallback() - analysis_interval = 100 - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - alive_callback = AliveCallback(analysis_interval=analysis_interval) - callbacks = CallbackSet( - summary_callback, - analysis_callback, - alive_callback - ) - sol = solve(ode, SSPRK43(), callback=callbacks) - Trixi.integrate(entropy, sol.u[end], semi) - end - ForwardDiff.derivative(entropy_at_final_time, 1.0) ≈ -0.4524664696235628 + ForwardDiff.derivative(entropy_at_final_time, 1.0) ≈ -0.4524664696235628 end @timed_testset "Linear advection 2D" begin - function energy_at_final_time(k) # k is the wave number of the initial condition - equations = LinearScalarAdvectionEquation2D(0.2, -0.7) - mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level=3, n_cells_max=10^4) - solver = DGSEM(3, flux_lax_friedrichs) - initial_condition = (x, t, equation) -> begin - x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) - return SVector(sinpi(k * sum(x_trans))) + function energy_at_final_time(k) # k is the wave number of the initial condition + equations = LinearScalarAdvectionEquation2D(0.2, -0.7) + mesh = TreeMesh((-1.0, -1.0), (1.0, 1.0), initial_refinement_level = 3, + n_cells_max = 10^4) + solver = DGSEM(3, flux_lax_friedrichs) + initial_condition = (x, t, equation) -> begin + x_trans = Trixi.x_trans_periodic_2d(x - equation.advection_velocity * t) + return SVector(sinpi(k * sum(x_trans))) + end + semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, + solver, + uEltype = typeof(k)) + ode = semidiscretize(semi, (0.0, 1.0)) + summary_callback = SummaryCallback() + analysis_interval = 100 + analysis_callback = AnalysisCallback(semi, interval = analysis_interval) + alive_callback = AliveCallback(analysis_interval = analysis_interval) + stepsize_callback = StepsizeCallback(cfl = 1.6) + callbacks = CallbackSet(summary_callback, + analysis_callback, + alive_callback, + stepsize_callback) + sol = solve(ode, CarpenterKennedy2N54(williamson_condition = false), + save_everystep = false, adaptive = false, dt = 1.0, + callback = callbacks) + Trixi.integrate(energy_total, sol.u[end], semi) end - semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver, - uEltype=typeof(k)) - ode = semidiscretize(semi, (0.0, 1.0)) - summary_callback = SummaryCallback() - analysis_interval = 100 - analysis_callback = AnalysisCallback(semi, interval=analysis_interval) - alive_callback = AliveCallback(analysis_interval=analysis_interval) - stepsize_callback = StepsizeCallback(cfl=1.6) - callbacks = CallbackSet( - summary_callback, - analysis_callback, - alive_callback, - stepsize_callback - ) - sol = solve(ode, CarpenterKennedy2N54(williamson_condition=false), save_everystep=false, adaptive=false, dt=1.0, callback=callbacks) - Trixi.integrate(energy_total, sol.u[end], semi) - end - ForwardDiff.derivative(energy_at_final_time, 1.0) ≈ 1.4388628342896945e-5 + ForwardDiff.derivative(energy_at_final_time, 1.0) ≈ 1.4388628342896945e-5 end @timed_testset "elixir_euler_ad.jl" begin - @test_trixi_include(joinpath(examples_dir(), "special_elixirs", "elixir_euler_ad.jl")) + @test_trixi_include(joinpath(examples_dir(), "special_elixirs", + "elixir_euler_ad.jl")) end - end end - +end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end #module diff --git a/test/test_structured_1d.jl b/test/test_structured_1d.jl index 85b26192fb5..f0eecfa9acd 100644 --- a/test/test_structured_1d.jl +++ b/test/test_structured_1d.jl @@ -9,115 +9,138 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_1d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "StructuredMesh1D" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [6.0388296447998465e-6], - linf = [3.217887726258972e-5]) - # 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 + # Expected errors are exactly the same as with TreeMesh! + l2=[6.0388296447998465e-6], + linf=[3.217887726258972e-5]) + # 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_advection_nonperiodic.jl" begin +@trixi_testset "elixir_advection_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), - l2 = [5.641921365468918e-5], - linf = [0.00021049780975179733]) - # 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 + l2=[5.641921365468918e-5], + linf=[0.00021049780975179733]) + # 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_advection_shockcapturing.jl" begin +@trixi_testset "elixir_advection_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_shockcapturing.jl"), - l2 = [0.08015029105233593], - linf = [0.610709468736576], - atol = 1.0e-5) - # 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 + l2=[0.08015029105233593], + linf=[0.610709468736576], + atol=1.0e-5) + # 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_euler_sedov.jl" begin +@trixi_testset "elixir_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [3.67478226e-01, 3.49491179e-01, 8.08910759e-01], - linf = [1.58971947e+00, 1.59812384e+00, 1.94732969e+00], - tspan = (0.0, 0.3)) - # 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 + l2=[3.67478226e-01, 3.49491179e-01, 8.08910759e-01], + linf=[1.58971947e+00, 1.59812384e+00, 1.94732969e+00], + tspan=(0.0, 0.3)) + # 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_euler_sedov_hll_davis.jl" begin +@trixi_testset "elixir_euler_sedov_hll_davis.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [1.278661029299215, 0.0663853410742763, 0.9585741943783386], - linf = [3.1661064228547255, 0.16256363944708607, 2.667676158812806], - tspan = (0.0, 12.5), - surface_flux = FluxHLL(min_max_speed_davis)) - # 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 + l2=[1.278661029299215, 0.0663853410742763, 0.9585741943783386], + linf=[ + 3.1661064228547255, + 0.16256363944708607, + 2.667676158812806, + ], + tspan=(0.0, 12.5), + surface_flux=FluxHLL(min_max_speed_davis)) + # 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_euler_source_terms.jl" begin +@trixi_testset "elixir_euler_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [2.2527950196212703e-8, 1.8187357193835156e-8, 7.705669939973104e-8], - linf = [1.6205433861493646e-7, 1.465427772462391e-7, 5.372255111879554e-7]) - # 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 + # Expected errors are exactly the same as with TreeMesh! + l2=[ + 2.2527950196212703e-8, + 1.8187357193835156e-8, + 7.705669939973104e-8, + ], + linf=[ + 1.6205433861493646e-7, + 1.465427772462391e-7, + 5.372255111879554e-7, + ]) + # 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_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [3.8099996914101204e-6, 1.6745575717106341e-6, 7.732189531480852e-6], - linf = [1.2971473393186272e-5, 9.270328934274374e-6, 3.092514399671842e-5]) - # 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_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 3.8099996914101204e-6, + 1.6745575717106341e-6, + 7.732189531480852e-6, + ], + linf=[ + 1.2971473393186272e-5, + 9.270328934274374e-6, + 3.092514399671842e-5, + ]) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_structured_2d.jl b/test/test_structured_2d.jl index c3192f52b2c..dd2248e10b2 100644 --- a/test/test_structured_2d.jl +++ b/test/test_structured_2d.jl @@ -11,652 +11,897 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "StructuredMesh2D" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - # 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_coupled.jl" begin + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + # 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_advection_coupled.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_coupled.jl"), - l2 = [7.816742843181738e-6, 7.816742843196112e-6], - linf = [6.314906965543265e-5, 6.314906965410039e-5], - coverage_override = (maxiters=10^5,)) + l2=[7.816742843181738e-6, 7.816742843196112e-6], + linf=[6.314906965543265e-5, 6.314906965410039e-5], + coverage_override=(maxiters = 10^5,)) @testset "analysis_callback(sol) for AnalysisCallbackCoupled" begin - errors = analysis_callback(sol) - @test errors.l2 ≈ [7.816742843181738e-6, 7.816742843196112e-6] rtol=1.0e-4 - @test errors.linf ≈ [6.314906965543265e-5, 6.314906965410039e-5] rtol=1.0e-4 - # 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_extended.jl" begin + errors = analysis_callback(sol) + @test errors.l2≈[7.816742843181738e-6, 7.816742843196112e-6] rtol=1.0e-4 + @test errors.linf≈[6.314906965543265e-5, 6.314906965410039e-5] rtol=1.0e-4 + # 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_extended.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [4.220397559713772e-6], - linf = [3.477948874874848e-5]) - # 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_advection_extended.jl with polydeg=4" begin + l2=[4.220397559713772e-6], + linf=[3.477948874874848e-5]) + # 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_advection_extended.jl with polydeg=4" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [5.32996976442737e-7], - linf = [4.1344662966569246e-6], - atol = 1e-12, # required to make CI tests pass on macOS - cells_per_dimension = (16, 23), - polydeg = 4, - cfl = 1.4) - # 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 - - @testset "elixir_advection_rotated.jl" begin + l2=[5.32996976442737e-7], + linf=[4.1344662966569246e-6], + atol=1e-12, # required to make CI tests pass on macOS + cells_per_dimension=(16, 23), + polydeg=4, + cfl=1.4) + # 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 + +@testset "elixir_advection_rotated.jl" begin @trixi_testset "elixir_advection_rotated.jl with α = 0.0" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5], - alpha = 0.0) - # 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 + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5], + alpha=0.0) + # 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_advection_rotated.jl with α = 0.1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors differ only slightly from elixir_advection_basic! - l2 = [8.3122750550501e-6], - linf = [6.626802581322089e-5], - alpha = 0.1) - # 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 + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors differ only slightly from elixir_advection_basic! + l2=[8.3122750550501e-6], + linf=[6.626802581322089e-5], + alpha=0.1) + # 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_advection_rotated.jl with α = 0.5 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5], - alpha = 0.5 * pi) - # 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_parallelogram.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_rotated.jl"), + # Expected errors are exactly the same as in elixir_advection_basic! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5], + alpha=0.5 * pi) + # 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_parallelogram.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_parallelogram.jl"), - # Expected errors are exactly the same as in elixir_advection_basic! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - # 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_advection_waving_flag.jl" begin + # Expected errors are exactly the same as in elixir_advection_basic! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + # 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_advection_waving_flag.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_waving_flag.jl"), - l2 = [0.00018553859900545866], - linf = [0.0016167719118129753]) - # 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_advection_free_stream.jl" begin + l2=[0.00018553859900545866], + linf=[0.0016167719118129753]) + # 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_advection_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), - l2 = [6.8925194184204476e-15], - linf = [9.903189379656396e-14]) - # 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_advection_nonperiodic.jl" begin + l2=[6.8925194184204476e-15], + linf=[9.903189379656396e-14]) + # 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_advection_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic.jl"), - l2 = [0.00025552740731641223], - linf = [0.007252625722805939]) - # 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_advection_restart.jl" begin + l2=[0.00025552740731641223], + linf=[0.007252625722805939]) + # 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_advection_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [4.219208035582454e-6], - linf = [3.438434404412494e-5]) - # 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_advection_restart.jl with waving flag mesh" begin + l2=[4.219208035582454e-6], + linf=[3.438434404412494e-5]) + # 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_advection_restart.jl with waving flag mesh" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.00016265538265929818], - linf = [0.0015194252169410394], - rtol = 5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) - elixir_file="elixir_advection_waving_flag.jl", - restart_file="restart_000021.h5") - # 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_advection_restart.jl with free stream mesh" begin + l2=[0.00016265538265929818], + linf=[0.0015194252169410394], + rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) + elixir_file="elixir_advection_waving_flag.jl", + restart_file="restart_000021.h5") + # 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_advection_restart.jl with free stream mesh" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [7.841217436552029e-15], - linf = [1.0857981180834031e-13], - elixir_file="elixir_advection_free_stream.jl", - restart_file="restart_000036.h5") - # 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_euler_source_terms.jl" begin + l2=[7.841217436552029e-15], + linf=[1.0857981180834031e-13], + elixir_file="elixir_advection_free_stream.jl", + restart_file="restart_000036.h5") + # 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_euler_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5]) - # 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 - - @testset "elixir_euler_source_terms_rotated.jl" begin + # Expected errors are exactly the same as with TreeMesh! + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ]) + # 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 + +@testset "elixir_euler_source_terms_rotated.jl" begin @trixi_testset "elixir_euler_source_terms_rotated.jl with α = 0.0" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors are exactly the same as in elixir_euler_source_terms! - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], - alpha = 0.0) - # 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 + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors are exactly the same as in elixir_euler_source_terms! + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ], + alpha=0.0) + # 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_euler_source_terms_rotated.jl with α = 0.1" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors differ only slightly from elixir_euler_source_terms! - l2 = [9.321188057029291e-7, 1.3195106906473365e-6, 1.510307360354032e-6, 4.82455408101712e-6], - linf = [9.57723626271445e-6, 1.0480225511866337e-5, 1.2817828088262928e-5, 4.886962393513272e-5], - alpha = 0.1) - # 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 + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors differ only slightly from elixir_euler_source_terms! + l2=[ + 9.321188057029291e-7, + 1.3195106906473365e-6, + 1.510307360354032e-6, + 4.82455408101712e-6, + ], + linf=[ + 9.57723626271445e-6, + 1.0480225511866337e-5, + 1.2817828088262928e-5, + 4.886962393513272e-5, + ], + alpha=0.1) + # 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_euler_source_terms_rotated.jl with α = 0.2 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors differ only slightly from elixir_euler_source_terms! - l2 = [9.32127973957391e-7, 8.477824799744325e-7, 1.8175286311402784e-6, 4.824562453521076e-6], - linf = [9.576898420737834e-6, 5.057704352218195e-6, 1.635260719945464e-5, 4.886978754825577e-5], - alpha = 0.2 * pi) - # 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 + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors differ only slightly from elixir_euler_source_terms! + l2=[ + 9.32127973957391e-7, + 8.477824799744325e-7, + 1.8175286311402784e-6, + 4.824562453521076e-6, + ], + linf=[ + 9.576898420737834e-6, + 5.057704352218195e-6, + 1.635260719945464e-5, + 4.886978754825577e-5, + ], + alpha=0.2 * pi) + # 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_euler_source_terms_rotated.jl with α = 0.5 * pi" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_rotated.jl"), - # Expected errors are exactly the same as in elixir_euler_source_terms! - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5], - alpha = 0.5 * pi) - # 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_euler_source_terms_parallelogram.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_parallelogram.jl"), - l2 = [1.1167802955144833e-5, 1.0805775514153104e-5, 1.953188337010932e-5, 5.5033856574857146e-5], - linf = [8.297006495561199e-5, 8.663281475951301e-5, 0.00012264160606778596, 0.00041818802502024965]) - # 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_euler_source_terms_waving_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_waving_flag.jl"), - l2 = [2.991891317562739e-5, 3.6063177168283174e-5, 2.7082941743640572e-5, 0.00011414695350996946], - linf = [0.0002437454930492855, 0.0003438936171968887, 0.00024217622945688078, 0.001266380414757684]) - # 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_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_rotated.jl"), + # Expected errors are exactly the same as in elixir_euler_source_terms! + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ], + alpha=0.5 * pi) + # 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_euler_source_terms_parallelogram.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_parallelogram.jl"), + l2=[ + 1.1167802955144833e-5, + 1.0805775514153104e-5, + 1.953188337010932e-5, + 5.5033856574857146e-5, + ], + linf=[ + 8.297006495561199e-5, + 8.663281475951301e-5, + 0.00012264160606778596, + 0.00041818802502024965, + ]) + # 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_euler_source_terms_waving_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_waving_flag.jl"), + l2=[ + 2.991891317562739e-5, + 3.6063177168283174e-5, + 2.7082941743640572e-5, + 0.00011414695350996946, + ], + linf=[ + 0.0002437454930492855, + 0.0003438936171968887, + 0.00024217622945688078, + 0.001266380414757684, + ]) + # 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_euler_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], - linf = [1.9539925233402755e-14, 2.9791447087035294e-13, 6.502853810985698e-13, 2.7000623958883807e-13], - atol = 7.0e-13) - # 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_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[ + 1.9539925233402755e-14, + 2.9791447087035294e-13, + 6.502853810985698e-13, + 2.7000623958883807e-13, + ], + atol=7.0e-13) + # 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_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - surface_flux=FluxRotated(flux_lax_friedrichs), - l2 = [2.063350241405049e-15, 1.8571016296925367e-14, 3.1769447886391905e-14, 1.4104095258528071e-14], - linf = [1.9539925233402755e-14, 2.9791447087035294e-13, 6.502853810985698e-13, 2.7000623958883807e-13], - atol = 7.0e-13) - # 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_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511901724e-6, 2.3188881559075347e-6, 2.3188881559568146e-6, 6.332786324137878e-6], - linf = [1.4987382622067003e-5, 1.918201192063762e-5, 1.918201192019353e-5, 6.052671713430158e-5]) - # 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_euler_ec.jl" begin + surface_flux=FluxRotated(flux_lax_friedrichs), + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[ + 1.9539925233402755e-14, + 2.9791447087035294e-13, + 6.502853810985698e-13, + 2.7000623958883807e-13, + ], + atol=7.0e-13) + # 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_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511901724e-6, + 2.3188881559075347e-6, + 2.3188881559568146e-6, + 6.332786324137878e-6, + ], + linf=[ + 1.4987382622067003e-5, + 1.918201192063762e-5, + 1.918201192019353e-5, + 6.052671713430158e-5, + ]) + # 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_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03774907669925568, 0.02845190575242045, 0.028262802829412605, 0.13785915638851698], - linf = [0.3368296929764073, 0.27644083771519773, 0.27990039685141377, 1.1971436487402016], - tspan = (0.0, 0.3)) - # 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_euler_sedov.jl" begin + l2=[ + 0.03774907669925568, + 0.02845190575242045, + 0.028262802829412605, + 0.13785915638851698, + ], + linf=[ + 0.3368296929764073, + 0.27644083771519773, + 0.27990039685141377, + 1.1971436487402016, + ], + tspan=(0.0, 0.3)) + # 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_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [3.69856202e-01, 2.35242180e-01, 2.41444928e-01, 1.28807120e+00], - linf = [1.82786223e+00, 1.30452904e+00, 1.40347257e+00, 6.21791658e+00], - tspan = (0.0, 0.3)) - # 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_euler_rayleigh_taylor_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_rayleigh_taylor_instability.jl"), - l2 = [0.06365630381017849, 0.007166887387738937, 0.002878708825497772, 0.010247678114070121], - linf = [0.4799214336153155, 0.024595483032220266, 0.02059808120543466, 0.03190756362943725], - cells_per_dimension = (8,8), - tspan = (0.0, 0.3)) - # 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_eulerpolytropic_convergence.jl" begin + l2=[ + 3.69856202e-01, + 2.35242180e-01, + 2.41444928e-01, + 1.28807120e+00, + ], + linf=[ + 1.82786223e+00, + 1.30452904e+00, + 1.40347257e+00, + 6.21791658e+00, + ], + tspan=(0.0, 0.3)) + # 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_euler_rayleigh_taylor_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_rayleigh_taylor_instability.jl"), + l2=[ + 0.06365630381017849, + 0.007166887387738937, + 0.002878708825497772, + 0.010247678114070121, + ], + linf=[ + 0.4799214336153155, + 0.024595483032220266, + 0.02059808120543466, + 0.03190756362943725, + ], + cells_per_dimension=(8, 8), + tspan=(0.0, 0.3)) + # 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_eulerpolytropic_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_convergence.jl"), - l2 = [0.0016688820596537988, 0.0025921681885685425, 0.003280950351435014], - linf = [0.010994679664394269, 0.01331197845637, 0.020080117011346488]) - # 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_eulerpolytropic_ec.jl" begin + l2=[ + 0.0016688820596537988, + 0.0025921681885685425, + 0.003280950351435014, + ], + linf=[ + 0.010994679664394269, + 0.01331197845637, + 0.020080117011346488, + ]) + # 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_eulerpolytropic_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_ec.jl"), - l2 = [0.03647890611450939, 0.025284915444045052, 0.025340697771609126], - linf = [0.32516731565355583, 0.37509762516540046, 0.29812843284727336]) - # 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_eulerpolytropic_isothermal_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_isothermal_wave.jl"), - l2 = [0.004998778491726366, 0.004998916000294425, 9.259136963058664e-17], - linf = [0.010001103673834888, 0.010051165098399503, 7.623942913643681e-16]) - # 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_eulerpolytropic_wave.jl" begin + l2=[ + 0.03647890611450939, + 0.025284915444045052, + 0.025340697771609126, + ], + linf=[ + 0.32516731565355583, + 0.37509762516540046, + 0.29812843284727336, + ]) + # 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_eulerpolytropic_isothermal_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulerpolytropic_isothermal_wave.jl"), + l2=[ + 0.004998778491726366, + 0.004998916000294425, + 9.259136963058664e-17, + ], + linf=[ + 0.010001103673834888, + 0.010051165098399503, + 7.623942913643681e-16, + ]) + # 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_eulerpolytropic_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulerpolytropic_wave.jl"), - l2 = [0.23642682112204072, 0.20904264390331334, 8.174982691297391e-17], - linf = [0.4848250368349989, 0.253350873815695, 4.984552457753618e-16]) - # 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_hypdiff_nonperiodic.jl" begin + l2=[ + 0.23642682112204072, + 0.20904264390331334, + 8.174982691297391e-17, + ], + linf=[ + 0.4848250368349989, + 0.253350873815695, + 4.984552457753618e-16, + ]) + # 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_hypdiff_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [0.8799744480157664, 0.8535008397034816, 0.7851383019164209], - linf = [1.0771947577311836, 1.9143913544309838, 2.149549109115789], - tspan = (0.0, 0.1), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - # 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)) < 15000 - end - end - - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [0.19357947606509474, 0.47041398037626814, 0.4704139803762686], - linf = [0.35026352556630114, 0.8344372248051408, 0.8344372248051408], - tspan = (0.0, 0.1), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - # 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_mhd_ec.jl" begin + l2=[0.8799744480157664, 0.8535008397034816, 0.7851383019164209], + linf=[1.0771947577311836, 1.9143913544309838, 2.149549109115789], + tspan=(0.0, 0.1), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + # 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)) < 15000 + end +end + +@trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[ + 0.19357947606509474, + 0.47041398037626814, + 0.4704139803762686, + ], + linf=[ + 0.35026352556630114, + 0.8344372248051408, + 0.8344372248051408, + ], + tspan=(0.0, 0.1), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + # 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_mhd_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.04937480811868297, 0.06117033019988596, 0.060998028674664716, 0.03155145889799417, - 0.2319175391388658, 0.02476283192966346, 0.024483244374818587, 0.035439957899127385, - 0.0016022148194667542], - linf = [0.24749024430983746, 0.2990608279625713, 0.3966937932860247, 0.22265033744519683, - 0.9757376320946505, 0.12123736788315098, 0.12837436699267113, 0.17793825293524734, - 0.03460761690059514], - tspan = (0.0, 0.3)) - # 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_mhd_alfven_wave.jl" begin + l2=[0.04937480811868297, 0.06117033019988596, + 0.060998028674664716, 0.03155145889799417, + 0.2319175391388658, 0.02476283192966346, + 0.024483244374818587, 0.035439957899127385, + 0.0016022148194667542], + linf=[0.24749024430983746, 0.2990608279625713, + 0.3966937932860247, 0.22265033744519683, + 0.9757376320946505, 0.12123736788315098, + 0.12837436699267113, 0.17793825293524734, + 0.03460761690059514], + tspan=(0.0, 0.3)) + # 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_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.02890769490562535, 0.0062599448721613205, 0.005650300017676721, 0.007334415940022972, - 0.00490446035599909, 0.007202284100220619, 0.007003258686714405, 0.006734267830082687, - 0.004253003868791559], - linf = [0.17517380432288565, 0.06197353710696667, 0.038494840938641646, 0.05293345499813148, - 0.03817506476831778, 0.042847170999492534, 0.03761563456810613, 0.048184237474911844, - 0.04114666955364693], - tspan = (0.0, 1.0)) - # 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_shallowwater_source_terms.jl" begin + l2=[0.02890769490562535, 0.0062599448721613205, + 0.005650300017676721, 0.007334415940022972, + 0.00490446035599909, 0.007202284100220619, + 0.007003258686714405, 0.006734267830082687, + 0.004253003868791559], + linf=[0.17517380432288565, 0.06197353710696667, + 0.038494840938641646, 0.05293345499813148, + 0.03817506476831778, 0.042847170999492534, + 0.03761563456810613, 0.048184237474911844, + 0.04114666955364693], + tspan=(0.0, 1.0)) + # 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_shallowwater_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0017285599436729316, 0.025584610912606776, 0.028373834961180594, 6.274146767730866e-5], - linf = [0.012972309788264802, 0.108283714215621, 0.15831585777928936, 0.00018196759554722775], - tspan = (0.0, 0.05)) - # 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_shallowwater_well_balanced.jl" begin + l2=[ + 0.0017285599436729316, + 0.025584610912606776, + 0.028373834961180594, + 6.274146767730866e-5, + ], + linf=[ + 0.012972309788264802, + 0.108283714215621, + 0.15831585777928936, + 0.00018196759554722775, + ], + tspan=(0.0, 0.05)) + # 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_shallowwater_well_balanced.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.7920927046419308, 9.92129670988898e-15, 1.0118635033124588e-14, 0.7920927046419308], - linf = [2.408429868800133, 5.5835419986809516e-14, 5.448874313931364e-14, 2.4084298688001335], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced_wet_dry.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_wet_dry.jl"), - l2 = [0.019731646454942086, 1.0694532773278277e-14, 1.1969913383405568e-14, 0.0771517260037954], - linf = [0.4999999999998892, 6.067153702623552e-14, 4.4849667259339357e-14, 1.9999999999999993], - tspan = (0.0, 0.25)) - # 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_shallowwater_conical_island.jl" begin + l2=[ + 0.7920927046419308, + 9.92129670988898e-15, + 1.0118635033124588e-14, + 0.7920927046419308, + ], + linf=[ + 2.408429868800133, + 5.5835419986809516e-14, + 5.448874313931364e-14, + 2.4084298688001335, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced_wet_dry.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_wet_dry.jl"), + l2=[ + 0.019731646454942086, + 1.0694532773278277e-14, + 1.1969913383405568e-14, + 0.0771517260037954, + ], + linf=[ + 0.4999999999998892, + 6.067153702623552e-14, + 4.4849667259339357e-14, + 1.9999999999999993, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_conical_island.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_conical_island.jl"), - l2 = [0.04593154164306353, 0.1644534881916908, 0.16445348819169076, 0.0011537702354532122], - linf = [0.21100717610846442, 0.9501592344310412, 0.950159234431041, 0.021790250683516296], - tspan = (0.0, 0.025)) - # 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_shallowwater_parabolic_bowl.jl" begin + l2=[ + 0.04593154164306353, + 0.1644534881916908, + 0.16445348819169076, + 0.0011537702354532122, + ], + linf=[ + 0.21100717610846442, + 0.9501592344310412, + 0.950159234431041, + 0.021790250683516296, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_parabolic_bowl.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_parabolic_bowl.jl"), - l2 = [0.00015285369980313484, 1.9536806395943226e-5, 9.936906607758672e-5, 5.0686313334616055e-15], - linf = [0.003316119030459211, 0.0005075409427972817, 0.001986721761060583, 4.701794509287538e-14], - tspan = (0.0, 0.025), cells_per_dimension = (40, 40)) - # 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_mhd_ec_shockcapturing.jl" begin + l2=[ + 0.00015285369980313484, + 1.9536806395943226e-5, + 9.936906607758672e-5, + 5.0686313334616055e-15, + ], + linf=[ + 0.003316119030459211, + 0.0005075409427972817, + 0.001986721761060583, + 4.701794509287538e-14, + ], + tspan=(0.0, 0.025), cells_per_dimension=(40, 40)) + # 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_mhd_ec_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2 = [0.0364192725149364, 0.0426667193422069, 0.04261673001449095, 0.025884071405646924, - 0.16181626564020496, 0.017346518770783536, 0.017291573200291104, 0.026856206495339655, - 0.0007443858043598808], - linf = [0.25144373906033013, 0.32881947152723745, 0.3053266801502693, 0.20989755319972866, - 0.9927517314507455, 0.1105172121361323, 0.1257708104676617, 0.1628334844841588, - 0.02624301627479052]) - # 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 + l2=[0.0364192725149364, 0.0426667193422069, 0.04261673001449095, + 0.025884071405646924, + 0.16181626564020496, 0.017346518770783536, + 0.017291573200291104, 0.026856206495339655, + 0.0007443858043598808], + linf=[0.25144373906033013, 0.32881947152723745, + 0.3053266801502693, 0.20989755319972866, + 0.9927517314507455, 0.1105172121361323, 0.1257708104676617, + 0.1628334844841588, + 0.02624301627479052]) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_structured_3d.jl b/test/test_structured_3d.jl index 07910e1119b..0213e1a9813 100644 --- a/test/test_structured_3d.jl +++ b/test/test_structured_3d.jl @@ -9,240 +9,331 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "structured_3d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "Structured mesh" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - # 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_advection_free_stream.jl" begin + # Expected errors are exactly the same as with TreeMesh! + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + # 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_advection_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"), - l2 = [1.2908196366970896e-14], - linf = [1.0262901639634947e-12], - atol = 8e-13, # required to make tests pass on Windows - ) - # 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_advection_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonperiodic_curved.jl"), - l2 = [0.0004483892474201268], - linf = [0.009201820593762955]) - # 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_advection_restart.jl" begin + l2=[1.2908196366970896e-14], + linf=[1.0262901639634947e-12], + atol=8e-13,) + # 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_advection_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonperiodic_curved.jl"), + l2=[0.0004483892474201268], + linf=[0.009201820593762955]) + # 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_advection_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.0025903889347585777], - linf = [0.018407576968841655]) - # 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_euler_source_terms.jl" begin + l2=[0.0025903889347585777], + linf=[0.018407576968841655]) + # 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_euler_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2 = [0.010385936842224346, 0.009776048833895767, 0.00977604883389591, 0.009776048833895733, 0.01506687097416608], - linf = [0.03285848350791731, 0.0321792316408982, 0.032179231640894645, 0.032179231640895534, 0.0655408023333299]) - # 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_euler_free_stream.jl" begin + # Expected errors are exactly the same as with TreeMesh! + l2=[ + 0.010385936842224346, + 0.009776048833895767, + 0.00977604883389591, + 0.009776048833895733, + 0.01506687097416608, + ], + linf=[ + 0.03285848350791731, + 0.0321792316408982, + 0.032179231640894645, + 0.032179231640895534, + 0.0655408023333299, + ]) + # 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_euler_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [2.8815700334367128e-15, 9.361915278236651e-15, 9.95614203619935e-15, 1.6809941842374106e-14, 1.4815037041566735e-14], - linf = [4.1300296516055823e-14, 2.0444756998472258e-13, 1.0133560657266116e-13, 2.0627943797535409e-13, 2.8954616482224083e-13]) - # 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_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin + l2=[ + 2.8815700334367128e-15, + 9.361915278236651e-15, + 9.95614203619935e-15, + 1.6809941842374106e-14, + 1.4815037041566735e-14, + ], + linf=[ + 4.1300296516055823e-14, + 2.0444756998472258e-13, + 1.0133560657266116e-13, + 2.0627943797535409e-13, + 2.8954616482224083e-13, + ]) + # 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_euler_free_stream.jl with FluxRotated(flux_lax_friedrichs)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - surface_flux=FluxRotated(flux_lax_friedrichs), - l2 = [2.8815700334367128e-15, 9.361915278236651e-15, 9.95614203619935e-15, 1.6809941842374106e-14, 1.4815037041566735e-14], - linf = [4.1300296516055823e-14, 2.0444756998472258e-13, 1.0133560657266116e-13, 2.0627943797535409e-13, 2.8954616482224083e-13]) - # 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_euler_source_terms_nonperiodic_curved.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic_curved.jl"), - l2 = [0.0032940531178824463, 0.003275679548217804, 0.0030020672748714084, 0.00324007343451744, 0.005721986362580164], - linf = [0.03156756290660656, 0.033597629023726316, 0.02095783702361409, 0.03353574465232212, 0.05873635745032857]) - # 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 + surface_flux=FluxRotated(flux_lax_friedrichs), + l2=[ + 2.8815700334367128e-15, + 9.361915278236651e-15, + 9.95614203619935e-15, + 1.6809941842374106e-14, + 1.4815037041566735e-14, + ], + linf=[ + 4.1300296516055823e-14, + 2.0444756998472258e-13, + 1.0133560657266116e-13, + 2.0627943797535409e-13, + 2.8954616482224083e-13, + ]) + # 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_euler_source_terms_nonperiodic_curved.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic_curved.jl"), + l2=[ + 0.0032940531178824463, + 0.003275679548217804, + 0.0030020672748714084, + 0.00324007343451744, + 0.005721986362580164, + ], + linf=[ + 0.03156756290660656, + 0.033597629023726316, + 0.02095783702361409, + 0.03353574465232212, + 0.05873635745032857, + ]) + # 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_euler_ec.jl" begin +@trixi_testset "elixir_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.011367083018614027, 0.007022020327490176, 0.006759580335962235, 0.006820337637760632, 0.02912659127566544], - linf = [0.2761764220925329, 0.20286331858055706, 0.18763944865434593, 0.19313636558790004, 0.707563913727584], - tspan = (0.0, 0.25), - coverage_override = (polydeg=3,)) # Prevent long compile time in CI - # 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_euler_sedov.jl" begin + l2=[ + 0.011367083018614027, + 0.007022020327490176, + 0.006759580335962235, + 0.006820337637760632, + 0.02912659127566544, + ], + linf=[ + 0.2761764220925329, + 0.20286331858055706, + 0.18763944865434593, + 0.19313636558790004, + 0.707563913727584, + ], + tspan=(0.0, 0.25), + coverage_override=(polydeg = 3,)) # Prevent long compile time in CI + # 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_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [5.30310390e-02, 2.53167260e-02, 2.64276438e-02, 2.52195992e-02, 3.56830295e-01], - linf = [6.16356950e-01, 2.50600049e-01, 2.74796377e-01, 2.46448217e-01, 4.77888479e+00], - tspan = (0.0, 0.3)) - # 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_mhd_ec.jl" begin + l2=[ + 5.30310390e-02, + 2.53167260e-02, + 2.64276438e-02, + 2.52195992e-02, + 3.56830295e-01, + ], + linf=[ + 6.16356950e-01, + 2.50600049e-01, + 2.74796377e-01, + 2.46448217e-01, + 4.77888479e+00, + ], + tspan=(0.0, 0.3)) + # 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_mhd_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.009082353036644902, 0.007128360240528109, 0.006970330025996491, 0.006898850266874514, - 0.03302008823756457, 0.003203389099143526, 0.003077498677885352, 0.0030740006760477624, - 4.192129696970217e-5], - linf = [0.2883946030582689, 0.25956437344015054, 0.2614364943543665, 0.24617277938134657, - 1.1370443512475847, 0.1278041831463388, 0.13347391885068594, 0.1457563463643099, - 0.0021174246048172563], - tspan = (0.0, 0.25)) - # 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_mhd_alfven_wave.jl" begin + l2=[0.009082353036644902, 0.007128360240528109, + 0.006970330025996491, 0.006898850266874514, + 0.03302008823756457, 0.003203389099143526, + 0.003077498677885352, 0.0030740006760477624, + 4.192129696970217e-5], + linf=[0.2883946030582689, 0.25956437344015054, + 0.2614364943543665, 0.24617277938134657, + 1.1370443512475847, 0.1278041831463388, 0.13347391885068594, + 0.1457563463643099, + 0.0021174246048172563], + tspan=(0.0, 0.25)) + # 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_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.003015476175153681, 0.00145499403283373, 0.0009125744757935803, 0.0017703080480578979, - 0.0013046447673965966, 0.0014564863387645508, 0.0013332311430907598, 0.001647832598455728, - 0.0013647609788548722], - linf = [0.027510637768610846, 0.02797062834945721, 0.01274249949295704, 0.038940694415543736, - 0.02200825678588325, 0.03167600959583505, 0.021420957993862344, 0.03386589835999665, - 0.01888303191983353], - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override = (polydeg=3,)) - # 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_mhd_alfven_wave.jl with flux_lax_friedrichs" begin + l2=[0.003015476175153681, 0.00145499403283373, + 0.0009125744757935803, 0.0017703080480578979, + 0.0013046447673965966, 0.0014564863387645508, + 0.0013332311430907598, 0.001647832598455728, + 0.0013647609788548722], + linf=[0.027510637768610846, 0.02797062834945721, + 0.01274249949295704, 0.038940694415543736, + 0.02200825678588325, 0.03167600959583505, + 0.021420957993862344, 0.03386589835999665, + 0.01888303191983353], + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override=(polydeg = 3,)) + # 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_mhd_alfven_wave.jl with flux_lax_friedrichs" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.003047854479955232, 0.0014572199588782184, 0.0009093737183251411, 0.0017937548694553895, - 0.0013010437110755424, 0.0014545607744895874, 0.001328514015121245, 0.001671342529206066, - 0.0013653963058149186], - linf = [0.027719103797310463, 0.027570111789910784, 0.012561901006903103, 0.03903568568480584, - 0.021311996934554767, 0.03154849824135775, 0.020996033645485412, 0.03403185137382961, - 0.019488952445771597], - surface_flux = (flux_lax_friedrichs, flux_nonconservative_powell), - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override = (polydeg=3,)) - # 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_mhd_ec_shockcapturing.jl" begin + l2=[0.003047854479955232, 0.0014572199588782184, + 0.0009093737183251411, 0.0017937548694553895, + 0.0013010437110755424, 0.0014545607744895874, + 0.001328514015121245, 0.001671342529206066, + 0.0013653963058149186], + linf=[0.027719103797310463, 0.027570111789910784, + 0.012561901006903103, 0.03903568568480584, + 0.021311996934554767, 0.03154849824135775, + 0.020996033645485412, 0.03403185137382961, + 0.019488952445771597], + surface_flux=(flux_lax_friedrichs, flux_nonconservative_powell), + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override=(polydeg = 3,)) + # 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_mhd_ec_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2 = [0.009352631220872144, 0.008058649103542618, 0.008027041293333663, 0.008071417851552725, - 0.034909149665869485, 0.00393019428600812, 0.0039219074393817, 0.003906321245184237, - 4.197255300781248e-5], - linf = [0.30749098250807516, 0.2679008863509767, 0.271243087484388, 0.26545396569129537, - 0.9620950892188596, 0.18163281157498123, 0.15995708312378454, 0.17918221526906408, - 0.015138346608166353], - tspan = (0.0, 0.25), - # Use same polydeg as everything else to prevent long compile times in CI - coverage_override = (polydeg=3,)) - # 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 + l2=[0.009352631220872144, 0.008058649103542618, + 0.008027041293333663, 0.008071417851552725, + 0.034909149665869485, 0.00393019428600812, + 0.0039219074393817, 0.003906321245184237, + 4.197255300781248e-5], + linf=[0.30749098250807516, 0.2679008863509767, + 0.271243087484388, 0.26545396569129537, + 0.9620950892188596, 0.18163281157498123, + 0.15995708312378454, 0.17918221526906408, + 0.015138346608166353], + tspan=(0.0, 0.25), + # Use same polydeg as everything else to prevent long compile times in CI + coverage_override=(polydeg = 3,)) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_t8code_2d.jl b/test/test_t8code_2d.jl index 660d7bc0a1d..b3e19471323 100644 --- a/test/test_t8code_2d.jl +++ b/test/test_t8code_2d.jl @@ -13,263 +13,264 @@ isdir(outdir) && rm(outdir, recursive = true) mkdir(outdir) @testset "T8codeMesh2D" begin +#! format: noindent - @trixi_testset "test save_mesh_file" begin - @test_throws Exception begin +@trixi_testset "test save_mesh_file" begin + @test_throws Exception begin # Save mesh file support will be added in the future. The following # lines of code are here for satisfying code coverage. # Create dummy mesh. mesh = T8codeMesh((1, 1), polydeg = 1, - mapping = Trixi.coordinates2mapping((-1.0, -1.0), ( 1.0, 1.0)), + mapping = Trixi.coordinates2mapping((-1.0, -1.0), (1.0, 1.0)), initial_refinement_level = 1) # This call throws an error. Trixi.save_mesh_file(mesh, "dummy") - end end +end - @trixi_testset "elixir_advection_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as with TreeMesh! - l2=[8.311947673061856e-6], - linf=[6.627000273229378e-5]) - # 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_advection_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), + # Expected errors are exactly the same as with TreeMesh! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + # 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_advection_nonconforming_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_nonconforming_flag.jl"), - l2=[3.198940059144588e-5], - linf=[0.00030636069494005547]) - # 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_advection_nonconforming_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_nonconforming_flag.jl"), + l2=[3.198940059144588e-5], + linf=[0.00030636069494005547]) + # 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_advection_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), - l2=[0.0005379687442422346], - linf=[0.007438525029884735]) - # 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_advection_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"), + l2=[0.0005379687442422346], + linf=[0.007438525029884735]) + # 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_advection_amr_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_unstructured_flag.jl"), - l2=[0.001993165013217687], - linf=[0.032891018571625796], - coverage_override=(maxiters = 6,)) - # 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_advection_amr_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_unstructured_flag.jl"), + l2=[0.001993165013217687], + linf=[0.032891018571625796], + coverage_override=(maxiters = 6,)) + # 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_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_advection_amr_solution_independent.jl"), - # Expected errors are exactly the same as with StructuredMesh! - l2=[4.949660644033807e-5], - linf=[0.0004867846262313763], - coverage_override=(maxiters = 6,)) - # 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_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + # Expected errors are exactly the same as with StructuredMesh! + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + # 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_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, - "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2=[ - 0.0034516244508588046, - 0.0023420334036925493, - 0.0024261923964557187, - 0.004731710454271893, - ], - linf=[ - 0.04155789011775046, - 0.024772109862748914, - 0.03759938693042297, - 0.08039824959535657, - ]) - # 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_euler_source_terms_nonconforming_unstructured_flag.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) + # 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_euler_free_stream.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2=[ - 2.063350241405049e-15, - 1.8571016296925367e-14, - 3.1769447886391905e-14, - 1.4104095258528071e-14, - ], - linf=[1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], - atol=2.0e-12,) - # 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_euler_free_stream.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), + l2=[ + 2.063350241405049e-15, + 1.8571016296925367e-14, + 3.1769447886391905e-14, + 1.4104095258528071e-14, + ], + linf=[1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12], + atol=2.0e-12,) + # 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_euler_shockcapturing_ec.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), - l2=[ - 9.53984675e-02, - 1.05633455e-01, - 1.05636158e-01, - 3.50747237e-01, - ], - linf=[ - 2.94357464e-01, - 4.07893014e-01, - 3.97334516e-01, - 1.08142520e+00, - ], - tspan=(0.0, 1.0)) - # 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_euler_shockcapturing_ec.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"), + l2=[ + 9.53984675e-02, + 1.05633455e-01, + 1.05636158e-01, + 3.50747237e-01, + ], + linf=[ + 2.94357464e-01, + 4.07893014e-01, + 3.97334516e-01, + 1.08142520e+00, + ], + tspan=(0.0, 1.0)) + # 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_euler_sedov.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2=[ - 3.76149952e-01, - 2.46970327e-01, - 2.46970327e-01, - 1.28889042e+00, - ], - linf=[ - 1.22139001e+00, - 1.17742626e+00, - 1.17742626e+00, - 6.20638482e+00, - ], - tspan=(0.0, 0.3)) - # 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_euler_sedov.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), + l2=[ + 3.76149952e-01, + 2.46970327e-01, + 2.46970327e-01, + 1.28889042e+00, + ], + linf=[ + 1.22139001e+00, + 1.17742626e+00, + 1.17742626e+00, + 6.20638482e+00, + ], + tspan=(0.0, 0.3)) + # 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_shallowwater_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2=[ - 9.168126407325352e-5, - 0.0009795410115453788, - 0.002546408320320785, - 3.941189812642317e-6, - ], - linf=[ - 0.0009903782521019089, - 0.0059752684687262025, - 0.010941106525454103, - 1.2129488214718265e-5, - ], - tspan=(0.0, 0.1)) - # 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_shallowwater_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), + l2=[ + 9.168126407325352e-5, + 0.0009795410115453788, + 0.002546408320320785, + 3.941189812642317e-6, + ], + linf=[ + 0.0009903782521019089, + 0.0059752684687262025, + 0.010941106525454103, + 1.2129488214718265e-5, + ], + tspan=(0.0, 0.1)) + # 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_mhd_alfven_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2=[1.0513414461545583e-5, 1.0517900957166411e-6, - 1.0517900957304043e-6, 1.511816606372376e-6, - 1.0443997728645063e-6, 7.879639064990798e-7, - 7.879639065049896e-7, 1.0628631669056271e-6, - 4.3382328912336153e-7], - linf=[4.255466285174592e-5, 1.0029706745823264e-5, - 1.0029706747467781e-5, 1.2122265939010224e-5, - 5.4791097160444835e-6, 5.18922042269665e-6, - 5.189220422141538e-6, 9.552667261422676e-6, - 1.4237578427628152e-6]) - # 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_mhd_alfven_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), + l2=[1.0513414461545583e-5, 1.0517900957166411e-6, + 1.0517900957304043e-6, 1.511816606372376e-6, + 1.0443997728645063e-6, 7.879639064990798e-7, + 7.879639065049896e-7, 1.0628631669056271e-6, + 4.3382328912336153e-7], + linf=[4.255466285174592e-5, 1.0029706745823264e-5, + 1.0029706747467781e-5, 1.2122265939010224e-5, + 5.4791097160444835e-6, 5.18922042269665e-6, + 5.189220422141538e-6, 9.552667261422676e-6, + 1.4237578427628152e-6]) + # 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_mhd_rotor.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2=[0.44211360369891683, 0.8805178316216257, 0.8262710688468049, - 0.0, - 0.9616090460973586, 0.10386643568745411, - 0.15403457366543802, 0.0, - 2.8399715649715473e-5], - linf=[10.04369305341599, 17.995640564998403, 9.576041548174265, - 0.0, - 19.429658884314534, 1.3821395681242314, 1.818559351543182, - 0.0, - 0.002261930217575465], - tspan=(0.0, 0.02)) - # 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_mhd_rotor.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), + l2=[0.44211360369891683, 0.8805178316216257, 0.8262710688468049, + 0.0, + 0.9616090460973586, 0.10386643568745411, + 0.15403457366543802, 0.0, + 2.8399715649715473e-5], + linf=[10.04369305341599, 17.995640564998403, 9.576041548174265, + 0.0, + 19.429658884314534, 1.3821395681242314, 1.818559351543182, + 0.0, + 0.002261930217575465], + tspan=(0.0, 0.02)) + # 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 # Clean up afterwards: delete Trixi.jl output directory diff --git a/test/test_threaded.jl b/test/test_threaded.jl index b13b5d0f5fc..478c90b476a 100644 --- a/test/test_threaded.jl +++ b/test/test_threaded.jl @@ -7,334 +7,466 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive=true) +Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true) @testset "Threaded tests" begin - @testset "TreeMesh" begin +#! format: noindent + +@testset "TreeMesh" begin @trixi_testset "elixir_advection_restart.jl" begin - elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_extended.jl") - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(elixir) - trixi_include(@__MODULE__, elixir, tspan = (0.0, 10.0)) - l2_expected, linf_expected = analysis_callback(sol) - - elixir = joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl") - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println(elixir) - # Errors are exactly the same as in the elixir_advection_extended.jl - trixi_include(@__MODULE__, elixir) - l2_actual, linf_actual = analysis_callback(sol) - - Trixi.mpi_isroot() && @test l2_actual == l2_expected - Trixi.mpi_isroot() && @test linf_actual == linf_expected - - # 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)) < 5000 - end + elixir = joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_extended.jl") + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(elixir) + trixi_include(@__MODULE__, elixir, tspan = (0.0, 10.0)) + l2_expected, linf_expected = analysis_callback(sol) + + elixir = joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_restart.jl") + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println(elixir) + # Errors are exactly the same as in the elixir_advection_extended.jl + trixi_include(@__MODULE__, elixir) + l2_actual, linf_actual = analysis_callback(sol) + + Trixi.mpi_isroot() && @test l2_actual == l2_expected + Trixi.mpi_isroot() && @test linf_actual == linf_expected + + # 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)) < 5000 + end end @trixi_testset "elixir_advection_restart.jl with threaded time integration" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_restart.jl"), - alg = CarpenterKennedy2N54(williamson_condition = false, thread = OrdinaryDiffEq.True()), - # Expected errors are exactly the same as in the serial test! - l2 = [8.005068880114254e-6], - linf = [6.39093577996519e-5]) + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_restart.jl"), + alg=CarpenterKennedy2N54(williamson_condition = false, + thread = OrdinaryDiffEq.True()), + # Expected errors are exactly the same as in the serial test! + l2=[8.005068880114254e-6], + linf=[6.39093577996519e-5]) end @trixi_testset "elixir_advection_amr_refine_twice.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_refine_twice.jl"), - l2 = [0.00020547512522578292], - linf = [0.007831753383083506]) + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_amr_refine_twice.jl"), + l2=[0.00020547512522578292], + linf=[0.007831753383083506]) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end @trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_coarsen_twice.jl"), - l2 = [0.0014321062757891826], - linf = [0.0253454486893413]) + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_amr_coarsen_twice.jl"), + l2=[0.0014321062757891826], + linf=[0.0253454486893413]) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end @trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], - linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5], - rtol = 0.001) + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511766445e-6, + 2.318888155713922e-6, + 2.3188881557894307e-6, + 6.3327863238858925e-6, + ], + linf=[ + 1.498738264560373e-5, + 1.9182011928187137e-5, + 1.918201192685487e-5, + 6.0526717141407005e-5, + ], + rtol=0.001) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end @trixi_testset "elixir_euler_ec.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_euler_ec.jl"), - l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], - linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_euler_ec.jl"), + l2=[ + 0.061751715597716854, + 0.05018223615408711, + 0.05018989446443463, + 0.225871559730513, + ], + linf=[ + 0.29347582879608825, + 0.31081249232844693, + 0.3107380389947736, + 1.0540358049885143, + ]) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end @trixi_testset "elixir_advection_diffusion.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_diffusion.jl"), - initial_refinement_level = 2, tspan = (0.0, 0.4), polydeg = 5, - alg = RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()), - l2 = [4.0915532997994255e-6], - linf = [2.3040850347877395e-5] - ) - - # 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)) < 5000 - end + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_diffusion.jl"), + initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5, + alg=RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()), + l2=[4.0915532997994255e-6], + linf=[2.3040850347877395e-5]) + + # 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)) < 5000 + end end @trixi_testset "FDSBP, elixir_advection_extended.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_fdsbp", "elixir_advection_extended.jl"), - l2 = [2.898644263922225e-6], - linf = [8.491517930142578e-6], - rtol = 1.0e-7) # These results change a little bit and depend on the CI system - - # 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)) < 5000 - end + @test_trixi_include(joinpath(examples_dir(), "tree_2d_fdsbp", + "elixir_advection_extended.jl"), + l2=[2.898644263922225e-6], + linf=[8.491517930142578e-6], + rtol=1.0e-7) # These results change a little bit and depend on the CI system + + # 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)) < 5000 + end end @trixi_testset "FDSBP, elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_fdsbp", "elixir_euler_convergence.jl"), - l2 = [1.7088389997042244e-6, 1.7437997855125774e-6, 1.7437997855350776e-6, 5.457223460127621e-6], - linf = [9.796504903736292e-6, 9.614745892783105e-6, 9.614745892783105e-6, 4.026107182575345e-5], - tspan = (0.0, 0.1)) - - # 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)) < 5000 - end - end - end + @test_trixi_include(joinpath(examples_dir(), "tree_2d_fdsbp", + "elixir_euler_convergence.jl"), + l2=[ + 1.7088389997042244e-6, + 1.7437997855125774e-6, + 1.7437997855350776e-6, + 5.457223460127621e-6, + ], + linf=[ + 9.796504903736292e-6, + 9.614745892783105e-6, + 9.614745892783105e-6, + 4.026107182575345e-5, + ], + tspan=(0.0, 0.1)) + # 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)) < 5000 + end + end +end - @testset "StructuredMesh" begin +@testset "StructuredMesh" begin @trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin - @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", "elixir_advection_restart.jl"), - l2 = [0.00016265538265929818], - linf = [0.0015194252169410394], - rtol = 5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) - elixir_file="elixir_advection_waving_flag.jl", - restart_file="restart_000021.h5") + @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", + "elixir_advection_restart.jl"), + l2=[0.00016265538265929818], + linf=[0.0015194252169410394], + rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS) + elixir_file="elixir_advection_waving_flag.jl", + restart_file="restart_000021.h5") # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end @trixi_testset "elixir_mhd_ec.jl" begin - @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", "elixir_mhd_ec.jl"), - l2 = [0.04937480811868297, 0.06117033019988596, 0.060998028674664716, 0.03155145889799417, - 0.2319175391388658, 0.02476283192966346, 0.024483244374818587, 0.035439957899127385, - 0.0016022148194667542], - linf = [0.24749024430983746, 0.2990608279625713, 0.3966937932860247, 0.22265033744519683, - 0.9757376320946505, 0.12123736788315098, 0.12837436699267113, 0.17793825293524734, - 0.03460761690059514], - tspan = (0.0, 0.3)) + @test_trixi_include(joinpath(examples_dir(), "structured_2d_dgsem", + "elixir_mhd_ec.jl"), + l2=[0.04937480811868297, 0.06117033019988596, + 0.060998028674664716, 0.03155145889799417, + 0.2319175391388658, 0.02476283192966346, + 0.024483244374818587, 0.035439957899127385, + 0.0016022148194667542], + linf=[0.24749024430983746, 0.2990608279625713, + 0.3966937932860247, 0.22265033744519683, + 0.9757376320946505, 0.12123736788315098, + 0.12837436699267113, 0.17793825293524734, + 0.03460761690059514], + tspan=(0.0, 0.3)) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end - end - +end - @testset "UnstructuredMesh" begin +@testset "UnstructuredMesh" begin @trixi_testset "elixir_acoustics_gauss_wall.jl" begin - @test_trixi_include(joinpath(examples_dir(), "unstructured_2d_dgsem", "elixir_acoustics_gauss_wall.jl"), - l2 = [0.029330394861252995, 0.029345079728907965, 0.03803795043486467, 0.0, - 7.175152371650832e-16, 1.4350304743301665e-15, 1.4350304743301665e-15], - linf = [0.36236334472179443, 0.3690785638275256, 0.8475748723784078, 0.0, - 8.881784197001252e-16, 1.7763568394002505e-15, 1.7763568394002505e-15], - tspan = (0.0, 5.0)) + @test_trixi_include(joinpath(examples_dir(), "unstructured_2d_dgsem", + "elixir_acoustics_gauss_wall.jl"), + l2=[0.029330394861252995, 0.029345079728907965, + 0.03803795043486467, 0.0, + 7.175152371650832e-16, 1.4350304743301665e-15, + 1.4350304743301665e-15], + linf=[0.36236334472179443, 0.3690785638275256, + 0.8475748723784078, 0.0, + 8.881784197001252e-16, 1.7763568394002505e-15, + 1.7763568394002505e-15], + tspan=(0.0, 5.0)) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end - end - +end - @testset "P4estMesh" begin +@testset "P4estMesh" begin @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) # 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)) < 5000 + t = sol.t[end] + u_ode = sol.u[end] + du_ode = similar(u_ode) + @test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000 end end @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_eulergravity_convergence.jl"), + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) end - end - +end - @testset "T8codeMesh" begin +@testset "T8codeMesh" begin @trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin - @test_trixi_include(joinpath(examples_dir(), "t8code_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - l2 = [0.0034516244508588046, 0.0023420334036925493, 0.0024261923964557187, 0.004731710454271893], - linf = [0.04155789011775046, 0.024772109862748914, 0.03759938693042297, 0.08039824959535657]) + @test_trixi_include(joinpath(examples_dir(), "t8code_2d_dgsem", + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + l2=[ + 0.0034516244508588046, + 0.0023420334036925493, + 0.0024261923964557187, + 0.004731710454271893, + ], + linf=[ + 0.04155789011775046, + 0.024772109862748914, + 0.03759938693042297, + 0.08039824959535657, + ]) end @trixi_testset "elixir_eulergravity_convergence.jl" begin - @test_trixi_include(joinpath(examples_dir(), "t8code_2d_dgsem", "elixir_eulergravity_convergence.jl"), - l2 = [0.00024871265138964204, 0.0003370077102132591, 0.0003370077102131964, 0.0007231525513793697], - linf = [0.0015813032944647087, 0.0020494288423820173, 0.0020494288423824614, 0.004793821195083758], - tspan = (0.0, 0.1)) + @test_trixi_include(joinpath(examples_dir(), "t8code_2d_dgsem", + "elixir_eulergravity_convergence.jl"), + l2=[ + 0.00024871265138964204, + 0.0003370077102132591, + 0.0003370077102131964, + 0.0007231525513793697, + ], + linf=[ + 0.0015813032944647087, + 0.0020494288423820173, + 0.0020494288423824614, + 0.004793821195083758, + ], + tspan=(0.0, 0.1)) end - end - +end - @testset "DGMulti" begin +@testset "DGMulti" begin @trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_weakform.jl"), - cells_per_dimension = (4, 4), - volume_integral = VolumeIntegralFluxDifferencing(flux_ranocha), - surface_integral = SurfaceIntegralWeakForm(flux_ranocha), - approximation_type = SBP(), - l2 = [0.006400337855843578, 0.005303799804137764, 0.005303799804119745, 0.013204169007030144], - linf = [0.03798302318566282, 0.05321027922532284, 0.05321027922605448, 0.13392025411839015], - ) - - # 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)) < 5000 - end + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_weakform.jl"), + cells_per_dimension=(4, 4), + volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha), + surface_integral=SurfaceIntegralWeakForm(flux_ranocha), + approximation_type=SBP(), + l2=[ + 0.006400337855843578, + 0.005303799804137764, + 0.005303799804119745, + 0.013204169007030144, + ], + linf=[ + 0.03798302318566282, + 0.05321027922532284, + 0.05321027922605448, + 0.13392025411839015, + ],) + + # 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)) < 5000 + end end @trixi_testset "elixir_euler_curved.jl with threaded time integration" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_curved.jl"), - alg = RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()), - l2 = [1.720476068165337e-5, 1.592168205710526e-5, 1.592168205812963e-5, 4.894094865697305e-5], - linf = [0.00010525416930584619, 0.00010003778091061122, 0.00010003778085621029, 0.00036426282101720275] - ) - - # 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)) < 5000 - end + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_curved.jl"), + alg=RDPK3SpFSAL49(thread = OrdinaryDiffEq.True()), + l2=[ + 1.720476068165337e-5, + 1.592168205710526e-5, + 1.592168205812963e-5, + 4.894094865697305e-5, + ], + linf=[ + 0.00010525416930584619, + 0.00010003778091061122, + 0.00010003778085621029, + 0.00036426282101720275, + ]) + + # 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)) < 5000 + end end @trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_triangulate_pkg_mesh.jl"), - l2 = [2.344080455438114e-6, 1.8610038753097983e-6, 2.4095165666095305e-6, 6.373308158814308e-6], - linf = [2.5099852761334418e-5, 2.2683684021362893e-5, 2.6180448559287584e-5, 5.5752932611508044e-5] - ) - - # 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)) < 5000 - end + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_triangulate_pkg_mesh.jl"), + l2=[ + 2.344080455438114e-6, + 1.8610038753097983e-6, + 2.4095165666095305e-6, + 6.373308158814308e-6, + ], + linf=[ + 2.5099852761334418e-5, + 2.2683684021362893e-5, + 2.6180448559287584e-5, + 5.5752932611508044e-5, + ]) + + # 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)) < 5000 + end end @trixi_testset "elixir_euler_fdsbp_periodic.jl" begin - @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", "elixir_euler_fdsbp_periodic.jl"), - l2 = [1.3333320340010056e-6, 2.044834627970641e-6, 2.044834627855601e-6, 5.282189803559564e-6], - linf = [2.7000151718858945e-6, 3.988595028259212e-6, 3.9885950273710336e-6, 8.848583042286862e-6] - ) - - # 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)) < 5000 - end + @test_trixi_include(joinpath(examples_dir(), "dgmulti_2d", + "elixir_euler_fdsbp_periodic.jl"), + l2=[ + 1.3333320340010056e-6, + 2.044834627970641e-6, + 2.044834627855601e-6, + 5.282189803559564e-6, + ], + linf=[ + 2.7000151718858945e-6, + 3.988595028259212e-6, + 3.9885950273710336e-6, + 8.848583042286862e-6, + ]) + + # 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)) < 5000 + end end - end +end end # Clean up afterwards: delete Trixi.jl output directory -Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive=true) +Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_tree_1d.jl b/test/test_tree_1d.jl index 7737a93a15a..4654f6313f7 100644 --- a/test/test_tree_1d.jl +++ b/test/test_tree_1d.jl @@ -9,275 +9,289 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh1D" begin +#! format: noindent # Run basic tests @testset "Examples 1D" begin - # Linear scalar advection - include("test_tree_1d_advection.jl") + # Linear scalar advection + include("test_tree_1d_advection.jl") - # Burgers - include("test_tree_1d_burgers.jl") + # Burgers + include("test_tree_1d_burgers.jl") - # Hyperbolic diffusion - include("test_tree_1d_hypdiff.jl") + # Hyperbolic diffusion + include("test_tree_1d_hypdiff.jl") - # Compressible Euler - include("test_tree_1d_euler.jl") + # Compressible Euler + include("test_tree_1d_euler.jl") - # Compressible Euler Multicomponent - include("test_tree_1d_eulermulti.jl") + # Compressible Euler Multicomponent + include("test_tree_1d_eulermulti.jl") - # MHD - include("test_tree_1d_mhd.jl") + # MHD + include("test_tree_1d_mhd.jl") - # MHD Multicomponent - include("test_tree_1d_mhdmulti.jl") + # MHD Multicomponent + include("test_tree_1d_mhdmulti.jl") - # Compressible Euler with self-gravity - include("test_tree_1d_eulergravity.jl") + # Compressible Euler with self-gravity + include("test_tree_1d_eulergravity.jl") - # Shallow water - include("test_tree_1d_shallowwater.jl") - # Two-layer Shallow Water - include("test_tree_1d_shallowwater_twolayer.jl") + # Shallow water + include("test_tree_1d_shallowwater.jl") + # Two-layer Shallow Water + include("test_tree_1d_shallowwater_twolayer.jl") - # FDSBP methods on the TreeMesh - include("test_tree_1d_fdsbp.jl") + # FDSBP methods on the TreeMesh + include("test_tree_1d_fdsbp.jl") end # Coverage test for all initial conditions @testset "Tests for initial conditions" begin - # Linear scalar advection - @trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.00017373554109980247], - linf = [0.0006021275678165239], - maxiters = 1, - initial_condition = Trixi.initial_condition_sin) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [2.441369287653687e-16], - linf = [4.440892098500626e-16], - maxiters = 1, - initial_condition = initial_condition_constant) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.9882464973192864e-16], - linf = [1.4432899320127035e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_x, - boundary_conditions = Trixi.boundary_condition_linear_x, - periodicity=false) - end - - @trixi_testset "elixir_advection_extended.jl with initial_condition_convergence_test" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [6.1803596620800215e-6], - linf = [2.4858560899509996e-5], - maxiters = 1, - initial_condition = initial_condition_convergence_test, - boundary_conditions = BoundaryConditionDirichlet(initial_condition_convergence_test), - periodicity=false) - end -end + # Linear scalar advection + @trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[0.00017373554109980247], + linf=[0.0006021275678165239], + maxiters=1, + initial_condition=Trixi.initial_condition_sin) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[2.441369287653687e-16], + linf=[4.440892098500626e-16], + maxiters=1, + initial_condition=initial_condition_constant) + end + + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[1.9882464973192864e-16], + linf=[1.4432899320127035e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_x, + boundary_conditions=Trixi.boundary_condition_linear_x, + periodicity=false) + end + @trixi_testset "elixir_advection_extended.jl with initial_condition_convergence_test" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[6.1803596620800215e-6], + linf=[2.4858560899509996e-5], + maxiters=1, + initial_condition=initial_condition_convergence_test, + boundary_conditions=BoundaryConditionDirichlet(initial_condition_convergence_test), + periodicity=false) + end +end @testset "Displaying components 1D" begin - @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) - - # test both short and long printing formats - @test_nowarn show(mesh); println() - @test_nowarn println(mesh) - @test_nowarn display(mesh) - - @test_nowarn show(equations); println() - @test_nowarn println(equations) - @test_nowarn display(equations) - - @test_nowarn show(solver); println() - @test_nowarn println(solver) - @test_nowarn display(solver) - - @test_nowarn show(solver.basis); println() - @test_nowarn println(solver.basis) - @test_nowarn display(solver.basis) - - @test_nowarn show(solver.mortar); println() - @test_nowarn println(solver.mortar) - @test_nowarn display(solver.mortar) - - @test_nowarn show(solver.volume_integral); println() - @test_nowarn println(solver.volume_integral) - @test_nowarn display(solver.volume_integral) - - @test_nowarn show(semi); println() - @test_nowarn println(semi) - @test_nowarn display(semi) - - @test_nowarn show(summary_callback); println() - @test_nowarn println(summary_callback) - @test_nowarn display(summary_callback) - - @test_nowarn show(amr_controller); println() - @test_nowarn println(amr_controller) - @test_nowarn display(amr_controller) - - @test_nowarn show(amr_callback); println() - @test_nowarn println(amr_callback) - @test_nowarn display(amr_callback) - - @test_nowarn show(stepsize_callback); println() - @test_nowarn println(stepsize_callback) - @test_nowarn display(stepsize_callback) - - @test_nowarn show(save_solution); println() - @test_nowarn println(save_solution) - @test_nowarn display(save_solution) - - @test_nowarn show(analysis_callback); println() - @test_nowarn println(analysis_callback) - @test_nowarn display(analysis_callback) - - @test_nowarn show(alive_callback); println() - @test_nowarn println(alive_callback) - @test_nowarn display(alive_callback) - - @test_nowarn println(callbacks) - - # Check whether all output is suppressed if the summary, analysis and alive - # callbacks are set to the TrivialCallback(). Modelled using `@test_nowarn` - # as basis. - let fname = tempname() - try - open(fname, "w") do f - redirect_stderr(f) do - trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - summary_callback=TrivialCallback(), - analysis_callback=TrivialCallback(), - alive_callback=TrivialCallback()) + @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) + + # test both short and long printing formats + @test_nowarn show(mesh) + println() + @test_nowarn println(mesh) + @test_nowarn display(mesh) + + @test_nowarn show(equations) + println() + @test_nowarn println(equations) + @test_nowarn display(equations) + + @test_nowarn show(solver) + println() + @test_nowarn println(solver) + @test_nowarn display(solver) + + @test_nowarn show(solver.basis) + println() + @test_nowarn println(solver.basis) + @test_nowarn display(solver.basis) + + @test_nowarn show(solver.mortar) + println() + @test_nowarn println(solver.mortar) + @test_nowarn display(solver.mortar) + + @test_nowarn show(solver.volume_integral) + println() + @test_nowarn println(solver.volume_integral) + @test_nowarn display(solver.volume_integral) + + @test_nowarn show(semi) + println() + @test_nowarn println(semi) + @test_nowarn display(semi) + + @test_nowarn show(summary_callback) + println() + @test_nowarn println(summary_callback) + @test_nowarn display(summary_callback) + + @test_nowarn show(amr_controller) + println() + @test_nowarn println(amr_controller) + @test_nowarn display(amr_controller) + + @test_nowarn show(amr_callback) + println() + @test_nowarn println(amr_callback) + @test_nowarn display(amr_callback) + + @test_nowarn show(stepsize_callback) + println() + @test_nowarn println(stepsize_callback) + @test_nowarn display(stepsize_callback) + + @test_nowarn show(save_solution) + println() + @test_nowarn println(save_solution) + @test_nowarn display(save_solution) + + @test_nowarn show(analysis_callback) + println() + @test_nowarn println(analysis_callback) + @test_nowarn display(analysis_callback) + + @test_nowarn show(alive_callback) + println() + @test_nowarn println(alive_callback) + @test_nowarn display(alive_callback) + + @test_nowarn println(callbacks) + + # Check whether all output is suppressed if the summary, analysis and alive + # callbacks are set to the TrivialCallback(). Modelled using `@test_nowarn` + # as basis. + let fname = tempname() + try + open(fname, "w") do f + redirect_stderr(f) do + trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_extended.jl"), + summary_callback = TrivialCallback(), + analysis_callback = TrivialCallback(), + alive_callback = TrivialCallback()) + end + end + output = read(fname, String) + output = replace(output, + "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n" => "") + @test isempty(output) + finally + rm(fname, force = true) end - end - output = read(fname, String) - output = replace(output, "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n" => "") - @test isempty(output) - finally - rm(fname, force=true) end - end end - @testset "Additional tests in 1D" begin - @testset "compressible Euler" begin - eqn = CompressibleEulerEquations1D(1.4) + @testset "compressible Euler" begin + eqn = CompressibleEulerEquations1D(1.4) - @test isapprox(Trixi.entropy_thermodynamic([1.0, 2.0, 20.0], eqn), 1.9740810260220094) - @test isapprox(Trixi.entropy_math([1.0, 2.0, 20.0], eqn), -4.935202565055024) - @test isapprox(Trixi.entropy([1.0, 2.0, 20.0], eqn), -4.935202565055024) + @test isapprox(Trixi.entropy_thermodynamic([1.0, 2.0, 20.0], eqn), + 1.9740810260220094) + @test isapprox(Trixi.entropy_math([1.0, 2.0, 20.0], eqn), -4.935202565055024) + @test isapprox(Trixi.entropy([1.0, 2.0, 20.0], eqn), -4.935202565055024) - @test isapprox(energy_total([1.0, 2.0, 20.0], eqn), 20.0) - @test isapprox(energy_kinetic([1.0, 2.0, 20.0], eqn), 2.0) - @test isapprox(energy_internal([1.0, 2.0, 20.0], eqn), 18.0) - end + @test isapprox(energy_total([1.0, 2.0, 20.0], eqn), 20.0) + @test isapprox(energy_kinetic([1.0, 2.0, 20.0], eqn), 2.0) + @test isapprox(energy_internal([1.0, 2.0, 20.0], eqn), 18.0) + end end @trixi_testset "Nonconservative terms in 1D (linear advection)" begin - # Same setup as docs/src/adding_new_equations/nonconservative_advection.md + # Same setup as docs/src/adding_new_equations/nonconservative_advection.md - # Define new physics - using Trixi - using Trixi: AbstractEquations, get_node_vars - - # Since there is no native support for variable coefficients, we use two - # variables: one for the basic unknown `u` and another one for the coefficient `a` - struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1 #= spatial dimension =#, - 2 #= two variables (u,a) =#} - end - - Trixi.varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", "advection_velocity") - - Trixi.default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () + # Define new physics + using Trixi + using Trixi: AbstractEquations, get_node_vars + # Since there is no native support for variable coefficients, we use two + # variables: one for the basic unknown `u` and another one for the coefficient `a` + struct NonconservativeLinearAdvectionEquation <: AbstractEquations{1, #= spatial dimension =# + 2} #= two variables (u,a) =# + end - # The conservative part of the flux is zero - Trixi.flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) + Trixi.varnames(::typeof(cons2cons), ::NonconservativeLinearAdvectionEquation) = ("scalar", + "advection_velocity") - # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation - function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, ::NonconservativeLinearAdvectionEquation) - _, advection_velocity_ll = u_ll - _, advection_velocity_rr = u_rr + Trixi.default_analysis_integrals(::NonconservativeLinearAdvectionEquation) = () - return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) - end + # The conservative part of the flux is zero + Trixi.flux(u, orientation, equation::NonconservativeLinearAdvectionEquation) = zero(u) + # Calculate maximum wave speed for local Lax-Friedrichs-type dissipation + function Trixi.max_abs_speed_naive(u_ll, u_rr, orientation::Integer, + ::NonconservativeLinearAdvectionEquation) + _, advection_velocity_ll = u_ll + _, advection_velocity_rr = u_rr - # We use nonconservative terms - Trixi.have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() + return max(abs(advection_velocity_ll), abs(advection_velocity_rr)) + end - function flux_nonconservative(u_mine, u_other, orientation, - equations::NonconservativeLinearAdvectionEquation) - _, advection_velocity = u_mine - scalar, _ = u_other + # We use nonconservative terms + Trixi.have_nonconservative_terms(::NonconservativeLinearAdvectionEquation) = Trixi.True() - return SVector(advection_velocity * scalar, zero(scalar)) - end + function flux_nonconservative(u_mine, u_other, orientation, + equations::NonconservativeLinearAdvectionEquation) + _, advection_velocity = u_mine + scalar, _ = u_other + return SVector(advection_velocity * scalar, zero(scalar)) + end - # Create a simulation setup - using Trixi - using OrdinaryDiffEq + # Create a simulation setup + using Trixi + using OrdinaryDiffEq - equation = NonconservativeLinearAdvectionEquation() + equation = NonconservativeLinearAdvectionEquation() - # You can derive the exact solution for this setup using the method of - # characteristics - function initial_condition_sine(x, t, equation::NonconservativeLinearAdvectionEquation) - x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) - scalar = sin(x0) - advection_velocity = 2 + cos(x[1]) - SVector(scalar, advection_velocity) - end + # You can derive the exact solution for this setup using the method of + # characteristics + function initial_condition_sine(x, t, + equation::NonconservativeLinearAdvectionEquation) + x0 = -2 * atan(sqrt(3) * tan(sqrt(3) / 2 * t - atan(tan(x[1] / 2) / sqrt(3)))) + scalar = sin(x0) + advection_velocity = 2 + cos(x[1]) + SVector(scalar, advection_velocity) + end - # Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries - mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates - initial_refinement_level=4, n_cells_max=10^4) + # Create a uniform mesh in 1D in the interval [-π, π] with periodic boundaries + mesh = TreeMesh(-Float64(π), Float64(π), # min/max coordinates + initial_refinement_level = 4, n_cells_max = 10^4) - # Create a DGSEM solver with polynomials of degree `polydeg` - volume_flux = (flux_central, flux_nonconservative) - surface_flux = (flux_lax_friedrichs, flux_nonconservative) - solver = DGSEM(polydeg=3, surface_flux=surface_flux, - volume_integral=VolumeIntegralFluxDifferencing(volume_flux)) + # Create a DGSEM solver with polynomials of degree `polydeg` + volume_flux = (flux_central, flux_nonconservative) + surface_flux = (flux_lax_friedrichs, flux_nonconservative) + solver = DGSEM(polydeg = 3, surface_flux = surface_flux, + volume_integral = VolumeIntegralFluxDifferencing(volume_flux)) - # Setup the spatial semidiscretization containing all ingredients - semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) + # Setup the spatial semidiscretization containing all ingredients + semi = SemidiscretizationHyperbolic(mesh, equation, initial_condition_sine, solver) - # Create an ODE problem with given time span - tspan = (0.0, 1.0) - ode = semidiscretize(semi, tspan); + # Create an ODE problem with given time span + tspan = (0.0, 1.0) + ode = semidiscretize(semi, tspan) - summary_callback = SummaryCallback() - analysis_callback = AnalysisCallback(semi, interval=50) - callbacks = CallbackSet(summary_callback, analysis_callback); + summary_callback = SummaryCallback() + analysis_callback = AnalysisCallback(semi, interval = 50) + callbacks = CallbackSet(summary_callback, analysis_callback) - # OrdinaryDiffEq's `solve` method evolves the solution in time and executes - # the passed callbacks - sol = solve(ode, Tsit5(), abstol=1.0e-6, reltol=1.0e-6, - save_everystep=false, callback=callbacks); + # OrdinaryDiffEq's `solve` method evolves the solution in time and executes + # the passed callbacks + sol = solve(ode, Tsit5(), abstol = 1.0e-6, reltol = 1.0e-6, + save_everystep = false, callback = callbacks) - @test analysis_callback(sol).l2 ≈ [0.00029609575838969394, 5.5681704039507985e-6] + @test analysis_callback(sol).l2 ≈ [0.00029609575838969394, 5.5681704039507985e-6] end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh1D end # module diff --git a/test/test_tree_1d_advection.jl b/test/test_tree_1d_advection.jl index 681fea4a8ae..7cfd78e0ade 100644 --- a/test/test_tree_1d_advection.jl +++ b/test/test_tree_1d_advection.jl @@ -8,63 +8,65 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - l2 = [6.0388296447998465e-6], - linf = [3.217887726258972e-5]) - # 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 + l2=[6.0388296447998465e-6], + linf=[3.217887726258972e-5]) + # 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_advection_amr.jl" begin +@trixi_testset "elixir_advection_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - l2 = [0.3540206249507417], - linf = [0.9999896603382347], - coverage_override = (maxiters=6,)) - # 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 + l2=[0.3540206249507417], + linf=[0.9999896603382347], + coverage_override=(maxiters = 6,)) + # 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_advection_amr_nonperiodic.jl" begin +@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - l2 = [4.283508859843524e-6], - linf = [3.235356127918171e-5], - coverage_override = (maxiters=6,)) - # 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 + l2=[4.283508859843524e-6], + linf=[3.235356127918171e-5], + coverage_override=(maxiters = 6,)) + # 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_advection_finite_volume.jl" begin +@trixi_testset "elixir_advection_finite_volume.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"), - l2 = [0.011662300515980219], - linf = [0.01647256923710194]) - # 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 + l2=[0.011662300515980219], + linf=[0.01647256923710194]) + # 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 end # module diff --git a/test/test_tree_1d_burgers.jl b/test/test_tree_1d_burgers.jl index eb4ece05b7e..56e1ee749f7 100644 --- a/test/test_tree_1d_burgers.jl +++ b/test/test_tree_1d_burgers.jl @@ -8,61 +8,63 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Inviscid Burgers" begin - @trixi_testset "elixir_burgers_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_burgers_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2 = [2.967470209082194e-5], - linf = [0.00016152468882624227]) - # 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 + l2=[2.967470209082194e-5], + linf=[0.00016152468882624227]) + # 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_burgers_linear_stability.jl" begin +@trixi_testset "elixir_burgers_linear_stability.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), - l2 = [0.5660569881106876], - linf = [1.9352238038313998]) - # 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 + l2=[0.5660569881106876], + linf=[1.9352238038313998]) + # 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_burgers_shock.jl" begin +@trixi_testset "elixir_burgers_shock.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_shock.jl"), - l2 = [0.4422505602587537], - linf = [1.0000000000000009]) - # 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 + l2=[0.4422505602587537], + linf=[1.0000000000000009]) + # 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_burgers_rarefaction.jl" begin +@trixi_testset "elixir_burgers_rarefaction.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_rarefaction.jl"), - l2 = [0.4038224690923722], - linf = [1.0049201454652736]) - # 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 + l2=[0.4038224690923722], + linf=[1.0049201454652736]) + # 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 end # module diff --git a/test/test_tree_1d_euler.jl b/test/test_tree_1d_euler.jl index 92a917d0622..f01124509cb 100644 --- a/test/test_tree_1d_euler.jl +++ b/test/test_tree_1d_euler.jl @@ -8,281 +8,395 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin +#! format: noindent + +@trixi_testset "elixir_euler_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [2.2527950196212703e-8, 1.8187357193835156e-8, 7.705669939973104e-8], - linf = [1.6205433861493646e-7, 1.465427772462391e-7, 5.372255111879554e-7]) - # 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 + l2=[ + 2.2527950196212703e-8, + 1.8187357193835156e-8, + 7.705669939973104e-8, + ], + linf=[ + 1.6205433861493646e-7, + 1.465427772462391e-7, + 5.372255111879554e-7, + ]) + # 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_euler_convergence_pure_fv.jl" begin +@trixi_testset "elixir_euler_convergence_pure_fv.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2 = [0.019355699748523896, 0.022326984561234497, 0.02523665947241734], - linf = [0.02895961127645519, 0.03293442484199227, 0.04246098278632804]) - # 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 + l2=[ + 0.019355699748523896, + 0.022326984561234497, + 0.02523665947241734, + ], + linf=[ + 0.02895961127645519, + 0.03293442484199227, + 0.04246098278632804, + ]) + # 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_euler_density_wave.jl" begin +@trixi_testset "elixir_euler_density_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [0.0011482554820217855, 0.00011482554830323462, 5.741277429325267e-6], - linf = [0.004090978306812376, 0.0004090978313582294, 2.045489210189544e-5]) - # 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 + l2=[ + 0.0011482554820217855, + 0.00011482554830323462, + 5.741277429325267e-6, + ], + linf=[ + 0.004090978306812376, + 0.0004090978313582294, + 2.045489210189544e-5, + ]) + # 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_euler_density_wave.jl with initial_condition_constant" begin +@trixi_testset "elixir_euler_density_wave.jl with initial_condition_constant" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [7.71293052584723e-16, 1.9712947511091717e-14, 7.50672833504266e-15], - linf = [3.774758283725532e-15, 6.733502644351574e-14, 2.4868995751603507e-14], - initial_condition = initial_condition_constant) - # 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 + l2=[ + 7.71293052584723e-16, + 1.9712947511091717e-14, + 7.50672833504266e-15, + ], + linf=[ + 3.774758283725532e-15, + 6.733502644351574e-14, + 2.4868995751603507e-14, + ], + initial_condition=initial_condition_constant) + # 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_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [3.8099996914101204e-6, 1.6745575717106341e-6, 7.732189531480852e-6], - linf = [1.2971473393186272e-5, 9.270328934274374e-6, 3.092514399671842e-5]) - # 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_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 3.8099996914101204e-6, + 1.6745575717106341e-6, + 7.732189531480852e-6, + ], + linf=[ + 1.2971473393186272e-5, + 9.270328934274374e-6, + 3.092514399671842e-5, + ]) + # 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_euler_ec.jl" begin +@trixi_testset "elixir_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.11821957357197649, 0.15330089521538678, 0.4417674632047301], - linf = [0.24280567569982958, 0.29130548795961936, 0.8847009003152442]) - # 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 + l2=[ + 0.11821957357197649, + 0.15330089521538678, + 0.4417674632047301, + ], + linf=[ + 0.24280567569982958, + 0.29130548795961936, + 0.8847009003152442, + ]) + # 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_euler_ec.jl with flux_kennedy_gruber" begin +@trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07803455838661963, 0.10032577312032283, 0.29228156303827935], - linf = [0.2549869853794955, 0.3376472164661263, 0.9650477546553962], - maxiters = 10, - surface_flux = flux_kennedy_gruber, - volume_flux = flux_kennedy_gruber) - # 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 + l2=[ + 0.07803455838661963, + 0.10032577312032283, + 0.29228156303827935, + ], + linf=[ + 0.2549869853794955, + 0.3376472164661263, + 0.9650477546553962, + ], + maxiters=10, + surface_flux=flux_kennedy_gruber, + volume_flux=flux_kennedy_gruber) + # 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_euler_ec.jl with flux_shima_etal" begin +@trixi_testset "elixir_euler_ec.jl with flux_shima_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07800654460172655, 0.10030365573277883, 0.2921481199111959], - linf = [0.25408579350400395, 0.3388657679031271, 0.9776486386921928], - maxiters = 10, - surface_flux = flux_shima_etal, - volume_flux = flux_shima_etal) - # 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 + l2=[ + 0.07800654460172655, + 0.10030365573277883, + 0.2921481199111959, + ], + linf=[ + 0.25408579350400395, + 0.3388657679031271, + 0.9776486386921928, + ], + maxiters=10, + surface_flux=flux_shima_etal, + volume_flux=flux_shima_etal) + # 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_euler_ec.jl with flux_chandrashekar" begin +@trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07801923089205756, 0.10039557434912669, 0.2922210399923278], - linf = [0.2576521982607225, 0.3409717926625057, 0.9772961936567048], - maxiters = 10, - surface_flux = flux_chandrashekar, - volume_flux = flux_chandrashekar) - # 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 + l2=[ + 0.07801923089205756, + 0.10039557434912669, + 0.2922210399923278, + ], + linf=[ + 0.2576521982607225, + 0.3409717926625057, + 0.9772961936567048, + ], + maxiters=10, + surface_flux=flux_chandrashekar, + volume_flux=flux_chandrashekar) + # 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_euler_ec.jl with flux_hll" begin +@trixi_testset "elixir_euler_ec.jl with flux_hll" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.07852272782240548, 0.10209790867523805, 0.293873048809011], - linf = [0.19244768908604093, 0.2515941686151897, 0.7258000837553769], - maxiters = 10, - surface_flux = flux_hll, - volume_flux = flux_ranocha) - # 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 + l2=[0.07852272782240548, 0.10209790867523805, 0.293873048809011], + linf=[ + 0.19244768908604093, + 0.2515941686151897, + 0.7258000837553769, + ], + maxiters=10, + surface_flux=flux_hll, + volume_flux=flux_ranocha) + # 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_euler_shockcapturing.jl" begin +@trixi_testset "elixir_euler_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2 = [0.11606096465319675, 0.15028768943458806, 0.4328230323046703], - linf = [0.18031710091067965, 0.2351582421501841, 0.6776805692092567]) - # 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 + l2=[ + 0.11606096465319675, + 0.15028768943458806, + 0.4328230323046703, + ], + linf=[ + 0.18031710091067965, + 0.2351582421501841, + 0.6776805692092567, + ]) + # 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_euler_sedov_blast_wave.jl" begin +@trixi_testset "elixir_euler_sedov_blast_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [1.250005061244617, 0.06878411345533507, 0.9264328311018613], - linf = [2.9766770877037168, 0.16838100902295852, 2.6655773445485798], - coverage_override = (maxiters=6,)) - # 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 + l2=[1.250005061244617, 0.06878411345533507, 0.9264328311018613], + linf=[ + 2.9766770877037168, + 0.16838100902295852, + 2.6655773445485798, + ], + coverage_override=(maxiters = 6,)) + # 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_euler_sedov_blast_wave_pure_fv.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave_pure_fv.jl"), - l2 = [1.0735456065491455, 0.07131078703089379, 0.9205739468590453], - linf = [3.4296365168219216, 0.17635583964559245, 2.6574584326179505], - # Let this test run longer to cover some lines in flux_hllc - coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) - # 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_euler_sedov_blast_wave_pure_fv.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_sedov_blast_wave_pure_fv.jl"), + l2=[1.0735456065491455, 0.07131078703089379, 0.9205739468590453], + linf=[ + 3.4296365168219216, + 0.17635583964559245, + 2.6574584326179505, + ], + # Let this test run longer to cover some lines in flux_hllc + coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) + # 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_euler_sedov_blast_wave.jl with pressure" begin +@trixi_testset "elixir_euler_sedov_blast_wave.jl with pressure" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [1.297525985166995, 0.07964929522694145, 0.9269991156246368], - linf = [3.1773015255764427, 0.21331831536493773, 2.6650170188241047], - shock_indicator_variable = pressure, - cfl = 0.2, - coverage_override = (maxiters=6,)) - # 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 + l2=[1.297525985166995, 0.07964929522694145, 0.9269991156246368], + linf=[ + 3.1773015255764427, + 0.21331831536493773, + 2.6650170188241047, + ], + shock_indicator_variable=pressure, + cfl=0.2, + coverage_override=(maxiters = 6,)) + # 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_euler_sedov_blast_wave.jl with density" begin +@trixi_testset "elixir_euler_sedov_blast_wave.jl with density" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [1.2798798835860528, 0.07103461242058921, 0.9273792517187003], - linf = [3.1087017048015824, 0.17734706962928956, 2.666689753470263], - shock_indicator_variable = density, - cfl = 0.2, - coverage_override = (maxiters=6,)) - # 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 + l2=[1.2798798835860528, 0.07103461242058921, 0.9273792517187003], + linf=[ + 3.1087017048015824, + 0.17734706962928956, + 2.666689753470263, + ], + shock_indicator_variable=density, + cfl=0.2, + coverage_override=(maxiters = 6,)) + # 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_euler_positivity.jl" begin +@trixi_testset "elixir_euler_positivity.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), - l2 = [1.6493820253458906, 0.19793887460986834, 0.9783506076125921], - linf = [4.71751203912051, 0.5272411022735763, 2.7426163947635844], - coverage_override = (maxiters=3,)) - # 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 + l2=[1.6493820253458906, 0.19793887460986834, 0.9783506076125921], + linf=[4.71751203912051, 0.5272411022735763, 2.7426163947635844], + coverage_override=(maxiters = 3,)) + # 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_euler_blast_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), - l2 = [0.21934822867340323, 0.28131919126002686, 0.554361702716662], - linf = [1.5180897390290355, 1.3967085956620369, 2.0663825294019595], - maxiters = 30) - # 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_euler_blast_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), + l2=[0.21934822867340323, 0.28131919126002686, 0.554361702716662], + linf=[ + 1.5180897390290355, + 1.3967085956620369, + 2.0663825294019595, + ], + maxiters=30) + # 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_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), - l2 = [0.21814833203212694, 0.2818328665444332, 0.5528379124720818], - linf = [1.5548653877320868, 1.4474018998129738, 2.071919577393772], - maxiters = 30) - end +@trixi_testset "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), + l2=[0.21814833203212694, 0.2818328665444332, 0.5528379124720818], + linf=[1.5548653877320868, 1.4474018998129738, 2.071919577393772], + maxiters=30) +end - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2 = [0.22054468879127423, 0.2828269190680846, 0.5542369885642424], - linf = [1.5623359741479623, 1.4290121654488288, 2.1040405133123072], - maxiters = 30) - end +@trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2=[0.22054468879127423, 0.2828269190680846, 0.5542369885642424], + linf=[ + 1.5623359741479623, + 1.4290121654488288, + 2.1040405133123072, + ], + maxiters=30) +end end end # module diff --git a/test/test_tree_1d_eulergravity.jl b/test/test_tree_1d_eulergravity.jl index 7738d847d31..9ab5b287d0b 100644 --- a/test/test_tree_1d_eulergravity.jl +++ b/test/test_tree_1d_eulergravity.jl @@ -8,19 +8,29 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler with self-gravity" begin - @trixi_testset "elixir_eulergravity_convergence.jl" begin +#! format: noindent + +@trixi_testset "elixir_eulergravity_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.0002170799126638106, 0.0002913792848717502, 0.0006112320856262327], - linf = [0.0004977401033188222, 0.0013594223337776157, 0.002041891084400227]) - # 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 + l2=[ + 0.0002170799126638106, + 0.0002913792848717502, + 0.0006112320856262327, + ], + linf=[ + 0.0004977401033188222, + 0.0013594223337776157, + 0.002041891084400227, + ]) + # 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 end # module diff --git a/test/test_tree_1d_eulermulti.jl b/test/test_tree_1d_eulermulti.jl index 7e0d69cea1c..bd86de928e3 100644 --- a/test/test_tree_1d_eulermulti.jl +++ b/test/test_tree_1d_eulermulti.jl @@ -8,100 +8,130 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Compressible Euler Multicomponent" begin +#! format: noindent - @trixi_testset "elixir_eulermulti_ec.jl" begin +@trixi_testset "elixir_eulermulti_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), - l2 = [0.15330089521538684, 0.4417674632047301, 0.016888510510282385, 0.03377702102056477, - 0.06755404204112954], - linf = [0.29130548795961864, 0.8847009003152357, 0.034686525099975274, 0.06937305019995055, - 0.1387461003999011]) - # 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 + l2=[0.15330089521538684, 0.4417674632047301, + 0.016888510510282385, 0.03377702102056477, + 0.06755404204112954], + linf=[0.29130548795961864, 0.8847009003152357, + 0.034686525099975274, 0.06937305019995055, + 0.1387461003999011]) + # 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_eulermulti_es.jl" begin +@trixi_testset "elixir_eulermulti_es.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), - l2 = [0.1522380497572071, 0.43830846465313206, 0.03907262116499431, 0.07814524232998862], - linf = [0.24939193075537294, 0.7139395740052739, 0.06324208768391237, 0.12648417536782475]) - # 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 + l2=[ + 0.1522380497572071, + 0.43830846465313206, + 0.03907262116499431, + 0.07814524232998862, + ], + linf=[ + 0.24939193075537294, + 0.7139395740052739, + 0.06324208768391237, + 0.12648417536782475, + ]) + # 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_eulermulti_convergence_ec.jl" begin +@trixi_testset "elixir_eulermulti_convergence_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), - l2 = [8.575236038539227e-5, 0.00016387804318585358, 1.9412699303977585e-5, 3.882539860795517e-5], - linf = [0.00030593277277124464, 0.0006244803933350696, 7.253121435135679e-5, 0.00014506242870271358]) - # 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 + l2=[ + 8.575236038539227e-5, + 0.00016387804318585358, + 1.9412699303977585e-5, + 3.882539860795517e-5, + ], + linf=[ + 0.00030593277277124464, + 0.0006244803933350696, + 7.253121435135679e-5, + 0.00014506242870271358, + ]) + # 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_eulermulti_convergence_es.jl" begin +@trixi_testset "elixir_eulermulti_convergence_es.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [1.8983933794407234e-5, 6.207744299844731e-5, 1.5466205761868047e-6, 3.0932411523736094e-6, - 6.186482304747219e-6, 1.2372964609494437e-5], - linf = [0.00012014372605895218, 0.0003313207215800418, 6.50836791016296e-6, 1.301673582032592e-5, - 2.603347164065184e-5, 5.206694328130368e-5]) - # 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 + l2=[1.8983933794407234e-5, 6.207744299844731e-5, + 1.5466205761868047e-6, 3.0932411523736094e-6, + 6.186482304747219e-6, 1.2372964609494437e-5], + linf=[0.00012014372605895218, 0.0003313207215800418, + 6.50836791016296e-6, 1.301673582032592e-5, + 2.603347164065184e-5, 5.206694328130368e-5]) + # 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_eulermulti_convergence_es.jl with flux_chandrashekar" begin +@trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [1.888450477353845e-5, 5.4910600482795386e-5, 9.426737161533622e-7, 1.8853474323067245e-6, - 3.770694864613449e-6, 7.541389729226898e-6], - linf = [0.00011622351152063004, 0.0003079221967086099, 3.2177423254231563e-6, 6.435484650846313e-6, - 1.2870969301692625e-5, 2.574193860338525e-5], - volume_flux = flux_chandrashekar) - # 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 + l2=[1.888450477353845e-5, 5.4910600482795386e-5, + 9.426737161533622e-7, 1.8853474323067245e-6, + 3.770694864613449e-6, 7.541389729226898e-6], + linf=[0.00011622351152063004, 0.0003079221967086099, + 3.2177423254231563e-6, 6.435484650846313e-6, + 1.2870969301692625e-5, 2.574193860338525e-5], + volume_flux=flux_chandrashekar) + # 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_eulermulti_two_interacting_blast_waves.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_two_interacting_blast_waves.jl"), - l2 = [1.288867611915533, 82.71335258388848, 0.00350680272313187, 0.013698784353152794, - 0.019179518517518084], - linf = [29.6413044707026, 1322.5844802186496, 0.09191919374782143, 0.31092970966717925, - 0.4417989757182038], - tspan = (0.0, 0.0001)) - # 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_eulermulti_two_interacting_blast_waves.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulermulti_two_interacting_blast_waves.jl"), + l2=[1.288867611915533, 82.71335258388848, 0.00350680272313187, + 0.013698784353152794, + 0.019179518517518084], + linf=[29.6413044707026, 1322.5844802186496, 0.09191919374782143, + 0.31092970966717925, + 0.4417989757182038], + tspan=(0.0, 0.0001)) + # 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 end # module diff --git a/test/test_tree_1d_fdsbp.jl b/test/test_tree_1d_fdsbp.jl index d11bf277807..33d67e3366f 100644 --- a/test/test_tree_1d_fdsbp.jl +++ b/test/test_tree_1d_fdsbp.jl @@ -8,148 +8,185 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_fdsbp") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_upwind.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_upwind.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_upwind.jl"), - l2 = [1.7735637157305526e-6], - linf = [1.0418854521951328e-5], - tspan = (0.0, 0.5)) + l2=[1.7735637157305526e-6], + linf=[1.0418854521951328e-5], + tspan=(0.0, 0.5)) # 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 + 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_upwind_periodic.jl" begin +@trixi_testset "elixir_advection_upwind_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_upwind_periodic.jl"), - l2 = [1.1672962783692568e-5], - linf = [1.650514414558435e-5]) + l2=[1.1672962783692568e-5], + linf=[1.650514414558435e-5]) # 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 + 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 end @testset "Inviscid Burgers" begin - @trixi_testset "elixir_burgers_basic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2 = [8.316190308678742e-7], - linf = [7.1087263324720595e-6], - tspan = (0.0, 0.5)) + @trixi_testset "elixir_burgers_basic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2=[8.316190308678742e-7], + linf=[7.1087263324720595e-6], + tspan=(0.0, 0.5)) + + # 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 - # 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 + # same tolerances as above since the methods should be identical (up to + # machine precision) + @trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), + l2=[8.316190308678742e-7], + linf=[7.1087263324720595e-6], + tspan=(0.0, 0.5), + solver=DG(D_upw, nothing, + SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)), + VolumeIntegralUpwind(flux_splitting))) + end + + @trixi_testset "elixir_burgers_linear_stability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), + l2=[0.9999995642691271], + linf=[1.824702804788453], + tspan=(0.0, 0.25)) + + # 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 - - # same tolerances as above since the methods should be identical (up to - # machine precision) - @trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"), - l2 = [8.316190308678742e-7], - linf = [7.1087263324720595e-6], - tspan = (0.0, 0.5), - solver = DG(D_upw, nothing, SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)), VolumeIntegralUpwind(flux_splitting))) - end - - @trixi_testset "elixir_burgers_linear_stability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"), - l2 = [0.9999995642691271], - linf = [1.824702804788453], - tspan = (0.0, 0.25)) - - # 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 @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [4.1370344463620254e-6, 4.297052451817826e-6, 9.857382045003056e-6], - linf = [1.675305070092392e-5, 1.3448113863834266e-5, 3.8185336878271414e-5], - tspan = (0.0, 0.5)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 4.1370344463620254e-6, + 4.297052451817826e-6, + 9.857382045003056e-6, + ], + linf=[ + 1.675305070092392e-5, + 1.3448113863834266e-5, + 3.8185336878271414e-5, + ], + tspan=(0.0, 0.5)) + + # 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 - # 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 + @trixi_testset "elixir_euler_convergence.jl with splitting_vanleer_haenel" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 3.413790589105506e-6, + 4.243957977156001e-6, + 8.667369423676437e-6, + ], + linf=[ + 1.4228079689537765e-5, + 1.3249887941046978e-5, + 3.201552933251861e-5, + ], + tspan=(0.0, 0.5), + flux_splitting=splitting_vanleer_haenel) + + # 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_euler_convergence.jl with VolumeIntegralStrongForm" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 8.6126767518378e-6, + 7.670897071480729e-6, + 1.4972772284191368e-5, + ], + linf=[ + 6.707982777909294e-5, + 3.487256699541419e-5, + 0.00010170331350556339, + ], + tspan=(0.0, 0.5), + solver=DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), + VolumeIntegralStrongForm())) + + # 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_euler_density_wave.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), + l2=[ + 1.5894925236031034e-5, + 9.428412101106044e-6, + 0.0008986477358789918, + ], + linf=[ + 4.969438024382544e-5, + 2.393091812063694e-5, + 0.003271817388146303, + ], + tspan=(0.0, 0.005), abstol=1.0e-9, reltol=1.0e-9) + + # 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_euler_convergence.jl with splitting_vanleer_haenel" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [3.413790589105506e-6, 4.243957977156001e-6, 8.667369423676437e-6], - linf = [1.4228079689537765e-5, 1.3249887941046978e-5, 3.201552933251861e-5], - tspan = (0.0, 0.5), - flux_splitting = splitting_vanleer_haenel) - - # 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_euler_convergence.jl with VolumeIntegralStrongForm" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [8.6126767518378e-6, 7.670897071480729e-6, 1.4972772284191368e-5], - linf = [6.707982777909294e-5, 3.487256699541419e-5, 0.00010170331350556339], - tspan = (0.0, 0.5), - solver = DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), VolumeIntegralStrongForm())) - - # 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_euler_density_wave.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [1.5894925236031034e-5, 9.428412101106044e-6, 0.0008986477358789918], - linf = [4.969438024382544e-5, 2.393091812063694e-5, 0.003271817388146303], - tspan = (0.0, 0.005), abstol = 1.0e-9, reltol = 1.0e-9) - - # 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 end # module diff --git a/test/test_tree_1d_hypdiff.jl b/test/test_tree_1d_hypdiff.jl index 19200b26892..896a3d4c8d6 100644 --- a/test/test_tree_1d_hypdiff.jl +++ b/test/test_tree_1d_hypdiff.jl @@ -8,36 +8,38 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Hyperbolic diffusion" begin +#! format: noindent - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin +@trixi_testset "elixir_hypdiff_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [1.3655114954641076e-7, 1.0200345025539218e-6], - linf = [7.173286515893551e-7, 4.507116363683394e-6], - atol = 2.5e-13) - # 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 + l2=[1.3655114954641076e-7, 1.0200345025539218e-6], + linf=[7.173286515893551e-7, 4.507116363683394e-6], + atol=2.5e-13) + # 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_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [3.0130941075207524e-12, 2.6240829677090014e-12], - linf = [4.054534485931072e-12, 3.8826719617190975e-12], - atol = 2.5e-13) - # 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) +@trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[3.0130941075207524e-12, 2.6240829677090014e-12], + linf=[4.054534485931072e-12, 3.8826719617190975e-12], + atol=2.5e-13) + # 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)) < 10000 - end - end + end +end end end # module diff --git a/test/test_tree_1d_mhd.jl b/test/test_tree_1d_mhd.jl index 77158001275..b34bdf0660c 100644 --- a/test/test_tree_1d_mhd.jl +++ b/test/test_tree_1d_mhd.jl @@ -8,145 +8,309 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "MHD" begin +#! format: noindent - @trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin +@trixi_testset "elixir_mhd_alfven_wave.jl with initial_condition_constant" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.440611823425164e-15, 1.1373567770134494e-14, 3.024482376149653e-15, 2.0553143516814395e-15, 3.9938347410210535e-14, 3.984545392098788e-16, 2.4782402104201577e-15, 1.551737464879987e-15], - linf = [1.9984014443252818e-15, 1.3405943022348765e-14, 3.3584246494910985e-15, 3.164135620181696e-15, 7.815970093361102e-14, 8.881784197001252e-16, 2.886579864025407e-15, 2.942091015256665e-15], - initial_condition = initial_condition_constant, - tspan = (0.0,1.0)) - # 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 + l2=[ + 1.440611823425164e-15, + 1.1373567770134494e-14, + 3.024482376149653e-15, + 2.0553143516814395e-15, + 3.9938347410210535e-14, + 3.984545392098788e-16, + 2.4782402104201577e-15, + 1.551737464879987e-15, + ], + linf=[ + 1.9984014443252818e-15, + 1.3405943022348765e-14, + 3.3584246494910985e-15, + 3.164135620181696e-15, + 7.815970093361102e-14, + 8.881784197001252e-16, + 2.886579864025407e-15, + 2.942091015256665e-15, + ], + initial_condition=initial_condition_constant, + tspan=(0.0, 1.0)) + # 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_mhd_alfven_wave.jl" begin +@trixi_testset "elixir_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.0375628983659061e-5, 6.571144191446236e-7, 3.5833569836289104e-5, 3.583356983615859e-5, 5.084863194951084e-6, 1.1963224165731992e-16, 3.598916927583752e-5, 3.598916927594727e-5], - linf = [2.614095879338585e-5, 9.577266731216823e-7, 0.00012406198007461344, 0.00012406198007509917, 1.5066209528846741e-5, 2.220446049250313e-16, 0.00012658678753942054, 0.00012658678753908748]) - # 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 + l2=[ + 1.0375628983659061e-5, + 6.571144191446236e-7, + 3.5833569836289104e-5, + 3.583356983615859e-5, + 5.084863194951084e-6, + 1.1963224165731992e-16, + 3.598916927583752e-5, + 3.598916927594727e-5, + ], + linf=[ + 2.614095879338585e-5, + 9.577266731216823e-7, + 0.00012406198007461344, + 0.00012406198007509917, + 1.5066209528846741e-5, + 2.220446049250313e-16, + 0.00012658678753942054, + 0.00012658678753908748, + ]) + # 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_mhd_alfven_wave.jl with flux_derigs_etal" begin +@trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.4396053943470756e-5, 1.1211016739165248e-5, 3.577870687983967e-5, 3.577870687982181e-5, 1.967962220860377e-6, 1.1963224165731992e-16, 3.583562899483433e-5, 3.583562899486565e-5], - linf = [5.830577969345718e-5, 3.280495696370357e-5, 0.00012279619948236953, 0.00012279619948227238, 6.978806516122482e-6, 2.220446049250313e-16, 0.00012564003648959932, 0.00012564003648994626], - volume_flux = flux_derigs_etal) - # 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 + l2=[ + 1.4396053943470756e-5, + 1.1211016739165248e-5, + 3.577870687983967e-5, + 3.577870687982181e-5, + 1.967962220860377e-6, + 1.1963224165731992e-16, + 3.583562899483433e-5, + 3.583562899486565e-5, + ], + linf=[ + 5.830577969345718e-5, + 3.280495696370357e-5, + 0.00012279619948236953, + 0.00012279619948227238, + 6.978806516122482e-6, + 2.220446049250313e-16, + 0.00012564003648959932, + 0.00012564003648994626, + ], + volume_flux=flux_derigs_etal) + # 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_mhd_ec.jl" begin +@trixi_testset "elixir_mhd_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.05815183849746399, 0.08166807325621023, 0.054659228513541165, 0.054659228513541165, 0.15578125987042743, 4.130462730494e-17, 0.05465258887150046, 0.05465258887150046], - linf = [0.12165312668363826, 0.1901920742264952, 0.10059813883022554, 0.10059813883022554, 0.44079257431070706, 1.1102230246251565e-16, 0.10528911365809579, 0.10528911365809579]) - # 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 + l2=[ + 0.05815183849746399, + 0.08166807325621023, + 0.054659228513541165, + 0.054659228513541165, + 0.15578125987042743, + 4.130462730494e-17, + 0.05465258887150046, + 0.05465258887150046, + ], + linf=[ + 0.12165312668363826, + 0.1901920742264952, + 0.10059813883022554, + 0.10059813883022554, + 0.44079257431070706, + 1.1102230246251565e-16, + 0.10528911365809579, + 0.10528911365809579, + ]) + # 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_mhd_briowu_shock_tube.jl" begin +@trixi_testset "elixir_mhd_briowu_shock_tube.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_briowu_shock_tube.jl"), - l2 = [0.17477712356961989, 0.19489623595086944, 0.3596546157640463, 0.0, 0.3723215736814466, 1.2060075775846403e-15, 0.36276754492568164, 0.0], - linf = [0.5797109945880677, 0.4372991899547103, 1.0906536287185835, 0.0, 1.0526758874956808, 5.995204332975845e-15, 1.5122922036932964, 0.0], - coverage_override = (maxiters=6,)) - # 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 + l2=[ + 0.17477712356961989, + 0.19489623595086944, + 0.3596546157640463, + 0.0, + 0.3723215736814466, + 1.2060075775846403e-15, + 0.36276754492568164, + 0.0, + ], + linf=[ + 0.5797109945880677, + 0.4372991899547103, + 1.0906536287185835, + 0.0, + 1.0526758874956808, + 5.995204332975845e-15, + 1.5122922036932964, + 0.0, + ], + coverage_override=(maxiters = 6,)) + # 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_mhd_torrilhon_shock_tube.jl" begin +@trixi_testset "elixir_mhd_torrilhon_shock_tube.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_torrilhon_shock_tube.jl"), - l2 = [0.45700904847931145, 0.4792535936512035, 0.340651203521865, 0.4478034694296928, 0.9204708961093411, 1.3216517820475193e-16, 0.28897419402047725, 0.25521206483145126], - linf = [1.2185238171352286, 0.8913202384963431, 0.8488793580488431, 0.973083603686, 1.660723397705417, 2.220446049250313e-16, 0.6874726847741993, 0.65536978110274]) - # 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 + l2=[ + 0.45700904847931145, + 0.4792535936512035, + 0.340651203521865, + 0.4478034694296928, + 0.9204708961093411, + 1.3216517820475193e-16, + 0.28897419402047725, + 0.25521206483145126, + ], + linf=[ + 1.2185238171352286, + 0.8913202384963431, + 0.8488793580488431, + 0.973083603686, + 1.660723397705417, + 2.220446049250313e-16, + 0.6874726847741993, + 0.65536978110274, + ]) + # 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_mhd_ryujones_shock_tube.jl" begin +@trixi_testset "elixir_mhd_ryujones_shock_tube.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ryujones_shock_tube.jl"), - l2 = [0.23469781891518154, 0.3916675299696121, 0.08245195301016353, 0.1745346945706147, 0.9606363432904367, 6.608258910237605e-17, 0.21542929107153735, 0.10705457908737925], - linf = [0.6447951791685409, 0.9461857095377463, 0.35074627554617605, 0.8515177411529542, 2.0770652030507053, 1.1102230246251565e-16, 0.49670855513788204, 0.24830199967863564], - tspan = (0.0, 0.1)) - # 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 + l2=[ + 0.23469781891518154, + 0.3916675299696121, + 0.08245195301016353, + 0.1745346945706147, + 0.9606363432904367, + 6.608258910237605e-17, + 0.21542929107153735, + 0.10705457908737925, + ], + linf=[ + 0.6447951791685409, + 0.9461857095377463, + 0.35074627554617605, + 0.8515177411529542, + 2.0770652030507053, + 1.1102230246251565e-16, + 0.49670855513788204, + 0.24830199967863564, + ], + tspan=(0.0, 0.1)) + # 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_mhd_shu_osher_shock_tube.jl" begin +@trixi_testset "elixir_mhd_shu_osher_shock_tube.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - l2 = [1.01126210e+00, 8.27157902e+00, 1.30882545e+00, 0.00000000e+00, 5.21930435e+01, 6.56538824e-16, 1.01022340e+00, 0.00000000e+00], - linf = [2.87172004e+00, 2.26438057e+01, 4.16672442e+00, 0.00000000e+00, 1.35152372e+02, 3.44169138e-15, 2.83556069e+00, 0.00000000e+00], - tspan = (0.0, 0.2), - coverage_override = (maxiters=6,)) - # 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 + l2=[ + 1.01126210e+00, + 8.27157902e+00, + 1.30882545e+00, + 0.00000000e+00, + 5.21930435e+01, + 6.56538824e-16, + 1.01022340e+00, + 0.00000000e+00, + ], + linf=[ + 2.87172004e+00, + 2.26438057e+01, + 4.16672442e+00, + 0.00000000e+00, + 1.35152372e+02, + 3.44169138e-15, + 2.83556069e+00, + 0.00000000e+00, + ], + tspan=(0.0, 0.2), + coverage_override=(maxiters = 6,)) + # 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_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin +@trixi_testset "elixir_mhd_shu_osher_shock_tube.jl with flipped shock direction" begin # Include this elixir to make `initial_condition_shu_osher_shock_tube_flipped` available, which is used below - trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), tspan=(0.0, 0.0)) + trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), + tspan = (0.0, 0.0)) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shu_osher_shock_tube.jl"), - l2 = [1.01539817e+00, 8.29625810e+00, 1.29548008e+00, 0.00000000e+00, 5.23565514e+01, 3.18641825e-16, 1.00485291e+00, 0.00000000e+00], - linf = [2.92876280e+00, 2.28341581e+01, 4.11643561e+00, 0.00000000e+00, 1.36966213e+02, 1.55431223e-15, 2.80548864e+00, 0.00000000e+00], - initial_condition = initial_condition_shu_osher_shock_tube_flipped, - boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped), - tspan = (0.0, 0.2), - coverage_override = (maxiters=6,)) - # 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 + l2=[ + 1.01539817e+00, + 8.29625810e+00, + 1.29548008e+00, + 0.00000000e+00, + 5.23565514e+01, + 3.18641825e-16, + 1.00485291e+00, + 0.00000000e+00, + ], + linf=[ + 2.92876280e+00, + 2.28341581e+01, + 4.11643561e+00, + 0.00000000e+00, + 1.36966213e+02, + 1.55431223e-15, + 2.80548864e+00, + 0.00000000e+00, + ], + initial_condition=initial_condition_shu_osher_shock_tube_flipped, + boundary_conditions=BoundaryConditionDirichlet(initial_condition_shu_osher_shock_tube_flipped), + tspan=(0.0, 0.2), + coverage_override=(maxiters = 6,)) + # 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 end # module diff --git a/test/test_tree_1d_mhdmulti.jl b/test/test_tree_1d_mhdmulti.jl index 9d0dbc65744..9bf34634886 100644 --- a/test/test_tree_1d_mhdmulti.jl +++ b/test/test_tree_1d_mhdmulti.jl @@ -8,99 +8,119 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "MHD Multicomponent" begin +#! format: noindent - @trixi_testset "elixir_mhdmulti_ec.jl" begin +@trixi_testset "elixir_mhdmulti_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.08166807325620999, 0.054659228513541616, 0.054659228513541616, 0.15578125987042812, - 4.130462730494e-17, 0.054652588871500665, 0.054652588871500665, 0.008307405499637766, - 0.01661481099927553, 0.03322962199855106], - linf = [0.19019207422649645, 0.10059813883022888, 0.10059813883022888, 0.4407925743107146, - 1.1102230246251565e-16, 0.10528911365809623, 0.10528911365809623, 0.01737901809766182, - 0.03475803619532364, 0.06951607239064728]) - # 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 + l2=[0.08166807325620999, 0.054659228513541616, + 0.054659228513541616, 0.15578125987042812, + 4.130462730494e-17, 0.054652588871500665, + 0.054652588871500665, 0.008307405499637766, + 0.01661481099927553, 0.03322962199855106], + linf=[0.19019207422649645, 0.10059813883022888, + 0.10059813883022888, 0.4407925743107146, + 1.1102230246251565e-16, 0.10528911365809623, + 0.10528911365809623, 0.01737901809766182, + 0.03475803619532364, 0.06951607239064728]) + # 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_mhdmulti_ec.jl with flux_derigs_etal" begin +@trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.08151404166186461, 0.054640238302693274, 0.054640238302693274, 0.15536125426328573, - 4.130462730494e-17, 0.054665489963920275, 0.054665489963920275, 0.008308349501359825, - 0.01661669900271965, 0.0332333980054393], - linf = [0.1824424257860952, 0.09734687137001484, 0.09734687137001484, 0.4243089502087325, - 1.1102230246251565e-16, 0.09558639591092555, 0.09558639591092555, 0.017364773041550624, - 0.03472954608310125, 0.0694590921662025], - volume_flux = flux_derigs_etal) - # 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 + l2=[0.08151404166186461, 0.054640238302693274, + 0.054640238302693274, 0.15536125426328573, + 4.130462730494e-17, 0.054665489963920275, + 0.054665489963920275, 0.008308349501359825, + 0.01661669900271965, 0.0332333980054393], + linf=[0.1824424257860952, 0.09734687137001484, + 0.09734687137001484, 0.4243089502087325, + 1.1102230246251565e-16, 0.09558639591092555, + 0.09558639591092555, 0.017364773041550624, + 0.03472954608310125, 0.0694590921662025], + volume_flux=flux_derigs_etal) + # 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_mhdmulti_es.jl" begin +@trixi_testset "elixir_mhdmulti_es.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), - l2 = [0.07994082660130175, 0.053940174914031976, 0.053940174914031976, 0.15165513559250643, - 4.130462730494e-17, 0.05363207135290325, 0.05363207135290325, 0.008258265884659555, - 0.01651653176931911, 0.03303306353863822], - linf = [0.14101014428198477, 0.07762441749521025, 0.07762441749521025, 0.3381334453289866, - 1.1102230246251565e-16, 0.07003646400675223, 0.07003646400675223, 0.014962483760600165, - 0.02992496752120033, 0.05984993504240066]) - # 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 + l2=[0.07994082660130175, 0.053940174914031976, + 0.053940174914031976, 0.15165513559250643, + 4.130462730494e-17, 0.05363207135290325, + 0.05363207135290325, 0.008258265884659555, + 0.01651653176931911, 0.03303306353863822], + linf=[0.14101014428198477, 0.07762441749521025, + 0.07762441749521025, 0.3381334453289866, + 1.1102230246251565e-16, 0.07003646400675223, + 0.07003646400675223, 0.014962483760600165, + 0.02992496752120033, 0.05984993504240066]) + # 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_mhdmulti_convergence.jl" begin +@trixi_testset "elixir_mhdmulti_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), - l2 = [1.7337265267786785e-5, 0.00032976971029271364, 0.0003297697102926479, 6.194071694759044e-5, - 4.130462730494001e-17, 0.00032596825025664136, 0.0003259682502567132, 2.5467510126885455e-5, - 5.093502025377091e-5, 0.00010187004050754182], - linf = [3.877554303711845e-5, 0.0012437848638874956, 0.0012437848638876898, 0.00016431262020277781, - 1.1102230246251565e-16, 0.0012443734922607112, 0.001244373492260704, 5.691007974162332e-5, - 0.00011382015948324664, 0.00022764031896649328]) - # 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 + l2=[1.7337265267786785e-5, 0.00032976971029271364, + 0.0003297697102926479, 6.194071694759044e-5, + 4.130462730494001e-17, 0.00032596825025664136, + 0.0003259682502567132, 2.5467510126885455e-5, + 5.093502025377091e-5, 0.00010187004050754182], + linf=[3.877554303711845e-5, 0.0012437848638874956, + 0.0012437848638876898, 0.00016431262020277781, + 1.1102230246251565e-16, 0.0012443734922607112, + 0.001244373492260704, 5.691007974162332e-5, + 0.00011382015948324664, 0.00022764031896649328]) + # 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_mhdmulti_briowu_shock_tube.jl" begin +@trixi_testset "elixir_mhdmulti_briowu_shock_tube.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_briowu_shock_tube.jl"), - l2 = [0.1877830835572639, 0.3455841730726793, 0.0, 0.35413123388836687, - 8.745556626531982e-16, 0.3629920109231055, 0.0, 0.05329005553971236, - 0.10658011107942472], - linf = [0.4288187627971754, 1.0386547815614993, 0.0, 0.9541678878162702, - 5.773159728050814e-15, 1.4595119339458051, 0.0, 0.18201910908829552, - 0.36403821817659104], - coverage_override = (maxiters=6,)) - # 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 + l2=[0.1877830835572639, 0.3455841730726793, 0.0, + 0.35413123388836687, + 8.745556626531982e-16, 0.3629920109231055, 0.0, + 0.05329005553971236, + 0.10658011107942472], + linf=[0.4288187627971754, 1.0386547815614993, 0.0, + 0.9541678878162702, + 5.773159728050814e-15, 1.4595119339458051, 0.0, + 0.18201910908829552, + 0.36403821817659104], + coverage_override=(maxiters = 6,)) + # 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 end # module diff --git a/test/test_tree_1d_shallowwater.jl b/test/test_tree_1d_shallowwater.jl index 27fe98c7d42..658f178c941 100644 --- a/test/test_tree_1d_shallowwater.jl +++ b/test/test_tree_1d_shallowwater.jl @@ -10,250 +10,381 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Shallow Water" begin - @trixi_testset "elixir_shallowwater_ec.jl" begin +#! format: noindent + +@trixi_testset "elixir_shallowwater_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2 = [0.244729018751225, 0.8583565222389505, 0.07330427577586297], - linf = [2.1635021283528504, 3.8717508164234453, 1.7711213427919539], - tspan = (0.0, 0.25)) - # 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 + l2=[0.244729018751225, 0.8583565222389505, 0.07330427577586297], + linf=[ + 2.1635021283528504, + 3.8717508164234453, + 1.7711213427919539, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_ec.jl with initial_condition_weak_blast_wave" begin +@trixi_testset "elixir_shallowwater_ec.jl with initial_condition_weak_blast_wave" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2 = [0.39464782107209717, 2.03880864210846, 4.1623084150546725e-10], - linf = [0.778905801278281, 3.2409883402608273, 7.419800190922032e-10], - initial_condition=initial_condition_weak_blast_wave, - tspan = (0.0, 0.25)) - # 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 + l2=[ + 0.39464782107209717, + 2.03880864210846, + 4.1623084150546725e-10, + ], + linf=[ + 0.778905801278281, + 3.2409883402608273, + 7.419800190922032e-10, + ], + initial_condition=initial_condition_weak_blast_wave, + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced.jl" begin +@trixi_testset "elixir_shallowwater_well_balanced.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.10416666834254829, 1.4352935256803184e-14, 0.10416666834254838], - linf = [1.9999999999999996, 3.248036646353028e-14, 2.0], - tspan = (0.0, 0.25)) - # 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 + l2=[ + 0.10416666834254829, + 1.4352935256803184e-14, + 0.10416666834254838, + ], + linf=[1.9999999999999996, 3.248036646353028e-14, 2.0], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin +@trixi_testset "elixir_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.10416666834254835, 1.1891029971551825e-14, 0.10416666834254838], - linf = [2.0000000000000018, 2.4019608337954543e-14, 2.0], - surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.25)) - # 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 + l2=[ + 0.10416666834254835, + 1.1891029971551825e-14, + 0.10416666834254838, + ], + linf=[2.0000000000000018, 2.4019608337954543e-14, 2.0], + surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced_wet_dry.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_wet_dry.jl"), - l2 = [0.00965787167169024, 5.345454081916856e-14, 0.03857583749209928], - linf = [0.4999999999998892, 2.2447689894899726e-13, 1.9999999999999714], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced_wet_dry.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_wet_dry.jl"), + l2=[ + 0.00965787167169024, + 5.345454081916856e-14, + 0.03857583749209928, + ], + linf=[ + 0.4999999999998892, + 2.2447689894899726e-13, + 1.9999999999999714, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_source_terms.jl" begin +@trixi_testset "elixir_shallowwater_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0022363707373868713, 0.01576799981934617, 4.436491725585346e-5], - linf = [0.00893601803417754, 0.05939797350246456, 9.098379777405796e-5], - tspan = (0.0, 0.025)) - # 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 + l2=[ + 0.0022363707373868713, + 0.01576799981934617, + 4.436491725585346e-5, + ], + linf=[ + 0.00893601803417754, + 0.05939797350246456, + 9.098379777405796e-5, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_source_terms.jl with flux_hll" begin +@trixi_testset "elixir_shallowwater_source_terms.jl with flux_hll" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0022758146627220154, 0.015864082886204556, 4.436491725585346e-5], - linf = [0.008457195427364006, 0.057201667446161064, 9.098379777405796e-5], - tspan = (0.0, 0.025), surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) - # 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 + l2=[ + 0.0022758146627220154, + 0.015864082886204556, + 4.436491725585346e-5, + ], + linf=[ + 0.008457195427364006, + 0.057201667446161064, + 9.098379777405796e-5, + ], + tspan=(0.0, 0.025), + surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) + # 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_shallowwater_source_terms_dirichlet.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), - l2 = [0.0022851099219788917, 0.01560453773635554, 4.43649172558535e-5], - linf = [0.008934615705174398, 0.059403169140869405, 9.098379777405796e-5], - tspan = (0.0, 0.025)) - # 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_shallowwater_source_terms_dirichlet.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_source_terms_dirichlet.jl"), + l2=[ + 0.0022851099219788917, + 0.01560453773635554, + 4.43649172558535e-5, + ], + linf=[ + 0.008934615705174398, + 0.059403169140869405, + 9.098379777405796e-5, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_source_terms_dirichlet.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), - l2 = [0.0022956052733432287, 0.015540053559855601, 4.43649172558535e-5], - linf = [0.008460440313118323, 0.05720939349382359, 9.098379777405796e-5], - surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.025)) - # 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_shallowwater_source_terms_dirichlet.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_source_terms_dirichlet.jl"), + l2=[ + 0.0022956052733432287, + 0.015540053559855601, + 4.43649172558535e-5, + ], + linf=[ + 0.008460440313118323, + 0.05720939349382359, + 9.098379777405796e-5, + ], + surface_flux=(FluxHydrostaticReconstruction(flux_hll, + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.025)) + # 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_shallowwater_well_balanced_nonperiodic.jl with Dirichlet boundary" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_nonperiodic.jl"), - l2 = [1.725964362045055e-8, 5.0427180314307505e-16, 1.7259643530442137e-8], - linf = [3.844551077492042e-8, 3.469453422316143e-15, 3.844551077492042e-8], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced_nonperiodic.jl with Dirichlet boundary" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_nonperiodic.jl"), + l2=[ + 1.725964362045055e-8, + 5.0427180314307505e-16, + 1.7259643530442137e-8, + ], + linf=[ + 3.844551077492042e-8, + 3.469453422316143e-15, + 3.844551077492042e-8, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_nonperiodic.jl"), - l2 = [1.7259643614361866e-8, 3.5519018243195145e-16, 1.7259643530442137e-8], - linf = [3.844551010878661e-8, 9.846474508971374e-16, 3.844551077492042e-8], - tspan = (0.0, 0.25), - boundary_condition = boundary_condition_slip_wall) - # 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_shallowwater_well_balanced_nonperiodic.jl with wall boundary" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_nonperiodic.jl"), + l2=[ + 1.7259643614361866e-8, + 3.5519018243195145e-16, + 1.7259643530442137e-8, + ], + linf=[ + 3.844551010878661e-8, + 9.846474508971374e-16, + 3.844551077492042e-8, + ], + tspan=(0.0, 0.25), + boundary_condition=boundary_condition_slip_wall) + # 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_shallowwater_shock_capturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_shock_capturing.jl"), - l2 = [0.07424140641160326, 0.2148642632748155, 0.0372579849000542], - linf = [1.1209754279344226, 1.3230788645853582, 0.8646939843534251], - tspan = (0.0, 0.05)) - # 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_shallowwater_shock_capturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_shock_capturing.jl"), + l2=[0.07424140641160326, 0.2148642632748155, 0.0372579849000542], + linf=[ + 1.1209754279344226, + 1.3230788645853582, + 0.8646939843534251, + ], + tspan=(0.0, 0.05)) + # 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_shallowwater_beach.jl" begin +@trixi_testset "elixir_shallowwater_beach.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_beach.jl"), - l2 = [0.17979210479598923, 1.2377495706611434, 6.289818963361573e-8], - linf = [0.845938394800688, 3.3740800777086575, 4.4541473087633676e-7], - tspan = (0.0, 0.05), - atol = 3e-10) # see https://github.com/trixi-framework/Trixi.jl/issues/1617 - # 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 + l2=[ + 0.17979210479598923, + 1.2377495706611434, + 6.289818963361573e-8, + ], + linf=[ + 0.845938394800688, + 3.3740800777086575, + 4.4541473087633676e-7, + ], + tspan=(0.0, 0.05), + atol=3e-10) # see https://github.com/trixi-framework/Trixi.jl/issues/1617 + # 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_shallowwater_parabolic_bowl.jl" begin +@trixi_testset "elixir_shallowwater_parabolic_bowl.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_parabolic_bowl.jl"), - l2 = [8.965981683033589e-5, 1.8565707397810857e-5, 4.1043039226164336e-17], - linf = [0.00041080213807871235, 0.00014823261488938177, 2.220446049250313e-16], - tspan = (0.0, 0.05)) - # 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 + l2=[ + 8.965981683033589e-5, + 1.8565707397810857e-5, + 4.1043039226164336e-17, + ], + linf=[ + 0.00041080213807871235, + 0.00014823261488938177, + 2.220446049250313e-16, + ], + tspan=(0.0, 0.05)) + # 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_shallow_water_quasi_1d_source_terms.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallow_water_quasi_1d_source_terms.jl"), + l2=[ + 6.37048760275098e-5, + 0.0002745658116815704, + 4.436491725647962e-6, + 8.872983451152218e-6, + ], + linf=[ + 0.00026747526881631956, + 0.0012106730729152249, + 9.098379777500165e-6, + 1.8196759554278685e-5, + ], + tspan=(0.0, 0.05)) + # 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_shallow_water_quasi_1d_source_terms.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallow_water_quasi_1d_source_terms.jl"), - l2 = [6.37048760275098e-5, 0.0002745658116815704, 4.436491725647962e-6, 8.872983451152218e-6], - linf = [0.00026747526881631956, 0.0012106730729152249, 9.098379777500165e-6, 1.8196759554278685e-5], - tspan = (0.0, 0.05)) - # 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_shallowwater_quasi_1d_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_quasi_1d_well_balanced.jl"), - l2 = [1.4250229186905198e-14, 2.495109919406496e-12, 7.408599286788738e-17, 2.7205812409138776e-16], - linf = [5.284661597215745e-14, 2.74056233065078e-12, 2.220446049250313e-16, 8.881784197001252e-16], - tspan = (0.0, 100.0)) - # 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_shallowwater_quasi_1d_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_quasi_1d_well_balanced.jl"), + l2=[ + 1.4250229186905198e-14, + 2.495109919406496e-12, + 7.408599286788738e-17, + 2.7205812409138776e-16, + ], + linf=[ + 5.284661597215745e-14, + 2.74056233065078e-12, + 2.220446049250313e-16, + 8.881784197001252e-16, + ], + tspan=(0.0, 100.0)) + # 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 end # module diff --git a/test/test_tree_1d_shallowwater_twolayer.jl b/test/test_tree_1d_shallowwater_twolayer.jl index 93b8a6f70a5..a504f4f93a6 100644 --- a/test/test_tree_1d_shallowwater_twolayer.jl +++ b/test/test_tree_1d_shallowwater_twolayer.jl @@ -10,75 +10,95 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_1d_dgsem") @testset "Shallow Water Two layer" begin - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.0050681532925156945, 0.002089013899370176, 0.005105544300292713, 0.002526442122643306, - 0.0004744186597732706], - linf = [0.022256679217306008, 0.005421833004652266, 0.02233993939574197, 0.008765261497422516, - 0.0008992474511784199], - tspan = (0.0, 0.25)) - # 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 +#! format: noindent - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.0027681377074701345, 0.0018007543202559165, 0.0028036917433720576, - 0.0013980358596935737, 0.0004744186597732706], - linf = [0.005699303919826093, 0.006432952918256296, 0.0058507082844360125, 0.002717615543961216, - 0.0008992474511784199], - surface_flux=(flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - # 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 +@trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.0050681532925156945, 0.002089013899370176, + 0.005105544300292713, 0.002526442122643306, + 0.0004744186597732706], + linf=[0.022256679217306008, 0.005421833004652266, + 0.02233993939574197, 0.008765261497422516, + 0.0008992474511784199], + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_well_balanced.jl"), - l2 = [8.949288784402005e-16, 4.0636427176237915e-17, 0.001002881985401548, - 2.133351105037203e-16, 0.0010028819854016578], - linf = [2.6229018956769323e-15, 1.878451903240623e-16, 0.005119880996670156, - 8.003199803957679e-16, 0.005119880996670666], - tspan = (0.0, 0.25)) - # 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 +@trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.0027681377074701345, 0.0018007543202559165, + 0.0028036917433720576, + 0.0013980358596935737, 0.0004744186597732706], + linf=[0.005699303919826093, 0.006432952918256296, + 0.0058507082844360125, 0.002717615543961216, + 0.0008992474511784199], + surface_flux=(flux_es_fjordholm_etal, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_dam_break.jl"), - l2 = [0.10010269243463918, 0.5668733957648654, 0.08759617327649398, - 0.4538443183566172, 0.013638618139749523], - linf = [0.5854202777756559, 2.1278930820498934, 0.5193686074348809, 1.8071213168086229, 0.5], - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - # 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 +@trixi_testset "elixir_shallowwater_twolayer_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_well_balanced.jl"), + l2=[8.949288784402005e-16, 4.0636427176237915e-17, + 0.001002881985401548, + 2.133351105037203e-16, 0.0010028819854016578], + linf=[2.6229018956769323e-15, 1.878451903240623e-16, + 0.005119880996670156, + 8.003199803957679e-16, 0.005119880996670666], + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_dam_break.jl"), + l2=[0.10010269243463918, 0.5668733957648654, + 0.08759617327649398, + 0.4538443183566172, 0.013638618139749523], + linf=[ + 0.5854202777756559, + 2.1278930820498934, + 0.5193686074348809, + 1.8071213168086229, + 0.5, + ], + surface_flux=(flux_lax_friedrichs, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + # 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 end # module diff --git a/test/test_tree_2d_acoustics.jl b/test/test_tree_2d_acoustics.jl index dbfe38dbde2..89bccbf8ca1 100644 --- a/test/test_tree_2d_acoustics.jl +++ b/test/test_tree_2d_acoustics.jl @@ -8,80 +8,137 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Acoustic Perturbation" begin - @trixi_testset "elixir_acoustics_convergence.jl" begin +#! format: noindent + +@trixi_testset "elixir_acoustics_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_convergence.jl"), - l2 = [0.0019921138796370834, 0.002090394698052287, 0.0006091925854593805, 0.0, 0.0, 0.0, 0.0], - linf = [0.00769282588065634, 0.008276649669227254, 0.004196479023954813, 0.0, 0.0, 0.0, 0.0]) - # 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 + l2=[ + 0.0019921138796370834, + 0.002090394698052287, + 0.0006091925854593805, + 0.0, + 0.0, + 0.0, + 0.0, + ], + linf=[ + 0.00769282588065634, + 0.008276649669227254, + 0.004196479023954813, + 0.0, + 0.0, + 0.0, + 0.0, + ]) + # 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_acoustics_gauss.jl" begin +@trixi_testset "elixir_acoustics_gauss.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss.jl"), - l2 = [0.08005276517890283, 0.08005276517890268, 0.4187202920734123, 0.0, 0.0, 0.0, 0.0], - linf = [0.17261097190220992, 0.17261097190220973, 1.13601894068238, 0.0, 0.0, 0.0, 0.0]) - # 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 + l2=[ + 0.08005276517890283, + 0.08005276517890268, + 0.4187202920734123, + 0.0, + 0.0, + 0.0, + 0.0, + ], + linf=[ + 0.17261097190220992, + 0.17261097190220973, + 1.13601894068238, + 0.0, + 0.0, + 0.0, + 0.0, + ]) + # 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_acoustics_gaussian_source.jl" begin +@trixi_testset "elixir_acoustics_gaussian_source.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gaussian_source.jl"), - l2 = [0.004296394903650806, 0.004241280404758938, 0.006269684906035964, 0.0, 0.0, 0.0, 0.0], - linf = [0.03970270697049378, 0.04151096349298151, 0.0640019829058819, 0.0, 0.0, 0.0, 0.0]) - # 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 + l2=[ + 0.004296394903650806, + 0.004241280404758938, + 0.006269684906035964, + 0.0, + 0.0, + 0.0, + 0.0, + ], + linf=[ + 0.03970270697049378, + 0.04151096349298151, + 0.0640019829058819, + 0.0, + 0.0, + 0.0, + 0.0, + ]) + # 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_acoustics_gauss_wall.jl" begin +@trixi_testset "elixir_acoustics_gauss_wall.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss_wall.jl"), - l2 = [0.019419398248465843, 0.019510701017551826, 0.04818246051887614, - 7.382060834820337e-17, 0.0, 1.4764121669640674e-16, 1.4764121669640674e-16], - linf = [0.18193631937316496, 0.1877464607867628, 1.0355388011792845, - 2.220446049250313e-16, 0.0, 4.440892098500626e-16, 4.440892098500626e-16]) - # 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 + l2=[0.019419398248465843, 0.019510701017551826, + 0.04818246051887614, + 7.382060834820337e-17, 0.0, 1.4764121669640674e-16, + 1.4764121669640674e-16], + linf=[0.18193631937316496, 0.1877464607867628, + 1.0355388011792845, + 2.220446049250313e-16, 0.0, 4.440892098500626e-16, + 4.440892098500626e-16]) + # 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_acoustics_monopole.jl" begin +@trixi_testset "elixir_acoustics_monopole.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_monopole.jl"), - l2 = [0.006816790293009947, 0.0065068948357351625, 0.008724512056168938, - 0.0009894398191644543, 0.0, 7.144325530679576e-17, 7.144325530679576e-17], - linf = [1.000633375007386, 0.5599788929862504, 0.5738432957070382, - 0.015590137026938428, 0.0, 2.220446049250313e-16, 2.220446049250313e-16], - maxiters=50) - # 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 + l2=[0.006816790293009947, 0.0065068948357351625, + 0.008724512056168938, + 0.0009894398191644543, 0.0, 7.144325530679576e-17, + 7.144325530679576e-17], + linf=[1.000633375007386, 0.5599788929862504, 0.5738432957070382, + 0.015590137026938428, 0.0, 2.220446049250313e-16, + 2.220446049250313e-16], + maxiters=50) + # 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 -end # module \ No newline at end of file +end # module diff --git a/test/test_tree_2d_advection.jl b/test/test_tree_2d_advection.jl index 365011eef53..b111651aa6f 100644 --- a/test/test_tree_2d_advection.jl +++ b/test/test_tree_2d_advection.jl @@ -8,346 +8,349 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5], - # Let the small basic test run to the end - coverage_override = (maxiters=10^5,)) - # 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 + # Expected errors are exactly the same as in the parallel test! + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5], + # Let the small basic test run to the end + coverage_override=(maxiters = 10^5,)) + # 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_advection_extended.jl with polydeg=1" begin +@trixi_testset "elixir_advection_extended.jl with polydeg=1" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.02134571266411136], - linf = [0.04347734797775926], - polydeg=1) - # 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 + l2=[0.02134571266411136], + linf=[0.04347734797775926], + polydeg=1) + # 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_restart.jl" begin +@trixi_testset "elixir_advection_restart.jl" begin using OrdinaryDiffEq: SSPRK43 println("═"^100) println(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl")) trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - alg = SSPRK43(), tspan = (0.0, 10.0)) + alg = SSPRK43(), tspan = (0.0, 10.0)) l2_expected, linf_expected = analysis_callback(sol) println("═"^100) println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl")) # Errors are exactly the same as in the elixir_advection_extended.jl trixi_include(@__MODULE__, joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - alg = SSPRK43()) + alg = SSPRK43()) l2_actual, linf_actual = analysis_callback(sol) - + @test l2_actual == l2_expected @test linf_actual == linf_expected - end +end - @trixi_testset "elixir_advection_mortar.jl" begin +@trixi_testset "elixir_advection_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [0.0015188466707237375], - linf = [0.008446655719187679]) + # Expected errors are exactly the same as in the parallel test! + l2=[0.0015188466707237375], + linf=[0.008446655719187679]) - # 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 + # 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_advection_amr.jl" begin +@trixi_testset "elixir_advection_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [4.913300828257469e-5], - linf = [0.00045263895394385967], - # Let this test run to the end to cover some AMR code - coverage_override = (maxiters=10^5,)) - # 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 + # Expected errors are exactly the same as in the parallel test! + l2=[4.913300828257469e-5], + linf=[0.00045263895394385967], + # Let this test run to the end to cover some AMR code + coverage_override=(maxiters = 10^5,)) + # 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_advection_amr_nonperiodic.jl" begin +@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [3.2207388565869075e-5], - linf = [0.0007508059772436404], - coverage_override = (maxiters=6,)) - # 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 + # Expected errors are exactly the same as in the parallel test! + l2=[3.2207388565869075e-5], + linf=[0.0007508059772436404], + coverage_override=(maxiters = 6,)) + # 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_advection_amr_solution_independent.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_solution_independent.jl"), - l2 = [4.949660644033807e-5], - linf = [0.0004867846262313763], - coverage_override = (maxiters=6,)) - # 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 +@trixi_testset "elixir_advection_amr_solution_independent.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_advection_amr_solution_independent.jl"), + l2=[4.949660644033807e-5], + linf=[0.0004867846262313763], + coverage_override=(maxiters = 6,)) + # 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_amr_visualization.jl" begin +@trixi_testset "elixir_advection_amr_visualization.jl" begin # To make CI tests work, disable showing a plot window with the GR backend of the Plots package # Xref: https://github.com/jheinen/GR.jl/issues/278 # Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103 if !isinteractive() - restore = get(ENV, "GKSwstype", nothing) - ENV["GKSwstype"] = "100" + restore = get(ENV, "GKSwstype", nothing) + ENV["GKSwstype"] = "100" end @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_visualization.jl"), - l2 = [0.0007225529919720868], - linf = [0.005954447875428925], - coverage_override = (maxiters=6,)) + l2=[0.0007225529919720868], + linf=[0.005954447875428925], + coverage_override=(maxiters = 6,)) # Restore GKSwstype to previous value (if it was set) if !isinteractive() - if isnothing(restore) - delete!(ENV, "GKSwstype") - else - ENV["GKSwstype"] = restore - end + if isnothing(restore) + delete!(ENV, "GKSwstype") + else + ENV["GKSwstype"] = restore + end end - end +end - @trixi_testset "elixir_advection_timeintegration.jl" begin +@trixi_testset "elixir_advection_timeintegration.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [2.4976030518356626e-5], - linf = [0.0005531580316338533], - # Let this test terminate by time instead of maxiters to cover some lines - # in time_integration/methods_2N.jl - coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) - # 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)) < 15000 - end + l2=[2.4976030518356626e-5], + linf=[0.0005531580316338533], + # Let this test terminate by time instead of maxiters to cover some lines + # in time_integration/methods_2N.jl + coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) + # 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)) < 15000 end - end +end +end - @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin +@trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [2.5314747030031457e-5], - linf = [0.0005437136621948904], - ode_algorithm=Trixi.CarpenterKennedy2N43(), - cfl = 1.0) - # 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)) < 15000 - end - end + l2=[2.5314747030031457e-5], + linf=[0.0005437136621948904], + ode_algorithm=Trixi.CarpenterKennedy2N43(), + cfl=1.0) + # 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)) < 15000 + end +end - @trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin +@trixi_testset "elixir_advection_timeintegration.jl with carpenter_kennedy_erk43 with maxiters=1" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [1.2135350502911197e-5], - linf = [9.999985420537649e-5], - ode_algorithm=Trixi.CarpenterKennedy2N43(), - cfl = 1.0, - maxiters = 1) - # 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)) < 15000 - end - end + l2=[1.2135350502911197e-5], + linf=[9.999985420537649e-5], + ode_algorithm=Trixi.CarpenterKennedy2N43(), + cfl=1.0, + maxiters=1) + # 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)) < 15000 + end +end - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin +@trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk94" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [2.4976673477385313e-5], - linf = [0.0005534166916640881], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94()) - # 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)) < 15000 - end - end + l2=[2.4976673477385313e-5], + linf=[0.0005534166916640881], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar94()) + # 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)) < 15000 + end +end - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin +@trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [3.667894656471403e-5], - linf = [0.0005799465470165757], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), - cfl = 1.0) - # 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)) < 15000 - end - end + l2=[3.667894656471403e-5], + linf=[0.0005799465470165757], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), + cfl=1.0) + # 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)) < 15000 + end +end - @trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin +@trixi_testset "elixir_advection_timeintegration.jl with parsani_ketcheson_deconinck_erk32 with maxiters=1" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_timeintegration.jl"), - l2 = [1.2198725469737875e-5], - linf = [9.977247740793407e-5], - ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), - cfl = 1.0, - maxiters = 1) - # 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)) < 15000 - end - end + l2=[1.2198725469737875e-5], + linf=[9.977247740793407e-5], + ode_algorithm=Trixi.ParsaniKetchesonDeconinck3Sstar32(), + cfl=1.0, + maxiters=1) + # 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)) < 15000 + end +end - @trixi_testset "elixir_advection_callbacks.jl" begin +@trixi_testset "elixir_advection_callbacks.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_callbacks.jl"), - l2 = [8.311947673061856e-6], - linf = [6.627000273229378e-5]) - # 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 + l2=[8.311947673061856e-6], + linf=[6.627000273229378e-5]) + # 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 # Coverage test for all initial conditions @testset "Linear scalar advection: Tests for initial conditions" begin - # Linear scalar advection - @trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.0001420618061089383], - linf = [0.0007140570281718439], - maxiters = 1, - initial_condition = Trixi.initial_condition_sin_sin) - # 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 + # Linear scalar advection + @trixi_testset "elixir_advection_extended.jl with initial_condition_sin_sin" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[0.0001420618061089383], + linf=[0.0007140570281718439], + maxiters=1, + initial_condition=Trixi.initial_condition_sin_sin) + # 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_extended.jl with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [3.8302867746057483e-16], - linf = [1.3322676295501878e-15], - maxiters = 1, - initial_condition = initial_condition_constant) - # 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_advection_extended.jl with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[3.8302867746057483e-16], + linf=[1.3322676295501878e-15], + maxiters=1, + initial_condition=initial_condition_constant) + # 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_advection_extended.jl with initial_condition_linear_x_y" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [2.7276160570381226e-16], - linf = [5.10702591327572e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_x_y, - boundary_conditions = Trixi.boundary_condition_linear_x_y, - periodicity=false) - # 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 + @trixi_testset "elixir_advection_extended.jl with initial_condition_linear_x_y" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[2.7276160570381226e-16], + linf=[5.10702591327572e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_x_y, + boundary_conditions=Trixi.boundary_condition_linear_x_y, + periodicity=false) + # 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_extended.jl with initial_condition_linear_x" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.5121648229368207e-16], - linf = [1.3322676295501878e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_x, - boundary_conditions = Trixi.boundary_condition_linear_x, - periodicity=false) - # 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_advection_extended.jl with initial_condition_linear_x" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[1.5121648229368207e-16], + linf=[1.3322676295501878e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_x, + boundary_conditions=Trixi.boundary_condition_linear_x, + periodicity=false) + # 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_advection_extended.jl with initial_condition_linear_y" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.714292614252588e-16], - linf = [2.220446049250313e-15], - maxiters = 1, - initial_condition = Trixi.initial_condition_linear_y, - boundary_conditions = Trixi.boundary_condition_linear_y, - periodicity=false) - # 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_advection_extended.jl with initial_condition_linear_y" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), + l2=[1.714292614252588e-16], + linf=[2.220446049250313e-15], + maxiters=1, + initial_condition=Trixi.initial_condition_linear_y, + boundary_conditions=Trixi.boundary_condition_linear_y, + periodicity=false) + # 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 end # module diff --git a/test/test_tree_2d_euler.jl b/test/test_tree_2d_euler.jl index 79a650ded8a..af7c5d8324c 100644 --- a/test/test_tree_2d_euler.jl +++ b/test/test_tree_2d_euler.jl @@ -8,537 +8,915 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin +#! format: noindent + +@trixi_testset "elixir_euler_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [9.321181253186009e-7, 1.4181210743438511e-6, 1.4181210743487851e-6, 4.824553091276693e-6], - linf = [9.577246529612893e-6, 1.1707525976012434e-5, 1.1707525976456523e-5, 4.8869615580926506e-5]) - # 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_euler_convergence_pure_fv.jl" begin + l2=[ + 9.321181253186009e-7, + 1.4181210743438511e-6, + 1.4181210743487851e-6, + 4.824553091276693e-6, + ], + linf=[ + 9.577246529612893e-6, + 1.1707525976012434e-5, + 1.1707525976456523e-5, + 4.8869615580926506e-5, + ]) + # 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_euler_convergence_pure_fv.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2 = [0.026440292358506527, 0.013245905852168414, 0.013245905852168479, 0.03912520302609374], - linf = [0.042130817806361964, 0.022685499230187034, 0.022685499230187922, 0.06999771202145322]) - # 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_euler_density_wave.jl" begin + l2=[ + 0.026440292358506527, + 0.013245905852168414, + 0.013245905852168479, + 0.03912520302609374, + ], + linf=[ + 0.042130817806361964, + 0.022685499230187034, + 0.022685499230187922, + 0.06999771202145322, + ]) + # 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_euler_density_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"), - l2 = [0.0010600778457964775, 0.00010600778457634275, 0.00021201556915872665, 2.650194614399671e-5], - linf = [0.006614198043413566, 0.0006614198043973507, 0.001322839608837334, 0.000165354951256802], - tspan = (0.0, 0.5)) - # 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_euler_source_terms_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms_nonperiodic.jl"), - l2 = [2.259440511766445e-6, 2.318888155713922e-6, 2.3188881557894307e-6, 6.3327863238858925e-6], - linf = [1.498738264560373e-5, 1.9182011928187137e-5, 1.918201192685487e-5, 6.0526717141407005e-5]) - # 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_euler_ec.jl" begin + l2=[ + 0.0010600778457964775, + 0.00010600778457634275, + 0.00021201556915872665, + 2.650194614399671e-5, + ], + linf=[ + 0.006614198043413566, + 0.0006614198043973507, + 0.001322839608837334, + 0.000165354951256802, + ], + tspan=(0.0, 0.5)) + # 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_euler_source_terms_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_source_terms_nonperiodic.jl"), + l2=[ + 2.259440511766445e-6, + 2.318888155713922e-6, + 2.3188881557894307e-6, + 6.3327863238858925e-6, + ], + linf=[ + 1.498738264560373e-5, + 1.9182011928187137e-5, + 1.918201192685487e-5, + 6.0526717141407005e-5, + ]) + # 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_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.061751715597716854, 0.05018223615408711, 0.05018989446443463, 0.225871559730513], - linf = [0.29347582879608825, 0.31081249232844693, 0.3107380389947736, 1.0540358049885143]) - # 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_euler_ec.jl with flux_kennedy_gruber" begin + l2=[ + 0.061751715597716854, + 0.05018223615408711, + 0.05018989446443463, + 0.225871559730513, + ], + linf=[ + 0.29347582879608825, + 0.31081249232844693, + 0.3107380389947736, + 1.0540358049885143, + ]) + # 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_euler_ec.jl with flux_kennedy_gruber" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03481471610306124, 0.027694280613944234, 0.027697905866996532, 0.12932052501462554], - linf = [0.31052098400669004, 0.3481295959664616, 0.34807152194137336, 1.1044947556170719], - maxiters = 10, - surface_flux = flux_kennedy_gruber, - volume_flux = flux_kennedy_gruber) - # 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_euler_ec.jl with flux_chandrashekar" begin + l2=[ + 0.03481471610306124, + 0.027694280613944234, + 0.027697905866996532, + 0.12932052501462554, + ], + linf=[ + 0.31052098400669004, + 0.3481295959664616, + 0.34807152194137336, + 1.1044947556170719, + ], + maxiters=10, + surface_flux=flux_kennedy_gruber, + volume_flux=flux_kennedy_gruber) + # 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_euler_ec.jl with flux_chandrashekar" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03481122603050542, 0.027662840593087695, 0.027665658732350273, 0.12927455860656786], - linf = [0.3110089578739834, 0.34888111987218107, 0.3488278669826813, 1.1056349046774305], - maxiters = 10, - surface_flux = flux_chandrashekar, - volume_flux = flux_chandrashekar) - # 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_euler_shockcapturing.jl" begin + l2=[ + 0.03481122603050542, + 0.027662840593087695, + 0.027665658732350273, + 0.12927455860656786, + ], + linf=[ + 0.3110089578739834, + 0.34888111987218107, + 0.3488278669826813, + 1.1056349046774305, + ], + maxiters=10, + surface_flux=flux_chandrashekar, + volume_flux=flux_chandrashekar) + # 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_euler_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2 = [0.05380629130119074, 0.04696798008325309, 0.04697067787841479, 0.19687382235494968], - linf = [0.18527440131928286, 0.2404798030563736, 0.23269573860381076, 0.6874012187446894]) - # 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_euler_shockcapturing_subcell.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_subcell.jl"), - l2 = [0.08508147906199143, 0.04510299017724501, 0.045103019801950375, 0.6930704343869766], - linf = [0.31123546471463326, 0.5616274869594462, 0.5619692712224448, 2.88670199345138]) - # 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)) < 15000 - end - end - - @trixi_testset "elixir_euler_blast_wave.jl" begin + l2=[ + 0.05380629130119074, + 0.04696798008325309, + 0.04697067787841479, + 0.19687382235494968, + ], + linf=[ + 0.18527440131928286, + 0.2404798030563736, + 0.23269573860381076, + 0.6874012187446894, + ]) + # 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_euler_shockcapturing_subcell.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_shockcapturing_subcell.jl"), + l2=[ + 0.08508147906199143, + 0.04510299017724501, + 0.045103019801950375, + 0.6930704343869766, + ], + linf=[ + 0.31123546471463326, + 0.5616274869594462, + 0.5619692712224448, + 2.88670199345138, + ]) + # 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)) < 15000 + end +end + +@trixi_testset "elixir_euler_blast_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave.jl"), - l2 = [0.14170569763947993, 0.11647068900798814, 0.11647072556898294, 0.3391989213659599], - linf = [1.6544204510794196, 1.35194638484646, 1.3519463848472744, 1.831228461662809], - maxiters = 30) - # 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_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), - l2 = [0.4758794741390833, 0.21045415565179362, 0.21045325630191866, 0.7022517958549878], - linf = [1.710832148442441, 0.9711663578827681, 0.9703787873632452, 2.9619758810532653], - initial_refinement_level = 4, - maxiters = 50) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2 = [0.472445774440313, 0.2090782039442978, 0.20885558673697927, 0.700569533591275], - linf = [1.7066492792835155, 0.9856122336679919, 0.9784316656930644, 2.9372978989672873], - initial_refinement_level = 4, - maxiters = 50) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl with mortars" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), - l2 = [0.016486406327766923, 0.03097329879894433, 0.03101012918167401, 0.15157175775429868], - linf = [0.27688647744873407, 0.5653724536715139, 0.565695523611447, 2.513047611639946], - refinement_patches=( - (type="box", coordinates_min=(-0.25, -0.25), coordinates_max=(0.25, 0.25)), - (type="box", coordinates_min=(-0.125, -0.125), coordinates_max=(0.125, 0.125)),), - initial_refinement_level = 4, - maxiters = 5) - end - - @trixi_testset "elixir_euler_blast_wave_neuralnetwork_cnn.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_neuralnetwork_cnn.jl"), - l2 = [0.4795795496408325, 0.2125148972465021, 0.21311260934645868, 0.7033388737692883], - linf = [1.8295385992182336, 0.9687795218482794, 0.9616033072376108, 2.9513245978047133], - initial_refinement_level = 4, - maxiters = 50, - rtol = 1.0e-7) - end - - @trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin + l2=[ + 0.14170569763947993, + 0.11647068900798814, + 0.11647072556898294, + 0.3391989213659599, + ], + linf=[ + 1.6544204510794196, + 1.35194638484646, + 1.3519463848472744, + 1.831228461662809, + ], + maxiters=30) + # 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_euler_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_perssonperaire.jl"), + l2=[ + 0.4758794741390833, + 0.21045415565179362, + 0.21045325630191866, + 0.7022517958549878, + ], + linf=[ + 1.710832148442441, + 0.9711663578827681, + 0.9703787873632452, + 2.9619758810532653, + ], + initial_refinement_level=4, + maxiters=50) +end + +@trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2=[ + 0.472445774440313, + 0.2090782039442978, + 0.20885558673697927, + 0.700569533591275, + ], + linf=[ + 1.7066492792835155, + 0.9856122336679919, + 0.9784316656930644, + 2.9372978989672873, + ], + initial_refinement_level=4, + maxiters=50) +end + +@trixi_testset "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl with mortars" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_rayhesthaven.jl"), + l2=[ + 0.016486406327766923, + 0.03097329879894433, + 0.03101012918167401, + 0.15157175775429868, + ], + linf=[ + 0.27688647744873407, + 0.5653724536715139, + 0.565695523611447, + 2.513047611639946, + ], + refinement_patches=((type = "box", + coordinates_min = (-0.25, -0.25), + coordinates_max = (0.25, 0.25)), + (type = "box", + coordinates_min = (-0.125, -0.125), + coordinates_max = (0.125, 0.125))), + initial_refinement_level=4, + maxiters=5) +end + +@trixi_testset "elixir_euler_blast_wave_neuralnetwork_cnn.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_blast_wave_neuralnetwork_cnn.jl"), + l2=[ + 0.4795795496408325, + 0.2125148972465021, + 0.21311260934645868, + 0.7033388737692883, + ], + linf=[ + 1.8295385992182336, + 0.9687795218482794, + 0.9616033072376108, + 2.9513245978047133, + ], + initial_refinement_level=4, + maxiters=50, + rtol=1.0e-7) +end + +@trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_pure_fv.jl"), - l2 = [0.39957047631960346, 0.21006912294983154, 0.21006903549932, 0.6280328163981136], - linf = [2.20417889887697, 1.5487238480003327, 1.5486788679247812, 2.4656795949035857], - tspan = (0.0, 0.5), - # Let this test run longer to cover some lines in flux_hllc - coverage_override = (maxiters=10^5, tspan=(0.0, 0.1))) - # 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_euler_blast_wave_amr.jl" begin + l2=[ + 0.39957047631960346, + 0.21006912294983154, + 0.21006903549932, + 0.6280328163981136, + ], + linf=[ + 2.20417889887697, + 1.5487238480003327, + 1.5486788679247812, + 2.4656795949035857, + ], + tspan=(0.0, 0.5), + # Let this test run longer to cover some lines in flux_hllc + coverage_override=(maxiters = 10^5, tspan = (0.0, 0.1))) + # 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_euler_blast_wave_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"), - l2 = [0.6835576416907511, 0.2839963955262972, 0.28399565983676, 0.7229447806293277], - linf = [3.0969614882801393, 1.7967947300740248, 1.7967508302506658, 3.040149575567518], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6,)) - # 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_euler_sedov_blast_wave.jl" begin + l2=[ + 0.6835576416907511, + 0.2839963955262972, + 0.28399565983676, + 0.7229447806293277, + ], + linf=[ + 3.0969614882801393, + 1.7967947300740248, + 1.7967508302506658, + 3.040149575567518, + ], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6,)) + # 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_euler_sedov_blast_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [0.4866953770742574, 0.1673477470091984, 0.16734774700934, 0.6184367248923149], - linf = [2.6724832723962053, 1.2916089288910635, 1.2916089289001427, 6.474699399394252], - tspan = (0.0, 1.0), - coverage_override = (maxiters=6,)) - # 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_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl"), - l2 = [0.0845430093623868, 0.09271459184623232, 0.09271459184623232, 0.4377291875101709], - linf = [1.3608553480069898, 1.6822884847136004, 1.6822884847135997, 4.2201475428867035], - maxiters = 30, - coverage_override = (maxiters=6,)) - end - - @trixi_testset "elixir_euler_positivity.jl" begin + l2=[ + 0.4866953770742574, + 0.1673477470091984, + 0.16734774700934, + 0.6184367248923149, + ], + linf=[ + 2.6724832723962053, + 1.2916089288910635, + 1.2916089289001427, + 6.474699399394252, + ], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 6,)) + # 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_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_sedov_blast_wave_neuralnetwork_perssonperaire.jl"), + l2=[ + 0.0845430093623868, + 0.09271459184623232, + 0.09271459184623232, + 0.4377291875101709, + ], + linf=[ + 1.3608553480069898, + 1.6822884847136004, + 1.6822884847135997, + 4.2201475428867035, + ], + maxiters=30, + coverage_override=(maxiters = 6,)) +end + +@trixi_testset "elixir_euler_positivity.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_positivity.jl"), - l2 = [0.48862067511841695, 0.16787541578869494, 0.16787541578869422, 0.6184319933114926], - linf = [2.6766520821013002, 1.2910938760258996, 1.2910938760258899, 6.473385481404865], - tspan = (0.0, 1.0), - coverage_override = (maxiters=3,)) - # 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_euler_blob_mortar.jl" begin + l2=[ + 0.48862067511841695, + 0.16787541578869494, + 0.16787541578869422, + 0.6184319933114926, + ], + linf=[ + 2.6766520821013002, + 1.2910938760258996, + 1.2910938760258899, + 6.473385481404865, + ], + tspan=(0.0, 1.0), + coverage_override=(maxiters = 3,)) + # 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_euler_blob_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_mortar.jl"), - l2 = [0.22271619518391986, 0.6284824759323494, 0.24864213447943648, 2.9591811489995474], - linf = [9.15245400430106, 24.96562810334389, 10.388109127032374, 101.20581544156934], - tspan = (0.0, 0.5)) - # 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_euler_blob_amr.jl" begin + l2=[ + 0.22271619518391986, + 0.6284824759323494, + 0.24864213447943648, + 2.9591811489995474, + ], + linf=[ + 9.15245400430106, + 24.96562810334389, + 10.388109127032374, + 101.20581544156934, + ], + tspan=(0.0, 0.5)) + # 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_euler_blob_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_amr.jl"), - l2 = [0.2086261501910662, 1.2118352377894666, 0.10255333189606497, 5.296238138639236], - linf = [14.829071984498198, 74.12967742435727, 6.863554388300223, 303.58813147491134], - tspan = (0.0, 0.12), - # Let this test run longer to cover the ControllerThreeLevelCombined lines - coverage_override = (maxiters=10^5,)) - # 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_euler_kelvin_helmholtz_instability_fjordholm_etal.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl"), - l2 = [0.1057230211245312, 0.10621112311257341, 0.07260957505339989, 0.11178239111065721], - linf = [2.998719417992662, 2.1400285015556166, 1.1569648700415078, 1.8922492268110913], - tspan = (0.0, 0.1)) - # 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_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - l2 = [0.055691508271624536, 0.032986009333751655, 0.05224390923711999, 0.08009536362771563], - linf = [0.24043622527087494, 0.1660878796929941, 0.12355946691711608, 0.2694290787257758], - tspan = (0.0, 0.2)) - # 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_euler_kelvin_helmholtz_instability_amr.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_amr.jl"), - l2 = [0.05569452733654995, 0.033107109983417926, 0.05223609622852158, 0.08007777597488817], - linf = [0.2535807803900303, 0.17397028249895308, 0.12321616095649354, 0.269046666668995], - tspan = (0.0, 0.2), - coverage_override = (maxiters=2,)) - # 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_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl"), - # This stuff is experimental and annoying to test. In the future, we plan - # to move it to another repository. Thus, we save developer time right now - # and do not run these tests anymore. - # l2 = [0.0009823702998067061, 0.004943231496200673, 0.0048604522073091815, 0.00496983530893294], - # linf = [0.00855717053383187, 0.02087422420794427, 0.017121993783086185, 0.02720703869972585], - maxiters = 30, - coverage_override = (maxiters=2,)) - end - - @trixi_testset "elixir_euler_colliding_flow.jl" begin + l2=[ + 0.2086261501910662, + 1.2118352377894666, + 0.10255333189606497, + 5.296238138639236, + ], + linf=[ + 14.829071984498198, + 74.12967742435727, + 6.863554388300223, + 303.58813147491134, + ], + tspan=(0.0, 0.12), + # Let this test run longer to cover the ControllerThreeLevelCombined lines + coverage_override=(maxiters = 10^5,)) + # 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_euler_kelvin_helmholtz_instability_fjordholm_etal.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability_fjordholm_etal.jl"), + l2=[ + 0.1057230211245312, + 0.10621112311257341, + 0.07260957505339989, + 0.11178239111065721, + ], + linf=[ + 2.998719417992662, + 2.1400285015556166, + 1.1569648700415078, + 1.8922492268110913, + ], + tspan=(0.0, 0.1)) + # 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_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + l2=[ + 0.055691508271624536, + 0.032986009333751655, + 0.05224390923711999, + 0.08009536362771563, + ], + linf=[ + 0.24043622527087494, + 0.1660878796929941, + 0.12355946691711608, + 0.2694290787257758, + ], + tspan=(0.0, 0.2)) + # 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_euler_kelvin_helmholtz_instability_amr.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability_amr.jl"), + l2=[ + 0.05569452733654995, + 0.033107109983417926, + 0.05223609622852158, + 0.08007777597488817, + ], + linf=[ + 0.2535807803900303, + 0.17397028249895308, + 0.12321616095649354, + 0.269046666668995, + ], + tspan=(0.0, 0.2), + coverage_override=(maxiters = 2,)) + # 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_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability_amr_neuralnetwork_perssonperaire.jl"), + # This stuff is experimental and annoying to test. In the future, we plan + # to move it to another repository. Thus, we save developer time right now + # and do not run these tests anymore. + # l2 = [0.0009823702998067061, 0.004943231496200673, 0.0048604522073091815, 0.00496983530893294], + # linf = [0.00855717053383187, 0.02087422420794427, 0.017121993783086185, 0.02720703869972585], + maxiters=30, + coverage_override=(maxiters = 2,)) +end + +@trixi_testset "elixir_euler_colliding_flow.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow.jl"), - l2 = [0.007237139090503349, 0.044887582765386916, 1.0453570959003603e-6, 0.6627307840935432], - linf = [0.19437260992446315, 0.5554343646648533, 5.943891455255412e-5, 15.188919846360125], - tspan = (0.0, 0.1)) - # 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_euler_colliding_flow_amr.jl" begin + l2=[ + 0.007237139090503349, + 0.044887582765386916, + 1.0453570959003603e-6, + 0.6627307840935432, + ], + linf=[ + 0.19437260992446315, + 0.5554343646648533, + 5.943891455255412e-5, + 15.188919846360125, + ], + tspan=(0.0, 0.1)) + # 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_euler_colliding_flow_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_colliding_flow_amr.jl"), - l2 = [0.006768801432802192, 0.032184992228603666, 6.923887797276484e-7, 0.6784222932398366], - linf = [0.2508663007713608, 0.4097017076529792, 0.0003528986458217968, 22.435474993016918], - tspan = (0.0, 0.1), - coverage_override = (maxiters=2,)) - # 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_euler_astro_jet_amr.jl" begin + l2=[ + 0.006768801432802192, + 0.032184992228603666, + 6.923887797276484e-7, + 0.6784222932398366, + ], + linf=[ + 0.2508663007713608, + 0.4097017076529792, + 0.0003528986458217968, + 22.435474993016918, + ], + tspan=(0.0, 0.1), + coverage_override=(maxiters = 2,)) + # 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_euler_astro_jet_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_astro_jet_amr.jl"), - l2 = [0.011338365293662804, 10.09743543555765, 0.00392429463200361, 4031.7811487690506], - linf = [3.3178633141984193, 2993.6445033486402, 8.031723414357423, 1.1918867260293828e6], - tspan = (0.0, 1.0e-7), - coverage_override = (maxiters=6,)) - # 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_euler_vortex.jl" begin + l2=[ + 0.011338365293662804, + 10.09743543555765, + 0.00392429463200361, + 4031.7811487690506, + ], + linf=[ + 3.3178633141984193, + 2993.6445033486402, + 8.031723414357423, + 1.1918867260293828e6, + ], + tspan=(0.0, 1.0e-7), + coverage_override=(maxiters = 6,)) + # 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_euler_vortex.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [0.00013492249515826863, 0.006615696236378061, 0.006782108219800376, 0.016393831451740604], - linf = [0.0020782600954247776, 0.08150078921935999, 0.08663621974991986, 0.2829930622010579]) - # 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_euler_vortex_mortar.jl" begin + l2=[ + 0.00013492249515826863, + 0.006615696236378061, + 0.006782108219800376, + 0.016393831451740604, + ], + linf=[ + 0.0020782600954247776, + 0.08150078921935999, + 0.08663621974991986, + 0.2829930622010579, + ]) + # 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_euler_vortex_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [0.0017208369388227673, 0.09628684992237334, 0.09620157717330868, 0.1758809552387432], - linf = [0.021869936355319086, 0.9956698009442038, 1.0002507727219028, 2.223249697515648]) - # 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_euler_vortex_mortar_split.jl" begin + # Expected errors are exactly the same as in the parallel test! + l2=[ + 0.0017208369388227673, + 0.09628684992237334, + 0.09620157717330868, + 0.1758809552387432, + ], + linf=[ + 0.021869936355319086, + 0.9956698009442038, + 1.0002507727219028, + 2.223249697515648, + ]) + # 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_euler_vortex_mortar_split.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_split.jl"), - l2 = [0.0017203323613648241, 0.09628962878682261, 0.09621241164155782, 0.17585995600340926], - linf = [0.021740570456931674, 0.9938841665880938, 1.004140123355135, 2.224108857746245]) - # 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_euler_vortex_shockcapturing.jl" begin + l2=[ + 0.0017203323613648241, + 0.09628962878682261, + 0.09621241164155782, + 0.17585995600340926, + ], + linf=[ + 0.021740570456931674, + 0.9938841665880938, + 1.004140123355135, + 2.224108857746245, + ]) + # 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_euler_vortex_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_shockcapturing.jl"), - l2 = [0.0017158367642679273, 0.09619888722871434, 0.09616432767924141, 0.17553381166255197], - linf = [0.021853862449723982, 0.9878047229255944, 0.9880191167111795, 2.2154030488035588]) - # 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_euler_vortex_mortar_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar_shockcapturing.jl"), - l2 = [0.0017203324051381415, 0.09628962899999398, 0.0962124115572114, 0.1758599596626405], - linf = [0.021740568112562086, 0.9938841624655501, 1.0041401179009877, 2.2241087041100798]) - # 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_euler_vortex_amr.jl" begin + l2=[ + 0.0017158367642679273, + 0.09619888722871434, + 0.09616432767924141, + 0.17553381166255197, + ], + linf=[ + 0.021853862449723982, + 0.9878047229255944, + 0.9880191167111795, + 2.2154030488035588, + ]) + # 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_euler_vortex_mortar_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_vortex_mortar_shockcapturing.jl"), + l2=[ + 0.0017203324051381415, + 0.09628962899999398, + 0.0962124115572114, + 0.1758599596626405, + ], + linf=[ + 0.021740568112562086, + 0.9938841624655501, + 1.0041401179009877, + 2.2241087041100798, + ]) + # 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_euler_vortex_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"), - # Expected errors are exactly the same as in the parallel test! - l2 = [5.051719943432265e-5, 0.0022574259317084747, 0.0021755998463189713, 0.004346492398617521], - linf = [0.0012880114865917447, 0.03857193149447702, 0.031090457959835893, 0.12125130332971423], - # Let this test run longer to cover some lines in the AMR indicator - coverage_override = (maxiters=10^5, tspan=(0.0, 10.5))) - # 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_euler_ec.jl with boundary_condition_slip_wall" begin + # Expected errors are exactly the same as in the parallel test! + l2=[ + 5.051719943432265e-5, + 0.0022574259317084747, + 0.0021755998463189713, + 0.004346492398617521, + ], + linf=[ + 0.0012880114865917447, + 0.03857193149447702, + 0.031090457959835893, + 0.12125130332971423, + ], + # Let this test run longer to cover some lines in the AMR indicator + coverage_override=(maxiters = 10^5, tspan = (0.0, 10.5))) + # 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_euler_ec.jl with boundary_condition_slip_wall" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.03341239373099515, 0.026673245711492915, 0.026678871434568822, 0.12397486476145089], - linf = [0.3290981764688339, 0.3812055782309788, 0.3812041851225023, 1.168251216556933], - periodicity = false, boundary_conditions = boundary_condition_slip_wall, - cfl = 0.3, tspan = (0.0, 0.1)) # this test is sensitive to the CFL factor - # 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 + l2=[ + 0.03341239373099515, + 0.026673245711492915, + 0.026678871434568822, + 0.12397486476145089, + ], + linf=[ + 0.3290981764688339, + 0.3812055782309788, + 0.3812041851225023, + 1.168251216556933, + ], + periodicity=false, + boundary_conditions=boundary_condition_slip_wall, + cfl=0.3, tspan=(0.0, 0.1)) # this test is sensitive to the CFL factor + # 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 # Coverage test for all initial conditions @testset "Compressible Euler: Tests for initial conditions" begin - @trixi_testset "elixir_euler_vortex.jl one step with initial_condition_constant" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [1.1790213022362371e-16, 8.580657423476384e-17, 1.3082387431804115e-16, 1.6182739965672862e-15], - linf = [3.3306690738754696e-16, 2.220446049250313e-16, 5.273559366969494e-16, 3.552713678800501e-15], - maxiters = 1, - initial_condition = initial_condition_constant) - # 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_euler_sedov_blast_wave.jl one step" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [0.0021196114178949396, 0.010703549234544042, 0.01070354923454404, 0.10719124037195142], - linf = [0.11987270645890724, 0.7468615461136827, 0.7468615461136827, 3.910689155287799], - maxiters=1) - - # 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_euler_vortex.jl one step with initial_condition_constant" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 1.1790213022362371e-16, + 8.580657423476384e-17, + 1.3082387431804115e-16, + 1.6182739965672862e-15, + ], + linf=[ + 3.3306690738754696e-16, + 2.220446049250313e-16, + 5.273559366969494e-16, + 3.552713678800501e-15, + ], + maxiters=1, + initial_condition=initial_condition_constant) + # 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_euler_sedov_blast_wave.jl one step" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), + l2=[ + 0.0021196114178949396, + 0.010703549234544042, + 0.01070354923454404, + 0.10719124037195142, + ], + linf=[ + 0.11987270645890724, + 0.7468615461136827, + 0.7468615461136827, + 3.910689155287799, + ], + maxiters=1) + + # 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 end -end # module \ No newline at end of file +end # module diff --git a/test/test_tree_2d_euleracoustics.jl b/test/test_tree_2d_euleracoustics.jl index df4bd5d7bfc..e3a4d65f398 100644 --- a/test/test_tree_2d_euleracoustics.jl +++ b/test/test_tree_2d_euleracoustics.jl @@ -8,22 +8,40 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "Acoustic perturbation coupled with compressible Euler" begin - @trixi_testset "elixir_euleracoustics_co-rotating_vortex_pair.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euleracoustics_co-rotating_vortex_pair.jl"), +#! format: noindent + +@trixi_testset "elixir_euleracoustics_co-rotating_vortex_pair.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euleracoustics_co-rotating_vortex_pair.jl"), initial_refinement_level=5, tspan1=(0.0, 1.0), tspan_averaging=(0.0, 1.0), tspan=(0.0, 1.0), - l2 = [0.00013268029905807722, 0.0001335062197031223, 0.00021776333678401362, 13.000001753042364, 26.00000080243847, 38.00000884725549, 51.000000003859995], - linf = [0.22312716933051027, 0.1579924424942319, 0.25194831158255576, 13.468872744263273, 26.54666679978679, 38.139032147739684, 51.378134660241294] - ) - # 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 + l2=[ + 0.00013268029905807722, + 0.0001335062197031223, + 0.00021776333678401362, + 13.000001753042364, + 26.00000080243847, + 38.00000884725549, + 51.000000003859995, + ], + linf=[ + 0.22312716933051027, + 0.1579924424942319, + 0.25194831158255576, + 13.468872744263273, + 26.54666679978679, + 38.139032147739684, + 51.378134660241294, + ]) + # 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 end -end # module \ No newline at end of file +end # module diff --git a/test/test_tree_2d_eulermulti.jl b/test/test_tree_2d_eulermulti.jl index c454a6bcfbf..2e808af6473 100644 --- a/test/test_tree_2d_eulermulti.jl +++ b/test/test_tree_2d_eulermulti.jl @@ -8,116 +8,205 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Compressible Euler Multicomponent" begin - # NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the - # simulations are set up with dimensional states. For example, the reference pressure in SI - # units is 101325 Pa, i.e., pressure has values of O(10^5) +#! format: noindent - @trixi_testset "elixir_eulermulti_shock_bubble.jl" begin +# NOTE: Some of the L2/Linf errors are comparably large. This is due to the fact that some of the +# simulations are set up with dimensional states. For example, the reference pressure in SI +# units is 101325 Pa, i.e., pressure has values of O(10^5) + +@trixi_testset "elixir_eulermulti_shock_bubble.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble.jl"), - l2 = [73.78467629094177, 0.9174752929795251, 57942.83587826468, 0.1828847253029943, 0.011127037850925347], - linf = [196.81051991521073, 7.8456811648529605, 158891.88930113698, 0.811379581519794, 0.08011973559187913], - tspan = (0.0, 0.001)) - # 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 + l2=[ + 73.78467629094177, + 0.9174752929795251, + 57942.83587826468, + 0.1828847253029943, + 0.011127037850925347, + ], + linf=[ + 196.81051991521073, + 7.8456811648529605, + 158891.88930113698, + 0.811379581519794, + 0.08011973559187913, + ], + tspan=(0.0, 0.001)) + # 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_eulermulti_shock_bubble_shockcapturing_subcell_positivity.jl" begin - rm("out/deviations.txt", force=true) - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_shock_bubble_shockcapturing_subcell_positivity.jl"), - l2 = [81.52845664909304, 2.5455678559421346, 63229.190712645846, 0.19929478404550321, 0.011068604228443425], - linf = [249.21708417382013, 40.33299887640794, 174205.0118831558, 0.6881458768113586, 0.11274401158173972], - initial_refinement_level = 3, - tspan = (0.0, 0.001), - output_directory="out") - lines = readlines("out/deviations.txt") - @test lines[1] == "# iter, simu_time, rho1_min, rho2_min" - @test startswith(lines[end], "1") - # 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)) < 15000 - end - end +@trixi_testset "elixir_eulermulti_shock_bubble_shockcapturing_subcell_positivity.jl" begin + rm("out/deviations.txt", force = true) + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_eulermulti_shock_bubble_shockcapturing_subcell_positivity.jl"), + l2=[ + 81.52845664909304, + 2.5455678559421346, + 63229.190712645846, + 0.19929478404550321, + 0.011068604228443425, + ], + linf=[ + 249.21708417382013, + 40.33299887640794, + 174205.0118831558, + 0.6881458768113586, + 0.11274401158173972, + ], + initial_refinement_level=3, + tspan=(0.0, 0.001), + output_directory="out") + lines = readlines("out/deviations.txt") + @test lines[1] == "# iter, simu_time, rho1_min, rho2_min" + @test startswith(lines[end], "1") + # 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)) < 15000 + end +end - @trixi_testset "elixir_eulermulti_ec.jl" begin +@trixi_testset "elixir_eulermulti_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_ec.jl"), - l2 = [0.050182236154087095, 0.050189894464434635, 0.2258715597305131, 0.06175171559771687], - linf = [0.3108124923284472, 0.3107380389947733, 1.054035804988521, 0.29347582879608936]) - # 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 + l2=[ + 0.050182236154087095, + 0.050189894464434635, + 0.2258715597305131, + 0.06175171559771687, + ], + linf=[ + 0.3108124923284472, + 0.3107380389947733, + 1.054035804988521, + 0.29347582879608936, + ]) + # 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_eulermulti_es.jl" begin +@trixi_testset "elixir_eulermulti_es.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_es.jl"), - l2 = [0.0496546258404055, 0.04965550099933263, 0.22425206549856372, 0.004087155041747821, 0.008174310083495642, 0.016348620166991283, 0.032697240333982566], - linf = [0.2488251110766228, 0.24832493304479406, 0.9310354690058298, 0.017452870465607374, 0.03490574093121475, 0.0698114818624295, 0.139622963724859]) - # 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 + l2=[ + 0.0496546258404055, + 0.04965550099933263, + 0.22425206549856372, + 0.004087155041747821, + 0.008174310083495642, + 0.016348620166991283, + 0.032697240333982566, + ], + linf=[ + 0.2488251110766228, + 0.24832493304479406, + 0.9310354690058298, + 0.017452870465607374, + 0.03490574093121475, + 0.0698114818624295, + 0.139622963724859, + ]) + # 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_eulermulti_convergence_ec.jl" begin +@trixi_testset "elixir_eulermulti_convergence_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_ec.jl"), - l2 = [0.00012290225488326508, 0.00012290225488321876, 0.00018867397906337653, 4.8542321753649044e-5, 9.708464350729809e-5], - linf = [0.0006722819239133315, 0.0006722819239128874, 0.0012662292789555885, 0.0002843844182700561, 0.0005687688365401122]) - # 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 + l2=[ + 0.00012290225488326508, + 0.00012290225488321876, + 0.00018867397906337653, + 4.8542321753649044e-5, + 9.708464350729809e-5, + ], + linf=[ + 0.0006722819239133315, + 0.0006722819239128874, + 0.0012662292789555885, + 0.0002843844182700561, + 0.0005687688365401122, + ]) + # 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_eulermulti_convergence_es.jl" begin +@trixi_testset "elixir_eulermulti_convergence_es.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [2.2661773867001696e-6, 2.266177386666318e-6, 6.593514692980009e-6, 8.836308667348217e-7, 1.7672617334696433e-6], - linf = [1.4713170997993075e-5, 1.4713170997104896e-5, 5.115618808515521e-5, 5.3639516094383666e-6, 1.0727903218876733e-5]) - # 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 + l2=[ + 2.2661773867001696e-6, + 2.266177386666318e-6, + 6.593514692980009e-6, + 8.836308667348217e-7, + 1.7672617334696433e-6, + ], + linf=[ + 1.4713170997993075e-5, + 1.4713170997104896e-5, + 5.115618808515521e-5, + 5.3639516094383666e-6, + 1.0727903218876733e-5, + ]) + # 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_eulermulti_convergence_es.jl with flux_chandrashekar" begin +@trixi_testset "elixir_eulermulti_convergence_es.jl with flux_chandrashekar" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulermulti_convergence_es.jl"), - l2 = [1.8621737639352465e-6, 1.862173764098385e-6, 5.942585713809631e-6, 6.216263279534722e-7, 1.2432526559069443e-6], - linf = [1.6235495582606063e-5, 1.6235495576388814e-5, 5.854523678827661e-5, 5.790274858807898e-6, 1.1580549717615796e-5], - volume_flux = flux_chandrashekar) - # 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 + l2=[ + 1.8621737639352465e-6, + 1.862173764098385e-6, + 5.942585713809631e-6, + 6.216263279534722e-7, + 1.2432526559069443e-6, + ], + linf=[ + 1.6235495582606063e-5, + 1.6235495576388814e-5, + 5.854523678827661e-5, + 5.790274858807898e-6, + 1.1580549717615796e-5, + ], + volume_flux=flux_chandrashekar) + # 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 end # module diff --git a/test/test_tree_2d_fdsbp.jl b/test/test_tree_2d_fdsbp.jl index efb24562e57..c0844ee5dba 100644 --- a/test/test_tree_2d_fdsbp.jl +++ b/test/test_tree_2d_fdsbp.jl @@ -8,105 +8,152 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_fdsbp") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_extended.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_extended.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [2.898644263922225e-6], - linf = [8.491517930142578e-6], - rtol = 1.0e-7) # These results change a little bit and depend on the CI system + l2=[2.898644263922225e-6], + linf=[8.491517930142578e-6], + rtol=1.0e-7) # These results change a little bit and depend on the CI system # 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 + 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_extended.jl with periodic operators" begin +@trixi_testset "elixir_advection_extended.jl with periodic operators" begin + global D = SummationByPartsOperators.periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, + xmax = 1.0, + N = 40) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.1239649404463432e-5], - linf = [1.5895264629195438e-5], - D_SBP = SummationByPartsOperators.periodic_derivative_operator( - derivative_order = 1, accuracy_order = 4, xmin = 0.0, xmax = 1.0, N = 40), - initial_refinement_level = 0) + l2=[1.1239649404463432e-5], + linf=[1.5895264629195438e-5], + D_SBP=D, + initial_refinement_level=0) # 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 + 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 end @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [1.7088389997042244e-6, 1.7437997855125774e-6, 1.7437997855350776e-6, 5.457223460127621e-6], - linf = [9.796504903736292e-6, 9.614745892783105e-6, 9.614745892783105e-6, 4.026107182575345e-5], - tspan = (0.0, 0.1)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 1.7088389997042244e-6, + 1.7437997855125774e-6, + 1.7437997855350776e-6, + 5.457223460127621e-6, + ], + linf=[ + 9.796504903736292e-6, + 9.614745892783105e-6, + 9.614745892783105e-6, + 4.026107182575345e-5, + ], + tspan=(0.0, 0.1)) + + # 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 - # 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 + @trixi_testset "elixir_euler_convergence.jl with Lax-Friedrichs splitting" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 2.1149087345799973e-6, + 1.9391438806845798e-6, + 1.9391438806759794e-6, + 5.842833764682604e-6, + ], + linf=[ + 1.3679037540903494e-5, + 1.1770587849069258e-5, + 1.1770587848403125e-5, + 4.68952678644996e-5, + ], + tspan=(0.0, 0.1), flux_splitting=splitting_lax_friedrichs) + + # 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_euler_convergence.jl with Lax-Friedrichs splitting" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [2.1149087345799973e-6, 1.9391438806845798e-6, 1.9391438806759794e-6, 5.842833764682604e-6], - linf = [1.3679037540903494e-5, 1.1770587849069258e-5, 1.1770587848403125e-5, 4.68952678644996e-5], - tspan = (0.0, 0.1), flux_splitting = splitting_lax_friedrichs) + @trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_euler_kelvin_helmholtz_instability.jl"), + l2=[ + 0.02607850081951497, + 0.020357717558016252, + 0.028510191844948945, + 0.02951535039734857, + ], + linf=[ + 0.12185328623662173, + 0.1065055387595834, + 0.06257122956937419, + 0.11992349951978643, + ], + tspan=(0.0, 0.1)) + + # 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 - # 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_euler_kelvin_helmholtz_instability.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_kelvin_helmholtz_instability.jl"), - l2 = [0.02607850081951497, 0.020357717558016252, 0.028510191844948945, 0.02951535039734857], - linf = [0.12185328623662173, 0.1065055387595834, 0.06257122956937419, 0.11992349951978643], - tspan = (0.0, 0.1)) - - # 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_euler_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), - l2 = [0.0005330228930711585, 0.028475888529345014, 0.02847513865894387, 0.056259951995581196], - linf = [0.007206088611304784, 0.31690373882847234, 0.31685665067192326, 0.7938167296134893], - tspan = (0.0, 0.25)) - - # 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_euler_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"), + l2=[ + 0.0005330228930711585, + 0.028475888529345014, + 0.02847513865894387, + 0.056259951995581196, + ], + linf=[ + 0.007206088611304784, + 0.31690373882847234, + 0.31685665067192326, + 0.7938167296134893, + ], + tspan=(0.0, 0.25)) + + # 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 end # module diff --git a/test/test_tree_2d_hypdiff.jl b/test/test_tree_2d_hypdiff.jl index 30481fe910a..8c5973cbf07 100644 --- a/test/test_tree_2d_hypdiff.jl +++ b/test/test_tree_2d_hypdiff.jl @@ -8,62 +8,97 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Hyperbolic diffusion" begin - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin +#! format: noindent + +@trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2 = [0.00015687751817403066, 0.001025986772216324, 0.0010259867722164071], - linf = [0.001198695637957381, 0.006423873515531753, 0.006423873515533529]) - # 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)) < 15000 - end - end + l2=[ + 0.00015687751817403066, + 0.001025986772216324, + 0.0010259867722164071, + ], + linf=[ + 0.001198695637957381, + 0.006423873515531753, + 0.006423873515533529, + ]) + # 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)) < 15000 + end +end - @trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_harmonic_nonperiodic.jl"), - l2 = [8.618132355121019e-8, 5.619399844384306e-7, 5.619399844844044e-7], - linf = [1.1248618588430072e-6, 8.622436487026874e-6, 8.622436487915053e-6]) - # 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_hypdiff_harmonic_nonperiodic.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_hypdiff_harmonic_nonperiodic.jl"), + l2=[ + 8.618132355121019e-8, + 5.619399844384306e-7, + 5.619399844844044e-7, + ], + linf=[ + 1.1248618588430072e-6, + 8.622436487026874e-6, + 8.622436487915053e-6, + ]) + # 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_hypdiff_nonperiodic.jl" begin +@trixi_testset "elixir_hypdiff_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [8.523077653954864e-6, 2.8779323653020624e-5, 5.454942769125663e-5], - linf = [5.522740952468297e-5, 0.00014544895978971679, 0.00032396328684924924]) - # 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 + l2=[ + 8.523077653954864e-6, + 2.8779323653020624e-5, + 5.454942769125663e-5, + ], + linf=[ + 5.522740952468297e-5, + 0.00014544895978971679, + 0.00032396328684924924, + ]) + # 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_hypdiff_godunov.jl" begin +@trixi_testset "elixir_hypdiff_godunov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"), - l2 = [5.868147556427088e-6, 3.80517927324465e-5, 3.805179273249344e-5], - linf = [3.701965498725812e-5, 0.0002122422943138247, 0.00021224229431116015], - atol = 2.0e-12 #= required for CI on macOS =#) - # 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 + l2=[ + 5.868147556427088e-6, + 3.80517927324465e-5, + 3.805179273249344e-5, + ], + linf=[ + 3.701965498725812e-5, + 0.0002122422943138247, + 0.00021224229431116015, + ], + atol=2.0e-12) #= required for CI on macOS =# + # 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 end # module diff --git a/test/test_tree_2d_kpp.jl b/test/test_tree_2d_kpp.jl index fb2a212ddf8..c9af68c6cc4 100644 --- a/test/test_tree_2d_kpp.jl +++ b/test/test_tree_2d_kpp.jl @@ -8,26 +8,28 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "KPP" begin - @trixi_testset "elixir_kpp.jl" begin +#! format: noindent + +@trixi_testset "elixir_kpp.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_kpp.jl"), - l2 = [0.36563290910786106], - linf = [9.116732052340398], - max_refinement_level = 6, - tspan = (0.0, 0.01), - atol = 1e-6, - rtol = 1e-6, - skip_coverage = true) - if @isdefined sol # Skipped in coverage run + l2=[0.36563290910786106], + linf=[9.116732052340398], + max_refinement_level=6, + tspan=(0.0, 0.01), + atol=1e-6, + rtol=1e-6, + skip_coverage=true) + if @isdefined sol # Skipped in coverage run # 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 + 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 + end +end end end # module diff --git a/test/test_tree_2d_lbm.jl b/test/test_tree_2d_lbm.jl index 690c04ceae3..4705c9d0d03 100644 --- a/test/test_tree_2d_lbm.jl +++ b/test/test_tree_2d_lbm.jl @@ -8,120 +8,154 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Lattice-Boltzmann" begin - @trixi_testset "elixir_lbm_constant.jl" begin +#! format: noindent + +@trixi_testset "elixir_lbm_constant.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_constant.jl"), - l2 = [4.888991832247047e-15, 4.8856380534982224e-15, 5.140829677785587e-16, - 7.340293204570167e-16, 2.0559494114924474e-15, 6.125746684189216e-16, - 1.6545443003155128e-16, 6.001333022242579e-16, 9.450994018139234e-15], - linf = [5.551115123125783e-15, 5.662137425588298e-15, 1.2212453270876722e-15, - 1.27675647831893e-15, 2.4980018054066022e-15, 7.494005416219807e-16, - 4.3021142204224816e-16, 8.881784197001252e-16, 1.0436096431476471e-14]) - # 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 + l2=[4.888991832247047e-15, 4.8856380534982224e-15, + 5.140829677785587e-16, + 7.340293204570167e-16, 2.0559494114924474e-15, + 6.125746684189216e-16, + 1.6545443003155128e-16, 6.001333022242579e-16, + 9.450994018139234e-15], + linf=[5.551115123125783e-15, 5.662137425588298e-15, + 1.2212453270876722e-15, + 1.27675647831893e-15, 2.4980018054066022e-15, + 7.494005416219807e-16, + 4.3021142204224816e-16, 8.881784197001252e-16, + 1.0436096431476471e-14]) + # 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_lbm_couette.jl" begin +@trixi_testset "elixir_lbm_couette.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), - l2 = [0.0007899749117603378, 7.0995283148275575e-6, 0.0007454191223764233, - 1.6482025869100257e-5, 0.00012684365365448903, 0.0001198942846383015, - 0.00028436349827736705, 0.0003005161103138576, 4.496683876631818e-5], - linf = [0.005596384769998769, 4.771160474496827e-5, 0.005270322068908595, - 0.00011747787108790098, 0.00084326349695725, 0.000795551892211168, - 0.001956482118303543, 0.0020739599893902436, 0.00032606270109525326], - tspan = (0.0, 1.0)) - # 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 + l2=[0.0007899749117603378, 7.0995283148275575e-6, + 0.0007454191223764233, + 1.6482025869100257e-5, 0.00012684365365448903, + 0.0001198942846383015, + 0.00028436349827736705, 0.0003005161103138576, + 4.496683876631818e-5], + linf=[0.005596384769998769, 4.771160474496827e-5, + 0.005270322068908595, + 0.00011747787108790098, 0.00084326349695725, + 0.000795551892211168, + 0.001956482118303543, 0.0020739599893902436, + 0.00032606270109525326], + tspan=(0.0, 1.0)) + # 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_lbm_lid_driven_cavity.jl" begin +@trixi_testset "elixir_lbm_lid_driven_cavity.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), - l2 = [0.0013628495945172754, 0.00021475256243322154, 0.0012579141312268184, - 0.00036542734715110765, 0.00024127756258120715, 0.00022899415795341014, - 0.0004225564518328741, 0.0004593854895507851, 0.00044244398903669927], - linf = [0.025886626070758242, 0.00573859077176217, 0.027568805277855102, 0.00946724671122974, - 0.004031686575556803, 0.0038728927083346437, 0.020038695575169005, - 0.02061789496737146, 0.05568236920459335], - tspan = (0.0, 1.0)) - # 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 + l2=[0.0013628495945172754, 0.00021475256243322154, + 0.0012579141312268184, + 0.00036542734715110765, 0.00024127756258120715, + 0.00022899415795341014, + 0.0004225564518328741, 0.0004593854895507851, + 0.00044244398903669927], + linf=[0.025886626070758242, 0.00573859077176217, + 0.027568805277855102, 0.00946724671122974, + 0.004031686575556803, 0.0038728927083346437, + 0.020038695575169005, + 0.02061789496737146, 0.05568236920459335], + tspan=(0.0, 1.0)) + # 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_lbm_couette.jl with initial_condition_couette_steady" begin +@trixi_testset "elixir_lbm_couette.jl with initial_condition_couette_steady" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_couette.jl"), - l2 = [9.321369073400123e-16, 1.6498793963435488e-6, 5.211495843124065e-16, - 1.6520893954826173e-6, 1.0406056181388841e-5, 8.801606429417205e-6, - 8.801710065560555e-6, 1.040614383799995e-5, 2.6135657178357052e-15], - linf = [1.4432899320127035e-15, 2.1821189867266e-6, 8.881784197001252e-16, - 2.2481261510165496e-6, 1.0692966335143494e-5, 9.606391697600247e-6, - 9.62138334279633e-6, 1.0725969916147021e-5, 3.3861802251067274e-15], - initial_condition=function initial_condition_couette_steady(x, t, equations::LatticeBoltzmannEquations2D) - # Initial state for a *steady* Couette flow setup. To be used in combination with - # [`boundary_condition_couette`](@ref) and [`boundary_condition_noslip_wall`](@ref). - @unpack L, u0, rho0 = equations + l2=[9.321369073400123e-16, 1.6498793963435488e-6, + 5.211495843124065e-16, + 1.6520893954826173e-6, 1.0406056181388841e-5, + 8.801606429417205e-6, + 8.801710065560555e-6, 1.040614383799995e-5, + 2.6135657178357052e-15], + linf=[1.4432899320127035e-15, 2.1821189867266e-6, + 8.881784197001252e-16, + 2.2481261510165496e-6, 1.0692966335143494e-5, + 9.606391697600247e-6, + 9.62138334279633e-6, 1.0725969916147021e-5, + 3.3861802251067274e-15], + initial_condition=function initial_condition_couette_steady(x, + t, + equations::LatticeBoltzmannEquations2D) + # Initial state for a *steady* Couette flow setup. To be used in combination with + # [`boundary_condition_couette`](@ref) and [`boundary_condition_noslip_wall`](@ref). + @unpack L, u0, rho0 = equations - rho = rho0 - v1 = u0 * x[2] / L - v2 = 0 + rho = rho0 + v1 = u0 * x[2] / L + v2 = 0 - return equilibrium_distribution(rho, v1, v2, equations) - # 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, - tspan = (0.0, 1.0)) - # 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 + return equilibrium_distribution(rho, v1, v2, equations) + # 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, + tspan=(0.0, 1.0)) + # 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_lbm_lid_driven_cavity.jl with stationary walls" begin +@trixi_testset "elixir_lbm_lid_driven_cavity.jl with stationary walls" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_lid_driven_cavity.jl"), - l2 = [1.7198203373689985e-16, 1.685644347036533e-16, 2.1604974801394525e-16, - 2.1527076266915764e-16, 4.2170298143732604e-17, 5.160156233016299e-17, - 6.167794865198169e-17, 5.24166554417795e-17, 6.694740573885739e-16], - linf = [5.967448757360216e-16, 6.522560269672795e-16, 6.522560269672795e-16, - 6.245004513516506e-16, 2.1163626406917047e-16, 2.185751579730777e-16, - 2.185751579730777e-16, 2.393918396847994e-16, 1.887379141862766e-15], - boundary_conditions=boundary_condition_noslip_wall, - tspan = (0, 0.1)) + l2=[1.7198203373689985e-16, 1.685644347036533e-16, + 2.1604974801394525e-16, + 2.1527076266915764e-16, 4.2170298143732604e-17, + 5.160156233016299e-17, + 6.167794865198169e-17, 5.24166554417795e-17, + 6.694740573885739e-16], + linf=[5.967448757360216e-16, 6.522560269672795e-16, + 6.522560269672795e-16, + 6.245004513516506e-16, 2.1163626406917047e-16, + 2.185751579730777e-16, + 2.185751579730777e-16, 2.393918396847994e-16, + 1.887379141862766e-15], + boundary_conditions=boundary_condition_noslip_wall, + tspan=(0, 0.1)) - # 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 + # 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 end # module diff --git a/test/test_tree_2d_linearizedeuler.jl b/test/test_tree_2d_linearizedeuler.jl index 93da887e73f..7bdb83e328e 100644 --- a/test/test_tree_2d_linearizedeuler.jl +++ b/test/test_tree_2d_linearizedeuler.jl @@ -7,33 +7,54 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "Linearized Euler Equations 2D" begin - @trixi_testset "elixir_linearizedeuler_convergence.jl" begin +#! format: noindent + +@trixi_testset "elixir_linearizedeuler_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_convergence.jl"), - l2 = [0.00020601485381444888, 0.00013380483421751216, 0.0001338048342174503, 0.00020601485381444888], - linf = [0.0011006084408365924, 0.0005788678074691855, 0.0005788678074701847, 0.0011006084408365924] - ) - # 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 + l2=[ + 0.00020601485381444888, + 0.00013380483421751216, + 0.0001338048342174503, + 0.00020601485381444888, + ], + linf=[ + 0.0011006084408365924, + 0.0005788678074691855, + 0.0005788678074701847, + 0.0011006084408365924, + ]) + # 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_linearizedeuler_gauss_wall.jl" begin +@trixi_testset "elixir_linearizedeuler_gauss_wall.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_linearizedeuler_gauss_wall.jl"), - l2 = [0.048185623945503485, 0.01941899333212175, 0.019510224816991825, 0.048185623945503485], - linf = [1.0392165942153189, 0.18188777290819994, 0.1877028372108587, 1.0392165942153189]) + l2=[ + 0.048185623945503485, + 0.01941899333212175, + 0.019510224816991825, + 0.048185623945503485, + ], + linf=[ + 1.0392165942153189, + 0.18188777290819994, + 0.1877028372108587, + 1.0392165942153189, + ]) - # 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 + # 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 diff --git a/test/test_tree_2d_mhd.jl b/test/test_tree_2d_mhd.jl index 270bdc19fa3..af264561027 100644 --- a/test/test_tree_2d_mhd.jl +++ b/test/test_tree_2d_mhd.jl @@ -8,143 +8,326 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "MHD" begin - @trixi_testset "elixir_mhd_alfven_wave.jl" begin +#! format: noindent + +@trixi_testset "elixir_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.00011149543672225127, 5.888242524520296e-6, 5.888242524510072e-6, 8.476931432519067e-6, 1.3160738644036652e-6, 1.2542675002588144e-6, 1.2542675002747718e-6, 1.8705223407238346e-6, 4.651717010670585e-7], - linf = [0.00026806333988971254, 1.6278838272418272e-5, 1.627883827305665e-5, 2.7551183488072617e-5, 5.457878055614707e-6, 8.130129322880819e-6, 8.130129322769797e-6, 1.2406302192291552e-5, 2.373765544951732e-6]) - # 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 + l2=[ + 0.00011149543672225127, + 5.888242524520296e-6, + 5.888242524510072e-6, + 8.476931432519067e-6, + 1.3160738644036652e-6, + 1.2542675002588144e-6, + 1.2542675002747718e-6, + 1.8705223407238346e-6, + 4.651717010670585e-7, + ], + linf=[ + 0.00026806333988971254, + 1.6278838272418272e-5, + 1.627883827305665e-5, + 2.7551183488072617e-5, + 5.457878055614707e-6, + 8.130129322880819e-6, + 8.130129322769797e-6, + 1.2406302192291552e-5, + 2.373765544951732e-6, + ]) + # 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_mhd_alfven_wave.jl with flux_derigs_etal" begin +@trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [1.7201098719531215e-6, 8.692057393373005e-7, 8.69205739320643e-7, 1.2726508184718958e-6, 1.040607127595208e-6, 1.07029565814218e-6, 1.0702956581404748e-6, 1.3291748105236525e-6, 4.6172239295786824e-7], - linf = [9.865325754310206e-6, 7.352074675170961e-6, 7.352074674185638e-6, 1.0675656902672803e-5, 5.112498347226158e-6, 7.789533065905019e-6, 7.789533065905019e-6, 1.0933531593274037e-5, 2.340244047768378e-6], - volume_flux = (flux_derigs_etal, flux_nonconservative_powell)) - # 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 + l2=[ + 1.7201098719531215e-6, + 8.692057393373005e-7, + 8.69205739320643e-7, + 1.2726508184718958e-6, + 1.040607127595208e-6, + 1.07029565814218e-6, + 1.0702956581404748e-6, + 1.3291748105236525e-6, + 4.6172239295786824e-7, + ], + linf=[ + 9.865325754310206e-6, + 7.352074675170961e-6, + 7.352074674185638e-6, + 1.0675656902672803e-5, + 5.112498347226158e-6, + 7.789533065905019e-6, + 7.789533065905019e-6, + 1.0933531593274037e-5, + 2.340244047768378e-6, + ], + volume_flux=(flux_derigs_etal, flux_nonconservative_powell)) + # 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_mhd_alfven_wave_mortar.jl" begin +@trixi_testset "elixir_mhd_alfven_wave_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_mortar.jl"), - l2 = [3.7762324533854616e-6, 1.5534623833573546e-6, 1.4577234868196855e-6, 1.7647724628707057e-6, 1.4831911814574333e-6, 1.456369119716533e-6, 1.4115666913995062e-6, 1.804758237422838e-6, 8.320469738087189e-7], - linf = [3.670661330201774e-5, 1.530289442645827e-5, 1.3592183785327006e-5, 1.5173897443654383e-5, 9.43771379136038e-6, 1.0906323046233624e-5, 1.0603954940346938e-5, 1.5900499596113726e-5, 5.978772247650426e-6], - tspan = (0.0, 1.0)) - # 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 + l2=[ + 3.7762324533854616e-6, + 1.5534623833573546e-6, + 1.4577234868196855e-6, + 1.7647724628707057e-6, + 1.4831911814574333e-6, + 1.456369119716533e-6, + 1.4115666913995062e-6, + 1.804758237422838e-6, + 8.320469738087189e-7, + ], + linf=[ + 3.670661330201774e-5, + 1.530289442645827e-5, + 1.3592183785327006e-5, + 1.5173897443654383e-5, + 9.43771379136038e-6, + 1.0906323046233624e-5, + 1.0603954940346938e-5, + 1.5900499596113726e-5, + 5.978772247650426e-6, + ], + tspan=(0.0, 1.0)) + # 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_mhd_ec.jl" begin +@trixi_testset "elixir_mhd_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.03637302248881514, 0.043002991956758996, 0.042987505670836056, 0.02574718055258975, 0.1621856170457943, 0.01745369341302589, 0.017454552320664566, 0.026873190440613117, 5.336243933079389e-16], - linf = [0.23623816236321427, 0.3137152204179957, 0.30378397831730597, 0.21500228807094865, 0.9042495730546518, 0.09398098096581875, 0.09470282020962917, 0.15277253978297378, 4.307694418935709e-15]) - # 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 + l2=[ + 0.03637302248881514, + 0.043002991956758996, + 0.042987505670836056, + 0.02574718055258975, + 0.1621856170457943, + 0.01745369341302589, + 0.017454552320664566, + 0.026873190440613117, + 5.336243933079389e-16, + ], + linf=[ + 0.23623816236321427, + 0.3137152204179957, + 0.30378397831730597, + 0.21500228807094865, + 0.9042495730546518, + 0.09398098096581875, + 0.09470282020962917, + 0.15277253978297378, + 4.307694418935709e-15, + ]) + # 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_mhd_orszag_tang.jl" begin +@trixi_testset "elixir_mhd_orszag_tang.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), - l2 = [0.21967600768935716, 0.2643126515795721, 0.31488287201980875, 0.0, 0.5160141621186931, 0.23028914748088603, 0.34413527376463915, 0.0, 0.003178793090381426], - linf = [1.2749969218080568, 0.6737013368774057, 0.8604154399895696, 0.0, 2.799342099887639, 0.6473347557712643, 0.9691773375490476, 0.0, 0.05729832038724348], - tspan = (0.0, 0.09)) - # 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 + l2=[ + 0.21967600768935716, + 0.2643126515795721, + 0.31488287201980875, + 0.0, + 0.5160141621186931, + 0.23028914748088603, + 0.34413527376463915, + 0.0, + 0.003178793090381426, + ], + linf=[ + 1.2749969218080568, + 0.6737013368774057, + 0.8604154399895696, + 0.0, + 2.799342099887639, + 0.6473347557712643, + 0.9691773375490476, + 0.0, + 0.05729832038724348, + ], + tspan=(0.0, 0.09)) + # 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_mhd_orszag_tang.jl with flux_hll" begin +@trixi_testset "elixir_mhd_orszag_tang.jl with flux_hll" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_orszag_tang.jl"), - l2 = [0.10806619664693064, 0.20199136742199922, 0.22984589847526207, 0.0, 0.29950152196422647, 0.15688413207147794, 0.24293641543490646, 0.0, 0.003246181006326598], - linf = [0.560316034595759, 0.5095520363866776, 0.6536748458764621, 0.0, 0.9627447086204038, 0.3981375420906146, 0.673472146198816, 0.0, 0.04879208429337193], - tspan = (0.0, 0.06), surface_flux = (flux_hll, flux_nonconservative_powell)) - # 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 + l2=[ + 0.10806619664693064, + 0.20199136742199922, + 0.22984589847526207, + 0.0, + 0.29950152196422647, + 0.15688413207147794, + 0.24293641543490646, + 0.0, + 0.003246181006326598, + ], + linf=[ + 0.560316034595759, + 0.5095520363866776, + 0.6536748458764621, + 0.0, + 0.9627447086204038, + 0.3981375420906146, + 0.673472146198816, + 0.0, + 0.04879208429337193, + ], + tspan=(0.0, 0.06), + surface_flux=(flux_hll, flux_nonconservative_powell)) + # 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_mhd_alfven_wave.jl one step with initial_condition_constant" begin +@trixi_testset "elixir_mhd_alfven_wave.jl one step with initial_condition_constant" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [7.144325530681224e-17, 2.123397983547417e-16, 5.061138912500049e-16, 3.6588423152083e-17, 8.449816179702522e-15, 3.9171737639099993e-16, 2.445565690318772e-16, 3.6588423152083e-17, 9.971153407737885e-17], - linf = [2.220446049250313e-16, 8.465450562766819e-16, 1.8318679906315083e-15, 1.1102230246251565e-16, 1.4210854715202004e-14, 8.881784197001252e-16, 4.440892098500626e-16, 1.1102230246251565e-16, 4.779017148551244e-16], - maxiters = 1, - initial_condition = initial_condition_constant, - atol = 2.0e-13) - # 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 + l2=[ + 7.144325530681224e-17, + 2.123397983547417e-16, + 5.061138912500049e-16, + 3.6588423152083e-17, + 8.449816179702522e-15, + 3.9171737639099993e-16, + 2.445565690318772e-16, + 3.6588423152083e-17, + 9.971153407737885e-17, + ], + linf=[ + 2.220446049250313e-16, + 8.465450562766819e-16, + 1.8318679906315083e-15, + 1.1102230246251565e-16, + 1.4210854715202004e-14, + 8.881784197001252e-16, + 4.440892098500626e-16, + 1.1102230246251565e-16, + 4.779017148551244e-16, + ], + maxiters=1, + initial_condition=initial_condition_constant, + atol=2.0e-13) + # 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_mhd_rotor.jl" begin +@trixi_testset "elixir_mhd_rotor.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"), - l2 = [1.2623319195262743, 1.8273050553090515, 1.7004151198284634, 0.0, 2.2978570581460818, 0.2147235065899803, 0.23558337696054493, 0.0, 0.0032515115395693483], - linf = [11.003677581472843, 14.70614192714736, 15.687648666952708, 0.0, 17.098104835553823, 1.3283750501377847, 1.4365828094434892, 0.0, 0.07886241196068537], - tspan = (0.0, 0.05)) - # 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 + l2=[ + 1.2623319195262743, + 1.8273050553090515, + 1.7004151198284634, + 0.0, + 2.2978570581460818, + 0.2147235065899803, + 0.23558337696054493, + 0.0, + 0.0032515115395693483, + ], + linf=[ + 11.003677581472843, + 14.70614192714736, + 15.687648666952708, + 0.0, + 17.098104835553823, + 1.3283750501377847, + 1.4365828094434892, + 0.0, + 0.07886241196068537, + ], + tspan=(0.0, 0.05)) + # 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_mhd_blast_wave.jl" begin +@trixi_testset "elixir_mhd_blast_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_blast_wave.jl"), - l2 = [0.17646728395490927, 3.866230215339417, 2.4867304651291255, 0.0, 355.4562971958441, 2.359493623565687, 1.4030741420730297, 0.0, 0.029613599942667133], - linf = [1.581630420824181, 44.15725488910748, 13.056964982196554, 0.0, 2244.875490238186, 13.07679044647926, 9.14612176426092, 0.0, 0.5154756722488522], - tspan = (0.0, 0.003), - # Calling the AnalysisCallback before iteration 9 causes the interpolation - # of this IC to have negative density/pressure values, crashing the simulation. - coverage_override = (maxiters=9,)) - # 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 + l2=[ + 0.17646728395490927, + 3.866230215339417, + 2.4867304651291255, + 0.0, + 355.4562971958441, + 2.359493623565687, + 1.4030741420730297, + 0.0, + 0.029613599942667133, + ], + linf=[ + 1.581630420824181, + 44.15725488910748, + 13.056964982196554, + 0.0, + 2244.875490238186, + 13.07679044647926, + 9.14612176426092, + 0.0, + 0.5154756722488522, + ], + tspan=(0.0, 0.003), + # Calling the AnalysisCallback before iteration 9 causes the interpolation + # of this IC to have negative density/pressure values, crashing the simulation. + coverage_override=(maxiters = 9,)) + # 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 end # module diff --git a/test/test_tree_2d_mhdmulti.jl b/test/test_tree_2d_mhdmulti.jl index a73e39a6d6d..d36554a6679 100644 --- a/test/test_tree_2d_mhdmulti.jl +++ b/test/test_tree_2d_mhdmulti.jl @@ -8,102 +8,126 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") @testset "MHD Multicomponent" begin +#! format: noindent - @trixi_testset "elixir_mhdmulti_ec.jl" begin +@trixi_testset "elixir_mhdmulti_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.04300299195675897, 0.042987505670835945, 0.025747180552589767, 0.1621856170457937, - 0.017453693413025828, 0.0174545523206645, 0.026873190440613162, 1.364647699274761e-15, - 0.012124340829605002, 0.024248681659210004], - linf = [0.31371522041799105, 0.3037839783173047, 0.21500228807094351, 0.904249573054642, - 0.0939809809658183, 0.09470282020962761, 0.1527725397829759, 8.245701827530042e-15, - 0.0787460541210726, 0.1574921082421452]) - # 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 + l2=[0.04300299195675897, 0.042987505670835945, + 0.025747180552589767, 0.1621856170457937, + 0.017453693413025828, 0.0174545523206645, + 0.026873190440613162, 1.364647699274761e-15, + 0.012124340829605002, 0.024248681659210004], + linf=[0.31371522041799105, 0.3037839783173047, + 0.21500228807094351, 0.904249573054642, + 0.0939809809658183, 0.09470282020962761, 0.1527725397829759, + 8.245701827530042e-15, + 0.0787460541210726, 0.1574921082421452]) + # 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_mhdmulti_ec.jl with flux_derigs_etal" begin +@trixi_testset "elixir_mhdmulti_ec.jl with flux_derigs_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_ec.jl"), - l2 = [0.04301155595653799, 0.04299735787276207, 0.025745530869947714, - 0.16206102676791553, 0.017454384272339165, 0.01745523378100091, - 0.026879482381500154, 0.0002038008756963954, 0.012094208262809778, - 0.024188416525619556], - linf = [0.3156206778985397, 0.30941696929809526, 0.21167563519254176, - 0.9688251298546122, 0.09076254289155083, 0.09160589769498295, - 0.15698032974768705, 0.006131914796912965, 0.07839287555951036, - 0.1567857511190207], - volume_flux = (flux_derigs_etal, flux_nonconservative_powell), - surface_flux = (flux_derigs_etal, flux_nonconservative_powell)) - # 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 + l2=[0.04301155595653799, 0.04299735787276207, + 0.025745530869947714, + 0.16206102676791553, 0.017454384272339165, + 0.01745523378100091, + 0.026879482381500154, 0.0002038008756963954, + 0.012094208262809778, + 0.024188416525619556], + linf=[0.3156206778985397, 0.30941696929809526, + 0.21167563519254176, + 0.9688251298546122, 0.09076254289155083, + 0.09160589769498295, + 0.15698032974768705, 0.006131914796912965, + 0.07839287555951036, + 0.1567857511190207], + volume_flux=(flux_derigs_etal, flux_nonconservative_powell), + surface_flux=(flux_derigs_etal, flux_nonconservative_powell)) + # 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_mhdmulti_es.jl" begin +@trixi_testset "elixir_mhdmulti_es.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_es.jl"), - l2 = [0.042511527162267, 0.04250603277530184, 0.02385422747993974, 0.11555081362726903, - 0.016366641053738043, 0.01636681584592762, 0.02581748418797907, 0.00023394429554818215, - 0.010834603551662698, 0.021669207103325396], - linf = [0.23454607703107877, 0.23464789247380322, 0.11898832084115452, 0.5331209602648022, - 0.061744814466827336, 0.061767127585091286, 0.09595041452184983, 0.004421037168524759, - 0.06186597801911198, 0.12373195603822396]) - # 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 + l2=[0.042511527162267, 0.04250603277530184, 0.02385422747993974, + 0.11555081362726903, + 0.016366641053738043, 0.01636681584592762, + 0.02581748418797907, 0.00023394429554818215, + 0.010834603551662698, 0.021669207103325396], + linf=[0.23454607703107877, 0.23464789247380322, + 0.11898832084115452, 0.5331209602648022, + 0.061744814466827336, 0.061767127585091286, + 0.09595041452184983, 0.004421037168524759, + 0.06186597801911198, 0.12373195603822396]) + # 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_mhdmulti_convergence.jl" begin +@trixi_testset "elixir_mhdmulti_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_convergence.jl"), - l2 = [0.0003808877028249613, 0.0003808877028249593, 0.0005155994511260122, 0.000570394227652563, - 0.000439568811048544, 0.0004395688110485541, 0.0005074093477702055, 0.0003859005258180428, - 7.4611207452221e-5, 0.000149222414904442, 0.000298444829808884], - linf = [0.0013324014301672943, 0.0013324014301669181, 0.002684449324758791, 0.0016236816790307085, - 0.0019172373117153363, 0.0019172373117148922, 0.002664932274107224, 0.0011872396664042962, - 0.0002855492944235094, 0.0005710985888470188, 0.0011421971776940376]) - # 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 + l2=[0.0003808877028249613, 0.0003808877028249593, + 0.0005155994511260122, 0.000570394227652563, + 0.000439568811048544, 0.0004395688110485541, + 0.0005074093477702055, 0.0003859005258180428, + 7.4611207452221e-5, 0.000149222414904442, + 0.000298444829808884], + linf=[0.0013324014301672943, 0.0013324014301669181, + 0.002684449324758791, 0.0016236816790307085, + 0.0019172373117153363, 0.0019172373117148922, + 0.002664932274107224, 0.0011872396664042962, + 0.0002855492944235094, 0.0005710985888470188, + 0.0011421971776940376]) + # 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_mhdmulti_rotor.jl" begin +@trixi_testset "elixir_mhdmulti_rotor.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhdmulti_rotor.jl"), - l2 = [0.6574605535168556, 0.6623234319361953, 0.0, 0.689806698245354, - 0.04883686128677976, 0.08382459729494686, 0.0, 0.0021114516459281177, - 0.15909290019096098, 0.07954645009548049], - linf = [9.362339085941425, 9.169838118652539, 0.0, 10.600957847359556, - 0.6628317732399827, 1.4185626901435056, 0.0, 0.06914316292003836, - 3.328770801731456, 1.664385400865728], - tspan = (0.0, 0.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 Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 - end + l2=[0.6574605535168556, 0.6623234319361953, 0.0, + 0.689806698245354, + 0.04883686128677976, 0.08382459729494686, 0.0, + 0.0021114516459281177, + 0.15909290019096098, 0.07954645009548049], + linf=[9.362339085941425, 9.169838118652539, 0.0, + 10.600957847359556, + 0.6628317732399827, 1.4185626901435056, 0.0, + 0.06914316292003836, + 3.328770801731456, 1.664385400865728], + tspan=(0.0, 0.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 Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000 + end end - end end # module diff --git a/test/test_tree_2d_part1.jl b/test/test_tree_2d_part1.jl index c2076a7e235..2af1f29fcb6 100644 --- a/test/test_tree_2d_part1.jl +++ b/test/test_tree_2d_part1.jl @@ -9,82 +9,94 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh2D Part 1" begin +#! format: noindent # Run basic tests @testset "Examples 2D" begin - # Linear advection - include("test_tree_2d_advection.jl") + # Linear advection + include("test_tree_2d_advection.jl") - # Hyperbolic diffusion - include("test_tree_2d_hypdiff.jl") + # Hyperbolic diffusion + include("test_tree_2d_hypdiff.jl") end - @testset "Displaying components 2D" begin - @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) - - # test both short and long printing formats - @test_nowarn show(mesh); println() - @test_nowarn println(mesh) - @test_nowarn display(mesh) - - @test_nowarn show(equations); println() - @test_nowarn println(equations) - @test_nowarn display(equations) - - @test_nowarn show(solver); println() - @test_nowarn println(solver) - @test_nowarn display(solver) - - @test_nowarn show(solver.basis); println() - @test_nowarn println(solver.basis) - @test_nowarn display(solver.basis) - - @test_nowarn show(solver.mortar); println() - @test_nowarn println(solver.mortar) - @test_nowarn display(solver.mortar) - - @test_nowarn show(semi); println() - @test_nowarn println(semi) - @test_nowarn display(semi) - - @test_nowarn show(summary_callback); println() - @test_nowarn println(summary_callback) - @test_nowarn display(summary_callback) - - @test_nowarn show(amr_controller); println() - @test_nowarn println(amr_controller) - @test_nowarn display(amr_controller) - - @test_nowarn show(amr_callback); println() - @test_nowarn println(amr_callback) - @test_nowarn display(amr_callback) - - @test_nowarn show(stepsize_callback); println() - @test_nowarn println(stepsize_callback) - @test_nowarn display(stepsize_callback) - - @test_nowarn show(save_solution); println() - @test_nowarn println(save_solution) - @test_nowarn display(save_solution) - - @test_nowarn show(analysis_callback); println() - @test_nowarn println(analysis_callback) - @test_nowarn display(analysis_callback) - - @test_nowarn show(alive_callback); println() - @test_nowarn println(alive_callback) - @test_nowarn display(alive_callback) - - @test_nowarn println(callbacks) + @test_nowarn include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl")) + + # test both short and long printing formats + @test_nowarn show(mesh) + println() + @test_nowarn println(mesh) + @test_nowarn display(mesh) + + @test_nowarn show(equations) + println() + @test_nowarn println(equations) + @test_nowarn display(equations) + + @test_nowarn show(solver) + println() + @test_nowarn println(solver) + @test_nowarn display(solver) + + @test_nowarn show(solver.basis) + println() + @test_nowarn println(solver.basis) + @test_nowarn display(solver.basis) + + @test_nowarn show(solver.mortar) + println() + @test_nowarn println(solver.mortar) + @test_nowarn display(solver.mortar) + + @test_nowarn show(semi) + println() + @test_nowarn println(semi) + @test_nowarn display(semi) + + @test_nowarn show(summary_callback) + println() + @test_nowarn println(summary_callback) + @test_nowarn display(summary_callback) + + @test_nowarn show(amr_controller) + println() + @test_nowarn println(amr_controller) + @test_nowarn display(amr_controller) + + @test_nowarn show(amr_callback) + println() + @test_nowarn println(amr_callback) + @test_nowarn display(amr_callback) + + @test_nowarn show(stepsize_callback) + println() + @test_nowarn println(stepsize_callback) + @test_nowarn display(stepsize_callback) + + @test_nowarn show(save_solution) + println() + @test_nowarn println(save_solution) + @test_nowarn display(save_solution) + + @test_nowarn show(analysis_callback) + println() + @test_nowarn println(analysis_callback) + @test_nowarn display(analysis_callback) + + @test_nowarn show(alive_callback) + println() + @test_nowarn println(alive_callback) + @test_nowarn display(alive_callback) + + @test_nowarn println(callbacks) end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh2D Part 1 end #module diff --git a/test/test_tree_2d_part2.jl b/test/test_tree_2d_part2.jl index e25b5888c63..d8e86d14f18 100644 --- a/test/test_tree_2d_part2.jl +++ b/test/test_tree_2d_part2.jl @@ -7,34 +7,34 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh2D Part 2" begin +#! format: noindent # Run basic tests @testset "Examples 2D" begin - # Acoustic perturbation - include("test_tree_2d_acoustics.jl") + # Acoustic perturbation + include("test_tree_2d_acoustics.jl") - # Linearized Euler - include("test_tree_2d_linearizedeuler.jl") + # Linearized Euler + include("test_tree_2d_linearizedeuler.jl") - # Compressible Euler - include("test_tree_2d_euler.jl") + # Compressible Euler + include("test_tree_2d_euler.jl") - # Compressible Euler Multicomponent - include("test_tree_2d_eulermulti.jl") + # Compressible Euler Multicomponent + include("test_tree_2d_eulermulti.jl") - # Compressible Euler coupled with acoustic perturbation equations - include("test_tree_2d_euleracoustics.jl") + # Compressible Euler coupled with acoustic perturbation equations + include("test_tree_2d_euleracoustics.jl") - # KPP problem - include("test_tree_2d_kpp.jl") + # KPP problem + include("test_tree_2d_kpp.jl") end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh2D Part 2 end #module diff --git a/test/test_tree_2d_part3.jl b/test/test_tree_2d_part3.jl index 450dad6eadd..ce9b3bc04f8 100644 --- a/test/test_tree_2d_part3.jl +++ b/test/test_tree_2d_part3.jl @@ -7,34 +7,34 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh2D Part 3" begin +#! format: noindent # Run basic tests @testset "Examples 2D" begin - # MHD - include("test_tree_2d_mhd.jl") + # MHD + include("test_tree_2d_mhd.jl") - # MHD Multicomponent - include("test_tree_2d_mhdmulti.jl") + # MHD Multicomponent + include("test_tree_2d_mhdmulti.jl") - # Lattice-Boltzmann - include("test_tree_2d_lbm.jl") + # Lattice-Boltzmann + include("test_tree_2d_lbm.jl") - # Shallow water - include("test_tree_2d_shallowwater.jl") + # Shallow water + include("test_tree_2d_shallowwater.jl") - # Two-Layer Shallow Water - include("test_tree_2d_shallowwater_twolayer.jl") + # Two-Layer Shallow Water + include("test_tree_2d_shallowwater_twolayer.jl") - # FDSBP methods on the TreeMesh - include("test_tree_2d_fdsbp.jl") + # FDSBP methods on the TreeMesh + include("test_tree_2d_fdsbp.jl") end # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh2D Part 3 end #module diff --git a/test/test_tree_2d_shallowwater.jl b/test/test_tree_2d_shallowwater.jl index 126c16e3356..d280e380192 100644 --- a/test/test_tree_2d_shallowwater.jl +++ b/test/test_tree_2d_shallowwater.jl @@ -10,157 +10,265 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "Shallow Water" begin - @trixi_testset "elixir_shallowwater_ec.jl" begin +#! format: noindent + +@trixi_testset "elixir_shallowwater_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2 = [0.991181203601035, 0.734130029040644, 0.7447696147162621, 0.5875351036989047], - linf = [2.0117744577945413, 2.9962317608172127, 2.6554999727293653, 3.0], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced.jl" begin + l2=[ + 0.991181203601035, + 0.734130029040644, + 0.7447696147162621, + 0.5875351036989047, + ], + linf=[ + 2.0117744577945413, + 2.9962317608172127, + 2.6554999727293653, + 3.0, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.9130579602987144, 1.0602847041965408e-14, 1.082225645390032e-14, 0.9130579602987147], - linf = [2.113062037615659, 4.6613606802974e-14, 5.4225772771633196e-14, 2.1130620376156584], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced_wall.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_wall.jl"), - l2 = [0.9130579602987144, 1.0602847041965408e-14, 1.082225645390032e-14, 0.9130579602987147], - linf = [2.113062037615659, 4.6613606802974e-14, 5.4225772771633196e-14, 2.1130620376156584], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin + l2=[ + 0.9130579602987144, + 1.0602847041965408e-14, + 1.082225645390032e-14, + 0.9130579602987147, + ], + linf=[ + 2.113062037615659, + 4.6613606802974e-14, + 5.4225772771633196e-14, + 2.1130620376156584, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced_wall.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_wall.jl"), + l2=[ + 0.9130579602987144, + 1.0602847041965408e-14, + 1.082225645390032e-14, + 0.9130579602987147, + ], + linf=[ + 2.113062037615659, + 4.6613606802974e-14, + 5.4225772771633196e-14, + 2.1130620376156584, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [0.9130579602987147, 9.68729463970494e-15, 9.694538537436981e-15, 0.9130579602987147], - linf = [2.1130620376156584, 2.3875905654916432e-14, 2.2492839032269154e-14, 2.1130620376156584], - surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced_wet_dry.jl with FluxHydrostaticReconstruction" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced_wet_dry.jl"), - l2 = [0.030186039395610056, 2.513287752536758e-14, 1.3631397744897607e-16, 0.10911781485920438], - linf = [0.49999999999993505, 5.5278950497971455e-14, 7.462550826772548e-16, 2.0], - tspan = (0.0, 0.25)) - # 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_shallowwater_source_terms.jl" begin + l2=[ + 0.9130579602987147, + 9.68729463970494e-15, + 9.694538537436981e-15, + 0.9130579602987147, + ], + linf=[ + 2.1130620376156584, + 2.3875905654916432e-14, + 2.2492839032269154e-14, + 2.1130620376156584, + ], + surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced_wet_dry.jl with FluxHydrostaticReconstruction" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_well_balanced_wet_dry.jl"), + l2=[ + 0.030186039395610056, + 2.513287752536758e-14, + 1.3631397744897607e-16, + 0.10911781485920438, + ], + linf=[ + 0.49999999999993505, + 5.5278950497971455e-14, + 7.462550826772548e-16, + 2.0, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.001868474306068482, 0.01731687445878443, 0.017649083171490863, 6.274146767717023e-5], - linf = [0.016962486402209986, 0.08768628853889782, 0.09038488750767648, 0.0001819675955490041], - tspan = (0.0, 0.025)) - # 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_shallowwater_source_terms_dirichlet.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms_dirichlet.jl"), - l2 = [0.0018746929418489125, 0.017332321628469628, 0.01634953679145536, 6.274146767717023e-5], - linf = [0.016262353691956388, 0.08726160620859424, 0.09043621801418844, 0.0001819675955490041], - tspan = (0.0, 0.025)) - # 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_shallowwater_source_terms.jl with flux_hll" begin + l2=[ + 0.001868474306068482, + 0.01731687445878443, + 0.017649083171490863, + 6.274146767717023e-5, + ], + linf=[ + 0.016962486402209986, + 0.08768628853889782, + 0.09038488750767648, + 0.0001819675955490041, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_source_terms_dirichlet.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_source_terms_dirichlet.jl"), + l2=[ + 0.0018746929418489125, + 0.017332321628469628, + 0.01634953679145536, + 6.274146767717023e-5, + ], + linf=[ + 0.016262353691956388, + 0.08726160620859424, + 0.09043621801418844, + 0.0001819675955490041, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_source_terms.jl with flux_hll" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0018957692481057034, 0.016943229710439864, 0.01755623297390675, 6.274146767717414e-5], - linf = [0.015156105797771602, 0.07964811135780492, 0.0839787097210376, 0.0001819675955490041], - tspan = (0.0, 0.025), surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) - # 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_shallowwater_conical_island.jl" begin + l2=[ + 0.0018957692481057034, + 0.016943229710439864, + 0.01755623297390675, + 6.274146767717414e-5, + ], + linf=[ + 0.015156105797771602, + 0.07964811135780492, + 0.0839787097210376, + 0.0001819675955490041, + ], + tspan=(0.0, 0.025), + surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal)) + # 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_shallowwater_conical_island.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_conical_island.jl"), - l2 = [0.0459315416430658, 0.1644534881916991, 0.16445348819169914, 0.0011537702354532694], - linf = [0.21100717610846464, 0.9501592344310412, 0.9501592344310417, 0.021790250683516282], - tspan = (0.0, 0.025)) - # 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_shallowwater_parabolic_bowl.jl" begin + l2=[ + 0.0459315416430658, + 0.1644534881916991, + 0.16445348819169914, + 0.0011537702354532694, + ], + linf=[ + 0.21100717610846464, + 0.9501592344310412, + 0.9501592344310417, + 0.021790250683516282, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_parabolic_bowl.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_parabolic_bowl.jl"), - l2 = [0.00025345501281482687, 4.4525120338817177e-5, 0.00015991819160294247, 7.750412064917294e-15], - linf = [0.004664246019836723, 0.0004972780116736669, 0.0028735707270457628, 6.866729407306593e-14], - tspan = (0.0, 0.025), - basis = LobattoLegendreBasis(3)) - # 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 + l2=[ + 0.00025345501281482687, + 4.4525120338817177e-5, + 0.00015991819160294247, + 7.750412064917294e-15, + ], + linf=[ + 0.004664246019836723, + 0.0004972780116736669, + 0.0028735707270457628, + 6.866729407306593e-14, + ], + tspan=(0.0, 0.025), + basis=LobattoLegendreBasis(3)) + # 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 end # module diff --git a/test/test_tree_2d_shallowwater_twolayer.jl b/test/test_tree_2d_shallowwater_twolayer.jl index d98d682506e..5959e7ed882 100644 --- a/test/test_tree_2d_shallowwater_twolayer.jl +++ b/test/test_tree_2d_shallowwater_twolayer.jl @@ -10,81 +10,105 @@ include("test_trixi.jl") EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem") @testset "Two-Layer Shallow Water" begin - @trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.0004040147445601598, 0.005466848793475609, 0.006149138398472166, 0.0002908599437447256, - 0.003011817461911792, 0.0026806180089700674, 8.873630921431545e-6], - linf = [0.002822006686981293, 0.014859895905040332, 0.017590546190827894, 0.0016323702636176218, - 0.009361402900653015, 0.008411036357379165, 3.361991620143279e-5], - tspan = (0.0, 0.25)) - # 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 +#! format: noindent + +@trixi_testset "elixir_shallowwater_twolayer_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.0004040147445601598, 0.005466848793475609, + 0.006149138398472166, 0.0002908599437447256, + 0.003011817461911792, 0.0026806180089700674, + 8.873630921431545e-6], + linf=[0.002822006686981293, 0.014859895905040332, + 0.017590546190827894, 0.0016323702636176218, + 0.009361402900653015, 0.008411036357379165, + 3.361991620143279e-5], + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.00024709443131137236, 0.0019215286339769443, 0.0023833298173254447, - 0.00021258247976270914, 0.0011299428031136195, 0.0009191313765262401, - 8.873630921431545e-6], - linf = [0.0016099763244645793, 0.007659242165565017, 0.009123320235427057, - 0.0013496983982568267, 0.0035573687287770994, 0.00296823235874899, - 3.361991620143279e-5], - surface_flux = (flux_es_fjordholm_etal, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - # 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 +@trixi_testset "elixir_shallowwater_twolayer_convergence.jl with flux_es_fjordholm_etal" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.00024709443131137236, 0.0019215286339769443, + 0.0023833298173254447, + 0.00021258247976270914, 0.0011299428031136195, + 0.0009191313765262401, + 8.873630921431545e-6], + linf=[0.0016099763244645793, 0.007659242165565017, + 0.009123320235427057, + 0.0013496983982568267, 0.0035573687287770994, + 0.00296823235874899, + 3.361991620143279e-5], + surface_flux=(flux_es_fjordholm_etal, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_well_balanced.jl"), - l2 = [3.2935164267930016e-16, 4.6800825611195103e-17, 4.843057532147818e-17, - 0.0030769233188015013, 1.4809161150389857e-16, 1.509071695038043e-16, - 0.0030769233188014935], - linf = [2.248201624865942e-15, 2.346382070278936e-16, 2.208565017494899e-16, - 0.026474051138910493, 9.237568031609006e-16, 7.520758026187046e-16, - 0.026474051138910267], - tspan = (0.0, 0.25)) - # 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 +@trixi_testset "elixir_shallowwater_twolayer_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_well_balanced.jl"), + l2=[3.2935164267930016e-16, 4.6800825611195103e-17, + 4.843057532147818e-17, + 0.0030769233188015013, 1.4809161150389857e-16, + 1.509071695038043e-16, + 0.0030769233188014935], + linf=[2.248201624865942e-15, 2.346382070278936e-16, + 2.208565017494899e-16, + 0.026474051138910493, 9.237568031609006e-16, + 7.520758026187046e-16, + 0.026474051138910267], + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_well_balanced with flux_lax_friedrichs.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_well_balanced.jl"), - l2 = [2.0525741072929735e-16, 6.000589392730905e-17, 6.102759428478984e-17, - 0.0030769233188014905, 1.8421386173122792e-16, 1.8473184927121752e-16, - 0.0030769233188014935], - linf = [7.355227538141662e-16, 2.960836949170518e-16, 4.2726562436938764e-16, - 0.02647405113891016, 1.038795478061861e-15, 1.0401789378532516e-15, - 0.026474051138910267], - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - # 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 +@trixi_testset "elixir_shallowwater_twolayer_well_balanced with flux_lax_friedrichs.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_well_balanced.jl"), + l2=[2.0525741072929735e-16, 6.000589392730905e-17, + 6.102759428478984e-17, + 0.0030769233188014905, 1.8421386173122792e-16, + 1.8473184927121752e-16, + 0.0030769233188014935], + linf=[7.355227538141662e-16, 2.960836949170518e-16, + 4.2726562436938764e-16, + 0.02647405113891016, 1.038795478061861e-15, + 1.0401789378532516e-15, + 0.026474051138910267], + surface_flux=(flux_lax_friedrichs, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + # 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 end end # module diff --git a/test/test_tree_3d_advection.jl b/test/test_tree_3d_advection.jl index 24e65934e60..56278629417 100644 --- a/test/test_tree_3d_advection.jl +++ b/test/test_tree_3d_advection.jl @@ -8,110 +8,114 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_basic.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - l2 = [0.00016263963870641478], - linf = [0.0014537194925779984]) - # 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 + l2=[0.00016263963870641478], + linf=[0.0014537194925779984]) + # 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_advection_restart.jl" begin +@trixi_testset "elixir_advection_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"), - l2 = [0.00016017848135651983], - linf = [0.0014175368788298393]) - # 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 + l2=[0.00016017848135651983], + linf=[0.0014175368788298393]) + # 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_advection_extended.jl with initial_condition_sin" begin +@trixi_testset "elixir_advection_extended.jl with initial_condition_sin" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.002647730309275237], - linf = [0.02114324070353557], - initial_condition=Trixi.initial_condition_sin) - # 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 + l2=[0.002647730309275237], + linf=[0.02114324070353557], + initial_condition=Trixi.initial_condition_sin) + # 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_extended.jl with initial_condition_constant" begin +@trixi_testset "elixir_advection_extended.jl with initial_condition_constant" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [7.728011630010656e-16], - linf = [3.9968028886505635e-15], - initial_condition=initial_condition_constant) - # 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 + l2=[7.728011630010656e-16], + linf=[3.9968028886505635e-15], + initial_condition=initial_condition_constant) + # 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_advection_extended.jl with initial_condition_linear_z and periodicity=false" begin +@trixi_testset "elixir_advection_extended.jl with initial_condition_linear_z and periodicity=false" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [3.007995700405795e-16], - linf = [2.886579864025407e-15], - initial_condition=Trixi.initial_condition_linear_z, - boundary_conditions=Trixi.boundary_condition_linear_z, periodicity=false) - # 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 + l2=[3.007995700405795e-16], + linf=[2.886579864025407e-15], + initial_condition=Trixi.initial_condition_linear_z, + boundary_conditions=Trixi.boundary_condition_linear_z, + periodicity=false) + # 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_mortar.jl" begin +@trixi_testset "elixir_advection_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"), - l2 = [0.001810141301577316], - linf = [0.017848192256602058]) + l2=[0.001810141301577316], + linf=[0.017848192256602058]) # 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 + 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_amr.jl" begin +@trixi_testset "elixir_advection_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"), - l2 = [9.773852895157622e-6], - linf = [0.0005853874124926162], - coverage_override = (maxiters=6, initial_refinement_level=1, base_level=1, med_level=1, max_level=3)) + l2=[9.773852895157622e-6], + linf=[0.0005853874124926162], + coverage_override=(maxiters = 6, initial_refinement_level = 1, + base_level = 1, med_level = 1, max_level = 3)) - # 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 + # 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 end # module diff --git a/test/test_tree_3d_euler.jl b/test/test_tree_3d_euler.jl index fe5e42843f8..d96dcff3977 100644 --- a/test/test_tree_3d_euler.jl +++ b/test/test_tree_3d_euler.jl @@ -8,262 +8,471 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_source_terms.jl" begin +#! format: noindent + +@trixi_testset "elixir_euler_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [0.010385936842224346, 0.009776048833895767, 0.00977604883389591, 0.009776048833895733, 0.01506687097416608], - linf = [0.03285848350791731, 0.0321792316408982, 0.032179231640894645, 0.032179231640895534, 0.0655408023333299]) - # 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 + l2=[ + 0.010385936842224346, + 0.009776048833895767, + 0.00977604883389591, + 0.009776048833895733, + 0.01506687097416608, + ], + linf=[ + 0.03285848350791731, + 0.0321792316408982, + 0.032179231640894645, + 0.032179231640895534, + 0.0655408023333299, + ]) + # 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_euler_convergence_pure_fv.jl" begin +@trixi_testset "elixir_euler_convergence_pure_fv.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence_pure_fv.jl"), - l2 = [0.037182410351406, 0.032062252638283974, 0.032062252638283974, 0.03206225263828395, 0.12228177813586687], - linf = [0.0693648413632646, 0.0622101894740843, 0.06221018947408474, 0.062210189474084965, 0.24196451799555962]) - # 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 + l2=[ + 0.037182410351406, + 0.032062252638283974, + 0.032062252638283974, + 0.03206225263828395, + 0.12228177813586687, + ], + linf=[ + 0.0693648413632646, + 0.0622101894740843, + 0.06221018947408474, + 0.062210189474084965, + 0.24196451799555962, + ]) + # 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_euler_source_terms.jl with split_form" begin +@trixi_testset "elixir_euler_source_terms.jl with split_form" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"), - l2 = [0.010385936842223388, 0.009776048833894784, 0.009776048833894784, 0.009776048833894765, 0.015066870974164096], - linf = [0.03285848350791687, 0.032179231640897754, 0.0321792316408942, 0.0321792316408982, 0.06554080233333615], - volume_integral=VolumeIntegralFluxDifferencing(flux_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 + l2=[ + 0.010385936842223388, + 0.009776048833894784, + 0.009776048833894784, + 0.009776048833894765, + 0.015066870974164096, + ], + linf=[ + 0.03285848350791687, + 0.032179231640897754, + 0.0321792316408942, + 0.0321792316408982, + 0.06554080233333615, + ], + volume_integral=VolumeIntegralFluxDifferencing(flux_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 - @trixi_testset "elixir_euler_convergence.jl" begin +@trixi_testset "elixir_euler_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [0.0003637241020254405, 0.0003955570866382718, 0.0003955570866383613, 0.00039555708663834417, 0.0007811613481640202], - linf = [0.0024000660244674066, 0.0029635410025339315, 0.0029635410025292686, 0.002963541002525938, 0.007191437359396424]) - # 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 + l2=[ + 0.0003637241020254405, + 0.0003955570866382718, + 0.0003955570866383613, + 0.00039555708663834417, + 0.0007811613481640202, + ], + linf=[ + 0.0024000660244674066, + 0.0029635410025339315, + 0.0029635410025292686, + 0.002963541002525938, + 0.007191437359396424, + ]) + # 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_euler_mortar.jl" begin +@trixi_testset "elixir_euler_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_mortar.jl"), - l2 = [0.0019428114665068841, 0.0018659907926698422, 0.0018659907926698589, 0.0018659907926698747, 0.0034549095578444056], - linf = [0.011355360771142298, 0.011526889155693887, 0.011526889155689002, 0.011526889155701436, 0.02299726519821288]) - # 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 + l2=[ + 0.0019428114665068841, + 0.0018659907926698422, + 0.0018659907926698589, + 0.0018659907926698747, + 0.0034549095578444056, + ], + linf=[ + 0.011355360771142298, + 0.011526889155693887, + 0.011526889155689002, + 0.011526889155701436, + 0.02299726519821288, + ]) + # 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_euler_amr.jl" begin +@trixi_testset "elixir_euler_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_amr.jl"), - l2 = [0.0038281920613404716, 0.003828192061340465, 0.0038281920613404694, 0.0038281920613404672, 0.005742288092010652], - linf = [0.07390396464027349, 0.07390396464027305, 0.07390396464027305, 0.07390396464027305, 0.11085594696041134], - tspan=(0.0, 0.1), - coverage_override = (maxiters=6, initial_refinement_level=0, base_level=0, med_level=0, max_level=1)) - # 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 + l2=[ + 0.0038281920613404716, + 0.003828192061340465, + 0.0038281920613404694, + 0.0038281920613404672, + 0.005742288092010652, + ], + linf=[ + 0.07390396464027349, + 0.07390396464027305, + 0.07390396464027305, + 0.07390396464027305, + 0.11085594696041134, + ], + tspan=(0.0, 0.1), + coverage_override=(maxiters = 6, initial_refinement_level = 0, + base_level = 0, med_level = 0, max_level = 1)) + # 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_euler_taylor_green_vortex.jl" begin +@trixi_testset "elixir_euler_taylor_green_vortex.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - l2 = [0.00034949871748737876, 0.03133384111621587, 0.03133384111621582, 0.04378599329988925, 0.015796137903453026], - linf = [0.0013935237751798724, 0.0724080091006194, 0.07240800910061806, 0.12795921224174792, 0.07677156293692633], - tspan = (0.0, 0.5)) - # 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 + l2=[ + 0.00034949871748737876, + 0.03133384111621587, + 0.03133384111621582, + 0.04378599329988925, + 0.015796137903453026, + ], + linf=[ + 0.0013935237751798724, + 0.0724080091006194, + 0.07240800910061806, + 0.12795921224174792, + 0.07677156293692633, + ], + tspan=(0.0, 0.5)) + # 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_euler_shockcapturing.jl" begin +@trixi_testset "elixir_euler_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"), - l2 = [0.02570137197844877, 0.016179934130642552, 0.01617993413064253, 0.016172648598753545, 0.09261669328795467], - linf = [0.3954458125573179, 0.26876916180359345, 0.26876916180359345, 0.26933123042178553, 1.3724137121660251]) - # 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 + l2=[ + 0.02570137197844877, + 0.016179934130642552, + 0.01617993413064253, + 0.016172648598753545, + 0.09261669328795467, + ], + linf=[ + 0.3954458125573179, + 0.26876916180359345, + 0.26876916180359345, + 0.26933123042178553, + 1.3724137121660251, + ]) + # 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_euler_shockcapturing_amr.jl" begin +@trixi_testset "elixir_euler_shockcapturing_amr.jl" begin # OBS! This setup does not make much practical sense. It is only added to exercise the # `sedov_self_gravity` AMR indicator, which in its original configuration is too expensive for # CI testing @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_amr.jl"), - l2 = [0.02217299067704248, 0.012771561294571411, 0.01277156129457143, 0.012770635779336643, 0.08091898488262424], - linf = [0.4047819603427084, 0.27493532130155474, 0.2749353213015551, 0.2749304638368023, 1.4053942765487641], - maxiters=10, - coverage_override = (maxiters=2,)) - # 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 + l2=[ + 0.02217299067704248, + 0.012771561294571411, + 0.01277156129457143, + 0.012770635779336643, + 0.08091898488262424, + ], + linf=[ + 0.4047819603427084, + 0.27493532130155474, + 0.2749353213015551, + 0.2749304638368023, + 1.4053942765487641, + ], + maxiters=10, + coverage_override=(maxiters = 2,)) + # 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_euler_density_pulse.jl" begin +@trixi_testset "elixir_euler_density_pulse.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_pulse.jl"), - l2 = [0.057196526814004715, 0.057196526814004715, 0.05719652681400473, 0.057196526814004736, 0.08579479022100575], - linf = [0.27415246703018203, 0.2741524670301829, 0.2741524670301827, 0.27415246703018226, 0.41122870054527816]) - # 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 + l2=[ + 0.057196526814004715, + 0.057196526814004715, + 0.05719652681400473, + 0.057196526814004736, + 0.08579479022100575, + ], + linf=[ + 0.27415246703018203, + 0.2741524670301829, + 0.2741524670301827, + 0.27415246703018226, + 0.41122870054527816, + ]) + # 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_euler_ec.jl" begin +@trixi_testset "elixir_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.02526341317987378, 0.016632068583699623, 0.016632068583699623, 0.01662548715216875, 0.0913477018048886], - linf = [0.4372549540810414, 0.28613118232798984, 0.28613118232799006, 0.28796686065271876, 1.5072828647309124]) - # 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 + l2=[ + 0.02526341317987378, + 0.016632068583699623, + 0.016632068583699623, + 0.01662548715216875, + 0.0913477018048886, + ], + linf=[ + 0.4372549540810414, + 0.28613118232798984, + 0.28613118232799006, + 0.28796686065271876, + 1.5072828647309124, + ]) + # 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_euler_ec.jl with initial_condition=initial_condition_constant" begin +@trixi_testset "elixir_euler_ec.jl with initial_condition=initial_condition_constant" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [4.183721551616214e-16, 6.059779958716338e-16, 4.916596221090319e-16, 9.739943366304456e-16, 3.7485908743251566e-15], - linf = [2.4424906541753444e-15, 3.733124920302089e-15, 4.440892098500626e-15, 5.329070518200751e-15, 2.4868995751603507e-14], - initial_condition=initial_condition_constant) - # 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 + l2=[ + 4.183721551616214e-16, + 6.059779958716338e-16, + 4.916596221090319e-16, + 9.739943366304456e-16, + 3.7485908743251566e-15, + ], + linf=[ + 2.4424906541753444e-15, + 3.733124920302089e-15, + 4.440892098500626e-15, + 5.329070518200751e-15, + 2.4868995751603507e-14, + ], + initial_condition=initial_condition_constant) + # 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_euler_ec.jl with flux_chandrashekar" begin +@trixi_testset "elixir_euler_ec.jl with flux_chandrashekar" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.025265721172813106, 0.016649800693500427, 0.01664980069350042, 0.01664379306708522, 0.09137248646784184], - linf = [0.4373399329742198, 0.28434487167605427, 0.28434487167605427, 0.28522678968890774, 1.532471676033761], - surface_flux=flux_chandrashekar, volume_flux=flux_chandrashekar) - # 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 + l2=[ + 0.025265721172813106, + 0.016649800693500427, + 0.01664980069350042, + 0.01664379306708522, + 0.09137248646784184, + ], + linf=[ + 0.4373399329742198, + 0.28434487167605427, + 0.28434487167605427, + 0.28522678968890774, + 1.532471676033761, + ], + surface_flux=flux_chandrashekar, volume_flux=flux_chandrashekar) + # 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_euler_ec.jl with flux_kennedy_gruber" begin +@trixi_testset "elixir_euler_ec.jl with flux_kennedy_gruber" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.025280033869871984, 0.016675487948639846, 0.016675487948639853, 0.016668992714991282, 0.091455613470441], - linf = [0.43348628145015766, 0.28853549062014217, 0.28853549062014217, 0.2903943042772536, 1.5236557526482426], - surface_flux=flux_kennedy_gruber, volume_flux=flux_kennedy_gruber) - # 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 + l2=[ + 0.025280033869871984, + 0.016675487948639846, + 0.016675487948639853, + 0.016668992714991282, + 0.091455613470441, + ], + linf=[ + 0.43348628145015766, + 0.28853549062014217, + 0.28853549062014217, + 0.2903943042772536, + 1.5236557526482426, + ], + surface_flux=flux_kennedy_gruber, + volume_flux=flux_kennedy_gruber) + # 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_euler_ec.jl with flux_shima_etal" begin +@trixi_testset "elixir_euler_ec.jl with flux_shima_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.025261716925811403, 0.016637655557848952, 0.01663765555784895, 0.01663105921013437, 0.09136239054024566], - linf = [0.43692416928732536, 0.28622033209064734, 0.28622033209064746, 0.2881197143457632, 1.506534270303663], - surface_flux=flux_shima_etal, volume_flux=flux_shima_etal) - # 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 + l2=[ + 0.025261716925811403, + 0.016637655557848952, + 0.01663765555784895, + 0.01663105921013437, + 0.09136239054024566, + ], + linf=[ + 0.43692416928732536, + 0.28622033209064734, + 0.28622033209064746, + 0.2881197143457632, + 1.506534270303663, + ], + surface_flux=flux_shima_etal, volume_flux=flux_shima_etal) + # 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_euler_blob_amr.jl" begin +@trixi_testset "elixir_euler_blob_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blob_amr.jl"), - l2 = [0.04867856452253151, 0.2640486962336911, 0.0354927658652858, 0.03549276586528571, 1.0777274757408568], - linf = [9.558543313792217, 49.4518309553356, 10.319859082570309, 10.319859082570487, 195.1066220797401], - tspan = (0.0, 0.2), - # Let this test run longer to cover some lines in the positivity preserving limiter - # and some AMR lines - coverage_override = (maxiters=10^5,)) - # 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 + l2=[ + 0.04867856452253151, + 0.2640486962336911, + 0.0354927658652858, + 0.03549276586528571, + 1.0777274757408568, + ], + linf=[ + 9.558543313792217, + 49.4518309553356, + 10.319859082570309, + 10.319859082570487, + 195.1066220797401, + ], + tspan=(0.0, 0.2), + # Let this test run longer to cover some lines in the positivity preserving limiter + # and some AMR lines + coverage_override=(maxiters = 10^5,)) + # 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_euler_sedov_blast_wave.jl" begin +@trixi_testset "elixir_euler_sedov_blast_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov_blast_wave.jl"), - l2 = [0.0007127163978031706, 0.0023166296394624025, 0.002316629639462401, 0.0023166296394624038, 0.010200581509653256], - linf = [0.06344190883105805, 0.6292607955969378, 0.6292607955969377, 0.6292607955969377, 2.397746252817731], - maxiters=5, max_level=6, - coverage_override = (maxiters=2, initial_refinement_level=1, base_level=1, max_level=3)) - # 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 + l2=[ + 0.0007127163978031706, + 0.0023166296394624025, + 0.002316629639462401, + 0.0023166296394624038, + 0.010200581509653256, + ], + linf=[ + 0.06344190883105805, + 0.6292607955969378, + 0.6292607955969377, + 0.6292607955969377, + 2.397746252817731, + ], + maxiters=5, max_level=6, + coverage_override=(maxiters = 2, initial_refinement_level = 1, + base_level = 1, max_level = 3)) + # 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 end # module diff --git a/test/test_tree_3d_eulergravity.jl b/test/test_tree_3d_eulergravity.jl index 3146b88aeb0..1b5e715f774 100644 --- a/test/test_tree_3d_eulergravity.jl +++ b/test/test_tree_3d_eulergravity.jl @@ -8,20 +8,34 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") @testset "Compressible Euler with self-gravity" begin - @trixi_testset "elixir_eulergravity_convergence.jl" begin +#! format: noindent + +@trixi_testset "elixir_eulergravity_convergence.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"), - l2 = [0.0004276779201667428, 0.00047204222332596204, 0.00047204222332608705, 0.0004720422233259819, 0.0010987026250960728], - linf = [0.003496616916238704, 0.003764418290373106, 0.003764418290377103, 0.0037644182903766588, 0.008370424899251105], - resid_tol = 1.0e-4, tspan = (0.0, 0.2)) - # 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 + l2=[ + 0.0004276779201667428, + 0.00047204222332596204, + 0.00047204222332608705, + 0.0004720422233259819, + 0.0010987026250960728, + ], + linf=[ + 0.003496616916238704, + 0.003764418290373106, + 0.003764418290377103, + 0.0037644182903766588, + 0.008370424899251105, + ], + resid_tol=1.0e-4, tspan=(0.0, 0.2)) + # 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 end # module diff --git a/test/test_tree_3d_fdsbp.jl b/test/test_tree_3d_fdsbp.jl index f45f2b0f78a..16508df300e 100644 --- a/test/test_tree_3d_fdsbp.jl +++ b/test/test_tree_3d_fdsbp.jl @@ -8,90 +8,133 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_fdsbp") @testset "Linear scalar advection" begin - @trixi_testset "elixir_advection_extended.jl" begin +#! format: noindent + +@trixi_testset "elixir_advection_extended.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [0.005355755365412444], - linf = [0.01856044696350767]) + l2=[0.005355755365412444], + linf=[0.01856044696350767]) # 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 + 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_extended.jl with periodic operators" begin +@trixi_testset "elixir_advection_extended.jl with periodic operators" begin + global D = SummationByPartsOperators.periodic_derivative_operator(derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, + xmax = 1.0, + N = 10) @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_extended.jl"), - l2 = [1.3819894522373702e-8], - linf = [3.381866298113323e-8], - D_SBP = SummationByPartsOperators.periodic_derivative_operator( - derivative_order = 1, accuracy_order = 4, xmin = 0.0, xmax = 1.0, N = 10), - initial_refinement_level = 0, - tspan = (0.0, 5.0)) + l2=[1.3819894522373702e-8], + linf=[3.381866298113323e-8], + D_SBP=D, + initial_refinement_level=0, + tspan=(0.0, 5.0)) # 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 + 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 end @testset "Compressible Euler" begin - @trixi_testset "elixir_euler_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [2.247522803543667e-5, 2.2499169224681058e-5, 2.24991692246826e-5, 2.2499169224684707e-5, 5.814121361417382e-5], - linf = [9.579357410749445e-5, 9.544871933409027e-5, 9.54487193367548e-5, 9.544871933453436e-5, 0.0004192294529472562], - tspan = (0.0, 0.2)) + @trixi_testset "elixir_euler_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 2.247522803543667e-5, + 2.2499169224681058e-5, + 2.24991692246826e-5, + 2.2499169224684707e-5, + 5.814121361417382e-5, + ], + linf=[ + 9.579357410749445e-5, + 9.544871933409027e-5, + 9.54487193367548e-5, + 9.544871933453436e-5, + 0.0004192294529472562, + ], + tspan=(0.0, 0.2)) - # 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 + # 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_euler_convergence.jl with VolumeIntegralStrongForm" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), - l2 = [4.084919840272202e-5, 4.1320630860402814e-5, 4.132063086040211e-5, 4.132063086039092e-5, 8.502518355874354e-5], - linf = [0.0001963934848161486, 0.00020239883896255861, 0.0002023988389729947, 0.00020239883896766564, 0.00052605624510349], - tspan = (0.0, 0.2), - solver = DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), VolumeIntegralStrongForm())) + @trixi_testset "elixir_euler_convergence.jl with VolumeIntegralStrongForm" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"), + l2=[ + 4.084919840272202e-5, + 4.1320630860402814e-5, + 4.132063086040211e-5, + 4.132063086039092e-5, + 8.502518355874354e-5, + ], + linf=[ + 0.0001963934848161486, + 0.00020239883896255861, + 0.0002023988389729947, + 0.00020239883896766564, + 0.00052605624510349, + ], + tspan=(0.0, 0.2), + solver=DG(D_upw.central, nothing, SurfaceIntegralStrongForm(), + VolumeIntegralStrongForm())) - # 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 + # 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_euler_taylor_green_vortex.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), - l2 = [3.529693407280806e-6, 0.0004691301922633193, 0.00046913019226332234, 0.0006630180220973541, 0.0015732759680929076], - linf = [3.4253965106145756e-5, 0.0010033197685090707, 0.0010033197685091054, 0.0018655642702542635, 0.008479800046757191], - tspan = (0.0, 0.0075), abstol = 1.0e-9, reltol = 1.0e-9) + @trixi_testset "elixir_euler_taylor_green_vortex.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"), + l2=[ + 3.529693407280806e-6, + 0.0004691301922633193, + 0.00046913019226332234, + 0.0006630180220973541, + 0.0015732759680929076, + ], + linf=[ + 3.4253965106145756e-5, + 0.0010033197685090707, + 0.0010033197685091054, + 0.0018655642702542635, + 0.008479800046757191, + ], + tspan=(0.0, 0.0075), abstol=1.0e-9, reltol=1.0e-9) - # 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 + # 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 end # module diff --git a/test/test_tree_3d_hypdiff.jl b/test/test_tree_3d_hypdiff.jl index 42231a9aaf6..5c9dacbd87d 100644 --- a/test/test_tree_3d_hypdiff.jl +++ b/test/test_tree_3d_hypdiff.jl @@ -8,49 +8,81 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") @testset "Hyperbolic diffusion" begin - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin +#! format: noindent + +@trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2 = [0.001530331609036682, 0.011314177033289238, 0.011314177033289402, 0.011314177033289631], - linf = [0.02263459033909354, 0.10139777904683545, 0.10139777904683545, 0.10139777904683545], - initial_refinement_level=2) - # 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)) < 15000 - end - end - - @trixi_testset "elixir_hypdiff_lax_friedrichs.jl with surface_flux=flux_godunov)" begin + l2=[ + 0.001530331609036682, + 0.011314177033289238, + 0.011314177033289402, + 0.011314177033289631, + ], + linf=[ + 0.02263459033909354, + 0.10139777904683545, + 0.10139777904683545, + 0.10139777904683545, + ], + initial_refinement_level=2) + # 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)) < 15000 + end +end + +@trixi_testset "elixir_hypdiff_lax_friedrichs.jl with surface_flux=flux_godunov)" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_lax_friedrichs.jl"), - l2 = [0.0015377731806850128, 0.01137685274151801, 0.011376852741518175, 0.011376852741518494], - linf = [0.022715420630041172, 0.10183745338964201, 0.10183745338964201, 0.1018374533896429], - initial_refinement_level=2, surface_flux=flux_godunov) - # 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)) < 15000 - end - end - - @trixi_testset "elixir_hypdiff_nonperiodic.jl" begin + l2=[ + 0.0015377731806850128, + 0.01137685274151801, + 0.011376852741518175, + 0.011376852741518494, + ], + linf=[ + 0.022715420630041172, + 0.10183745338964201, + 0.10183745338964201, + 0.1018374533896429, + ], + initial_refinement_level=2, surface_flux=flux_godunov) + # 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)) < 15000 + end +end + +@trixi_testset "elixir_hypdiff_nonperiodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"), - l2 = [0.00022868320512754316, 0.0007974309948540525, 0.0015035143230654987, 0.0015035143230655293], - linf = [0.0016405001653623241, 0.0029870057159104594, 0.009410031618285686, 0.009410031618287462]) - # 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)) < 15000 - end - end + l2=[ + 0.00022868320512754316, + 0.0007974309948540525, + 0.0015035143230654987, + 0.0015035143230655293, + ], + linf=[ + 0.0016405001653623241, + 0.0029870057159104594, + 0.009410031618285686, + 0.009410031618287462, + ]) + # 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)) < 15000 + end +end end end # module diff --git a/test/test_tree_3d_lbm.jl b/test/test_tree_3d_lbm.jl index af7b147e609..dc7e770dfa4 100644 --- a/test/test_tree_3d_lbm.jl +++ b/test/test_tree_3d_lbm.jl @@ -8,68 +8,104 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") @testset "Lattice-Boltzmann" begin - @trixi_testset "elixir_lbm_constant.jl" begin +#! format: noindent + +@trixi_testset "elixir_lbm_constant.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_constant.jl"), - l2 = [5.861930511199053e-16, 6.282772442363201e-16, 5.47591540767842e-16, - 6.379244339335046e-16, 5.81421258408584e-16, 6.634626069779352e-16, - 2.9188639102691596e-16, 2.1539168764807097e-16, 3.0131714783573674e-16, - 2.2126555191449657e-16, 2.622901122013102e-16, 2.2115776381362187e-16, - 6.32031843208421e-17, 6.103875364141341e-17, 6.821138567646266e-17, - 6.48022057541854e-17, 5.013642264182462e-17, 7.169498358338181e-17, - 1.3879946832660896e-16, 5.649850447603551e-17, 3.4686869828797276e-17, - 3.8719518141614167e-17, 3.5852179230919525e-17, 4.292415147083455e-17, - 3.608945206319316e-17, 4.187850903422495e-17, 8.254587760492495e-16], - linf = [1.1657341758564144e-15, 1.5543122344752192e-15, 1.1657341758564144e-15, - 1.4710455076283324e-15, 1.0547118733938987e-15, 1.4988010832439613e-15, - 5.273559366969494e-16, 5.065392549852277e-16, 5.967448757360216e-16, - 5.342948306008566e-16, 5.412337245047638e-16, 5.967448757360216e-16, - 3.608224830031759e-16, 3.469446951953614e-16, 2.42861286636753e-16, - 2.498001805406602e-16, 2.2898349882893854e-16, 4.3021142204224816e-16, - 2.1510571102112408e-16, 1.43982048506075e-16, 1.214306433183765e-16, - 1.4224732503009818e-16, 1.214306433183765e-16, 1.3877787807814457e-16, - 8.673617379884035e-17, 9.71445146547012e-17, 2.7755575615628914e-15], - tspan=(0.0, 0.5)) - # 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 + l2=[5.861930511199053e-16, 6.282772442363201e-16, + 5.47591540767842e-16, + 6.379244339335046e-16, 5.81421258408584e-16, + 6.634626069779352e-16, + 2.9188639102691596e-16, 2.1539168764807097e-16, + 3.0131714783573674e-16, + 2.2126555191449657e-16, 2.622901122013102e-16, + 2.2115776381362187e-16, + 6.32031843208421e-17, 6.103875364141341e-17, + 6.821138567646266e-17, + 6.48022057541854e-17, 5.013642264182462e-17, + 7.169498358338181e-17, + 1.3879946832660896e-16, 5.649850447603551e-17, + 3.4686869828797276e-17, + 3.8719518141614167e-17, 3.5852179230919525e-17, + 4.292415147083455e-17, + 3.608945206319316e-17, 4.187850903422495e-17, + 8.254587760492495e-16], + linf=[1.1657341758564144e-15, 1.5543122344752192e-15, + 1.1657341758564144e-15, + 1.4710455076283324e-15, 1.0547118733938987e-15, + 1.4988010832439613e-15, + 5.273559366969494e-16, 5.065392549852277e-16, + 5.967448757360216e-16, + 5.342948306008566e-16, 5.412337245047638e-16, + 5.967448757360216e-16, + 3.608224830031759e-16, 3.469446951953614e-16, + 2.42861286636753e-16, + 2.498001805406602e-16, 2.2898349882893854e-16, + 4.3021142204224816e-16, + 2.1510571102112408e-16, 1.43982048506075e-16, + 1.214306433183765e-16, + 1.4224732503009818e-16, 1.214306433183765e-16, + 1.3877787807814457e-16, + 8.673617379884035e-17, 9.71445146547012e-17, + 2.7755575615628914e-15], + tspan=(0.0, 0.5)) + # 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_lbm_taylor_green_vortex.jl" begin +@trixi_testset "elixir_lbm_taylor_green_vortex.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_lbm_taylor_green_vortex.jl"), - l2 = [7.516128821554829e-5, 7.516128821554695e-5, 7.516128821554932e-5, - 7.516128821554856e-5, 7.022624942862394e-6, 7.022624942862171e-6, - 2.961794427142361e-6, 2.961794427142168e-6, 2.6527195181287848e-5, - 2.6527195181287404e-5, 2.652719518128811e-5, 2.6527195181287916e-5, - 2.9617944271423104e-6, 2.961794427142108e-6, 2.652719518128758e-5, - 2.6527195181287513e-5, 2.6527195181287916e-5, 2.6527195181287872e-5, - 6.697526775466e-6, 6.697526775466029e-6, 6.697526775465903e-6, 6.697526775465986e-6, - 6.697526775466051e-6, 6.697526775465938e-6, 6.697526775465983e-6, - 6.697526775466005e-6, 2.8805380887802028e-6], - linf = [0.00021570074723312183, 0.0002157007472331357, 0.00021570074723314958, - 0.00021570074723316346, 1.9675688146578163e-5, 1.967568814660592e-5, - 9.53539471547013e-6, 9.53539471547013e-6, 5.7339968249785905e-5, - 5.7339968249778966e-5, 5.7339968249792844e-5, 5.7339968249778966e-5, - 9.535394715480539e-6, 9.53539471546666e-6, 5.73399682497755e-5, 5.7339968249785905e-5, - 5.7339968249782436e-5, 5.7339968249782436e-5, 1.3570400471223966e-5, - 1.3570400471222231e-5, 1.3570400471220496e-5, 1.3570400471224833e-5, - 1.3570400471223966e-5, 1.3570400471221364e-5, 1.3570400471224833e-5, - 1.3570400471224833e-5, 1.4249297322244114e-5], - tspan=(0.0, 0.1), - initial_refinement_level=3) - # 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 + l2=[7.516128821554829e-5, 7.516128821554695e-5, + 7.516128821554932e-5, + 7.516128821554856e-5, 7.022624942862394e-6, + 7.022624942862171e-6, + 2.961794427142361e-6, 2.961794427142168e-6, + 2.6527195181287848e-5, + 2.6527195181287404e-5, 2.652719518128811e-5, + 2.6527195181287916e-5, + 2.9617944271423104e-6, 2.961794427142108e-6, + 2.652719518128758e-5, + 2.6527195181287513e-5, 2.6527195181287916e-5, + 2.6527195181287872e-5, + 6.697526775466e-6, 6.697526775466029e-6, + 6.697526775465903e-6, 6.697526775465986e-6, + 6.697526775466051e-6, 6.697526775465938e-6, + 6.697526775465983e-6, + 6.697526775466005e-6, 2.8805380887802028e-6], + linf=[0.00021570074723312183, 0.0002157007472331357, + 0.00021570074723314958, + 0.00021570074723316346, 1.9675688146578163e-5, + 1.967568814660592e-5, + 9.53539471547013e-6, 9.53539471547013e-6, + 5.7339968249785905e-5, + 5.7339968249778966e-5, 5.7339968249792844e-5, + 5.7339968249778966e-5, + 9.535394715480539e-6, 9.53539471546666e-6, + 5.73399682497755e-5, 5.7339968249785905e-5, + 5.7339968249782436e-5, 5.7339968249782436e-5, + 1.3570400471223966e-5, + 1.3570400471222231e-5, 1.3570400471220496e-5, + 1.3570400471224833e-5, + 1.3570400471223966e-5, 1.3570400471221364e-5, + 1.3570400471224833e-5, + 1.3570400471224833e-5, 1.4249297322244114e-5], + tspan=(0.0, 0.1), + initial_refinement_level=3) + # 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 end # module diff --git a/test/test_tree_3d_mhd.jl b/test/test_tree_3d_mhd.jl index 708f2a1a038..7ce5ef1d18f 100644 --- a/test/test_tree_3d_mhd.jl +++ b/test/test_tree_3d_mhd.jl @@ -8,143 +8,288 @@ include("test_trixi.jl") EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_3d_dgsem") @testset "MHD" begin - @trixi_testset "elixir_mhd_ec.jl" begin +#! format: noindent + +@trixi_testset "elixir_mhd_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.017590099293094203, 0.017695875823827714, 0.017695875823827686, 0.017698038279620777, 0.07495006099352074, 0.010391801950005755, 0.010391801950005759, 0.010393502246627087, 2.524766553484067e-16], - linf = [0.28173002819718196, 0.3297583616136297, 0.32975836161363004, 0.356862935505337, 1.2893514981209626, 0.10950981489747313, 0.10950981489747136, 0.11517234329681891, 2.0816911067714202e-15]) - # 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 + l2=[ + 0.017590099293094203, + 0.017695875823827714, + 0.017695875823827686, + 0.017698038279620777, + 0.07495006099352074, + 0.010391801950005755, + 0.010391801950005759, + 0.010393502246627087, + 2.524766553484067e-16, + ], + linf=[ + 0.28173002819718196, + 0.3297583616136297, + 0.32975836161363004, + 0.356862935505337, + 1.2893514981209626, + 0.10950981489747313, + 0.10950981489747136, + 0.11517234329681891, + 2.0816911067714202e-15, + ]) + # 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_mhd_ec.jl with initial_condition=initial_condition_constant" begin +@trixi_testset "elixir_mhd_ec.jl with initial_condition=initial_condition_constant" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [4.270231310667203e-16, 2.4381208042014784e-15, 5.345107673575357e-15, 3.00313882171883e-15, 1.7772703118758417e-14, 1.0340110783830874e-15, 1.1779095371939702e-15, 9.961878521814573e-16, 8.1201730630719145e-16], - linf = [2.4424906541753444e-15, 2.881028748902281e-14, 2.4646951146678475e-14, 2.3092638912203256e-14, 2.3447910280083306e-13, 1.7763568394002505e-14, 1.0436096431476471e-14, 2.042810365310288e-14, 7.057203733035201e-15], - atol = 1000*eps(), - initial_condition=initial_condition_constant) - # 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 + l2=[ + 4.270231310667203e-16, + 2.4381208042014784e-15, + 5.345107673575357e-15, + 3.00313882171883e-15, + 1.7772703118758417e-14, + 1.0340110783830874e-15, + 1.1779095371939702e-15, + 9.961878521814573e-16, + 8.1201730630719145e-16, + ], + linf=[ + 2.4424906541753444e-15, + 2.881028748902281e-14, + 2.4646951146678475e-14, + 2.3092638912203256e-14, + 2.3447910280083306e-13, + 1.7763568394002505e-14, + 1.0436096431476471e-14, + 2.042810365310288e-14, + 7.057203733035201e-15, + ], + atol=1000 * eps(), + initial_condition=initial_condition_constant) + # 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_mhd_alfven_wave.jl" begin +@trixi_testset "elixir_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.0032217291057246157, 0.009511644936958913, 0.004217358459420256, 0.011591709179125335, 0.009456218722393708, 0.00916500047763897, 0.005069863732625444, 0.011503011541926135, 0.003988175543749985], - linf = [0.01188593784273051, 0.03638015998373141, 0.01568200398945724, 0.04666974730787579, 0.031235294705421968, 0.03316343064943483, 0.011539436992528018, 0.04896687646520839, 0.018714054039927555]) - # 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 + l2=[ + 0.0032217291057246157, + 0.009511644936958913, + 0.004217358459420256, + 0.011591709179125335, + 0.009456218722393708, + 0.00916500047763897, + 0.005069863732625444, + 0.011503011541926135, + 0.003988175543749985, + ], + linf=[ + 0.01188593784273051, + 0.03638015998373141, + 0.01568200398945724, + 0.04666974730787579, + 0.031235294705421968, + 0.03316343064943483, + 0.011539436992528018, + 0.04896687646520839, + 0.018714054039927555, + ]) + # 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_mhd_alfven_wave.jl with flux_derigs_etal" begin +@trixi_testset "elixir_mhd_alfven_wave.jl with flux_derigs_etal" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.003755235939722358, 0.009062519246840721, 0.004096299856228109, 0.011429935838448906, 0.006897420817511043, 0.00900886245212482, 0.004926537542780259, 0.01153285554590683, 0.0037842060148666886], - linf = [0.012982853115883541, 0.0320228076558316, 0.011575276754611022, 0.04425778643430531, 0.02478109022285846, 0.03198699034954189, 0.009761077061886558, 0.04433669321441455, 0.01618905441148782], - volume_flux = (flux_derigs_etal, flux_nonconservative_powell)) - # 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 + l2=[ + 0.003755235939722358, + 0.009062519246840721, + 0.004096299856228109, + 0.011429935838448906, + 0.006897420817511043, + 0.00900886245212482, + 0.004926537542780259, + 0.01153285554590683, + 0.0037842060148666886, + ], + linf=[ + 0.012982853115883541, + 0.0320228076558316, + 0.011575276754611022, + 0.04425778643430531, + 0.02478109022285846, + 0.03198699034954189, + 0.009761077061886558, + 0.04433669321441455, + 0.01618905441148782, + ], + volume_flux=(flux_derigs_etal, flux_nonconservative_powell)) + # 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_mhd_alfven_wave_mortar.jl" begin +@trixi_testset "elixir_mhd_alfven_wave_mortar.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_mortar.jl"), - l2 = [0.001879021634926363, 0.007032724521848316, 0.0032793932234187325, 0.009056594733320348, 0.007514150120617965, 0.007328739509868727, 0.00309794018112387, 0.009026356949274878, 0.0035732583778049776], - linf = [0.013734346970999622, 0.06173467158736011, 0.02183946452704291, 0.06258216169457917, 0.03672304497348122, 0.055120532123884625, 0.018202716205672487, 0.06133688282205586, 0.019888161885935608], - tspan = (0.0, 0.25)) - # 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 + l2=[ + 0.001879021634926363, + 0.007032724521848316, + 0.0032793932234187325, + 0.009056594733320348, + 0.007514150120617965, + 0.007328739509868727, + 0.00309794018112387, + 0.009026356949274878, + 0.0035732583778049776, + ], + linf=[ + 0.013734346970999622, + 0.06173467158736011, + 0.02183946452704291, + 0.06258216169457917, + 0.03672304497348122, + 0.055120532123884625, + 0.018202716205672487, + 0.06133688282205586, + 0.019888161885935608, + ], + tspan=(0.0, 0.25)) + # 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_mhd_alfven_wave.jl with Orszag-Tang setup + flux_hll" begin +@trixi_testset "elixir_mhd_alfven_wave.jl with Orszag-Tang setup + flux_hll" begin # OBS! This setup does not make much sense and is only used to exercise all components of the # flux_hll implementation @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [0.004391143689111404, 0.04144737547475548, 0.041501307637678286, 0.04150353006408862, 0.03693135855995625, 0.021125605214031118, 0.03295607553556973, 0.03296235755245784, 7.16035229384135e-6], - linf = [0.017894703320895378, 0.08486850681397005, 0.0891044523165206, 0.08492024792056754, 0.10448301878352373, 0.05381260695579509, 0.0884774018719996, 0.07784546966765199, 7.71609149516089e-5], - initial_condition = function initial_condition_orszag_tang(x, t, equations::IdealGlmMhdEquations3D) - # The classical Orszag-Tang vortex test case adapted to 3D. Setup is taken from - # Table 4 of the paper - # - M. Bohm, A. R. Winters, G. J. Gassner, D. Derigs, F. Hindenlang, & J. Saur (2020) - # An entropy stable nodal discontinuous Galerkin method for the resistive MHD - # equations. Part I: Theory and numerical verification - # [doi: 10.1016/j.jcp.2018.06.027](https://doi.org/10.1016/j.jcp.2018.06.027) - # Domain must be [0, 1]^3 , γ = 5/3 - rho = 25.0 / (36.0 * pi) - v1 = -sin(2.0*pi*x[3]) - v2 = sin(2.0*pi*x[1]) - v3 = sin(2.0*pi*x[2]) - p = 5.0 / (12.0 * pi) - B1 = -sin(2.0*pi*x[3]) / (4.0*pi) - B2 = sin(4.0*pi*x[1]) / (4.0*pi) - B3 = sin(4.0*pi*x[2]) / (4.0*pi) - psi = 0.0 - return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, psi), equations) - # 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, - surface_flux = (flux_hll, flux_nonconservative_powell), - volume_flux = (flux_central, flux_nonconservative_powell), - coordinates_min = (0.0, 0.0, 0.0), - coordinates_max = (1.0, 1.0, 1.0), - initial_refinement_level=3, - cfl = 1.1, - tspan = (0.0, 0.06)) - # 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 + l2=[ + 0.004391143689111404, + 0.04144737547475548, + 0.041501307637678286, + 0.04150353006408862, + 0.03693135855995625, + 0.021125605214031118, + 0.03295607553556973, + 0.03296235755245784, + 7.16035229384135e-6, + ], + linf=[ + 0.017894703320895378, + 0.08486850681397005, + 0.0891044523165206, + 0.08492024792056754, + 0.10448301878352373, + 0.05381260695579509, + 0.0884774018719996, + 0.07784546966765199, + 7.71609149516089e-5, + ], + initial_condition=function initial_condition_orszag_tang(x, t, + equations::IdealGlmMhdEquations3D) + # The classical Orszag-Tang vortex test case adapted to 3D. Setup is taken from + # Table 4 of the paper + # - M. Bohm, A. R. Winters, G. J. Gassner, D. Derigs, F. Hindenlang, & J. Saur (2020) + # An entropy stable nodal discontinuous Galerkin method for the resistive MHD + # equations. Part I: Theory and numerical verification + # [doi: 10.1016/j.jcp.2018.06.027](https://doi.org/10.1016/j.jcp.2018.06.027) + # Domain must be [0, 1]^3 , γ = 5/3 + rho = 25.0 / (36.0 * pi) + v1 = -sin(2.0 * pi * x[3]) + v2 = sin(2.0 * pi * x[1]) + v3 = sin(2.0 * pi * x[2]) + p = 5.0 / (12.0 * pi) + B1 = -sin(2.0 * pi * x[3]) / (4.0 * pi) + B2 = sin(4.0 * pi * x[1]) / (4.0 * pi) + B3 = sin(4.0 * pi * x[2]) / (4.0 * pi) + psi = 0.0 + return prim2cons(SVector(rho, v1, v2, v3, p, B1, B2, B3, + psi), equations) + # 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, + surface_flux=(flux_hll, flux_nonconservative_powell), + volume_flux=(flux_central, flux_nonconservative_powell), + coordinates_min=(0.0, 0.0, 0.0), + coordinates_max=(1.0, 1.0, 1.0), + initial_refinement_level=3, + cfl=1.1, + tspan=(0.0, 0.06)) + # 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_mhd_ec_shockcapturing.jl" begin +@trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"), - l2 = [0.0186712969755079, 0.01620736832264799, 0.01620736832264803, 0.016207474382769683, 0.07306422729650594, 0.007355137041002365, 0.0073551370410023425, 0.00735520932001833, 0.000506140942330923], - linf = [0.28040713666979633, 0.27212885844703694, 0.2721288584470349, 0.2837380205051839, 0.7915852408267114, 0.08770240288089526, 0.08770240288089792, 0.08773409387876674, 0.050221095224119834]) - # 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 + l2=[ + 0.0186712969755079, + 0.01620736832264799, + 0.01620736832264803, + 0.016207474382769683, + 0.07306422729650594, + 0.007355137041002365, + 0.0073551370410023425, + 0.00735520932001833, + 0.000506140942330923, + ], + linf=[ + 0.28040713666979633, + 0.27212885844703694, + 0.2721288584470349, + 0.2837380205051839, + 0.7915852408267114, + 0.08770240288089526, + 0.08770240288089792, + 0.08773409387876674, + 0.050221095224119834, + ]) + # 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 end # module diff --git a/test/test_tree_3d_part1.jl b/test/test_tree_3d_part1.jl index b1bf313d1b6..3fdddc77239 100644 --- a/test/test_tree_3d_part1.jl +++ b/test/test_tree_3d_part1.jl @@ -7,20 +7,19 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh3D Part 1" begin +#! format: noindent # Run basic tests @testset "Examples 3D" begin - # Compressible Euler - include("test_tree_3d_euler.jl") + # Compressible Euler + include("test_tree_3d_euler.jl") end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh3D Part 1 end #module diff --git a/test/test_tree_3d_part2.jl b/test/test_tree_3d_part2.jl index 77af51c7481..5c7301654ad 100644 --- a/test/test_tree_3d_part2.jl +++ b/test/test_tree_3d_part2.jl @@ -7,102 +7,113 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh3D Part 2" begin +#! format: noindent # Run basic tests @testset "Examples 3D" begin - # Linear scalar advection - include("test_tree_3d_advection.jl") + # Linear scalar advection + include("test_tree_3d_advection.jl") - # Hyperbolic diffusion - include("test_tree_3d_hypdiff.jl") + # Hyperbolic diffusion + include("test_tree_3d_hypdiff.jl") - # Compressible Euler with self-gravity - include("test_tree_3d_eulergravity.jl") + # Compressible Euler with self-gravity + include("test_tree_3d_eulergravity.jl") end - @trixi_testset "Additional tests in 3D" begin - @trixi_testset "compressible Euler" begin - eqn = CompressibleEulerEquations3D(1.4) - - @test isapprox(energy_total([1.0, 2.0, 3.0, 4.0, 20.0], eqn), 20.0) - @test isapprox(energy_kinetic([1.0, 2.0, 3.0, 4.0, 20], eqn), 14.5) - @test isapprox(energy_internal([1.0, 2.0, 3.0, 4.0, 20], eqn), 5.5) - end - - @trixi_testset "hyperbolic diffusion" begin - @test_nowarn HyperbolicDiffusionEquations3D(nu=1.0) - eqn = HyperbolicDiffusionEquations3D(nu=1.0) - end + @trixi_testset "compressible Euler" begin + eqn = CompressibleEulerEquations3D(1.4) + + @test isapprox(energy_total([1.0, 2.0, 3.0, 4.0, 20.0], eqn), 20.0) + @test isapprox(energy_kinetic([1.0, 2.0, 3.0, 4.0, 20], eqn), 14.5) + @test isapprox(energy_internal([1.0, 2.0, 3.0, 4.0, 20], eqn), 5.5) + end + + @trixi_testset "hyperbolic diffusion" begin + @test_nowarn HyperbolicDiffusionEquations3D(nu = 1.0) + eqn = HyperbolicDiffusionEquations3D(nu = 1.0) + end end - @trixi_testset "Displaying components 3D" begin - @test_nowarn include(joinpath(examples_dir(), "tree_3d_dgsem", "elixir_advection_amr.jl")) - - # test both short and long printing formats - @test_nowarn show(mesh); println() - @test_nowarn println(mesh) - @test_nowarn display(mesh) - - @test_nowarn show(equations); println() - @test_nowarn println(equations) - @test_nowarn display(equations) - - @test_nowarn show(solver); println() - @test_nowarn println(solver) - @test_nowarn display(solver) - - @test_nowarn show(solver.basis); println() - @test_nowarn println(solver.basis) - @test_nowarn display(solver.basis) - - @test_nowarn show(solver.mortar); println() - @test_nowarn println(solver.mortar) - @test_nowarn display(solver.mortar) - - @test_nowarn show(semi); println() - @test_nowarn println(semi) - @test_nowarn display(semi) - - @test_nowarn show(summary_callback); println() - @test_nowarn println(summary_callback) - @test_nowarn display(summary_callback) - - @test_nowarn show(amr_controller); println() - @test_nowarn println(amr_controller) - @test_nowarn display(amr_controller) - - @test_nowarn show(amr_callback); println() - @test_nowarn println(amr_callback) - @test_nowarn display(amr_callback) - - @test_nowarn show(stepsize_callback); println() - @test_nowarn println(stepsize_callback) - @test_nowarn display(stepsize_callback) - - @test_nowarn show(save_solution); println() - @test_nowarn println(save_solution) - @test_nowarn display(save_solution) - - @test_nowarn show(analysis_callback); println() - @test_nowarn println(analysis_callback) - @test_nowarn display(analysis_callback) - - @test_nowarn show(alive_callback); println() - @test_nowarn println(alive_callback) - @test_nowarn display(alive_callback) - - @test_nowarn println(callbacks) + @test_nowarn include(joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_advection_amr.jl")) + + # test both short and long printing formats + @test_nowarn show(mesh) + println() + @test_nowarn println(mesh) + @test_nowarn display(mesh) + + @test_nowarn show(equations) + println() + @test_nowarn println(equations) + @test_nowarn display(equations) + + @test_nowarn show(solver) + println() + @test_nowarn println(solver) + @test_nowarn display(solver) + + @test_nowarn show(solver.basis) + println() + @test_nowarn println(solver.basis) + @test_nowarn display(solver.basis) + + @test_nowarn show(solver.mortar) + println() + @test_nowarn println(solver.mortar) + @test_nowarn display(solver.mortar) + + @test_nowarn show(semi) + println() + @test_nowarn println(semi) + @test_nowarn display(semi) + + @test_nowarn show(summary_callback) + println() + @test_nowarn println(summary_callback) + @test_nowarn display(summary_callback) + + @test_nowarn show(amr_controller) + println() + @test_nowarn println(amr_controller) + @test_nowarn display(amr_controller) + + @test_nowarn show(amr_callback) + println() + @test_nowarn println(amr_callback) + @test_nowarn display(amr_callback) + + @test_nowarn show(stepsize_callback) + println() + @test_nowarn println(stepsize_callback) + @test_nowarn display(stepsize_callback) + + @test_nowarn show(save_solution) + println() + @test_nowarn println(save_solution) + @test_nowarn display(save_solution) + + @test_nowarn show(analysis_callback) + println() + @test_nowarn println(analysis_callback) + @test_nowarn display(analysis_callback) + + @test_nowarn show(alive_callback) + println() + @test_nowarn println(alive_callback) + @test_nowarn display(alive_callback) + + @test_nowarn println(callbacks) end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh3D Part 2 end #module diff --git a/test/test_tree_3d_part3.jl b/test/test_tree_3d_part3.jl index 7a77f0e4927..9e1e8bc4dc9 100644 --- a/test/test_tree_3d_part3.jl +++ b/test/test_tree_3d_part3.jl @@ -7,49 +7,47 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "TreeMesh3D Part 2" begin +#! format: noindent # Run basic tests @testset "Examples 3D" begin - # MHD - include("test_tree_3d_mhd.jl") + # MHD + include("test_tree_3d_mhd.jl") - # Lattice-Boltzmann - include("test_tree_3d_lbm.jl") + # Lattice-Boltzmann + include("test_tree_3d_lbm.jl") - # FDSBP methods on the TreeMesh - include("test_tree_3d_fdsbp.jl") + # FDSBP methods on the TreeMesh + include("test_tree_3d_fdsbp.jl") end - @trixi_testset "Additional tests in 3D" begin - @testset "ideal GLM MHD" begin - eqn = IdealGlmMhdEquations3D(1.4) - u = [1.0, 2.0, 3.0, 4.0, 20.0, 0.1, 0.2, 0.3, 1.5] + @testset "ideal GLM MHD" begin + eqn = IdealGlmMhdEquations3D(1.4) + u = [1.0, 2.0, 3.0, 4.0, 20.0, 0.1, 0.2, 0.3, 1.5] - @test isapprox(density(u, eqn), 1.0) - @test isapprox(pressure(u, eqn), 1.7219999999999995) - @test isapprox(density_pressure(u, eqn), 1.7219999999999995) + @test isapprox(density(u, eqn), 1.0) + @test isapprox(pressure(u, eqn), 1.7219999999999995) + @test isapprox(density_pressure(u, eqn), 1.7219999999999995) - @test isapprox(Trixi.entropy_thermodynamic(u, eqn), 0.5434864060055388) - @test isapprox(Trixi.entropy_math(u, eqn), -1.3587160150138473) - @test isapprox(Trixi.entropy(u, eqn), -1.3587160150138473) + @test isapprox(Trixi.entropy_thermodynamic(u, eqn), 0.5434864060055388) + @test isapprox(Trixi.entropy_math(u, eqn), -1.3587160150138473) + @test isapprox(Trixi.entropy(u, eqn), -1.3587160150138473) - @test isapprox(energy_total(u, eqn), 20.0) - @test isapprox(energy_kinetic(u, eqn), 14.5) - @test isapprox(energy_magnetic(u, eqn), 0.07) - @test isapprox(energy_internal(u, eqn), 4.305) + @test isapprox(energy_total(u, eqn), 20.0) + @test isapprox(energy_kinetic(u, eqn), 14.5) + @test isapprox(energy_magnetic(u, eqn), 0.07) + @test isapprox(energy_internal(u, eqn), 4.305) - @test isapprox(cross_helicity(u, eqn), 2.0) - end + @test isapprox(cross_helicity(u, eqn), 2.0) + end end - # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) - +@test_nowarn rm(outdir, recursive = true) end # TreeMesh3D Part 2 end #module diff --git a/test/test_trixi.jl b/test/test_trixi.jl index f2cd0cab94d..245efbc0175 100644 --- a/test/test_trixi.jl +++ b/test/test_trixi.jl @@ -15,165 +15,162 @@ are compared approximately against these reference values, using `atol, rtol` as absolute/relative tolerance. """ macro test_trixi_include(elixir, args...) - - local l2 = get_kwarg(args, :l2, nothing) - local linf = get_kwarg(args, :linf, nothing) - local atol = get_kwarg(args, :atol, 500*eps()) - local rtol = get_kwarg(args, :rtol, sqrt(eps())) - local skip_coverage = get_kwarg(args, :skip_coverage, false) - local coverage_override = expr_to_named_tuple(get_kwarg(args, :coverage_override, :())) - if !(:maxiters in keys(coverage_override)) - # maxiters in coverage_override defaults to 1 - coverage_override = (; coverage_override..., maxiters=1) - end - - local cmd = string(Base.julia_cmd()) - local coverage = occursin("--code-coverage", cmd) && !occursin("--code-coverage=none", cmd) - - local kwargs = Pair{Symbol, Any}[] - for arg in args - if (arg.head == :(=) && !(arg.args[1] in (:l2, :linf, :atol, :rtol, :coverage_override)) - && !(coverage && arg.args[1] in keys(coverage_override))) - push!(kwargs, Pair(arg.args...)) + local l2 = get_kwarg(args, :l2, nothing) + local linf = get_kwarg(args, :linf, nothing) + local atol = get_kwarg(args, :atol, 500 * eps()) + local rtol = get_kwarg(args, :rtol, sqrt(eps())) + local skip_coverage = get_kwarg(args, :skip_coverage, false) + local coverage_override = expr_to_named_tuple(get_kwarg(args, :coverage_override, :())) + if !(:maxiters in keys(coverage_override)) + # maxiters in coverage_override defaults to 1 + coverage_override = (; coverage_override..., maxiters = 1) end - end - if coverage - for key in keys(coverage_override) - push!(kwargs, Pair(key, coverage_override[key])) - end - end - - if coverage && skip_coverage - return quote - if Trixi.mpi_isroot() - println("═"^100) - println("Skipping coverage test of ", $elixir) - println("═"^100) - println("\n\n") - end - end - end - - quote - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println($elixir) - - # if `maxiters` is set in tests, it is usually set to a small number to - # run only a few steps - ignore possible warnings coming from that - if any(==(:maxiters) ∘ first, $kwargs) - additional_ignore_content = [ - r"┌ Warning: Interrupted\. Larger maxiters is needed\..*\n└ @ SciMLBase .+\n", - r"┌ Warning: Interrupted\. Larger maxiters is needed\..*\n└ @ Trixi .+\n"] - else - additional_ignore_content = [] + local cmd = string(Base.julia_cmd()) + local coverage = occursin("--code-coverage", cmd) && + !occursin("--code-coverage=none", cmd) + + local kwargs = Pair{Symbol, Any}[] + for arg in args + if (arg.head == :(=) && + !(arg.args[1] in (:l2, :linf, :atol, :rtol, :coverage_override)) + && !(coverage && arg.args[1] in keys(coverage_override))) + push!(kwargs, Pair(arg.args...)) + end end - # evaluate examples in the scope of the module they're called from - @test_nowarn_mod trixi_include(@__MODULE__, $elixir; $kwargs...) additional_ignore_content + if coverage + for key in keys(coverage_override) + push!(kwargs, Pair(key, coverage_override[key])) + end + end - # if present, compare l2 and linf errors against reference values - if !$coverage && (!isnothing($l2) || !isnothing($linf)) - l2_measured, linf_measured = analysis_callback(sol) + if coverage && skip_coverage + return quote + if Trixi.mpi_isroot() + println("═"^100) + println("Skipping coverage test of ", $elixir) + println("═"^100) + println("\n\n") + end + end + end - if Trixi.mpi_isroot() && !isnothing($l2) - @test length($l2) == length(l2_measured) - for (l2_expected, l2_actual) in zip($l2, l2_measured) - @test isapprox(l2_expected, l2_actual, atol=$atol, rtol=$rtol) + quote + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println($elixir) + + # if `maxiters` is set in tests, it is usually set to a small number to + # run only a few steps - ignore possible warnings coming from that + if any(==(:maxiters) ∘ first, $kwargs) + additional_ignore_content = [ + r"┌ Warning: Interrupted\. Larger maxiters is needed\..*\n└ @ SciMLBase .+\n", + r"┌ Warning: Interrupted\. Larger maxiters is needed\..*\n└ @ Trixi .+\n"] + else + additional_ignore_content = [] end - end - if Trixi.mpi_isroot() && !isnothing($linf) - @test length($linf) == length(linf_measured) - for (linf_expected, linf_actual) in zip($linf, linf_measured) - @test isapprox(linf_expected, linf_actual, atol=$atol, rtol=$rtol) + # evaluate examples in the scope of the module they're called from + @test_nowarn_mod trixi_include(@__MODULE__, $elixir; $kwargs...) additional_ignore_content + + # if present, compare l2 and linf errors against reference values + if !$coverage && (!isnothing($l2) || !isnothing($linf)) + l2_measured, linf_measured = analysis_callback(sol) + + if Trixi.mpi_isroot() && !isnothing($l2) + @test length($l2) == length(l2_measured) + for (l2_expected, l2_actual) in zip($l2, l2_measured) + @test isapprox(l2_expected, l2_actual, atol = $atol, rtol = $rtol) + end + end + + if Trixi.mpi_isroot() && !isnothing($linf) + @test length($linf) == length(linf_measured) + for (linf_expected, linf_actual) in zip($linf, linf_measured) + @test isapprox(linf_expected, linf_actual, atol = $atol, rtol = $rtol) + end + end end - end - end - Trixi.mpi_isroot() && println("═"^100) - Trixi.mpi_isroot() && println("\n\n") - end + Trixi.mpi_isroot() && println("═"^100) + Trixi.mpi_isroot() && println("\n\n") + end end - # Get the first value assigned to `keyword` in `args` and return `default_value` # if there are no assignments to `keyword` in `args`. function get_kwarg(args, keyword, default_value) - val = default_value - for arg in args - if arg.head == :(=) && arg.args[1] == keyword - val = arg.args[2] - break + val = default_value + for arg in args + if arg.head == :(=) && arg.args[1] == keyword + val = arg.args[2] + break + end end - end - return val + return val end function expr_to_named_tuple(expr) - result = (;) + result = (;) - for arg in expr.args - if arg.head != :(=) - error("Invalid expression") + for arg in expr.args + if arg.head != :(=) + error("Invalid expression") + end + result = (; result..., arg.args[1] => arg.args[2]) end - result = (; result..., arg.args[1] => arg.args[2]) - end - return result + return result end - # Modified version of `@test_nowarn` that prints the content of `stderr` when # it is not empty and ignores module replacements. -macro test_nowarn_mod(expr, additional_ignore_content=String[]) - quote - let fname = tempname() - try - ret = open(fname, "w") do f - redirect_stderr(f) do - $(esc(expr)) - end +macro test_nowarn_mod(expr, additional_ignore_content = String[]) + quote + let fname = tempname() + try + ret = open(fname, "w") do f + redirect_stderr(f) do + $(esc(expr)) + end + end + stderr_content = read(fname, String) + if !isempty(stderr_content) + println("Content of `stderr`:\n", stderr_content) + end + + # Patterns matching the following ones will be ignored. Additional patterns + # passed as arguments can also be regular expressions, so we just use the + # type `Any` for `ignore_content`. + ignore_content = Any[ + # We need to ignore steady state information reported by our callbacks + r"┌ Info: Steady state tolerance reached\n│ steady_state_callback .+\n└ t = .+\n", + # We also ignore our own compilation messages + "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n", + # TODO: Upstream (PlotUtils). This should be removed again once the + # deprecated stuff is fixed upstream. + "WARNING: importing deprecated binding Colors.RGB1 into Plots.\n", + "WARNING: importing deprecated binding Colors.RGB4 into Plots.\n", + r"┌ Warning: Keyword argument letter not supported with Plots.+\n└ @ Plots.+\n", + r"┌ Warning: `parse\(::Type, ::Coloarant\)` is deprecated.+\n│.+\n│.+\n└ @ Plots.+\n", + # TODO: Silence warning introduced by Flux v0.13.13. Should be properly fixed. + r"┌ Warning: Layer with Float32 parameters got Float64 input.+\n│.+\n│.+\n│.+\n└ @ Flux.+\n"] + append!(ignore_content, $additional_ignore_content) + for pattern in ignore_content + stderr_content = replace(stderr_content, pattern => "") + end + + # We also ignore simple module redefinitions for convenience. Thus, we + # check whether every line of `stderr_content` is of the form of a + # module replacement warning. + @test occursin(r"^(WARNING: replacing module .+\.\n)*$", stderr_content) + ret + finally + rm(fname, force = true) + end end - stderr_content = read(fname, String) - if !isempty(stderr_content) - println("Content of `stderr`:\n", stderr_content) - end - - # Patterns matching the following ones will be ignored. Additional patterns - # passed as arguments can also be regular expressions, so we just use the - # type `Any` for `ignore_content`. - ignore_content = Any[ - # We need to ignore steady state information reported by our callbacks - r"┌ Info: Steady state tolerance reached\n│ steady_state_callback .+\n└ t = .+\n", - # We also ignore our own compilation messages - "[ Info: You just called `trixi_include`. Julia may now compile the code, please be patient.\n", - # TODO: Upstream (PlotUtils). This should be removed again once the - # deprecated stuff is fixed upstream. - "WARNING: importing deprecated binding Colors.RGB1 into Plots.\n", - "WARNING: importing deprecated binding Colors.RGB4 into Plots.\n", - r"┌ Warning: Keyword argument letter not supported with Plots.+\n└ @ Plots.+\n", - r"┌ Warning: `parse\(::Type, ::Coloarant\)` is deprecated.+\n│.+\n│.+\n└ @ Plots.+\n", - # TODO: Silence warning introduced by Flux v0.13.13. Should be properly fixed. - r"┌ Warning: Layer with Float32 parameters got Float64 input.+\n│.+\n│.+\n│.+\n└ @ Flux.+\n", - ] - append!(ignore_content, $additional_ignore_content) - for pattern in ignore_content - stderr_content = replace(stderr_content, pattern => "") - end - - # We also ignore simple module redefinitions for convenience. Thus, we - # check whether every line of `stderr_content` is of the form of a - # module replacement warning. - @test occursin(r"^(WARNING: replacing module .+\.\n)*$", stderr_content) - ret - finally - rm(fname, force=true) - end end - end end - """ @timed_testset "name of the testset" #= code to test #= @@ -181,21 +178,20 @@ Similar to `@testset`, but prints the name of the testset and its runtime after execution. """ macro timed_testset(name, expr) - @assert name isa String - quote - local time_start = time_ns() - @testset $name $expr - local time_stop = time_ns() - if Trixi.mpi_isroot() - flush(stdout) - @info("Testset " * $name * " finished in " - * string(1.0e-9 * (time_stop - time_start)) * " seconds.\n") - flush(stdout) + @assert name isa String + quote + local time_start = time_ns() + @testset $name $expr + local time_stop = time_ns() + if Trixi.mpi_isroot() + flush(stdout) + @info("Testset "*$name*" finished in " + *string(1.0e-9 * (time_stop - time_start))*" seconds.\n") + flush(stdout) + end end - end end - """ @trixi_testset "name of the testset" #= code to test #= @@ -205,38 +201,38 @@ definition of `@test_trixi_include`. Moreover, it records the execution time of the testset similarly to [`timed_testset`](@ref). """ macro trixi_testset(name, expr) - @assert name isa String - # TODO: `@eval` is evil - # We would like to use - # mod = gensym(name) - # ... - # module $mod - # to create new module names for every test set. However, this is not - # compatible with the dirty hack using `@eval` to get the mapping when - # loading structured, curvilinear meshes. Thus, we need to use a plain - # module name here. - quote - local time_start = time_ns() - @eval module TrixiTestModule - using Test - using Trixi - include(@__FILE__) - # We define `EXAMPLES_DIR` in (nearly) all test modules and use it to - # get the path to the elixirs to be tested. However, that's not required - # and we want to fail gracefully if it's not defined. - try - import ..EXAMPLES_DIR - catch + @assert name isa String + # TODO: `@eval` is evil + # We would like to use + # mod = gensym(name) + # ... + # module $mod + # to create new module names for every test set. However, this is not + # compatible with the dirty hack using `@eval` to get the mapping when + # loading structured, curvilinear meshes. Thus, we need to use a plain + # module name here. + quote + local time_start = time_ns() + @eval module TrixiTestModule + using Test + using Trixi + include(@__FILE__) + # We define `EXAMPLES_DIR` in (nearly) all test modules and use it to + # get the path to the elixirs to be tested. However, that's not required + # and we want to fail gracefully if it's not defined. + try + import ..EXAMPLES_DIR + catch + nothing + end + @testset $name $expr + end + local time_stop = time_ns() + if Trixi.mpi_isroot() + flush(stdout) + @info("Testset "*$name*" finished in " + *string(1.0e-9 * (time_stop - time_start))*" seconds.\n") + end nothing - end - @testset $name $expr - end - local time_stop = time_ns() - if Trixi.mpi_isroot() - flush(stdout) - @info("Testset " * $name * " finished in " - * string(1.0e-9 * (time_stop - time_start)) * " seconds.\n") end - nothing - end end diff --git a/test/test_unit.jl b/test/test_unit.jl index 5c5291c2430..5422db7a66d 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -7,396 +7,408 @@ include("test_trixi.jl") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) # Run various unit (= non-elixir-triggered) tests @testset "Unit tests" begin - @timed_testset "SerialTree" begin +#! format: noindent + +@timed_testset "SerialTree" begin @testset "constructors" begin - @test_nowarn Trixi.SerialTree(Val(1), 10, 0.0, 1.0) + @test_nowarn Trixi.SerialTree(Val(1), 10, 0.0, 1.0) end @testset "helper functions" begin - t = Trixi.SerialTree(Val(1), 10, 0.0, 1.0) - @test_nowarn display(t) - @test Trixi.ndims(t) == 1 - @test Trixi.has_any_neighbor(t, 1, 1) == true - @test Trixi.isperiodic(t, 1) == true - @test Trixi.n_children_per_cell(t) == 2 - @test Trixi.n_directions(t) == 2 + t = Trixi.SerialTree(Val(1), 10, 0.0, 1.0) + @test_nowarn display(t) + @test Trixi.ndims(t) == 1 + @test Trixi.has_any_neighbor(t, 1, 1) == true + @test Trixi.isperiodic(t, 1) == true + @test Trixi.n_children_per_cell(t) == 2 + @test Trixi.n_directions(t) == 2 end @testset "refine!/coarsen!" begin - t = Trixi.SerialTree(Val(1), 10, 0.0, 1.0) - @test Trixi.refine!(t) == [1] - @test Trixi.coarsen!(t) == [1] - @test Trixi.refine!(t) == [1] - @test Trixi.coarsen!(t, 1) == [1] - @test Trixi.coarsen!(t) == Int[] # Coarsen twice to check degenerate case of single-cell tree - @test Trixi.refine!(t) == [1] - @test Trixi.refine!(t) == [2,3] - @test Trixi.coarsen_box!(t, [-0.5], [0.0]) == [2] - @test Trixi.coarsen_box!(t, 0.0, 0.5) == [3] - @test isnothing(Trixi.reset_data_structures!(t)) - end - end - - @timed_testset "ParallelTree" begin + t = Trixi.SerialTree(Val(1), 10, 0.0, 1.0) + @test Trixi.refine!(t) == [1] + @test Trixi.coarsen!(t) == [1] + @test Trixi.refine!(t) == [1] + @test Trixi.coarsen!(t, 1) == [1] + @test Trixi.coarsen!(t) == Int[] # Coarsen twice to check degenerate case of single-cell tree + @test Trixi.refine!(t) == [1] + @test Trixi.refine!(t) == [2, 3] + @test Trixi.coarsen_box!(t, [-0.5], [0.0]) == [2] + @test Trixi.coarsen_box!(t, 0.0, 0.5) == [3] + @test isnothing(Trixi.reset_data_structures!(t)) + end +end + +@timed_testset "ParallelTree" begin @testset "constructors" begin - @test_nowarn Trixi.ParallelTree(Val(1), 10, 0.0, 1.0) + @test_nowarn Trixi.ParallelTree(Val(1), 10, 0.0, 1.0) end @testset "helper functions" begin - t = Trixi.ParallelTree(Val(1), 10, 0.0, 1.0) - @test isnothing(display(t)) - @test isnothing(Trixi.reset_data_structures!(t)) + t = Trixi.ParallelTree(Val(1), 10, 0.0, 1.0) + @test isnothing(display(t)) + @test isnothing(Trixi.reset_data_structures!(t)) end - end +end - @timed_testset "TreeMesh" begin +@timed_testset "TreeMesh" begin @testset "constructors" begin - @test TreeMesh{1, Trixi.SerialTree{1}}(1, 5.0, 2.0) isa TreeMesh + @test TreeMesh{1, Trixi.SerialTree{1}}(1, 5.0, 2.0) isa TreeMesh end - end +end - @timed_testset "ParallelTreeMesh" begin +@timed_testset "ParallelTreeMesh" begin @testset "partition!" begin - @testset "mpi_nranks() = 2" begin - Trixi.mpi_nranks() = 2 - let - @test Trixi.mpi_nranks() == 2 - - mesh = TreeMesh{2, Trixi.ParallelTree{2}}(30, (0.0, 0.0), 1) - # Refine twice - Trixi.refine!(mesh.tree) - Trixi.refine!(mesh.tree) - - # allow_coarsening = true - Trixi.partition!(mesh) - # Use parent for OffsetArray - @test parent(mesh.n_cells_by_rank) == [11, 10] - @test mesh.tree.mpi_ranks[1:21] == - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - @test parent(mesh.first_cell_by_rank) == [1, 12] - - # allow_coarsening = false - Trixi.partition!(mesh; allow_coarsening=false) - @test parent(mesh.n_cells_by_rank) == [11, 10] - @test mesh.tree.mpi_ranks[1:21] == - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] - @test parent(mesh.first_cell_by_rank) == [1, 12] + @testset "mpi_nranks() = 2" begin + Trixi.mpi_nranks() = 2 + let + @test Trixi.mpi_nranks() == 2 + + mesh = TreeMesh{2, Trixi.ParallelTree{2}}(30, (0.0, 0.0), 1) + # Refine twice + Trixi.refine!(mesh.tree) + Trixi.refine!(mesh.tree) + + # allow_coarsening = true + Trixi.partition!(mesh) + # Use parent for OffsetArray + @test parent(mesh.n_cells_by_rank) == [11, 10] + @test mesh.tree.mpi_ranks[1:21] == + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + @test parent(mesh.first_cell_by_rank) == [1, 12] + + # allow_coarsening = false + Trixi.partition!(mesh; allow_coarsening = false) + @test parent(mesh.n_cells_by_rank) == [11, 10] + @test mesh.tree.mpi_ranks[1:21] == + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + @test parent(mesh.first_cell_by_rank) == [1, 12] + end + Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior end - Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior - end - - @testset "mpi_nranks() = 3" begin - Trixi.mpi_nranks() = 3 - let - @test Trixi.mpi_nranks() == 3 - - mesh = TreeMesh{2, Trixi.ParallelTree{2}}(100, (0.0, 0.0), 1) - # Refine twice - Trixi.refine!(mesh.tree) - Trixi.refine!(mesh.tree) - - # allow_coarsening = true - Trixi.partition!(mesh) - # Use parent for OffsetArray - @test parent(mesh.n_cells_by_rank) == [11, 5, 5] - @test mesh.tree.mpi_ranks[1:21] == - [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2] - @test parent(mesh.first_cell_by_rank) == [1, 12, 17] - - # allow_coarsening = false - Trixi.partition!(mesh; allow_coarsening=false) - @test parent(mesh.n_cells_by_rank) == [9, 6, 6] - @test mesh.tree.mpi_ranks[1:21] == - [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] - @test parent(mesh.first_cell_by_rank) == [1, 10, 16] + + @testset "mpi_nranks() = 3" begin + Trixi.mpi_nranks() = 3 + let + @test Trixi.mpi_nranks() == 3 + + mesh = TreeMesh{2, Trixi.ParallelTree{2}}(100, (0.0, 0.0), 1) + # Refine twice + Trixi.refine!(mesh.tree) + Trixi.refine!(mesh.tree) + + # allow_coarsening = true + Trixi.partition!(mesh) + # Use parent for OffsetArray + @test parent(mesh.n_cells_by_rank) == [11, 5, 5] + @test mesh.tree.mpi_ranks[1:21] == + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2] + @test parent(mesh.first_cell_by_rank) == [1, 12, 17] + + # allow_coarsening = false + Trixi.partition!(mesh; allow_coarsening = false) + @test parent(mesh.n_cells_by_rank) == [9, 6, 6] + @test mesh.tree.mpi_ranks[1:21] == + [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2] + @test parent(mesh.first_cell_by_rank) == [1, 10, 16] + end + Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior end - Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior - end - - @testset "mpi_nranks() = 9" begin - Trixi.mpi_nranks() = 9 - let - @test Trixi.mpi_nranks() == 9 - - mesh = TreeMesh{2, Trixi.ParallelTree{2}}(1000, (0.0, 0.0), 1) - # Refine twice - Trixi.refine!(mesh.tree) - Trixi.refine!(mesh.tree) - Trixi.refine!(mesh.tree) - Trixi.refine!(mesh.tree) - - # allow_coarsening = true - Trixi.partition!(mesh) - # Use parent for OffsetArray - @test parent(mesh.n_cells_by_rank) == [44, 37, 38, 37, 37, 37, 38, 37, 36] - @test parent(mesh.first_cell_by_rank) == [1, 45, 82, 120, 157, 194, 231, 269, 306] + + @testset "mpi_nranks() = 9" begin + Trixi.mpi_nranks() = 9 + let + @test Trixi.mpi_nranks() == 9 + + mesh = TreeMesh{2, Trixi.ParallelTree{2}}(1000, (0.0, 0.0), 1) + # Refine twice + Trixi.refine!(mesh.tree) + Trixi.refine!(mesh.tree) + Trixi.refine!(mesh.tree) + Trixi.refine!(mesh.tree) + + # allow_coarsening = true + Trixi.partition!(mesh) + # Use parent for OffsetArray + @test parent(mesh.n_cells_by_rank) == + [44, 37, 38, 37, 37, 37, 38, 37, 36] + @test parent(mesh.first_cell_by_rank) == + [1, 45, 82, 120, 157, 194, 231, 269, 306] + end + Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior end - Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior - end - - @testset "mpi_nranks() = 3 non-uniform" begin - Trixi.mpi_nranks() = 3 - let - @test Trixi.mpi_nranks() == 3 - - mesh = TreeMesh{2, Trixi.ParallelTree{2}}(100, (0.0, 0.0), 1) - # Refine whole tree - Trixi.refine!(mesh.tree) - # Refine left leaf - Trixi.refine!(mesh.tree, [2]) - - # allow_coarsening = true - Trixi.partition!(mesh) - # Use parent for OffsetArray - @test parent(mesh.n_cells_by_rank) == [6, 1, 2] - @test mesh.tree.mpi_ranks[1:9] == [0, 0, 0, 0, 0, 0, 1, 2, 2] - @test parent(mesh.first_cell_by_rank) == [1, 7, 8] - - # allow_coarsening = false - Trixi.partition!(mesh; allow_coarsening=false) - @test parent(mesh.n_cells_by_rank) == [5, 2, 2] - @test mesh.tree.mpi_ranks[1:9] == [0, 0, 0, 0, 0, 1, 1, 2, 2] - @test parent(mesh.first_cell_by_rank) == [1, 6, 8] + + @testset "mpi_nranks() = 3 non-uniform" begin + Trixi.mpi_nranks() = 3 + let + @test Trixi.mpi_nranks() == 3 + + mesh = TreeMesh{2, Trixi.ParallelTree{2}}(100, (0.0, 0.0), 1) + # Refine whole tree + Trixi.refine!(mesh.tree) + # Refine left leaf + Trixi.refine!(mesh.tree, [2]) + + # allow_coarsening = true + Trixi.partition!(mesh) + # Use parent for OffsetArray + @test parent(mesh.n_cells_by_rank) == [6, 1, 2] + @test mesh.tree.mpi_ranks[1:9] == [0, 0, 0, 0, 0, 0, 1, 2, 2] + @test parent(mesh.first_cell_by_rank) == [1, 7, 8] + + # allow_coarsening = false + Trixi.partition!(mesh; allow_coarsening = false) + @test parent(mesh.n_cells_by_rank) == [5, 2, 2] + @test mesh.tree.mpi_ranks[1:9] == [0, 0, 0, 0, 0, 1, 1, 2, 2] + @test parent(mesh.first_cell_by_rank) == [1, 6, 8] + end + Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior end - Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior - end - @testset "not enough ranks" begin - Trixi.mpi_nranks() = 3 - let - @test Trixi.mpi_nranks() == 3 + @testset "not enough ranks" begin + Trixi.mpi_nranks() = 3 + let + @test Trixi.mpi_nranks() == 3 - mesh = TreeMesh{2, Trixi.ParallelTree{2}}(100, (0.0, 0.0), 1) + mesh = TreeMesh{2, Trixi.ParallelTree{2}}(100, (0.0, 0.0), 1) - # Only one leaf - @test_throws AssertionError( - "Too many ranks to properly partition the mesh!") Trixi.partition!(mesh) + # Only one leaf + @test_throws AssertionError("Too many ranks to properly partition the mesh!") Trixi.partition!(mesh) - # Refine to 4 leaves - Trixi.refine!(mesh.tree) + # Refine to 4 leaves + Trixi.refine!(mesh.tree) - # All four leaves will need to be on one rank to allow coarsening - @test_throws AssertionError( - "Too many ranks to properly partition the mesh!") Trixi.partition!(mesh) - @test_nowarn Trixi.partition!(mesh; allow_coarsening=false) + # All four leaves will need to be on one rank to allow coarsening + @test_throws AssertionError("Too many ranks to properly partition the mesh!") Trixi.partition!(mesh) + @test_nowarn Trixi.partition!(mesh; allow_coarsening = false) + end + Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior end - Trixi.mpi_nranks() = Trixi.MPI_SIZE[] # restore the original behavior - end end - end +end - @timed_testset "curved mesh" begin +@timed_testset "curved mesh" begin @testset "calc_jacobian_matrix" begin - @testset "identity map" begin - basis = LobattoLegendreBasis(5) - nodes = Trixi.get_nodes(basis) - jacobian_matrix = Array{Float64, 5}(undef, 2, 2, 6, 6, 1) - - node_coordinates = Array{Float64, 4}(undef, 2, 6, 6, 1) - node_coordinates[1, :, :, 1] .= [nodes[i] for i in 1:6, j in 1:6] - node_coordinates[2, :, :, 1] .= [nodes[j] for i in 1:6, j in 1:6] - expected = zeros(2, 2, 6, 6, 1) - expected[1, 1, :, :, 1] .= 1 - expected[2, 2, :, :, 1] .= 1 - @test Trixi.calc_jacobian_matrix!(jacobian_matrix, 1, node_coordinates, basis) ≈ expected - end - - @testset "maximum exact polydeg" begin - basis = LobattoLegendreBasis(3) - nodes = Trixi.get_nodes(basis) - jacobian_matrix = Array{Float64, 5}(undef, 2, 2, 4, 4, 1) - - # f(x, y) = [x^3, xy^2] - node_coordinates = Array{Float64, 4}(undef, 2, 4, 4, 1) - node_coordinates[1, :, :, 1] .= [nodes[i]^3 for i in 1:4, j in 1:4] - node_coordinates[2, :, :, 1] .= [nodes[i] * nodes[j]^2 for i in 1:4, j in 1:4] - - # Df(x, y) = [3x^2 0; - # y^2 2xy] - expected = zeros(2, 2, 4, 4, 1) - expected[1, 1, :, :, 1] .= [3 * nodes[i]^2 for i in 1:4, j in 1:4] - expected[2, 1, :, :, 1] .= [nodes[j]^2 for i in 1:4, j in 1:4] - expected[2, 2, :, :, 1] .= [2 * nodes[i] * nodes[j] for i in 1:4, j in 1:4] - @test Trixi.calc_jacobian_matrix!(jacobian_matrix, 1, node_coordinates, basis) ≈ expected - end - end - end - - @timed_testset "interpolation" begin + @testset "identity map" begin + basis = LobattoLegendreBasis(5) + nodes = Trixi.get_nodes(basis) + jacobian_matrix = Array{Float64, 5}(undef, 2, 2, 6, 6, 1) + + node_coordinates = Array{Float64, 4}(undef, 2, 6, 6, 1) + node_coordinates[1, :, :, 1] .= [nodes[i] for i in 1:6, j in 1:6] + node_coordinates[2, :, :, 1] .= [nodes[j] for i in 1:6, j in 1:6] + expected = zeros(2, 2, 6, 6, 1) + expected[1, 1, :, :, 1] .= 1 + expected[2, 2, :, :, 1] .= 1 + @test Trixi.calc_jacobian_matrix!(jacobian_matrix, 1, node_coordinates, + basis) ≈ expected + end + + @testset "maximum exact polydeg" begin + basis = LobattoLegendreBasis(3) + nodes = Trixi.get_nodes(basis) + jacobian_matrix = Array{Float64, 5}(undef, 2, 2, 4, 4, 1) + + # f(x, y) = [x^3, xy^2] + node_coordinates = Array{Float64, 4}(undef, 2, 4, 4, 1) + node_coordinates[1, :, :, 1] .= [nodes[i]^3 for i in 1:4, j in 1:4] + node_coordinates[2, :, :, 1] .= [nodes[i] * nodes[j]^2 + for i in 1:4, j in 1:4] + + # Df(x, y) = [3x^2 0; + # y^2 2xy] + expected = zeros(2, 2, 4, 4, 1) + expected[1, 1, :, :, 1] .= [3 * nodes[i]^2 for i in 1:4, j in 1:4] + expected[2, 1, :, :, 1] .= [nodes[j]^2 for i in 1:4, j in 1:4] + expected[2, 2, :, :, 1] .= [2 * nodes[i] * nodes[j] for i in 1:4, j in 1:4] + @test Trixi.calc_jacobian_matrix!(jacobian_matrix, 1, node_coordinates, + basis) ≈ expected + end + end +end + +@timed_testset "interpolation" begin @testset "nodes and weights" begin - @test Trixi.gauss_nodes_weights(1) == ([0.0], [2.0]) + @test Trixi.gauss_nodes_weights(1) == ([0.0], [2.0]) end @testset "multiply_dimensionwise" begin - nodes_in = [0.0, 0.5, 1.0] - nodes_out = [0.0, 1/3, 2/3, 1.0] - matrix = Trixi.polynomial_interpolation_matrix(nodes_in, nodes_out) - data_in = [3.0 4.5 6.0] - @test isapprox(Trixi.multiply_dimensionwise(matrix, data_in), [3.0 4.0 5.0 6.0]) - - n_vars = 3 - size_in = 2 - size_out = 3 - matrix = randn(size_out, size_in) - # 1D - data_in = randn(n_vars, size_in) - data_out = Trixi.multiply_dimensionwise_naive(matrix, data_in) - @test isapprox(data_out, Trixi.multiply_dimensionwise(matrix, data_in)) - # 2D - data_in = randn(n_vars, size_in, size_in) - data_out = Trixi.multiply_dimensionwise_naive(matrix, data_in) - @test isapprox(data_out, Trixi.multiply_dimensionwise(matrix, data_in)) - # 3D - data_in = randn(n_vars, size_in, size_in, size_in) - data_out = Trixi.multiply_dimensionwise_naive(matrix, data_in) - @test isapprox(data_out, Trixi.multiply_dimensionwise(matrix, data_in)) - end - end - - @timed_testset "L2 projection" begin + nodes_in = [0.0, 0.5, 1.0] + nodes_out = [0.0, 1 / 3, 2 / 3, 1.0] + matrix = Trixi.polynomial_interpolation_matrix(nodes_in, nodes_out) + data_in = [3.0 4.5 6.0] + @test isapprox(Trixi.multiply_dimensionwise(matrix, data_in), [3.0 4.0 5.0 6.0]) + + n_vars = 3 + size_in = 2 + size_out = 3 + matrix = randn(size_out, size_in) + # 1D + data_in = randn(n_vars, size_in) + data_out = Trixi.multiply_dimensionwise_naive(matrix, data_in) + @test isapprox(data_out, Trixi.multiply_dimensionwise(matrix, data_in)) + # 2D + data_in = randn(n_vars, size_in, size_in) + data_out = Trixi.multiply_dimensionwise_naive(matrix, data_in) + @test isapprox(data_out, Trixi.multiply_dimensionwise(matrix, data_in)) + # 3D + data_in = randn(n_vars, size_in, size_in, size_in) + data_out = Trixi.multiply_dimensionwise_naive(matrix, data_in) + @test isapprox(data_out, Trixi.multiply_dimensionwise(matrix, data_in)) + end +end + +@timed_testset "L2 projection" begin @testset "calc_reverse_upper for LGL" begin - @test isapprox(Trixi.calc_reverse_upper(2, Val(:gauss_lobatto)), [[0.25, 0.25] [0.0, 0.5]]) + @test isapprox(Trixi.calc_reverse_upper(2, Val(:gauss_lobatto)), + [[0.25, 0.25] [0.0, 0.5]]) end @testset "calc_reverse_lower for LGL" begin - @test isapprox(Trixi.calc_reverse_lower(2, Val(:gauss_lobatto)), [[0.5, 0.0] [0.25, 0.25]]) + @test isapprox(Trixi.calc_reverse_lower(2, Val(:gauss_lobatto)), + [[0.5, 0.0] [0.25, 0.25]]) end - end +end - @testset "containers" begin +@testset "containers" begin # Set up mock container mutable struct MyContainer <: Trixi.AbstractContainer - data::Vector{Int} - capacity::Int - length::Int - dummy::Int + data::Vector{Int} + capacity::Int + length::Int + dummy::Int end function MyContainer(data, capacity) - c = MyContainer(Vector{Int}(undef, capacity+1), capacity, length(data), capacity+1) - c.data[1:length(data)] .= data - return c + c = MyContainer(Vector{Int}(undef, capacity + 1), capacity, length(data), + capacity + 1) + c.data[1:length(data)] .= data + return c end MyContainer(data::AbstractArray) = MyContainer(data, length(data)) Trixi.invalidate!(c::MyContainer, first, last) = (c.data[first:last] .= 0; c) - function Trixi.raw_copy!(target::MyContainer, source::MyContainer, first, last, destination) - Trixi.copy_data!(target.data, source.data, first, last, destination) - return target + function Trixi.raw_copy!(target::MyContainer, source::MyContainer, first, last, + destination) + Trixi.copy_data!(target.data, source.data, first, last, destination) + return target end Trixi.move_connectivity!(c::MyContainer, first, last, destination) = c Trixi.delete_connectivity!(c::MyContainer, first, last) = c - Trixi.reset_data_structures!(c::MyContainer) = (c.data = Vector{Int}(undef, c.capacity+1); c) + Trixi.reset_data_structures!(c::MyContainer) = (c.data = Vector{Int}(undef, + c.capacity + 1); + c) function Base.:(==)(c1::MyContainer, c2::MyContainer) - return (c1.capacity == c2.capacity && - c1.length == c2.length && - c1.dummy == c2.dummy && - c1.data[1:c1.length] == c2.data[1:c2.length]) + return (c1.capacity == c2.capacity && + c1.length == c2.length && + c1.dummy == c2.dummy && + c1.data[1:(c1.length)] == c2.data[1:(c2.length)]) end @testset "size" begin - c = MyContainer([1, 2, 3]) - @test size(c) == (3,) + c = MyContainer([1, 2, 3]) + @test size(c) == (3,) end @testset "resize!" begin - c = MyContainer([1, 2, 3]) - @test length(resize!(c, 2)) == 2 + c = MyContainer([1, 2, 3]) + @test length(resize!(c, 2)) == 2 end @testset "copy!" begin - c1 = MyContainer([1, 2, 3]) - c2 = MyContainer([4, 5]) - @test Trixi.copy!(c1, c2, 2, 1, 2) == MyContainer([1, 2, 3]) # no-op + c1 = MyContainer([1, 2, 3]) + c2 = MyContainer([4, 5]) + @test Trixi.copy!(c1, c2, 2, 1, 2) == MyContainer([1, 2, 3]) # no-op - c1 = MyContainer([1, 2, 3]) - c2 = MyContainer([4, 5]) - @test Trixi.copy!(c1, c2, 1, 2, 2) == MyContainer([1, 4, 5]) + c1 = MyContainer([1, 2, 3]) + c2 = MyContainer([4, 5]) + @test Trixi.copy!(c1, c2, 1, 2, 2) == MyContainer([1, 4, 5]) - c1 = MyContainer([1, 2, 3]) - @test Trixi.copy!(c1, c2, 1, 2) == MyContainer([1, 4, 3]) + c1 = MyContainer([1, 2, 3]) + @test Trixi.copy!(c1, c2, 1, 2) == MyContainer([1, 4, 3]) - c1 = MyContainer([1, 2, 3]) - @test Trixi.copy!(c1, 2, 3, 1) == MyContainer([2, 3, 3]) + c1 = MyContainer([1, 2, 3]) + @test Trixi.copy!(c1, 2, 3, 1) == MyContainer([2, 3, 3]) - c1 = MyContainer([1, 2, 3]) - @test Trixi.copy!(c1, 1, 3) == MyContainer([1, 2, 1]) + c1 = MyContainer([1, 2, 3]) + @test Trixi.copy!(c1, 1, 3) == MyContainer([1, 2, 1]) end @testset "move!" begin - c = MyContainer([1, 2, 3]) - @test Trixi.move!(c, 1, 1) == MyContainer([1, 2, 3]) # no-op + c = MyContainer([1, 2, 3]) + @test Trixi.move!(c, 1, 1) == MyContainer([1, 2, 3]) # no-op - c = MyContainer([1, 2, 3]) - @test Trixi.move!(c, 1, 2) == MyContainer([0, 1, 3]) + c = MyContainer([1, 2, 3]) + @test Trixi.move!(c, 1, 2) == MyContainer([0, 1, 3]) end @testset "swap!" begin - c = MyContainer([1,2]) - @test Trixi.swap!(c, 1, 1) == MyContainer([1, 2]) # no-op + c = MyContainer([1, 2]) + @test Trixi.swap!(c, 1, 1) == MyContainer([1, 2]) # no-op - c = MyContainer([1,2]) - @test Trixi.swap!(c, 1, 2) == MyContainer([2,1]) + c = MyContainer([1, 2]) + @test Trixi.swap!(c, 1, 2) == MyContainer([2, 1]) end @testset "erase!" begin - c = MyContainer([1, 2]) - @test Trixi.erase!(c, 2, 1) == MyContainer([1, 2]) # no-op + c = MyContainer([1, 2]) + @test Trixi.erase!(c, 2, 1) == MyContainer([1, 2]) # no-op - c = MyContainer([1, 2]) - @test Trixi.erase!(c, 1) == MyContainer([0, 2]) + c = MyContainer([1, 2]) + @test Trixi.erase!(c, 1) == MyContainer([0, 2]) end @testset "remove_shift!" begin - c = MyContainer([1, 2, 3, 4]) - @test Trixi.remove_shift!(c, 2, 1) == MyContainer([1, 2, 3, 4]) # no-op + c = MyContainer([1, 2, 3, 4]) + @test Trixi.remove_shift!(c, 2, 1) == MyContainer([1, 2, 3, 4]) # no-op - c = MyContainer([1, 2, 3, 4]) - @test Trixi.remove_shift!(c, 2, 2) == MyContainer([1, 3, 4], 4) + c = MyContainer([1, 2, 3, 4]) + @test Trixi.remove_shift!(c, 2, 2) == MyContainer([1, 3, 4], 4) - c = MyContainer([1, 2, 3, 4]) - @test Trixi.remove_shift!(c, 2) == MyContainer([1, 3, 4], 4) + c = MyContainer([1, 2, 3, 4]) + @test Trixi.remove_shift!(c, 2) == MyContainer([1, 3, 4], 4) end @testset "remove_fill!" begin - c = MyContainer([1, 2, 3, 4]) - @test Trixi.remove_fill!(c, 2, 1) == MyContainer([1, 2, 3, 4]) # no-op + c = MyContainer([1, 2, 3, 4]) + @test Trixi.remove_fill!(c, 2, 1) == MyContainer([1, 2, 3, 4]) # no-op - c = MyContainer([1, 2, 3, 4]) - @test Trixi.remove_fill!(c, 2, 2) == MyContainer([1, 4, 3], 4) + c = MyContainer([1, 2, 3, 4]) + @test Trixi.remove_fill!(c, 2, 2) == MyContainer([1, 4, 3], 4) end @testset "reset!" begin - c = MyContainer([1, 2, 3]) - @test Trixi.reset!(c, 2) == MyContainer(Int[], 2) + c = MyContainer([1, 2, 3]) + @test Trixi.reset!(c, 2) == MyContainer(Int[], 2) end - end +end - @timed_testset "example elixirs" begin +@timed_testset "example elixirs" begin @test basename(examples_dir()) == "examples" @test !isempty(get_examples()) @test endswith(default_example(), "elixir_advection_basic.jl") - end +end - @timed_testset "HLL flux with vanishing wave speed estimates (#502)" begin +@timed_testset "HLL flux with vanishing wave speed estimates (#502)" begin equations = CompressibleEulerEquations1D(1.4) u = SVector(1.0, 0.0, 0.0) @test !any(isnan, flux_hll(u, u, 1, equations)) - end +end - @timed_testset "DG L2 mortar container debug output" begin +@timed_testset "DG L2 mortar container debug output" begin c2d = Trixi.L2MortarContainer2D{Float64}(1, 1, 1) @test isnothing(display(c2d)) c3d = Trixi.L2MortarContainer3D{Float64}(1, 1, 1) @test isnothing(display(c3d)) - end +end - @timed_testset "Printing indicators/controllers" begin +@timed_testset "Printing indicators/controllers" begin # OBS! Constructing indicators/controllers using the parameters below doesn't make sense. It's # just useful to run basic tests of `show` methods. - c = ControllerThreeLevelCombined(1, 2, 3, 10.0, 11.0, 12.0, "primary", "secondary", "cache") + c = ControllerThreeLevelCombined(1, 2, 3, 10.0, 11.0, 12.0, "primary", "secondary", + "cache") @test_nowarn show(stdout, c) indicator_hg = IndicatorHennemannGassner(1.0, 0.0, true, "variable", "cache") @@ -406,194 +418,208 @@ isdir(outdir) && rm(outdir, recursive=true) @test_nowarn show(stdout, limiter_idp) # TODO: TrixiShallowWater: move unit test - indicator_hg_swe = IndicatorHennemannGassnerShallowWater(1.0, 0.0, true, "variable", "cache") + indicator_hg_swe = IndicatorHennemannGassnerShallowWater(1.0, 0.0, true, "variable", + "cache") @test_nowarn show(stdout, indicator_hg_swe) - indicator_loehner = IndicatorLöhner(1.0, "variable", (; cache=nothing)) + indicator_loehner = IndicatorLöhner(1.0, "variable", (; cache = nothing)) @test_nowarn show(stdout, indicator_loehner) - indicator_max = IndicatorMax("variable", (; cache=nothing)) + indicator_max = IndicatorMax("variable", (; cache = nothing)) @test_nowarn show(stdout, indicator_max) equations = CompressibleEulerEquations2D(1.4) basis = LobattoLegendreBasis(3) - indicator_neuralnetwork = IndicatorNeuralNetwork( - equations, basis, indicator_type=NeuralNetworkPerssonPeraire(), variable=density, - network=nothing) + indicator_neuralnetwork = IndicatorNeuralNetwork(equations, basis, + indicator_type = NeuralNetworkPerssonPeraire(), + variable = density, + network = nothing) @test_nowarn show(stdout, indicator_neuralnetwork) - end +end - @timed_testset "LBM 2D constructor" begin +@timed_testset "LBM 2D constructor" begin # Neither Mach number nor velocity set - @test_throws ErrorException LatticeBoltzmannEquations2D(Ma=nothing, Re=1000) + @test_throws ErrorException LatticeBoltzmannEquations2D(Ma = nothing, Re = 1000) # Both Mach number and velocity set - @test_throws ErrorException LatticeBoltzmannEquations2D(Ma=0.1, Re=1000, u0=1) + @test_throws ErrorException LatticeBoltzmannEquations2D(Ma = 0.1, Re = 1000, u0 = 1) # Neither Reynolds number nor viscosity set - @test_throws ErrorException LatticeBoltzmannEquations2D(Ma=0.1, Re=nothing) + @test_throws ErrorException LatticeBoltzmannEquations2D(Ma = 0.1, Re = nothing) # Both Reynolds number and viscosity set - @test_throws ErrorException LatticeBoltzmannEquations2D(Ma=0.1, Re=1000, nu=1) + @test_throws ErrorException LatticeBoltzmannEquations2D(Ma = 0.1, Re = 1000, nu = 1) # No non-dimensional values set - @test LatticeBoltzmannEquations2D(Ma=nothing, Re=nothing, u0=1, nu=1) isa LatticeBoltzmannEquations2D - end + @test LatticeBoltzmannEquations2D(Ma = nothing, Re = nothing, u0 = 1, nu = 1) isa + LatticeBoltzmannEquations2D +end - @timed_testset "LBM 3D constructor" begin +@timed_testset "LBM 3D constructor" begin # Neither Mach number nor velocity set - @test_throws ErrorException LatticeBoltzmannEquations3D(Ma=nothing, Re=1000) + @test_throws ErrorException LatticeBoltzmannEquations3D(Ma = nothing, Re = 1000) # Both Mach number and velocity set - @test_throws ErrorException LatticeBoltzmannEquations3D(Ma=0.1, Re=1000, u0=1) + @test_throws ErrorException LatticeBoltzmannEquations3D(Ma = 0.1, Re = 1000, u0 = 1) # Neither Reynolds number nor viscosity set - @test_throws ErrorException LatticeBoltzmannEquations3D(Ma=0.1, Re=nothing) + @test_throws ErrorException LatticeBoltzmannEquations3D(Ma = 0.1, Re = nothing) # Both Reynolds number and viscosity set - @test_throws ErrorException LatticeBoltzmannEquations3D(Ma=0.1, Re=1000, nu=1) + @test_throws ErrorException LatticeBoltzmannEquations3D(Ma = 0.1, Re = 1000, nu = 1) # No non-dimensional values set - @test LatticeBoltzmannEquations3D(Ma=nothing, Re=nothing, u0=1, nu=1) isa LatticeBoltzmannEquations3D - end + @test LatticeBoltzmannEquations3D(Ma = nothing, Re = nothing, u0 = 1, nu = 1) isa + LatticeBoltzmannEquations3D +end - @timed_testset "LBM 2D functions" begin +@timed_testset "LBM 2D functions" begin # Set up LBM struct and dummy distribution - equation = LatticeBoltzmannEquations2D(Ma=0.1, Re=1000) + equation = LatticeBoltzmannEquations2D(Ma = 0.1, Re = 1000) u = Trixi.equilibrium_distribution(1, 2, 3, equation) # Component-wise velocity @test isapprox(Trixi.velocity(u, 1, equation), 2) @test isapprox(Trixi.velocity(u, 2, equation), 3) - end +end - @timed_testset "LBM 3D functions" begin +@timed_testset "LBM 3D functions" begin # Set up LBM struct and dummy distribution - equation = LatticeBoltzmannEquations3D(Ma=0.1, Re=1000) + equation = LatticeBoltzmannEquations3D(Ma = 0.1, Re = 1000) u = Trixi.equilibrium_distribution(1, 2, 3, 4, equation) # Component-wise velocity @test isapprox(velocity(u, 1, equation), 2) @test isapprox(velocity(u, 2, equation), 3) @test isapprox(velocity(u, 3, equation), 4) - end +end - @timed_testset "LBMCollisionCallback" begin +@timed_testset "LBMCollisionCallback" begin # Printing of LBM collision callback callback = LBMCollisionCallback() @test_nowarn show(stdout, callback) println() @test_nowarn show(stdout, "text/plain", callback) println() - end +end - @timed_testset "Acoustic perturbation 2D varnames" begin +@timed_testset "Acoustic perturbation 2D varnames" begin v_mean_global = (0.0, 0.0) c_mean_global = 1.0 rho_mean_global = 1.0 - equations = AcousticPerturbationEquations2D(v_mean_global, c_mean_global, rho_mean_global) + equations = AcousticPerturbationEquations2D(v_mean_global, c_mean_global, + rho_mean_global) - @test Trixi.varnames(cons2state, equations) == ("v1_prime", "v2_prime", "p_prime_scaled") - @test Trixi.varnames(cons2mean, equations) == ("v1_mean", "v2_mean", "c_mean", "rho_mean") - end + @test Trixi.varnames(cons2state, equations) == + ("v1_prime", "v2_prime", "p_prime_scaled") + @test Trixi.varnames(cons2mean, equations) == + ("v1_mean", "v2_mean", "c_mean", "rho_mean") +end - @timed_testset "Euler conversion between conservative/entropy variables" begin +@timed_testset "Euler conversion between conservative/entropy variables" begin rho, v1, v2, v3, p = 1.0, 0.1, 0.2, 0.3, 2.0 let equations = CompressibleEulerEquations1D(1.4) - cons_vars = prim2cons(SVector(rho, v1, p),equations) - entropy_vars = cons2entropy(cons_vars, equations) - @test cons_vars ≈ entropy2cons(entropy_vars, equations) + cons_vars = prim2cons(SVector(rho, v1, p), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) - # test tuple args - cons_vars = prim2cons((rho, v1, p),equations) - entropy_vars = cons2entropy(cons_vars, equations) - @test cons_vars ≈ entropy2cons(entropy_vars, equations) + # test tuple args + cons_vars = prim2cons((rho, v1, p), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) end let equations = CompressibleEulerEquations2D(1.4) - cons_vars = prim2cons(SVector(rho,v1,v2,p),equations) - entropy_vars = cons2entropy(cons_vars,equations) - @test cons_vars ≈ entropy2cons(entropy_vars,equations) + cons_vars = prim2cons(SVector(rho, v1, v2, p), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) - # test tuple args - cons_vars = prim2cons((rho, v1, v2, p), equations) - entropy_vars = cons2entropy(cons_vars, equations) - @test cons_vars ≈ entropy2cons(entropy_vars, equations) + # test tuple args + cons_vars = prim2cons((rho, v1, v2, p), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) end let equations = CompressibleEulerEquations3D(1.4) - cons_vars = prim2cons(SVector(rho,v1,v2,v3,p),equations) - entropy_vars = cons2entropy(cons_vars,equations) - @test cons_vars ≈ entropy2cons(entropy_vars,equations) + cons_vars = prim2cons(SVector(rho, v1, v2, v3, p), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) - # test tuple args - cons_vars = prim2cons((rho, v1, v2, v3, p), equations) - entropy_vars = cons2entropy(cons_vars, equations) - @test cons_vars ≈ entropy2cons(entropy_vars, equations) + # test tuple args + cons_vars = prim2cons((rho, v1, v2, v3, p), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) end - end +end - @timed_testset "Shallow water conversion between conservative/entropy variables" begin +@timed_testset "Shallow water conversion between conservative/entropy variables" begin H, v1, v2, b = 3.5, 0.25, 0.1, 0.4 - let equations = ShallowWaterEquations1D(gravity_constant=9.8) - cons_vars = prim2cons(SVector(H, v1, b),equations) - entropy_vars = cons2entropy(cons_vars,equations) - @test cons_vars ≈ entropy2cons(entropy_vars,equations) + let equations = ShallowWaterEquations1D(gravity_constant = 9.8) + cons_vars = prim2cons(SVector(H, v1, b), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) - total_energy = energy_total(cons_vars, equations) - @test total_energy ≈ entropy(cons_vars, equations) + total_energy = energy_total(cons_vars, equations) + @test total_energy ≈ entropy(cons_vars, equations) - # test tuple args - cons_vars = prim2cons((H, v1, b), equations) - entropy_vars = cons2entropy(cons_vars, equations) - @test cons_vars ≈ entropy2cons(entropy_vars, equations) + # test tuple args + cons_vars = prim2cons((H, v1, b), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) end - let equations = ShallowWaterEquations2D(gravity_constant=9.8) - cons_vars = prim2cons(SVector(H,v1,v2,b),equations) - entropy_vars = cons2entropy(cons_vars,equations) - @test cons_vars ≈ entropy2cons(entropy_vars,equations) + let equations = ShallowWaterEquations2D(gravity_constant = 9.8) + cons_vars = prim2cons(SVector(H, v1, v2, b), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) - total_energy = energy_total(cons_vars, equations) - @test total_energy ≈ entropy(cons_vars, equations) + total_energy = energy_total(cons_vars, equations) + @test total_energy ≈ entropy(cons_vars, equations) - # test tuple args - cons_vars = prim2cons((H, v1, v2, b), equations) - entropy_vars = cons2entropy(cons_vars, equations) - @test cons_vars ≈ entropy2cons(entropy_vars, equations) + # test tuple args + cons_vars = prim2cons((H, v1, v2, b), equations) + entropy_vars = cons2entropy(cons_vars, equations) + @test cons_vars ≈ entropy2cons(entropy_vars, equations) end - end +end - @timed_testset "boundary_condition_do_nothing" begin +@timed_testset "boundary_condition_do_nothing" begin rho, v1, v2, p = 1.0, 0.1, 0.2, 0.3, 2.0 let equations = CompressibleEulerEquations2D(1.4) - u = prim2cons(SVector(rho, v1, v2, p), equations) - x = SVector(1.0, 2.0) - t = 0.5 - surface_flux = flux_lax_friedrichs - - outward_direction = SVector(0.2, -0.3) - @test flux(u, outward_direction, equations) ≈ boundary_condition_do_nothing(u, outward_direction, x, t, surface_flux, equations) - - orientation = 2 - direction = 4 - @test flux(u, orientation, equations) ≈ boundary_condition_do_nothing(u, orientation, direction, x, t, surface_flux, equations) + u = prim2cons(SVector(rho, v1, v2, p), equations) + x = SVector(1.0, 2.0) + t = 0.5 + surface_flux = flux_lax_friedrichs + + outward_direction = SVector(0.2, -0.3) + @test flux(u, outward_direction, equations) ≈ + boundary_condition_do_nothing(u, outward_direction, x, t, surface_flux, + equations) + + orientation = 2 + direction = 4 + @test flux(u, orientation, equations) ≈ + boundary_condition_do_nothing(u, orientation, direction, x, t, + surface_flux, equations) end - end +end - @timed_testset "TimeSeriesCallback" begin +@timed_testset "TimeSeriesCallback" begin @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_acoustics_gaussian_source.jl"), - tspan=(0, 0.05)) + joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_acoustics_gaussian_source.jl"), + tspan = (0, 0.05)) point_data_1 = time_series.affect!.point_data[1] - @test all(isapprox.(point_data_1[1:7], [-2.4417734981719132e-5, -3.4296207289200194e-5, - 0.0018130846385739788, -0.5, 0.25, 1.0, 1.0])) - @test_throws DimensionMismatch Trixi.get_elements_by_coordinates!([1, 2], rand(2, 4), mesh, + @test all(isapprox.(point_data_1[1:7], + [-2.4417734981719132e-5, -3.4296207289200194e-5, + 0.0018130846385739788, -0.5, 0.25, 1.0, 1.0])) + @test_throws DimensionMismatch Trixi.get_elements_by_coordinates!([1, 2], + rand(2, 4), mesh, solver, nothing) @test_nowarn show(stdout, time_series) - @test_throws ArgumentError TimeSeriesCallback(semi, [(1.0, 1.0)]; interval=-1) + @test_throws ArgumentError TimeSeriesCallback(semi, [(1.0, 1.0)]; interval = -1) @test_throws ArgumentError TimeSeriesCallback(semi, [1.0 1.0 1.0; 2.0 2.0 2.0]) - end +end - @timed_testset "Consistency check for HLL flux (naive): CEE" begin +@timed_testset "Consistency check for HLL flux (naive): CEE" begin flux_hll = FluxHLL(min_max_speed_naive) # Set up equations and dummy conservative variables state @@ -602,7 +628,7 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end equations = CompressibleEulerEquations2D(1.4) @@ -610,7 +636,7 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end equations = CompressibleEulerEquations3D(1.4) @@ -618,11 +644,11 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2, 3] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end - end +end - @timed_testset "Consistency check for HLL flux (naive): LEE" begin +@timed_testset "Consistency check for HLL flux (naive): LEE" begin flux_hll = FluxHLL(min_max_speed_naive) equations = LinearizedEulerEquations2D(SVector(1.0, 1.0), 1.0, 1.0) @@ -630,87 +656,91 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLL flux (naive): SWE" begin +@timed_testset "Consistency check for HLL flux (naive): SWE" begin flux_hll = FluxHLL(min_max_speed_naive) - equations = ShallowWaterEquations1D(gravity_constant=9.81) + equations = ShallowWaterEquations1D(gravity_constant = 9.81) u = SVector(1, 0.5, 0.0) @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) - equations = ShallowWaterEquations2D(gravity_constant=9.81) + equations = ShallowWaterEquations2D(gravity_constant = 9.81) normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] u = SVector(1, 0.5, 0.5, 0.0) for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLL flux (naive): MHD" begin +@timed_testset "Consistency check for HLL flux (naive): MHD" begin flux_hll = FluxHLL(min_max_speed_naive) equations = IdealGlmMhdEquations1D(1.4) u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2)] for u in u_values - @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) end - equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) + equations = IdealGlmMhdEquations2D(1.4, 5.0) #= c_h =# normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] orientations = [1, 2] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] for u in u_values, orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for u in u_values, normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) + equations = IdealGlmMhdEquations3D(1.4, 5.0) #= c_h =# normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] orientations = [1, 2, 3] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] for u in u_values, orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for u in u_values, normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLL flux with Davis wave speed estimates: CEE" begin +@timed_testset "Consistency check for HLL flux with Davis wave speed estimates: CEE" begin flux_hll = FluxHLL(min_max_speed_davis) # Set up equations and dummy conservative variables state @@ -719,7 +749,7 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end equations = CompressibleEulerEquations2D(1.4) @@ -727,16 +757,17 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end equations = CompressibleEulerEquations3D(1.4) @@ -744,21 +775,22 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2, 3] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLL flux with Davis wave speed estimates: LEE" begin +@timed_testset "Consistency check for HLL flux with Davis wave speed estimates: LEE" begin flux_hll = FluxHLL(min_max_speed_davis) equations = LinearizedEulerEquations2D(SVector(1.0, 1.0), 1.0, 1.0) @@ -766,99 +798,103 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLL flux with Davis wave speed estimates: SWE" begin +@timed_testset "Consistency check for HLL flux with Davis wave speed estimates: SWE" begin flux_hll = FluxHLL(min_max_speed_davis) - equations = ShallowWaterEquations1D(gravity_constant=9.81) + equations = ShallowWaterEquations1D(gravity_constant = 9.81) u = SVector(1, 0.5, 0.0) @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) - equations = ShallowWaterEquations2D(gravity_constant=9.81) + equations = ShallowWaterEquations2D(gravity_constant = 9.81) normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] u = SVector(1, 0.5, 0.5, 0.0) for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end orientations = [1, 2] for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end - end +end - @timed_testset "Consistency check for HLL flux with Davis wave speed estimates: MHD" begin +@timed_testset "Consistency check for HLL flux with Davis wave speed estimates: MHD" begin flux_hll = FluxHLL(min_max_speed_davis) equations = IdealGlmMhdEquations1D(1.4) u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2)] for u in u_values - @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) end - equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) + equations = IdealGlmMhdEquations2D(1.4, 5.0) #= c_h =# normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] orientations = [1, 2] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] for u in u_values, orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for u in u_values, normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) + equations = IdealGlmMhdEquations3D(1.4, 5.0) #= c_h =# normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] orientations = [1, 2, 3] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] for u in u_values, orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for u in u_values, normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLLE flux: CEE" begin +@timed_testset "Consistency check for HLLE flux: CEE" begin # Set up equations and dummy conservative variables state equations = CompressibleEulerEquations1D(1.4) u = SVector(1.1, 2.34, 5.5) orientations = [1] for orientation in orientations - @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) end equations = CompressibleEulerEquations2D(1.4) @@ -866,16 +902,17 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end equations = CompressibleEulerEquations3D(1.4) @@ -883,97 +920,101 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2, 3] for orientation in orientations - @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hlle(u, u, orientation, equations) ≈ flux(u, orientation, equations) end normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLLE flux: SWE" begin +@timed_testset "Consistency check for HLLE flux: SWE" begin # Test HLL flux with min_max_speed_einfeldt flux_hll = FluxHLL(min_max_speed_einfeldt) - equations = ShallowWaterEquations1D(gravity_constant=9.81) + equations = ShallowWaterEquations1D(gravity_constant = 9.81) u = SVector(1, 0.5, 0.0) @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) - equations = ShallowWaterEquations2D(gravity_constant=9.81) + equations = ShallowWaterEquations2D(gravity_constant = 9.81) normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] orientations = [1, 2] u = SVector(1, 0.5, 0.5, 0.0) for orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for HLLE flux: MHD" begin +@timed_testset "Consistency check for HLLE flux: MHD" begin # Test HLL flux with min_max_speed_einfeldt flux_hll = FluxHLL(min_max_speed_naive) equations = IdealGlmMhdEquations1D(1.4) u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2)] for u in u_values - @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) + @test flux_hll(u, u, 1, equations) ≈ flux(u, 1, equations) end - equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) + equations = IdealGlmMhdEquations2D(1.4, 5.0) #= c_h =# normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] orientations = [1, 2] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] for u in u_values, orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for u in u_values, normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) + equations = IdealGlmMhdEquations3D(1.4, 5.0) #= c_h =# normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] orientations = [1, 2, 3] u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] for u in u_values, orientation in orientations - @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) + @test flux_hll(u, u, orientation, equations) ≈ flux(u, orientation, equations) end for u in u_values, normal_direction in normal_directions - @test flux_hll(u, u, normal_direction, equations) ≈ flux(u, normal_direction, equations) + @test flux_hll(u, u, normal_direction, equations) ≈ + flux(u, normal_direction, equations) end - end +end - @timed_testset "Consistency check for Godunov flux" begin +@timed_testset "Consistency check for Godunov flux" begin # Set up equations and dummy conservative variables state # Burgers' Equation @@ -982,7 +1023,7 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations, u in u_values - @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) end # Linear Advection 1D @@ -991,7 +1032,7 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations - @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) end # Linear Advection 2D @@ -1000,16 +1041,17 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions - @test flux_godunov(u, u, normal_direction, equation) ≈ flux(u, normal_direction, equation) + @test flux_godunov(u, u, normal_direction, equation) ≈ + flux(u, normal_direction, equation) end # Linear Advection 3D @@ -1018,48 +1060,52 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2, 3] for orientation in orientations - @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) end normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] for normal_direction in normal_directions - @test flux_godunov(u, u, normal_direction, equation) ≈ flux(u, normal_direction, equation) + @test flux_godunov(u, u, normal_direction, equation) ≈ + flux(u, normal_direction, equation) end # Linearized Euler 2D - equation = LinearizedEulerEquations2D(v_mean_global=(0.5, -0.7), c_mean_global=1.1, - rho_mean_global=1.2) + equation = LinearizedEulerEquations2D(v_mean_global = (0.5, -0.7), + c_mean_global = 1.1, + rho_mean_global = 1.2) u_values = [SVector(1.0, 0.5, -0.7, 1.0), - SVector(1.5, -0.2, 0.1, 5.0),] + SVector(1.5, -0.2, 0.1, 5.0)] orientations = [1, 2] for orientation in orientations, u in u_values - @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test flux_godunov(u, u, orientation, equation) ≈ flux(u, orientation, equation) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions, u in u_values - @test flux_godunov(u, u, normal_direction, equation) ≈ flux(u, normal_direction, equation) + @test flux_godunov(u, u, normal_direction, equation) ≈ + flux(u, normal_direction, equation) end - end +end - @timed_testset "Consistency check for Engquist-Osher flux" begin +@timed_testset "Consistency check for Engquist-Osher flux" begin # Set up equations and dummy conservative variables state equation = InviscidBurgersEquation1D() u_values = [SVector(42.0), SVector(-42.0)] orientations = [1] for orientation in orientations, u in u_values - @test Trixi.flux_engquist_osher(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test Trixi.flux_engquist_osher(u, u, orientation, equation) ≈ + flux(u, orientation, equation) end equation = LinearScalarAdvectionEquation1D(-4.2) @@ -1067,11 +1113,12 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations - @test Trixi.flux_engquist_osher(u, u, orientation, equation) ≈ flux(u, orientation, equation) + @test Trixi.flux_engquist_osher(u, u, orientation, equation) ≈ + flux(u, orientation, equation) end - end +end - @testset "Equivalent Fluxes" begin +@testset "Equivalent Fluxes" begin # Set up equations and dummy conservative variables state # Burgers' Equation @@ -1080,7 +1127,8 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations, u in u_values - @test flux_godunov(0.75*u, u, orientation, equation) ≈ Trixi.flux_engquist_osher(0.75*u, u, orientation, equation) + @test flux_godunov(0.75 * u, u, orientation, equation) ≈ + Trixi.flux_engquist_osher(0.75 * u, u, orientation, equation) end # Linear Advection 1D @@ -1089,8 +1137,10 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1] for orientation in orientations - @test flux_godunov(0.5*u, u, orientation, equation) ≈ flux_lax_friedrichs(0.5*u, u, orientation, equation) - @test flux_godunov(2*u, u, orientation, equation) ≈ Trixi.flux_engquist_osher(2*u, u, orientation, equation) + @test flux_godunov(0.5 * u, u, orientation, equation) ≈ + flux_lax_friedrichs(0.5 * u, u, orientation, equation) + @test flux_godunov(2 * u, u, orientation, equation) ≈ + Trixi.flux_engquist_osher(2 * u, u, orientation, equation) end # Linear Advection 2D @@ -1099,16 +1149,18 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2] for orientation in orientations - @test flux_godunov(0.25*u, u, orientation, equation) ≈ flux_lax_friedrichs(0.25*u, u, orientation, equation) + @test flux_godunov(0.25 * u, u, orientation, equation) ≈ + flux_lax_friedrichs(0.25 * u, u, orientation, equation) end normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] for normal_direction in normal_directions - @test flux_godunov(3*u, u, normal_direction, equation) ≈ flux_lax_friedrichs(3*u, u, normal_direction, equation) + @test flux_godunov(3 * u, u, normal_direction, equation) ≈ + flux_lax_friedrichs(3 * u, u, normal_direction, equation) end # Linear Advection 3D @@ -1117,113 +1169,137 @@ isdir(outdir) && rm(outdir, recursive=true) orientations = [1, 2, 3] for orientation in orientations - @test flux_godunov(1.5*u, u, orientation, equation) ≈ flux_lax_friedrichs(1.5*u, u, orientation, equation) + @test flux_godunov(1.5 * u, u, orientation, equation) ≈ + flux_lax_friedrichs(1.5 * u, u, orientation, equation) end normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] for normal_direction in normal_directions - @test flux_godunov(1.3*u, u, normal_direction, equation) ≈ flux_lax_friedrichs(1.3*u, u, normal_direction, equation) + @test flux_godunov(1.3 * u, u, normal_direction, equation) ≈ + flux_lax_friedrichs(1.3 * u, u, normal_direction, equation) end - end +end - @testset "FluxRotated vs. direct implementation" begin +@testset "FluxRotated vs. direct implementation" begin @timed_testset "CompressibleEulerEquations2D" begin - equations = CompressibleEulerEquations2D(1.4) - normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] - u_values = [SVector(1.0, 0.5, -0.7, 1.0), - SVector(1.5, -0.2, 0.1, 5.0),] - fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, - flux_hll, FluxHLL(min_max_speed_davis)] - - for f_std in fluxes - f_rot = FluxRotated(f_std) - for u_ll in u_values, u_rr in u_values, normal_direction in normal_directions - @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ f_std(u_ll, u_rr, normal_direction, equations) + equations = CompressibleEulerEquations2D(1.4) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u_values = [SVector(1.0, 0.5, -0.7, 1.0), + SVector(1.5, -0.2, 0.1, 5.0)] + fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, + flux_hll, FluxHLL(min_max_speed_davis)] + + for f_std in fluxes + f_rot = FluxRotated(f_std) + for u_ll in u_values, u_rr in u_values, + normal_direction in normal_directions + + @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ + f_std(u_ll, u_rr, normal_direction, equations) + end end - end end @timed_testset "CompressibleEulerEquations3D" begin - equations = CompressibleEulerEquations3D(1.4) - normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] - u_values = [SVector(1.0, 0.5, -0.7, 0.1, 1.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0),] - fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, FluxLMARS(340), - flux_hll, FluxHLL(min_max_speed_davis)] - - for f_std in fluxes - f_rot = FluxRotated(f_std) - for u_ll in u_values, u_rr in u_values, normal_direction in normal_directions - @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ f_std(u_ll, u_rr, normal_direction, equations) + equations = CompressibleEulerEquations3D(1.4) + normal_directions = [SVector(1.0, 0.0, 0.0), + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] + u_values = [SVector(1.0, 0.5, -0.7, 0.1, 1.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0)] + fluxes = [flux_central, flux_ranocha, flux_shima_etal, flux_kennedy_gruber, + FluxLMARS(340), + flux_hll, FluxHLL(min_max_speed_davis)] + + for f_std in fluxes + f_rot = FluxRotated(f_std) + for u_ll in u_values, u_rr in u_values, + normal_direction in normal_directions + + @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ + f_std(u_ll, u_rr, normal_direction, equations) + end end - end end @timed_testset "ShallowWaterEquations2D" begin - equations = ShallowWaterEquations2D(gravity_constant=9.81) - normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] - - u = SVector(1, 0.5, 0.5, 0.0) + equations = ShallowWaterEquations2D(gravity_constant = 9.81) + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] - fluxes = [flux_central, flux_fjordholm_etal, flux_wintermeyer_etal, - flux_hll, FluxHLL(min_max_speed_davis), FluxHLL(min_max_speed_einfeldt)] + u = SVector(1, 0.5, 0.5, 0.0) + fluxes = [flux_central, flux_fjordholm_etal, flux_wintermeyer_etal, + flux_hll, FluxHLL(min_max_speed_davis), FluxHLL(min_max_speed_einfeldt)] end @timed_testset "IdealGlmMhdEquations2D" begin - equations = IdealGlmMhdEquations2D(1.4, 5.0 #= c_h =#) - normal_directions = [SVector(1.0, 0.0), - SVector(0.0, 1.0), - SVector(0.5, -0.5), - SVector(-1.2, 0.3)] - u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] - fluxes = [flux_central, flux_hindenlang_gassner, flux_hll, FluxHLL(min_max_speed_davis)] - - for f_std in fluxes - f_rot = FluxRotated(f_std) - for u_ll in u_values, u_rr in u_values, normal_direction in normal_directions - @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ f_std(u_ll, u_rr, normal_direction, equations) + equations = IdealGlmMhdEquations2D(1.4, 5.0) #= c_h =# + normal_directions = [SVector(1.0, 0.0), + SVector(0.0, 1.0), + SVector(0.5, -0.5), + SVector(-1.2, 0.3)] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] + fluxes = [ + flux_central, + flux_hindenlang_gassner, + flux_hll, + FluxHLL(min_max_speed_davis), + ] + + for f_std in fluxes + f_rot = FluxRotated(f_std) + for u_ll in u_values, u_rr in u_values, + normal_direction in normal_directions + + @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ + f_std(u_ll, u_rr, normal_direction, equations) + end end - end end @timed_testset "IdealGlmMhdEquations3D" begin - equations = IdealGlmMhdEquations3D(1.4, 5.0 #= c_h =#) - normal_directions = [SVector(1.0, 0.0, 0.0), - SVector(0.0, 1.0, 0.0), - SVector(0.0, 0.0, 1.0), - SVector(0.5, -0.5, 0.2), - SVector(-1.2, 0.3, 1.4)] - u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), - SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2),] - fluxes = [flux_central, flux_hindenlang_gassner, flux_hll, FluxHLL(min_max_speed_davis)] - - for f_std in fluxes - f_rot = FluxRotated(f_std) - for u_ll in u_values, u_rr in u_values, normal_direction in normal_directions - @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ f_std(u_ll, u_rr, normal_direction, equations) + equations = IdealGlmMhdEquations3D(1.4, 5.0) #= c_h =# + normal_directions = [SVector(1.0, 0.0, 0.0), + SVector(0.0, 1.0, 0.0), + SVector(0.0, 0.0, 1.0), + SVector(0.5, -0.5, 0.2), + SVector(-1.2, 0.3, 1.4)] + u_values = [SVector(1.0, 0.4, -0.5, 0.1, 1.0, 0.1, -0.2, 0.1, 0.0), + SVector(1.5, -0.2, 0.1, 0.2, 5.0, -0.1, 0.1, 0.2, 0.2)] + fluxes = [ + flux_central, + flux_hindenlang_gassner, + flux_hll, + FluxHLL(min_max_speed_davis), + ] + + for f_std in fluxes + f_rot = FluxRotated(f_std) + for u_ll in u_values, u_rr in u_values, + normal_direction in normal_directions + + @test f_rot(u_ll, u_rr, normal_direction, equations) ≈ + f_std(u_ll, u_rr, normal_direction, equations) + end end - end end - end +end - @testset "SimpleKronecker" begin +@testset "SimpleKronecker" begin N = 3 NDIMS = 2 @@ -1240,30 +1316,28 @@ isdir(outdir) && rm(outdir, recursive=true) Trixi.mul!(b, V, x) Trixi.mul!(b_kron, V_kron, x) @test b ≈ b_kron - end +end - @testset "SummationByPartsOperators + StartUpDG" begin - dg = DGMulti(polydeg = 3, element_type = Quad(), - approximation_type = derivative_operator( - SummationByPartsOperators.MattssonNordström2004(), - derivative_order=1, accuracy_order=4, - xmin=0.0, xmax=1.0, N=10)) +@testset "SummationByPartsOperators + StartUpDG" begin + global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(), + derivative_order = 1, + accuracy_order = 4, + xmin = 0.0, xmax = 1.0, + N = 10) + dg = DGMulti(polydeg = 3, element_type = Quad(), approximation_type = D) @test StartUpDG.inverse_trace_constant(dg.basis) ≈ 50.8235294117647 - end +end - @testset "1D non-periodic DGMultiMesh" begin +@testset "1D non-periodic DGMultiMesh" begin # checks whether or not boundary faces are initialized correctly for DGMultiMesh in 1D dg = DGMulti(polydeg = 1, element_type = Line(), approximation_type = Polynomial(), surface_integral = SurfaceIntegralWeakForm(flux_central), volume_integral = VolumeIntegralFluxDifferencing(flux_central)) - mesh = DGMultiMesh(dg, cells_per_dimension=(1,), periodicity=false) + mesh = DGMultiMesh(dg, cells_per_dimension = (1,), periodicity = false) @test mesh.boundary_faces[:entire_boundary] == [1, 2] - end - end - - +end end #module diff --git a/test/test_unstructured_2d.jl b/test/test_unstructured_2d.jl index 567cbd9ea57..26483931cf3 100644 --- a/test/test_unstructured_2d.jl +++ b/test/test_unstructured_2d.jl @@ -11,394 +11,601 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "unstructured_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) @testset "UnstructuredMesh2D" begin - @trixi_testset "elixir_euler_periodic.jl" begin +#! format: noindent + +@trixi_testset "elixir_euler_periodic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_periodic.jl"), - l2 = [0.00010978828464875207, 0.00013010359527356914, 0.00013010359527326057, 0.0002987656724828824], - linf = [0.00638626102818618, 0.009804042508242183, 0.009804042508253286, 0.02183139311614468]) - # 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_euler_free_stream.jl" begin + l2=[ + 0.00010978828464875207, + 0.00013010359527356914, + 0.00013010359527326057, + 0.0002987656724828824, + ], + linf=[ + 0.00638626102818618, + 0.009804042508242183, + 0.009804042508253286, + 0.02183139311614468, + ]) + # 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_euler_free_stream.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"), - l2 = [3.3937971107485363e-14, 2.447586447887882e-13, 1.4585205789296455e-13, 4.716993468962946e-13], - linf = [8.804734719092266e-12, 6.261270668606045e-11, 2.93670088247211e-11, 1.205400224080222e-10], - tspan = (0.0, 0.1), - atol = 3.0e-13) - # 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_euler_wall_bc.jl" begin + l2=[ + 3.3937971107485363e-14, + 2.447586447887882e-13, + 1.4585205789296455e-13, + 4.716993468962946e-13, + ], + linf=[ + 8.804734719092266e-12, + 6.261270668606045e-11, + 2.93670088247211e-11, + 1.205400224080222e-10, + ], + tspan=(0.0, 0.1), + atol=3.0e-13) + # 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_euler_wall_bc.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc.jl"), - l2 = [0.040189107976346644, 0.04256154998030852, 0.03734120743842209, 0.10057425897733507], - linf = [0.24455374304626365, 0.2970686406973577, 0.29339040847600434, 0.5915610037764794], - tspan = (0.0, 0.25)) - # 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_euler_basic.jl" begin + l2=[ + 0.040189107976346644, + 0.04256154998030852, + 0.03734120743842209, + 0.10057425897733507, + ], + linf=[ + 0.24455374304626365, + 0.2970686406973577, + 0.29339040847600434, + 0.5915610037764794, + ], + tspan=(0.0, 0.25)) + # 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_euler_basic.jl" begin @test_trixi_include(default_example_unstructured(), - l2 = [0.0007213418215265047, 0.0006752337675043779, 0.0006437485997536973, 0.0014782883071363362], - linf = [0.004301288971032324, 0.005243995459478956, 0.004685630332338153, 0.01750217718347713], - tspan = (0.0, 1.0)) - # 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_euler_restart.jl" begin + l2=[ + 0.0007213418215265047, + 0.0006752337675043779, + 0.0006437485997536973, + 0.0014782883071363362, + ], + linf=[ + 0.004301288971032324, + 0.005243995459478956, + 0.004685630332338153, + 0.01750217718347713, + ], + tspan=(0.0, 1.0)) + # 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_euler_restart.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_restart.jl"), - l2 = [0.0007213418215265047, 0.0006752337675043779, 0.0006437485997536973, 0.0014782883071363362], - linf = [0.004301288971032324, 0.005243995459478956, 0.004685630332338153, 0.01750217718347713]) - # 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_euler_ec.jl" begin + l2=[ + 0.0007213418215265047, + 0.0006752337675043779, + 0.0006437485997536973, + 0.0014782883071363362, + ], + linf=[ + 0.004301288971032324, + 0.005243995459478956, + 0.004685630332338153, + 0.01750217718347713, + ]) + # 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_euler_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"), - l2 = [0.06594600495903137, 0.10803914821786433, 0.10805946357846291, 0.1738171782368222], - linf = [0.31880214280781305, 0.3468488554333352, 0.34592958184413264, 0.784555926860546], - tspan = (0.0, 1.0)) - # 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_advection_basic.jl" begin + l2=[ + 0.06594600495903137, + 0.10803914821786433, + 0.10805946357846291, + 0.1738171782368222, + ], + linf=[ + 0.31880214280781305, + 0.3468488554333352, + 0.34592958184413264, + 0.784555926860546, + ], + tspan=(0.0, 1.0)) + # 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_advection_basic.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"), - l2 = [0.00018729339078205488], - linf = [0.0018997287705734278]) - # 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_euler_sedov.jl" begin + l2=[0.00018729339078205488], + linf=[0.0018997287705734278]) + # 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_euler_sedov.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"), - l2 = [2.19945600e-01, 1.71050453e-01, 1.71050453e-01, 1.21719195e+00], - linf = [7.44218635e-01, 7.02887039e-01, 7.02887039e-01, 6.11732719e+00], - tspan = (0.0, 0.3)) - # 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_acoustics_gauss_wall.jl" begin + l2=[ + 2.19945600e-01, + 1.71050453e-01, + 1.71050453e-01, + 1.21719195e+00, + ], + linf=[ + 7.44218635e-01, + 7.02887039e-01, + 7.02887039e-01, + 6.11732719e+00, + ], + tspan=(0.0, 0.3)) + # 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_acoustics_gauss_wall.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_acoustics_gauss_wall.jl"), - l2 = [0.029330394861252995, 0.029345079728907965, 0.03803795043486467, 0.0, - 7.175152371650832e-16, 1.4350304743301665e-15, 1.4350304743301665e-15], - linf = [0.36236334472179443, 0.3690785638275256, 0.8475748723784078, 0.0, - 8.881784197001252e-16, 1.7763568394002505e-15, 1.7763568394002505e-15], - tspan = (0.0, 5.0)) - # 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_mhd_ec.jl" begin + l2=[0.029330394861252995, 0.029345079728907965, + 0.03803795043486467, 0.0, + 7.175152371650832e-16, 1.4350304743301665e-15, + 1.4350304743301665e-15], + linf=[0.36236334472179443, 0.3690785638275256, + 0.8475748723784078, 0.0, + 8.881784197001252e-16, 1.7763568394002505e-15, + 1.7763568394002505e-15], + tspan=(0.0, 5.0)) + # 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_mhd_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"), - l2 = [0.06418293357851637, 0.12085176618704108, 0.12085099342419513, 0.07743005602933221, - 0.1622218916638482, 0.04044434425257972, 0.04044440614962498, 0.05735896706356321, - 0.0020992340041681734], - linf = [0.1417000509328017, 0.3210578460652491, 0.335041095545175, 0.22500796423572675, - 0.44230628074326406, 0.16743171716317784, 0.16745989278866702, 0.17700588224362557, - 0.02692320090677309], - tspan = (0.0, 0.5)) - # 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_mhd_alfven_wave.jl" begin + l2=[0.06418293357851637, 0.12085176618704108, + 0.12085099342419513, 0.07743005602933221, + 0.1622218916638482, 0.04044434425257972, + 0.04044440614962498, 0.05735896706356321, + 0.0020992340041681734], + linf=[0.1417000509328017, 0.3210578460652491, 0.335041095545175, + 0.22500796423572675, + 0.44230628074326406, 0.16743171716317784, + 0.16745989278866702, 0.17700588224362557, + 0.02692320090677309], + tspan=(0.0, 0.5)) + # 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_mhd_alfven_wave.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"), - l2 = [5.377518922553881e-5, 0.09999999206243514, 0.09999999206243441, 0.1414213538550799, - 8.770450430886394e-6, 0.0999999926130084, 0.0999999926130088, 0.14142135396487032, - 1.1553833987291942e-5], - linf = [0.00039334982566352483, 0.14144904937275282, 0.14144904937277897, 0.20003315928443416, - 6.826863293230012e-5, 0.14146512909995967, 0.14146512909994702, 0.20006706837452526, - 0.00013645610312810813], - tspan = (0.0, 0.5)) - # 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_shallowwater_ec.jl" begin + l2=[5.377518922553881e-5, 0.09999999206243514, + 0.09999999206243441, 0.1414213538550799, + 8.770450430886394e-6, 0.0999999926130084, + 0.0999999926130088, 0.14142135396487032, + 1.1553833987291942e-5], + linf=[0.00039334982566352483, 0.14144904937275282, + 0.14144904937277897, 0.20003315928443416, + 6.826863293230012e-5, 0.14146512909995967, + 0.14146512909994702, 0.20006706837452526, + 0.00013645610312810813], + tspan=(0.0, 0.5)) + # 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_shallowwater_ec.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec.jl"), - l2 = [0.6106939484178353, 0.48586236867426724, 0.48234490854514356, 0.29467422718511727], - linf = [2.775979948281604, 3.1721242154451548, 3.5713448319601393, 2.052861364219655], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced.jl" begin + l2=[ + 0.6106939484178353, + 0.48586236867426724, + 0.48234490854514356, + 0.29467422718511727, + ], + linf=[ + 2.775979948281604, + 3.1721242154451548, + 3.5713448319601393, + 2.052861364219655, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [1.2164292510839076, 2.6118925543469468e-12, 1.1636046671473883e-12, 1.2164292510839079], - linf = [1.5138512282315846, 4.998482888288039e-11, 2.0246214978154587e-11, 1.513851228231574], - tspan = (0.0, 0.25)) - # 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_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin + l2=[ + 1.2164292510839076, + 2.6118925543469468e-12, + 1.1636046671473883e-12, + 1.2164292510839079, + ], + linf=[ + 1.5138512282315846, + 4.998482888288039e-11, + 2.0246214978154587e-11, + 1.513851228231574, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_well_balanced.jl with FluxHydrostaticReconstruction" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_well_balanced.jl"), - l2 = [1.2164292510839085, 1.2643106818778908e-12, 7.46884905098358e-13, 1.2164292510839079], - linf = [1.513851228231562, 1.6287765844373185e-11, 6.8766999132716964e-12, 1.513851228231574], - surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.2)) - # 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_shallowwater_source_terms.jl" begin + l2=[ + 1.2164292510839085, + 1.2643106818778908e-12, + 7.46884905098358e-13, + 1.2164292510839079, + ], + linf=[ + 1.513851228231562, + 1.6287765844373185e-11, + 6.8766999132716964e-12, + 1.513851228231574, + ], + surface_flux=(FluxHydrostaticReconstruction(flux_lax_friedrichs, + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.2)) + # 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_shallowwater_source_terms.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0011197623982310795, 0.04456344888447023, 0.014317376629669337, 5.089218476758975e-6], - linf = [0.007835284004819698, 0.3486891284278597, 0.11242778979399048, 2.6407324614119432e-5], - tspan = (0.0, 0.025)) - # 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_shallowwater_source_terms.jl with FluxHydrostaticReconstruction" begin + l2=[ + 0.0011197623982310795, + 0.04456344888447023, + 0.014317376629669337, + 5.089218476758975e-6, + ], + linf=[ + 0.007835284004819698, + 0.3486891284278597, + 0.11242778979399048, + 2.6407324614119432e-5, + ], + tspan=(0.0, 0.025)) + # 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_shallowwater_source_terms.jl with FluxHydrostaticReconstruction" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0011197139793938152, 0.015430259691310781, 0.017081031802719724, 5.089218476758271e-6], - linf = [0.014300809338967824, 0.12783372461225184, 0.17625472321992852, 2.6407324614341476e-5], - surface_flux=(FluxHydrostaticReconstruction(flux_hll, hydrostatic_reconstruction_audusse_etal), flux_nonconservative_audusse_etal), - tspan = (0.0, 0.025)) - # 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_shallowwater_source_terms.jl with flux_hll" begin + l2=[ + 0.0011197139793938152, + 0.015430259691310781, + 0.017081031802719724, + 5.089218476758271e-6, + ], + linf=[ + 0.014300809338967824, + 0.12783372461225184, + 0.17625472321992852, + 2.6407324614341476e-5, + ], + surface_flux=(FluxHydrostaticReconstruction(flux_hll, + hydrostatic_reconstruction_audusse_etal), + flux_nonconservative_audusse_etal), + tspan=(0.0, 0.025)) + # 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_shallowwater_source_terms.jl with flux_hll" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_source_terms.jl"), - l2 = [0.0011197139793938727, 0.015430259691311309, 0.017081031802719554, 5.089218476759981e-6], - linf = [0.014300809338967824, 0.12783372461224918, 0.17625472321993918, 2.6407324614341476e-5], - surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.025)) - # 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_shallowwater_dirichlet.jl" begin + l2=[ + 0.0011197139793938727, + 0.015430259691311309, + 0.017081031802719554, + 5.089218476759981e-6, + ], + linf=[ + 0.014300809338967824, + 0.12783372461224918, + 0.17625472321993918, + 2.6407324614341476e-5, + ], + surface_flux=(flux_hll, flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.025)) + # 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_shallowwater_dirichlet.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_dirichlet.jl"), - l2 = [1.1577518608940115e-5, 4.867189932537344e-13, 4.647273240470541e-13, 1.1577518608933468e-5], - linf = [8.394063878602864e-5, 1.1469760027632646e-10, 1.1146619484429974e-10, 8.394063879602065e-5], - tspan = (0.0, 2.0)) - # 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_shallowwater_wall_bc_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_wall_bc_shockcapturing.jl"), - l2 = [0.04444388691670699, 0.1527771788033111, 0.1593763537203512, 6.225080476986749e-8], - linf = [0.6526506870169639, 1.980765893182952, 2.4807635459119757, 3.982097158683473e-7], - tspan = (0.0, 0.05)) - # 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_shallowwater_ec_shockcapturing.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_ec_shockcapturing.jl"), - l2 = [0.6124656312639043, 0.504371951785709, 0.49180896200746366, 0.29467422718511727], - linf = [2.7639232436274392, 3.3985508653311767, 3.3330308209196224, 2.052861364219655], - tspan = (0.0, 0.25)) - # 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_shallowwater_three_mound_dam_break.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_three_mound_dam_break.jl"), - l2 = [0.0892957892027502, 0.30648836484407915, 2.28712547616214e-15, 0.0008778654298684622], - linf = [0.850329472915091, 2.330631694956507, 5.783660020252348e-14, 0.04326237921249021], - basis = LobattoLegendreBasis(3), - tspan = (0.0, 0.25)) - # 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_shallowwater_twolayer_convergence.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_convergence.jl"), - l2 = [0.0007953969898161991, 0.00882074628714633, 0.0024322572528892934, - 0.0007597425017400447, 0.004501238950166439, 0.0015784803573661104, - 6.849532064729749e-6], - linf = [0.00592559068081977, 0.08072451118697077, 0.0344854497419107, 0.005892196680485795, - 0.04262651217675306, 0.014006223513881366, 2.5829318284764646e-5], - tspan = (0.0, 0.25)) - # 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_shallowwater_twolayer_well_balanced.jl" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_well_balanced.jl"), - l2 = [4.706532184998499e-16, 1.1215950712872183e-15, 6.7822712922421565e-16, - 0.002192812926266047, 5.506855295923691e-15, 3.3105180099689275e-15, - 0.0021928129262660085], - linf = [4.468647674116255e-15, 1.3607872120431166e-14, 9.557155049520056e-15, - 0.024280130945632084, 6.68910907640583e-14, 4.7000983997100496e-14, - 0.024280130945632732], - tspan = (0.0, 0.25)) - # 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_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin - @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_shallowwater_twolayer_dam_break.jl"), - l2 = [0.012471300561905669, 0.012363413819726868, 0.0009541478004413331, - 0.09120260327331643, 0.015269590815749993, 0.0012064657396853422, - 0.09991983966647647], - linf = [0.04497814714937959, 0.03286959000796511, 0.010746094385294369, - 0.11138723974511211, 0.03640850605444494, 0.014368386516056392, 0.10000000000000003], - surface_flux = (flux_lax_friedrichs, flux_nonconservative_fjordholm_etal), - tspan = (0.0, 0.25)) - # 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 + l2=[ + 1.1577518608940115e-5, + 4.867189932537344e-13, + 4.647273240470541e-13, + 1.1577518608933468e-5, + ], + linf=[ + 8.394063878602864e-5, + 1.1469760027632646e-10, + 1.1146619484429974e-10, + 8.394063879602065e-5, + ], + tspan=(0.0, 2.0)) + # 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_shallowwater_wall_bc_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_wall_bc_shockcapturing.jl"), + l2=[ + 0.04444388691670699, + 0.1527771788033111, + 0.1593763537203512, + 6.225080476986749e-8, + ], + linf=[ + 0.6526506870169639, + 1.980765893182952, + 2.4807635459119757, + 3.982097158683473e-7, + ], + tspan=(0.0, 0.05)) + # 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_shallowwater_ec_shockcapturing.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_ec_shockcapturing.jl"), + l2=[ + 0.6124656312639043, + 0.504371951785709, + 0.49180896200746366, + 0.29467422718511727, + ], + linf=[ + 2.7639232436274392, + 3.3985508653311767, + 3.3330308209196224, + 2.052861364219655, + ], + tspan=(0.0, 0.25)) + # 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_shallowwater_three_mound_dam_break.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_three_mound_dam_break.jl"), + l2=[ + 0.0892957892027502, + 0.30648836484407915, + 2.28712547616214e-15, + 0.0008778654298684622, + ], + linf=[ + 0.850329472915091, + 2.330631694956507, + 5.783660020252348e-14, + 0.04326237921249021, + ], + basis=LobattoLegendreBasis(3), + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_convergence.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_convergence.jl"), + l2=[0.0007953969898161991, 0.00882074628714633, + 0.0024322572528892934, + 0.0007597425017400447, 0.004501238950166439, + 0.0015784803573661104, + 6.849532064729749e-6], + linf=[0.00592559068081977, 0.08072451118697077, + 0.0344854497419107, 0.005892196680485795, + 0.04262651217675306, 0.014006223513881366, + 2.5829318284764646e-5], + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_well_balanced.jl" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_well_balanced.jl"), + l2=[4.706532184998499e-16, 1.1215950712872183e-15, + 6.7822712922421565e-16, + 0.002192812926266047, 5.506855295923691e-15, + 3.3105180099689275e-15, + 0.0021928129262660085], + linf=[4.468647674116255e-15, 1.3607872120431166e-14, + 9.557155049520056e-15, + 0.024280130945632084, 6.68910907640583e-14, + 4.7000983997100496e-14, + 0.024280130945632732], + tspan=(0.0, 0.25)) + # 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_shallowwater_twolayer_dam_break.jl with flux_lax_friedrichs" begin + @test_trixi_include(joinpath(EXAMPLES_DIR, + "elixir_shallowwater_twolayer_dam_break.jl"), + l2=[0.012471300561905669, 0.012363413819726868, + 0.0009541478004413331, + 0.09120260327331643, 0.015269590815749993, + 0.0012064657396853422, + 0.09991983966647647], + linf=[0.04497814714937959, 0.03286959000796511, + 0.010746094385294369, + 0.11138723974511211, 0.03640850605444494, + 0.014368386516056392, 0.10000000000000003], + surface_flux=(flux_lax_friedrichs, + flux_nonconservative_fjordholm_etal), + tspan=(0.0, 0.25)) + # 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 # Clean up afterwards: delete Trixi.jl output directory -@test_nowarn rm(outdir, recursive=true) +@test_nowarn rm(outdir, recursive = true) end # module diff --git a/test/test_visualization.jl b/test/test_visualization.jl index b700fc71a8f..48164a70fb3 100644 --- a/test/test_visualization.jl +++ b/test/test_visualization.jl @@ -15,33 +15,40 @@ EXAMPLES_DIR = pkgdir(Trixi, "examples", "tree_2d_dgsem") # Start with a clean environment: remove Trixi.jl output directory if it exists outdir = "out" -isdir(outdir) && rm(outdir, recursive=true) +isdir(outdir) && rm(outdir, recursive = true) # Run various visualization tests @testset "Visualization tests" begin - # Run 2D tests with elixirs for all mesh types - test_examples_2d = Dict( - "TreeMesh" => ("tree_2d_dgsem", "elixir_euler_blast_wave_amr.jl"), - "StructuredMesh" => ("structured_2d_dgsem", "elixir_euler_source_terms_waving_flag.jl"), - "UnstructuredMesh" => ("unstructured_2d_dgsem", "elixir_euler_basic.jl"), - "P4estMesh" => ("p4est_2d_dgsem", "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), - "DGMulti" => ("dgmulti_2d", "elixir_euler_weakform.jl"), - ) - - @testset "PlotData2D, PlotDataSeries, PlotMesh with $mesh" for mesh in keys(test_examples_2d) +#! format: noindent + +# Run 2D tests with elixirs for all mesh types +test_examples_2d = Dict("TreeMesh" => ("tree_2d_dgsem", + "elixir_euler_blast_wave_amr.jl"), + "StructuredMesh" => ("structured_2d_dgsem", + "elixir_euler_source_terms_waving_flag.jl"), + "UnstructuredMesh" => ("unstructured_2d_dgsem", + "elixir_euler_basic.jl"), + "P4estMesh" => ("p4est_2d_dgsem", + "elixir_euler_source_terms_nonconforming_unstructured_flag.jl"), + "DGMulti" => ("dgmulti_2d", "elixir_euler_weakform.jl")) + +@testset "PlotData2D, PlotDataSeries, PlotMesh with $mesh" for mesh in keys(test_examples_2d) # Run Trixi.jl directory, elixir = test_examples_2d[mesh] - @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), directory, elixir), - tspan=(0,0.1)) + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), directory, elixir), + tspan = (0, 0.1)) # Constructor tests if mesh == "TreeMesh" - @test PlotData2D(sol) isa Trixi.PlotData2DCartesian - @test PlotData2D(sol; nvisnodes=0, grid_lines=false, solution_variables=cons2cons) isa Trixi.PlotData2DCartesian - @test Trixi.PlotData2DTriangulated(sol) isa Trixi.PlotData2DTriangulated + @test PlotData2D(sol) isa Trixi.PlotData2DCartesian + @test PlotData2D(sol; nvisnodes = 0, grid_lines = false, + solution_variables = cons2cons) isa Trixi.PlotData2DCartesian + @test Trixi.PlotData2DTriangulated(sol) isa Trixi.PlotData2DTriangulated else - @test PlotData2D(sol) isa Trixi.PlotData2DTriangulated - @test PlotData2D(sol; nvisnodes=0, solution_variables=cons2cons) isa Trixi.PlotData2DTriangulated + @test PlotData2D(sol) isa Trixi.PlotData2DTriangulated + @test PlotData2D(sol; nvisnodes = 0, solution_variables = cons2cons) isa + Trixi.PlotData2DTriangulated end pd = PlotData2D(sol) @@ -64,9 +71,9 @@ isdir(outdir) && rm(outdir, recursive=true) @test keys(pd) == ("rho", "v1", "v2", "p") @test eltype(pd) <: Pair{String, <:Trixi.PlotDataSeries} @test [v for v in pd] == ["rho" => Trixi.PlotDataSeries(pd, 1), - "v1" => Trixi.PlotDataSeries(pd, 2), - "v2" => Trixi.PlotDataSeries(pd, 3), - "p" => Trixi.PlotDataSeries(pd, 4)] + "v1" => Trixi.PlotDataSeries(pd, 2), + "v2" => Trixi.PlotDataSeries(pd, 3), + "p" => Trixi.PlotDataSeries(pd, 4)] # PlotDataSeries pds = pd["p"] @@ -82,48 +89,52 @@ isdir(outdir) && rm(outdir, recursive=true) println(stdout) @testset "2D plot recipes" begin - pd = PlotData2D(sol) - - @test_nowarn_mod Plots.plot(sol) - @test_nowarn_mod Plots.plot(pd) - @test_nowarn_mod Plots.plot(pd["p"]) - @test_nowarn_mod Plots.plot(getmesh(pd)) - - semi = sol.prob.p - if mesh == "DGMulti" - scalar_data = StructArrays.component(sol.u[end], 1) - @test_nowarn_mod Plots.plot(ScalarPlotData2D(scalar_data, semi)) - else - cache = semi.cache - x = view(cache.elements.node_coordinates, 1, :, :, :) - @test_nowarn_mod Plots.plot(ScalarPlotData2D(x, semi)) - end + pd = PlotData2D(sol) + + @test_nowarn_mod Plots.plot(sol) + @test_nowarn_mod Plots.plot(pd) + @test_nowarn_mod Plots.plot(pd["p"]) + @test_nowarn_mod Plots.plot(getmesh(pd)) + + semi = sol.prob.p + if mesh == "DGMulti" + scalar_data = StructArrays.component(sol.u[end], 1) + @test_nowarn_mod Plots.plot(ScalarPlotData2D(scalar_data, semi)) + else + cache = semi.cache + x = view(cache.elements.node_coordinates, 1, :, :, :) + @test_nowarn_mod Plots.plot(ScalarPlotData2D(x, semi)) + end end @testset "1D plot from 2D solution" begin - if mesh != "DGMulti" - @testset "Create 1D plot as slice" begin - @test_nowarn_mod PlotData1D(sol, slice=:y, point=(0.5, 0.0)) isa PlotData1D - @test_nowarn_mod PlotData1D(sol, slice=:x, point=(0.5, 0.0)) isa PlotData1D - pd1D = PlotData1D(sol, slice=:y, point=(0.5, 0.0)) - @test_nowarn_mod Plots.plot(pd1D) - - @testset "Create 1D plot along curve" begin - curve = zeros(2, 10) - curve[1, :] = range(-1, 1,length=10) - @test_nowarn_mod PlotData1D(sol, curve=curve) isa PlotData1D - pd1D = PlotData1D(sol, curve=curve) - @test_nowarn_mod Plots.plot(pd1D) - end + if mesh != "DGMulti" + @testset "Create 1D plot as slice" begin + @test_nowarn_mod PlotData1D(sol, slice = :y, point = (0.5, 0.0)) isa + PlotData1D + @test_nowarn_mod PlotData1D(sol, slice = :x, point = (0.5, 0.0)) isa + PlotData1D + pd1D = PlotData1D(sol, slice = :y, point = (0.5, 0.0)) + @test_nowarn_mod Plots.plot(pd1D) + + @testset "Create 1D plot along curve" begin + curve = zeros(2, 10) + curve[1, :] = range(-1, 1, length = 10) + @test_nowarn_mod PlotData1D(sol, curve = curve) isa PlotData1D + pd1D = PlotData1D(sol, curve = curve) + @test_nowarn_mod Plots.plot(pd1D) + end + end end - end end - end +end - @timed_testset "PlotData1D, PlotDataSeries, PlotMesh" begin +@timed_testset "PlotData1D, PlotDataSeries, PlotMesh" begin # Run Trixi.jl - @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_1d_dgsem", "elixir_euler_blast_wave.jl"), - tspan=(0,0.1)) + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_euler_blast_wave.jl"), + tspan = (0, 0.1)) # Constructor @test PlotData1D(sol) isa PlotData1D @@ -147,8 +158,8 @@ isdir(outdir) && rm(outdir, recursive=true) @test keys(pd) == ("rho", "v1", "p") @test eltype(pd) <: Pair{String, <:Trixi.PlotDataSeries} @test [v for v in pd] == ["rho" => Trixi.PlotDataSeries(pd, 1), - "v1" => Trixi.PlotDataSeries(pd, 2), - "p" => Trixi.PlotDataSeries(pd, 3)] + "v1" => Trixi.PlotDataSeries(pd, 2), + "p" => Trixi.PlotDataSeries(pd, 3)] # PlotDataSeries pds = pd["p"] @@ -165,174 +176,195 @@ isdir(outdir) && rm(outdir, recursive=true) # nvisnodes @test size(pd.data) == (512, 3) - pd0 = PlotData1D(sol, nvisnodes=0) + pd0 = PlotData1D(sol, nvisnodes = 0) @test size(pd0.data) == (256, 3) - pd2 = PlotData1D(sol, nvisnodes=2) + pd2 = PlotData1D(sol, nvisnodes = 2) @test size(pd2.data) == (128, 3) @testset "1D plot recipes" begin - pd = PlotData1D(sol) + pd = PlotData1D(sol) - @test_nowarn_mod Plots.plot(sol) - @test_nowarn_mod Plots.plot(pd) - @test_nowarn_mod Plots.plot(pd["p"]) - @test_nowarn_mod Plots.plot(getmesh(pd)) + @test_nowarn_mod Plots.plot(sol) + @test_nowarn_mod Plots.plot(pd) + @test_nowarn_mod Plots.plot(pd["p"]) + @test_nowarn_mod Plots.plot(getmesh(pd)) end # Fake a PlotDataXD objects to test code for plotting multiple variables on at least two rows # with at least one plot remaining empty @testset "plotting multiple variables" begin - x = collect(0.0:0.1:1.0) - data1d = rand(5, 11) - variable_names = string.('a':'e') - mesh_vertices_x1d = [x[begin], x[end]] - fake1d = PlotData1D(x, data1d, variable_names, mesh_vertices_x1d, 0) - @test_nowarn_mod Plots.plot(fake1d) - - y = x - data2d = [rand(11,11) for _ in 1:5] - mesh_vertices_x2d = [0.0, 1.0, 1.0, 0.0] - mesh_vertices_y2d = [0.0, 0.0, 1.0, 1.0] - fake2d = Trixi.PlotData2DCartesian(x, y, data2d, variable_names, mesh_vertices_x2d, mesh_vertices_y2d, 0, 0) - @test_nowarn_mod Plots.plot(fake2d) + x = collect(0.0:0.1:1.0) + data1d = rand(5, 11) + variable_names = string.('a':'e') + mesh_vertices_x1d = [x[begin], x[end]] + fake1d = PlotData1D(x, data1d, variable_names, mesh_vertices_x1d, 0) + @test_nowarn_mod Plots.plot(fake1d) + + y = x + data2d = [rand(11, 11) for _ in 1:5] + mesh_vertices_x2d = [0.0, 1.0, 1.0, 0.0] + mesh_vertices_y2d = [0.0, 0.0, 1.0, 1.0] + fake2d = Trixi.PlotData2DCartesian(x, y, data2d, variable_names, + mesh_vertices_x2d, mesh_vertices_y2d, 0, 0) + @test_nowarn_mod Plots.plot(fake2d) end - end +end - @timed_testset "PlotData1D (DGMulti)" begin +@timed_testset "PlotData1D (DGMulti)" begin # Test two different approximation types since these use different memory layouts: # - structure of arrays for `Polynomial()` # - array of structures for `SBP()` @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "dgmulti_1d", "elixir_euler_flux_diff.jl"), tspan=(0.0 ,0.0), - approximation_type=Polynomial()) + joinpath(examples_dir(), "dgmulti_1d", + "elixir_euler_flux_diff.jl"), + tspan = (0.0, 0.0), + approximation_type = Polynomial()) @test PlotData1D(sol) isa PlotData1D @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "dgmulti_1d", "elixir_euler_flux_diff.jl"), tspan=(0.0 ,0.0), - approximation_type=SBP()) + joinpath(examples_dir(), "dgmulti_1d", + "elixir_euler_flux_diff.jl"), + tspan = (0.0, 0.0), + approximation_type = SBP()) @test PlotData1D(sol) isa PlotData1D - end +end - @timed_testset "plot time series" begin +@timed_testset "plot time series" begin @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_acoustics_gaussian_source.jl"), - tspan=(0, 0.05)) + joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_acoustics_gaussian_source.jl"), + tspan = (0, 0.05)) @test_nowarn_mod Plots.plot(time_series, 1) @test PlotData1D(time_series, 1) isa PlotData1D - end +end - @timed_testset "adapt_to_mesh_level" begin - @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_basic.jl"), - tspan=(0,0.1), analysis_callback=Trixi.TrivialCallback()) +@timed_testset "adapt_to_mesh_level" begin + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_basic.jl"), + tspan = (0, 0.1), + analysis_callback = Trixi.TrivialCallback()) @test adapt_to_mesh_level(sol, 5) isa Tuple u_ode_level5, semi_level5 = adapt_to_mesh_level(sol, 5) u_ode_level4, semi_level4 = adapt_to_mesh_level(u_ode_level5, semi_level5, 4) - @test isapprox(sol.u[end], u_ode_level4, atol=1e-13) + @test isapprox(sol.u[end], u_ode_level4, atol = 1e-13) @test adapt_to_mesh_level!(sol, 5) isa Tuple - @test isapprox(sol.u[end], u_ode_level5, atol=1e-13) - end + @test isapprox(sol.u[end], u_ode_level5, atol = 1e-13) +end - @timed_testset "plot 3D" begin - @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "tree_3d_dgsem", "elixir_advection_basic.jl"), - tspan=(0,0.1), analysis_callback=Trixi.TrivialCallback(), initial_refinement_level=1) +@timed_testset "plot 3D" begin + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "tree_3d_dgsem", + "elixir_advection_basic.jl"), + tspan = (0, 0.1), + analysis_callback = Trixi.TrivialCallback(), + initial_refinement_level = 1) @test PlotData2D(sol) isa Trixi.PlotData2DCartesian - @test PlotData2D(sol, slice =:yz) isa Trixi.PlotData2DCartesian - @test PlotData2D(sol, slice =:xz) isa Trixi.PlotData2DCartesian + @test PlotData2D(sol, slice = :yz) isa Trixi.PlotData2DCartesian + @test PlotData2D(sol, slice = :xz) isa Trixi.PlotData2DCartesian @testset "1D plot from 3D solution and Tree-mesh" begin - @testset "Create 1D plot as slice" begin - @test_nowarn_mod PlotData1D(sol) isa PlotData1D - pd1D = PlotData1D(sol) - @test_nowarn_mod Plots.plot(pd1D) - @test_nowarn_mod PlotData1D(sol, slice=:y, point = (0.5, 0.3, 0.1)) isa PlotData1D - @test_nowarn_mod PlotData1D(sol, slice=:z, point = (0.1, 0.3, 0.3)) isa PlotData1D - - end - - @testset "Create 1D plot along curve" begin - curve = zeros(3, 10) - curve[1, :] = range(-1.0, -0.5, length=10) - @test_nowarn_mod PlotData1D(sol, curve=curve) isa PlotData1D - pd1D = PlotData1D(sol, curve=curve) - @test_nowarn_mod Plots.plot(pd1D) - end + @testset "Create 1D plot as slice" begin + @test_nowarn_mod PlotData1D(sol) isa PlotData1D + pd1D = PlotData1D(sol) + @test_nowarn_mod Plots.plot(pd1D) + @test_nowarn_mod PlotData1D(sol, slice = :y, point = (0.5, 0.3, 0.1)) isa + PlotData1D + @test_nowarn_mod PlotData1D(sol, slice = :z, point = (0.1, 0.3, 0.3)) isa + PlotData1D + end + + @testset "Create 1D plot along curve" begin + curve = zeros(3, 10) + curve[1, :] = range(-1.0, -0.5, length = 10) + @test_nowarn_mod PlotData1D(sol, curve = curve) isa PlotData1D + pd1D = PlotData1D(sol, curve = curve) + @test_nowarn_mod Plots.plot(pd1D) + end end - @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "structured_3d_dgsem", "elixir_advection_basic.jl"), - tspan=(0,0.1)) + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "structured_3d_dgsem", + "elixir_advection_basic.jl"), + tspan = (0, 0.1)) @testset "1D plot from 3D solution and general mesh" begin - @testset "Create 1D plot as slice" begin - @test_nowarn_mod PlotData1D(sol) isa PlotData1D - pd1D = PlotData1D(sol) - @test_nowarn_mod Plots.plot(pd1D) - @test_nowarn_mod PlotData1D(sol, slice=:y, point = (0.5, 0.3, 0.1)) isa PlotData1D - @test_nowarn_mod PlotData1D(sol, slice=:z, point = (0.1, 0.3, 0.3)) isa PlotData1D - - end - - @testset "Create 1D plot along curve" begin - curve = zeros(3, 10) - curve[1, :] = range(-1.0, 1.0, length=10) - @test_nowarn_mod PlotData1D(sol, curve=curve) isa PlotData1D - pd1D = PlotData1D(sol, curve=curve) - @test_nowarn_mod Plots.plot(pd1D) - end + @testset "Create 1D plot as slice" begin + @test_nowarn_mod PlotData1D(sol) isa PlotData1D + pd1D = PlotData1D(sol) + @test_nowarn_mod Plots.plot(pd1D) + @test_nowarn_mod PlotData1D(sol, slice = :y, point = (0.5, 0.3, 0.1)) isa + PlotData1D + @test_nowarn_mod PlotData1D(sol, slice = :z, point = (0.1, 0.3, 0.3)) isa + PlotData1D + end + + @testset "Create 1D plot along curve" begin + curve = zeros(3, 10) + curve[1, :] = range(-1.0, 1.0, length = 10) + @test_nowarn_mod PlotData1D(sol, curve = curve) isa PlotData1D + pd1D = PlotData1D(sol, curve = curve) + @test_nowarn_mod Plots.plot(pd1D) + end end - end +end - @timed_testset "plotting TimeIntegratorSolution" begin - @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", "elixir_hypdiff_lax_friedrichs.jl"), +@timed_testset "plotting TimeIntegratorSolution" begin + @test_trixi_include(joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_hypdiff_lax_friedrichs.jl"), maxiters=1, analysis_callback=Trixi.TrivialCallback(), initial_refinement_level=1) @test_nowarn_mod Plots.plot(sol) - end +end - @timed_testset "VisualizationCallback" begin +@timed_testset "VisualizationCallback" begin # To make CI tests work, disable showing a plot window with the GR backend of the Plots package # Xref: https://github.com/jheinen/GR.jl/issues/278 # Xref: https://github.com/JuliaPlots/Plots.jl/blob/8cc6d9d48755ba452a2835f9b89d3880e9945377/test/runtests.jl#L103 if !isinteractive() - restore = get(ENV, "GKSwstype", nothing) - ENV["GKSwstype"] = "100" + restore = get(ENV, "GKSwstype", nothing) + ENV["GKSwstype"] = "100" end @test_nowarn_mod trixi_include(@__MODULE__, - joinpath(examples_dir(), "tree_2d_dgsem", "elixir_advection_amr_visualization.jl"), - visualization = VisualizationCallback(interval=20, - clims=(0,1), - plot_creator=Trixi.save_plot), - tspan=(0.0, 3.0)) + joinpath(examples_dir(), "tree_2d_dgsem", + "elixir_advection_amr_visualization.jl"), + visualization = VisualizationCallback(interval = 20, + clims = (0, 1), + plot_creator = Trixi.save_plot), + tspan = (0.0, 3.0)) @testset "elixir_advection_amr_visualization.jl with save_plot" begin - @test isfile(joinpath(outdir, "solution_000000.png")) - @test isfile(joinpath(outdir, "solution_000020.png")) - @test isfile(joinpath(outdir, "solution_000022.png")) + @test isfile(joinpath(outdir, "solution_000000.png")) + @test isfile(joinpath(outdir, "solution_000020.png")) + @test isfile(joinpath(outdir, "solution_000022.png")) end @testset "show" begin - @test_nowarn_mod show(stdout, visualization) - println(stdout) + @test_nowarn_mod show(stdout, visualization) + println(stdout) - @test_nowarn_mod show(stdout, "text/plain", visualization) - println(stdout) + @test_nowarn_mod show(stdout, "text/plain", visualization) + println(stdout) end # Restore GKSwstype to previous value (if it was set) if !isinteractive() - if isnothing(restore) - delete!(ENV, "GKSwstype") - else - ENV["GKSwstype"] = restore - end + if isnothing(restore) + delete!(ENV, "GKSwstype") + else + ENV["GKSwstype"] = restore + end end - end +end - @timed_testset "Makie visualization tests for UnstructuredMesh2D" begin - @test_nowarn_mod trixi_include(@__MODULE__, joinpath(examples_dir(), "unstructured_2d_dgsem", "elixir_euler_wall_bc.jl")) +@timed_testset "Makie visualization tests for UnstructuredMesh2D" begin + @test_nowarn_mod trixi_include(@__MODULE__, + joinpath(examples_dir(), "unstructured_2d_dgsem", + "elixir_euler_wall_bc.jl")) # test interactive surface plot @test_nowarn_mod Trixi.iplot(sol) @@ -343,12 +375,12 @@ isdir(outdir) && rm(outdir, recursive=true) # test interactive ScalarPlotData2D plotting semi = sol.prob.p - x = view(semi.cache.elements.node_coordinates, 1, :, :, :); # extracts the node x coordinates - y = view(semi.cache.elements.node_coordinates, 2, :, :, :); # extracts the node x coordinates - @test_nowarn_mod iplot(ScalarPlotData2D(x.+y, semi), plot_mesh=true) + x = view(semi.cache.elements.node_coordinates, 1, :, :, :) # extracts the node x coordinates + y = view(semi.cache.elements.node_coordinates, 2, :, :, :) # extracts the node x coordinates + @test_nowarn_mod iplot(ScalarPlotData2D(x .+ y, semi), plot_mesh = true) # test heatmap plot - @test_nowarn_mod Makie.plot(sol, plot_mesh=true) + @test_nowarn_mod Makie.plot(sol, plot_mesh = true) # test unpacking/iteration for FigureAndAxes fa = Makie.plot(sol) @@ -360,11 +392,10 @@ isdir(outdir) && rm(outdir, recursive=true) # test plotting of constant solutions with Makie # related issue: https://github.com/MakieOrg/Makie.jl/issues/931 for i in eachindex(sol.u) - fill!(sol.u[i], one(eltype(sol.u[i]))) + fill!(sol.u[i], one(eltype(sol.u[i]))) end @test_nowarn_mod Trixi.iplot(sol) - end end - +end end #module