Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_tree_1d_fdsbp.jl
2055 views
1
module TestTree1DFDSBP
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "tree_1d_fdsbp")
9
10
@testset "Linear scalar advection" begin
11
#! format: noindent
12
13
@trixi_testset "elixir_advection_upwind.jl" begin
14
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_upwind.jl"),
15
l2=[1.7735637157305526e-6],
16
linf=[1.0418854521951328e-5],
17
tspan=(0.0, 0.5))
18
19
# Ensure that we do not have excessive memory allocations
20
# (e.g., from type instabilities)
21
let
22
t = sol.t[end]
23
u_ode = sol.u[end]
24
du_ode = similar(u_ode)
25
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
26
end
27
end
28
29
@trixi_testset "elixir_advection_upwind_periodic.jl" begin
30
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_upwind_periodic.jl"),
31
l2=[1.1672962783692568e-5],
32
linf=[1.650514414558435e-5])
33
34
# Ensure that we do not have excessive memory allocations
35
# (e.g., from type instabilities)
36
let
37
t = sol.t[end]
38
u_ode = sol.u[end]
39
du_ode = similar(u_ode)
40
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
41
end
42
end
43
end
44
45
@testset "Inviscid Burgers" begin
46
@trixi_testset "elixir_burgers_basic.jl" begin
47
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"),
48
l2=[8.316190308678742e-7],
49
linf=[7.1087263324720595e-6],
50
tspan=(0.0, 0.5))
51
52
# Ensure that we do not have excessive memory allocations
53
# (e.g., from type instabilities)
54
let
55
t = sol.t[end]
56
u_ode = sol.u[end]
57
du_ode = similar(u_ode)
58
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
59
end
60
end
61
62
# same tolerances as above since the methods should be identical (up to
63
# machine precision)
64
@trixi_testset "elixir_burgers_basic.jl with SurfaceIntegralStrongForm and FluxUpwind" begin
65
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_basic.jl"),
66
l2=[8.316190308678742e-7],
67
linf=[7.1087263324720595e-6],
68
tspan=(0.0, 0.5),
69
solver=DG(D_upw, nothing,
70
SurfaceIntegralStrongForm(FluxUpwind(flux_splitting)),
71
VolumeIntegralUpwind(flux_splitting)))
72
end
73
74
@trixi_testset "elixir_burgers_linear_stability.jl" begin
75
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_burgers_linear_stability.jl"),
76
l2=[0.9999995642691271],
77
linf=[1.824702804788453],
78
tspan=(0.0, 0.25))
79
80
# Ensure that we do not have excessive memory allocations
81
# (e.g., from type instabilities)
82
let
83
t = sol.t[end]
84
u_ode = sol.u[end]
85
du_ode = similar(u_ode)
86
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
87
end
88
end
89
end
90
91
@testset "Compressible Euler" begin
92
@trixi_testset "elixir_euler_convergence.jl" begin
93
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"),
94
l2=[
95
4.1370344463620254e-6,
96
4.297052451817826e-6,
97
9.857382045003056e-6
98
],
99
linf=[
100
1.675305070092392e-5,
101
1.3448113863834266e-5,
102
3.8185336878271414e-5
103
],
104
tspan=(0.0, 0.5))
105
106
# Ensure that we do not have excessive memory allocations
107
# (e.g., from type instabilities)
108
let
109
t = sol.t[end]
110
u_ode = sol.u[end]
111
du_ode = similar(u_ode)
112
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
113
end
114
end
115
116
@trixi_testset "elixir_euler_convergence.jl with splitting_vanleer_haenel" begin
117
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"),
118
l2=[
119
3.4137906030996366e-6,
120
4.24395804622208e-6,
121
8.667369559486434e-6
122
],
123
linf=[
124
1.4228079725286946e-5,
125
1.324988815953887e-5,
126
3.20155297650615e-5
127
],
128
tspan=(0.0, 0.5),
129
flux_splitting=splitting_vanleer_haenel)
130
131
# Ensure that we do not have excessive memory allocations
132
# (e.g., from type instabilities)
133
let
134
t = sol.t[end]
135
u_ode = sol.u[end]
136
du_ode = similar(u_ode)
137
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
138
end
139
end
140
141
@trixi_testset "elixir_euler_convergence.jl with VolumeIntegralStrongForm" begin
142
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_convergence.jl"),
143
l2=[
144
8.612676636826464e-6,
145
7.670896994006107e-6,
146
1.4972772137651304e-5
147
],
148
linf=[
149
6.707982749043495e-5,
150
3.48725672254524e-5,
151
0.00010170331503767116
152
],
153
tspan=(0.0, 0.5),
154
solver=DG(D_upw.central, nothing, SurfaceIntegralStrongForm(),
155
VolumeIntegralStrongForm()))
156
157
# Ensure that we do not have excessive memory allocations
158
# (e.g., from type instabilities)
159
let
160
t = sol.t[end]
161
u_ode = sol.u[end]
162
du_ode = similar(u_ode)
163
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
164
end
165
end
166
167
@trixi_testset "elixir_euler_density_wave.jl" begin
168
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave.jl"),
169
l2=[
170
1.5894925236031034e-5,
171
9.428412101106044e-6,
172
0.0008986477358789918
173
],
174
linf=[
175
4.969438024382544e-5,
176
2.393091812063694e-5,
177
0.003271817388146303
178
],
179
tspan=(0.0, 0.005), abstol=1.0e-9, reltol=1.0e-9)
180
181
# Ensure that we do not have excessive memory allocations
182
# (e.g., from type instabilities)
183
let
184
t = sol.t[end]
185
u_ode = sol.u[end]
186
du_ode = similar(u_ode)
187
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
188
end
189
end
190
end
191
192
end # module
193
194