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
2055 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
let
20
t = sol.t[end]
21
u_ode = sol.u[end]
22
du_ode = similar(u_ode)
23
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
24
end
25
end
26
27
@trixi_testset "elixir_advection_basic.jl (max_abs_speed)" begin
28
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
29
surface_flux=FluxLaxFriedrichs(max_abs_speed),
30
l2=[6.0388296447998465e-6],
31
linf=[3.217887726258972e-5])
32
# Ensure that we do not have excessive memory allocations
33
# (e.g., from type instabilities)
34
let
35
t = sol.t[end]
36
u_ode = sol.u[end]
37
du_ode = similar(u_ode)
38
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
39
end
40
end
41
42
@trixi_testset "elixir_advection_amr.jl" begin
43
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
44
l2=[0.3540206249507417],
45
linf=[0.9999896603382347])
46
# Ensure that we do not have excessive memory allocations
47
# (e.g., from type instabilities)
48
let
49
t = sol.t[end]
50
u_ode = sol.u[end]
51
du_ode = similar(u_ode)
52
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
53
end
54
end
55
56
@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin
57
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr_nonperiodic.jl"),
58
l2=[4.283508859843524e-6],
59
linf=[3.235356127918171e-5])
60
# Ensure that we do not have excessive memory allocations
61
# (e.g., from type instabilities)
62
let
63
t = sol.t[end]
64
u_ode = sol.u[end]
65
du_ode = similar(u_ode)
66
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
67
end
68
end
69
70
@trixi_testset "elixir_advection_basic.jl (No errors)" begin
71
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
72
analysis_callback=AnalysisCallback(semi, interval = 42,
73
analysis_errors = Symbol[]))
74
# Ensure that we do not have excessive memory allocations
75
# (e.g., from type instabilities)
76
let
77
t = sol.t[end]
78
u_ode = sol.u[end]
79
du_ode = similar(u_ode)
80
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
81
end
82
end
83
84
@trixi_testset "elixir_advection_finite_volume.jl" begin
85
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_finite_volume.jl"),
86
l2=[0.011662300515980219],
87
linf=[0.01647256923710194])
88
# Ensure that we do not have excessive memory allocations
89
# (e.g., from type instabilities)
90
let
91
t = sol.t[end]
92
u_ode = sol.u[end]
93
du_ode = similar(u_ode)
94
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
95
end
96
end
97
98
@trixi_testset "elixir_advection_perk2.jl" begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2.jl"),
100
l2=[0.011288030389423475],
101
linf=[0.01596735472556976])
102
# Ensure that we do not have excessive memory allocations
103
# (e.g., from type instabilities)
104
let
105
t = sol.t[end]
106
u_ode = sol.u[end]
107
du_ode = similar(u_ode)
108
# Larger values for allowed allocations due to usage of custom
109
# integrator which are not *recorded* for the methods from
110
# OrdinaryDiffEq.jl
111
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
112
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 8000
113
end
114
end
115
116
# Testing the second-order paired explicit Runge-Kutta (PERK) method without stepsize callback
117
@trixi_testset "elixir_advection_perk2.jl(fixed time step)" begin
118
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2.jl"),
119
dt=2.0e-3,
120
tspan=(0.0, 20.0),
121
save_solution=SaveSolutionCallback(dt = 0.1 + 1.0e-8),
122
callbacks=CallbackSet(summary_callback, save_solution,
123
analysis_callback, alive_callback),
124
l2=[9.886271430207691e-6],
125
linf=[3.729460413781638e-5])
126
# Ensure that we do not have excessive memory allocations
127
# (e.g., from type instabilities)
128
let
129
t = sol.t[end]
130
u_ode = sol.u[end]
131
du_ode = similar(u_ode)
132
# Larger values for allowed allocations due to usage of custom
133
# integrator which are not *recorded* for the methods from
134
# OrdinaryDiffEq.jl
135
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
136
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 8000
137
end
138
end
139
140
# Testing the second-order paired explicit Runge-Kutta (PERK) method with the optimal CFL number
141
@trixi_testset "elixir_advection_perk2_optimal_cfl.jl" begin
142
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_perk2_optimal_cfl.jl"),
143
l2=[0.0009700887119146429],
144
linf=[0.00137209242077041])
145
# Ensure that we do not have excessive memory allocations
146
# (e.g., from type instabilities)
147
let
148
t = sol.t[end]
149
u_ode = sol.u[end]
150
du_ode = similar(u_ode)
151
# Larger values for allowed allocations due to usage of custom
152
# integrator which are not *recorded* for the methods from
153
# OrdinaryDiffEq.jl
154
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
155
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 8000
156
end
157
end
158
159
@trixi_testset "elixir_advection_doublefloat.jl" begin
160
using DoubleFloats: Double64
161
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_doublefloat.jl"),
162
l2=Double64[6.80895929885700039832943251427357703e-11],
163
linf=Double64[5.82834770064525291688100323411704252e-10])
164
# Ensure that we do not have excessive memory allocations
165
# (e.g., from type instabilities)
166
let
167
t = sol.t[end]
168
u_ode = sol.u[end]
169
du_ode = similar(u_ode)
170
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
171
end
172
end
173
end
174
175
end # module
176
177