Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_tree_1d_advection.jl
5582 views
1
module TestExamples1DAdvection
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "tree_1d_dgsem")
9
10
@testset "Linear scalar advection" begin
11
#! format: noindent
12
13
@trixi_testset "elixir_advection_basic.jl" begin
14
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
15
l2=[6.0388296447998465e-6],
16
linf=[3.217887726258972e-5])
17
# Ensure that we do not have excessive memory allocations
18
# (e.g., from type instabilities)
19
@test_allocations(Trixi.rhs!, semi, sol, 1000)
20
end
21
22
@trixi_testset "elixir_advection_gauss_legendre.jl" begin
23
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_gauss_legendre.jl"),
24
l2=[2.515203865524688e-6], linf=[8.660338936650191e-6])
25
# Ensure that we do not have excessive memory allocations
26
# (e.g., from type instabilities)
27
@test_allocations(Trixi.rhs!, semi, sol, 1000)
28
end
29
30
@trixi_testset "elixir_advection_basic.jl (max_abs_speed)" begin
31
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
32
surface_flux=FluxLaxFriedrichs(max_abs_speed),
33
l2=[6.0388296447998465e-6],
34
linf=[3.217887726258972e-5])
35
# Ensure that we do not have excessive memory allocations
36
# (e.g., from type instabilities)
37
@test_allocations(Trixi.rhs!, semi, sol, 1000)
38
end
39
40
@trixi_testset "elixir_advection_amr.jl" begin
41
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
42
l2=[0.3540206249507417],
43
linf=[0.9999896603382347])
44
# Ensure that we do not have excessive memory allocations
45
# (e.g., from type instabilities)
46
@test_allocations(Trixi.rhs!, semi, sol, 1000)
47
end
48
49
@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin
50
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"),
51
l2=[4.283508859843524e-6],
52
linf=[3.235356127918171e-5])
53
# Ensure that we do not have excessive memory allocations
54
# (e.g., from type instabilities)
55
@test_allocations(Trixi.rhs!, semi, sol, 1000)
56
end
57
58
@trixi_testset "elixir_advection_basic.jl (No errors)" begin
59
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
60
analysis_callback=AnalysisCallback(semi, interval = 42,
61
analysis_errors = Symbol[]))
62
# Ensure that we do not have excessive memory allocations
63
# (e.g., from type instabilities)
64
@test_allocations(Trixi.rhs!, semi, sol, 1000)
65
end
66
67
@trixi_testset "elixir_advection_convergence_fvO2.jl" begin
68
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_convergence_fvO2.jl"),
69
l2=[0.0024544920169555706], linf=[0.007837347144210138])
70
# Ensure that we do not have excessive memory allocations
71
# (e.g., from type instabilities)
72
@test_allocations(Trixi.rhs!, semi, sol, 1000)
73
end
74
75
@trixi_testset "elixir_advection_finite_volume.jl" begin
76
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"),
77
l2=[0.011662300515980219],
78
linf=[0.01647256923710194])
79
# Ensure that we do not have excessive memory allocations
80
# (e.g., from type instabilities)
81
@test_allocations(Trixi.rhs!, semi, sol, 1000)
82
end
83
84
@trixi_testset "elixir_advection_perk2.jl" begin
85
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2.jl"),
86
l2=[0.011288030389423475],
87
linf=[0.01596735472556976])
88
# Ensure that we do not have excessive memory allocations
89
# (e.g., from type instabilities)
90
# Larger values for allowed allocations due to usage of custom
91
# integrator which are not *recorded* for the methods from
92
# OrdinaryDiffEq.jl
93
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
94
@test_allocations(Trixi.rhs!, semi, sol, 8000)
95
end
96
97
# Testing the second-order paired explicit Runge-Kutta (PERK) method without stepsize callback
98
@trixi_testset "elixir_advection_perk2.jl(fixed time step)" begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2.jl"),
100
dt=2.0e-3,
101
tspan=(0.0, 20.0),
102
save_solution=SaveSolutionCallback(dt = 0.1 + 1.0e-8),
103
callbacks=CallbackSet(summary_callback, save_solution,
104
analysis_callback, alive_callback),
105
l2=[9.886271430207691e-6],
106
linf=[3.729460413781638e-5])
107
# Ensure that we do not have excessive memory allocations
108
# (e.g., from type instabilities)
109
# Larger values for allowed allocations due to usage of custom
110
# integrator which are not *recorded* for the methods from
111
# OrdinaryDiffEq.jl
112
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
113
@test_allocations(Trixi.rhs!, semi, sol, 8000)
114
end
115
116
# Testing the second-order paired explicit Runge-Kutta (PERK) method with the optimal CFL number
117
@trixi_testset "elixir_advection_perk2_optimal_cfl.jl" begin
118
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2_optimal_cfl.jl"),
119
l2=[0.0009700887119146429],
120
linf=[0.00137209242077041])
121
# Ensure that we do not have excessive memory allocations
122
# (e.g., from type instabilities)
123
# Larger values for allowed allocations due to usage of custom
124
# integrator which are not *recorded* for the methods from
125
# OrdinaryDiffEq.jl
126
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
127
@test_allocations(Trixi.rhs!, semi, sol, 8000)
128
end
129
130
@trixi_testset "elixir_advection_doublefloat.jl" begin
131
using DoubleFloats: Double64
132
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_doublefloat.jl"),
133
l2=Double64[6.80895929885700039832943251427357703e-11],
134
linf=Double64[5.82834770064525291688100323411704252e-10])
135
# Ensure that we do not have excessive memory allocations
136
# (e.g., from type instabilities)
137
@test_allocations(Trixi.rhs!, semi, sol, 1000)
138
end
139
end
140
141
end # module
142
143