Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_dgmulti_3d.jl
2055 views
1
module TestExamplesDGMulti3D
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_3d")
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 "DGMulti 3D" begin
15
#! format: noindent
16
17
# 3d tet/hex tests
18
@trixi_testset "elixir_euler_weakform.jl" begin
19
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
20
l2=[
21
0.000354593110864001, 0.00041301573702385284,
22
0.00037934556184883277, 0.0003525767114354012,
23
0.0013917457634530887
24
],
25
linf=[
26
0.0036608123230692513, 0.005625540942772123,
27
0.0030565781898950206, 0.004158099048202857,
28
0.01932716837214299
29
])
30
# Ensure that we do not have excessive memory allocations
31
# (e.g., from type instabilities)
32
let
33
t = sol.t[end]
34
u_ode = sol.u[end]
35
du_ode = similar(u_ode)
36
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
37
end
38
end
39
40
@trixi_testset "elixir_euler_weakform.jl (EC)" begin
41
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
42
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
43
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
44
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
45
l2=[
46
0.014932088450136542,
47
0.017080219613061526,
48
0.016589517840793006,
49
0.015905000907070196,
50
0.03903416208587798
51
] ./ sqrt(8),
52
linf=[
53
0.06856547797256729,
54
0.08225664880340489,
55
0.06925055630951782,
56
0.06913016119820181,
57
0.19161418499621874
58
])
59
# Ensure that we do not have excessive memory allocations
60
# (e.g., from type instabilities)
61
let
62
t = sol.t[end]
63
u_ode = sol.u[end]
64
du_ode = similar(u_ode)
65
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
66
end
67
end
68
69
@trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin
70
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
71
element_type=Hex(),
72
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
73
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
74
l2=[
75
0.00030580190715769566,
76
0.00040146357607439464,
77
0.00040146357607564597,
78
0.000401463576075708,
79
0.0015749412434154315
80
] ./ sqrt(8),
81
linf=[
82
0.00036910287847780054,
83
0.00042659774184228283,
84
0.0004265977427213574,
85
0.00042659774250686233,
86
0.00143803344597071
87
])
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_euler_curved.jl (Hex elements, SBP, flux differencing)" begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
100
l2=[
101
0.0019393929700612259,
102
0.003213659298633126,
103
0.003203104361527826,
104
0.0019407707245105426,
105
0.0109274471764788
106
],
107
linf=[
108
0.01914151956454324,
109
0.0270195960766606,
110
0.026891238631389536,
111
0.019817504336972602,
112
0.09645660501766873
113
])
114
# Ensure that we do not have excessive memory allocations
115
# (e.g., from type instabilities)
116
let
117
t = sol.t[end]
118
u_ode = sol.u[end]
119
du_ode = similar(u_ode)
120
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
121
end
122
end
123
124
@trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin
125
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
126
approximation_type=GaussSBP(),
127
l2=[
128
0.0026311315195097097, 0.002914422404496567,
129
0.0029138891106640368, 0.002615140832315232,
130
0.006881528610616624
131
],
132
linf=[
133
0.02099611487415931, 0.021314522450152307,
134
0.021288322783027613, 0.020273381695449455,
135
0.05259874039006007
136
])
137
# Ensure that we do not have excessive memory allocations
138
# (e.g., from type instabilities)
139
let
140
t = sol.t[end]
141
u_ode = sol.u[end]
142
du_ode = similar(u_ode)
143
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
144
end
145
end
146
147
@trixi_testset "elixir_euler_weakform_periodic.jl" begin
148
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
149
l2=[
150
0.00036475807571383924, 0.00043404536371780537,
151
0.0003985850214093045, 0.0003683451584072326,
152
0.00143503620472638
153
],
154
linf=[
155
0.0032278615418719347, 0.005620238272054934,
156
0.0030514261010661237, 0.0039871165455998,
157
0.019282771780667396
158
])
159
# Ensure that we do not have excessive memory allocations
160
# (e.g., from type instabilities)
161
let
162
t = sol.t[end]
163
u_ode = sol.u[end]
164
du_ode = similar(u_ode)
165
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
166
end
167
end
168
169
@trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin
170
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
171
element_type=Hex(),
172
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
173
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
174
l2=[
175
0.00034230612468547436,
176
0.00044397204714598747,
177
0.0004439720471461567,
178
0.0004439720471464591,
179
0.0016639410646990126
180
] ./ sqrt(8),
181
linf=[
182
0.0003674374460325147,
183
0.0004253921341716982,
184
0.0004253921340786615,
185
0.0004253921340831024,
186
0.0014333414071048267
187
])
188
# Ensure that we do not have excessive memory allocations
189
# (e.g., from type instabilities)
190
let
191
t = sol.t[end]
192
u_ode = sol.u[end]
193
du_ode = similar(u_ode)
194
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
195
end
196
end
197
198
@trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin
199
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
200
element_type=Hex(),
201
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
202
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
203
approximation_type=SBP(),
204
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
205
l2=[
206
0.001712443468716032,
207
0.002491315550718859,
208
0.0024913155507195303,
209
0.002491315550720031,
210
0.008585818982343299
211
] ./ sqrt(8),
212
linf=[
213
0.003810078279323559,
214
0.004998778644230928,
215
0.004998778643986235,
216
0.0049987786444081195,
217
0.016455044373650196
218
])
219
# Ensure that we do not have excessive memory allocations
220
# (e.g., from type instabilities)
221
let
222
t = sol.t[end]
223
u_ode = sol.u[end]
224
du_ode = similar(u_ode)
225
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
226
end
227
end
228
229
@trixi_testset "elixir_euler_taylor_green_vortex.jl" begin
230
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"),
231
polydeg=3, tspan=(0.0, 1.0), cells_per_dimension=(2, 2, 2),
232
l2=[
233
0.00036128264902931644,
234
0.06219350570157671,
235
0.062193505701565316,
236
0.08121963725209637,
237
0.0708269605813566
238
],
239
linf=[
240
0.0007893500666786846,
241
0.14819541663164099,
242
0.14819541663231595,
243
0.148472950090691,
244
0.2131352319423172
245
])
246
# Ensure that we do not have excessive memory allocations
247
# (e.g., from type instabilities)
248
let
249
t = sol.t[end]
250
u_ode = sol.u[end]
251
du_ode = similar(u_ode)
252
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
253
end
254
end
255
256
@trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin
257
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"),
258
polydeg=3, approximation_type=GaussSBP(), tspan=(0.0, 1.0),
259
cells_per_dimension=(2, 2, 2),
260
l2=[
261
0.0003612826490291416,
262
0.06219350570157282,
263
0.06219350570156088,
264
0.08121963725209767,
265
0.07082696058040763
266
],
267
linf=[
268
0.0007893500666356079,
269
0.14819541663140268,
270
0.14819541663222624,
271
0.14847295009030398,
272
0.21313523192395678
273
])
274
# Ensure that we do not have excessive memory allocations
275
# (e.g., from type instabilities)
276
let
277
t = sol.t[end]
278
u_ode = sol.u[end]
279
du_ode = similar(u_ode)
280
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
281
end
282
end
283
284
@trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin
285
using Trixi: SummationByPartsOperators, derivative_operator
286
global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
287
derivative_order = 1,
288
accuracy_order = 2,
289
xmin = 0.0, xmax = 1.0,
290
N = 8)
291
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
292
element_type=Hex(),
293
cells_per_dimension=(2, 2, 2),
294
approximation_type=D,
295
l2=[
296
0.0024092707138829925,
297
0.003318758964118284,
298
0.0033187589641182386,
299
0.003318758964118252,
300
0.012689348410504253
301
],
302
linf=[
303
0.006118565824207778,
304
0.008486456080185167,
305
0.008486456080180282,
306
0.008486456080185611,
307
0.035113544599208346
308
])
309
# Ensure that we do not have excessive memory allocations
310
# (e.g., from type instabilities)
311
let
312
t = sol.t[end]
313
u_ode = sol.u[end]
314
du_ode = similar(u_ode)
315
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
316
end
317
end
318
319
@trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin
320
using Trixi: SummationByPartsOperators, derivative_operator
321
global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
322
derivative_order = 1,
323
accuracy_order = 2,
324
xmin = 0.0, xmax = 1.0,
325
N = 8)
326
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
327
element_type=Hex(),
328
cells_per_dimension=(2, 2, 2),
329
approximation_type=D,
330
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
331
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
332
l2=[
333
0.0034543609010604407,
334
0.004944363692625066,
335
0.0049443636926250435,
336
0.004944363692625037,
337
0.01788695279620914
338
],
339
linf=[
340
0.013861851418853988,
341
0.02126572106620328,
342
0.021265721066209053,
343
0.021265721066210386,
344
0.0771455289446683
345
])
346
# Ensure that we do not have excessive memory allocations
347
# (e.g., from type instabilities)
348
let
349
t = sol.t[end]
350
u_ode = sol.u[end]
351
du_ode = similar(u_ode)
352
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
353
end
354
end
355
356
@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin
357
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
358
N=8,
359
l2=[
360
0.002185087935179595,
361
0.0021985878136213353,
362
0.0021985878136213588,
363
0.002198587813621343,
364
0.006911667548137964
365
],
366
linf=[
367
0.0034358445996525155,
368
0.003728543352167435,
369
0.0037285433521714317,
370
0.0037285433521709876,
371
0.011530662012638082
372
])
373
# Ensure that we do not have excessive memory allocations
374
# (e.g., from type instabilities)
375
let
376
t = sol.t[end]
377
u_ode = sol.u[end]
378
du_ode = similar(u_ode)
379
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
380
end
381
end
382
383
@trixi_testset "elixir_advection_tensor_wedge.jl" begin
384
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"),
385
l2=[0.00023048791012406786],
386
linf=[0.0006317952824828055])
387
# Ensure that we do not have excessive memory allocations
388
# (e.g., from type instabilities)
389
let
390
t = sol.t[end]
391
u_ode = sol.u[end]
392
du_ode = similar(u_ode)
393
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
394
end
395
396
# Load the mesh file for code coverage.
397
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"),
398
n_cells_max = 0,
399
RealT = Float64)
400
end
401
402
@trixi_testset "elixir_advection_tensor_wedge.jl (scalar polydeg)" begin
403
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"),
404
polydeg=3,
405
l2=[0.0002332063232167919],
406
linf=[0.0006597931027270132],
407
atol=1e-10) # MacOS and Ubuntu differ here
408
# Ensure that we do not have excessive memory allocations
409
# (e.g., from type instabilities)
410
let
411
t = sol.t[end]
412
u_ode = sol.u[end]
413
du_ode = similar(u_ode)
414
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
415
end
416
417
# Load the mesh file for code coverage.
418
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"),
419
n_cells_max = 0,
420
RealT = Float64)
421
end
422
end
423
424
# Clean up afterwards: delete Trixi.jl output directory
425
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)
426
427
end # module
428
429