Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_structured_3d.jl
5582 views
1
module TestExamples3DStructured
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "structured_3d_dgsem")
9
10
# Start with a clean environment: remove Trixi.jl output directory if it exists
11
outdir = "out"
12
isdir(outdir) && rm(outdir, recursive = true)
13
14
@testset "StructuredMesh3D" begin
15
#! format: noindent
16
17
@trixi_testset "elixir_advection_basic.jl" begin
18
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
19
# Expected errors are exactly the same as with TreeMesh!
20
l2=[0.00016263963870641478],
21
linf=[0.0014537194925779984])
22
# Ensure that we do not have excessive memory allocations
23
# (e.g., from type instabilities)
24
@test_allocations(Trixi.rhs!, semi, sol, 1000)
25
end
26
27
@trixi_testset "elixir_advection_free_stream.jl" begin
28
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_free_stream.jl"),
29
l2=[1.2908196366970896e-14],
30
linf=[1.0262901639634947e-12],
31
atol=8e-13)
32
# Ensure that we do not have excessive memory allocations
33
# (e.g., from type instabilities)
34
@test_allocations(Trixi.rhs!, semi, sol, 1000)
35
end
36
37
@trixi_testset "elixir_advection_nonperiodic_curved.jl" begin
38
@test_trixi_include(joinpath(EXAMPLES_DIR,
39
"elixir_advection_nonperiodic_curved.jl"),
40
l2=[0.0004483892474201268],
41
linf=[0.009201820593762955])
42
# Ensure that we do not have excessive memory allocations
43
# (e.g., from type instabilities)
44
@test_allocations(Trixi.rhs!, semi, sol, 1000)
45
end
46
47
@trixi_testset "elixir_advection_restart.jl" begin
48
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
49
l2=[0.0025903889347585777],
50
linf=[0.018407576968841655])
51
# Ensure that we do not have excessive memory allocations
52
# (e.g., from type instabilities)
53
@test_allocations(Trixi.rhs!, semi, sol, 1000)
54
end
55
56
@trixi_testset "elixir_euler_source_terms.jl" begin
57
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"),
58
# Expected errors are exactly the same as with TreeMesh!
59
l2=[
60
0.010385936842224346,
61
0.009776048833895767,
62
0.00977604883389591,
63
0.009776048833895733,
64
0.01506687097416608
65
],
66
linf=[
67
0.03285848350791731,
68
0.0321792316408982,
69
0.032179231640894645,
70
0.032179231640895534,
71
0.0655408023333299
72
])
73
# Ensure that we do not have excessive memory allocations
74
# (e.g., from type instabilities)
75
@test_allocations(Trixi.rhs!, semi, sol, 1000)
76
end
77
78
@trixi_testset "elixir_euler_free_stream.jl" begin
79
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"),
80
l2=[
81
2.8815700334367128e-15,
82
9.361915278236651e-15,
83
9.95614203619935e-15,
84
1.6809941842374106e-14,
85
1.4815037041566735e-14
86
],
87
linf=[
88
4.1300296516055823e-14,
89
2.0444756998472258e-13,
90
1.0133560657266116e-13,
91
2.0627943797535409e-13,
92
2.8954616482224083e-13
93
])
94
# Ensure that we do not have excessive memory allocations
95
# (e.g., from type instabilities)
96
@test_allocations(Trixi.rhs!, semi, sol, 1000)
97
end
98
99
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
100
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
101
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
102
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
103
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
104
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
105
# `StepsizeCallback` (CFL-Condition) and less diffusion.
106
@trixi_testset "elixir_euler_free_stream.jl with FluxRotated(FluxLaxFriedrichs(max_abs_speed_naive))" begin
107
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"),
108
surface_flux=FluxRotated(FluxLaxFriedrichs(max_abs_speed_naive)),
109
l2=[
110
2.8815700334367128e-15,
111
9.361915278236651e-15,
112
9.95614203619935e-15,
113
1.6809941842374106e-14,
114
1.4815037041566735e-14
115
],
116
linf=[
117
4.1300296516055823e-14,
118
2.0444756998472258e-13,
119
1.0133560657266116e-13,
120
2.0627943797535409e-13,
121
2.8954616482224083e-13
122
])
123
# Ensure that we do not have excessive memory allocations
124
# (e.g., from type instabilities)
125
@test_allocations(Trixi.rhs!, semi, sol, 1000)
126
end
127
128
@trixi_testset "elixir_euler_source_terms_nonperiodic_curved.jl" begin
129
@test_trixi_include(joinpath(EXAMPLES_DIR,
130
"elixir_euler_source_terms_nonperiodic_curved.jl"),
131
l2=[
132
0.0032940531178824463,
133
0.003275679548217804,
134
0.0030020672748714084,
135
0.00324007343451744,
136
0.005721986362580164
137
],
138
linf=[
139
0.03156756290660656,
140
0.033597629023726316,
141
0.02095783702361409,
142
0.03353574465232212,
143
0.05873635745032857
144
])
145
# Ensure that we do not have excessive memory allocations
146
# (e.g., from type instabilities)
147
@test_allocations(Trixi.rhs!, semi, sol, 1000)
148
end
149
150
@trixi_testset "elixir_euler_source_terms_adaptive_vol_int.jl" begin
151
@test_trixi_include(joinpath(EXAMPLES_DIR,
152
"elixir_euler_source_terms_adaptive_vol_int.jl"),
153
l2=[
154
0.0022878466025464924,
155
0.0022468985135237107,
156
0.002033101904326531,
157
0.0022483293238877004,
158
0.004345885176536526
159
],
160
linf=[
161
0.02684833550245891,
162
0.028038458002909383,
163
0.022367626384228956,
164
0.02930352451545737,
165
0.05222743788433171
166
])
167
# Ensure that we do not have excessive memory allocations
168
# (e.g., from type instabilities)
169
@test_allocations(Trixi.rhs!, semi, sol, 1000)
170
end
171
172
@trixi_testset "elixir_euler_source_terms_nonperiodic_fvO2.jl" begin
173
@test_trixi_include(joinpath(EXAMPLES_DIR,
174
"elixir_euler_source_terms_nonperiodic_fvO2.jl"),
175
l2=[
176
0.046860892952192236,
177
0.04269641872975366,
178
0.04269641872975368,
179
0.042696418729753556,
180
0.1443421265167028
181
],
182
linf=[
183
0.42250001347847244,
184
0.2975151811754566,
185
0.29751518117545483,
186
0.29751518117545617,
187
0.3982472383589144
188
])
189
# Ensure that we do not have excessive memory allocations
190
# (e.g., from type instabilities)
191
@test_allocations(Trixi.rhs!, semi, sol, 1000)
192
end
193
194
@trixi_testset "elixir_euler_ec.jl" begin
195
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"),
196
l2=[
197
0.011367083018614027,
198
0.007022020327490176,
199
0.006759580335962235,
200
0.006820337637760632,
201
0.02912659127566544
202
],
203
linf=[
204
0.2761764220925329,
205
0.20286331858055706,
206
0.18763944865434593,
207
0.19313636558790004,
208
0.707563913727584
209
],
210
tspan=(0.0, 0.25))
211
# Ensure that we do not have excessive memory allocations
212
# (e.g., from type instabilities)
213
@test_allocations(Trixi.rhs!, semi, sol, 1000)
214
end
215
216
@trixi_testset "elixir_euler_sedov.jl" begin
217
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"),
218
l2=[
219
5.30310390e-02,
220
2.53167260e-02,
221
2.64276438e-02,
222
2.52195992e-02,
223
3.56830295e-01
224
],
225
linf=[
226
6.16356950e-01,
227
2.50600049e-01,
228
2.74796377e-01,
229
2.46448217e-01,
230
4.77888479e+00
231
],
232
tspan=(0.0, 0.3))
233
# Ensure that we do not have excessive memory allocations
234
# (e.g., from type instabilities)
235
@test_allocations(Trixi.rhs!, semi, sol, 1000)
236
end
237
238
@trixi_testset "elixir_mhd_ec.jl" begin
239
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec.jl"),
240
l2=[0.009082353008355219, 0.007128360330314966,
241
0.0069703300260751545, 0.006898850266164216,
242
0.033020091335659474, 0.003203389281512797,
243
0.0030774985678369746, 0.00307400076520122,
244
4.192572922118587e-5],
245
linf=[0.28839460197220435, 0.25956437090703427,
246
0.26143649456148177, 0.24617277684934058,
247
1.1370439348603143, 0.12780410700666367,
248
0.13347392283166903,
249
0.145756208548534,
250
0.0021181795153149053],
251
tspan=(0.0, 0.25))
252
# Ensure that we do not have excessive memory allocations
253
# (e.g., from type instabilities)
254
@test_allocations(Trixi.rhs!, semi, sol, 1000)
255
end
256
257
@trixi_testset "elixir_mhd_alfven_wave.jl" begin
258
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
259
l2=[0.003015390232128414, 0.0014538563096541798,
260
0.000912478356719486, 0.0017715065044433436,
261
0.0013017575272262197, 0.0014545437537522726,
262
0.0013322897333898482, 0.0016493009787844212,
263
0.0013747547738038235],
264
linf=[0.027577067632765795, 0.027912829563483885,
265
0.01282206030593043, 0.03911437990598213,
266
0.021962225923304324, 0.03169774571258743,
267
0.021591564663781426, 0.034028148178115364,
268
0.020084593242858988])
269
# Ensure that we do not have excessive memory allocations
270
# (e.g., from type instabilities)
271
@test_allocations(Trixi.rhs!, semi, sol, 1000)
272
end
273
274
# Up to version 0.13.0, `max_abs_speed_naive` was used as the default wave speed estimate of
275
# `const flux_lax_friedrichs = FluxLaxFriedrichs(), i.e., `FluxLaxFriedrichs(max_abs_speed = max_abs_speed_naive)`.
276
# In the `StepsizeCallback`, though, the less diffusive `max_abs_speeds` is employed which is consistent with `max_abs_speed`.
277
# Thus, we exchanged in PR#2458 the default wave speed used in the LLF flux to `max_abs_speed`.
278
# To ensure that every example still runs we specify explicitly `FluxLaxFriedrichs(max_abs_speed_naive)`.
279
# We remark, however, that the now default `max_abs_speed` is in general recommended due to compliance with the
280
# `StepsizeCallback` (CFL-Condition) and less diffusion.
281
@trixi_testset "elixir_mhd_alfven_wave.jl with FluxLaxFriedrichs(max_abs_speed_naive)" begin
282
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
283
l2=[0.0030477691235949685, 0.00145609137038748,
284
0.0009092809766088607, 0.0017949926915475929,
285
0.0012981612165627713, 0.0014525841626158234,
286
0.0013275465154956557, 0.0016728767532610933,
287
0.0013751925705271012],
288
linf=[0.02778552932540901, 0.027511633996169835,
289
0.012637649797178449, 0.03920805095546112,
290
0.02126543791857216, 0.031563506812970266,
291
0.02116105422516923, 0.03419432640106229,
292
0.020324891223351533],
293
surface_flux=(FluxLaxFriedrichs(max_abs_speed_naive),
294
flux_nonconservative_powell))
295
# Ensure that we do not have excessive memory allocations
296
# (e.g., from type instabilities)
297
@test_allocations(Trixi.rhs!, semi, sol, 1000)
298
end
299
300
@trixi_testset "elixir_mhd_ec_shockcapturing.jl" begin
301
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_ec_shockcapturing.jl"),
302
l2=[0.009352631216098996, 0.008058649096024162,
303
0.00802704129788766, 0.008071417834885589,
304
0.03490914976431044, 0.003930194255268652,
305
0.003921907459117296, 0.003906321239858786,
306
4.1971260184918575e-5],
307
linf=[0.307491045404509, 0.26790087991041506,
308
0.2712430701672931, 0.2654540237991884,
309
0.9620943261873176, 0.181632512204141,
310
0.15995711137712265, 0.1791807940466812,
311
0.015138421396338456],
312
tspan=(0.0, 0.25))
313
# Ensure that we do not have excessive memory allocations
314
# (e.g., from type instabilities)
315
@test_allocations(Trixi.rhs!, semi, sol, 1000)
316
end
317
end
318
319
# Clean up afterwards: delete Trixi.jl output directory
320
@test_nowarn rm(outdir, recursive = true)
321
322
end # module
323
324