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
5582 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
@test_allocations(Trixi.rhs!, semi, sol, 1000)
33
end
34
35
@trixi_testset "elixir_euler_weakform.jl (EC)" begin
36
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
37
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
38
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
39
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
40
l2=[
41
0.014932088450136542,
42
0.017080219613061526,
43
0.016589517840793006,
44
0.015905000907070196,
45
0.03903416208587798
46
] ./ sqrt(8),
47
linf=[
48
0.06856547797256729,
49
0.08225664880340489,
50
0.06925055630951782,
51
0.06913016119820181,
52
0.19161418499621874
53
])
54
# Ensure that we do not have excessive memory allocations
55
# (e.g., from type instabilities)
56
@test_allocations(Trixi.rhs!, semi, sol, 1000)
57
end
58
59
@trixi_testset "elixir_euler_weakform.jl (Hexahedral elements)" begin
60
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
61
element_type=Hex(),
62
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
63
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
64
l2=[
65
0.00030580190715769566,
66
0.00040146357607439464,
67
0.00040146357607564597,
68
0.000401463576075708,
69
0.0015749412434154315
70
] ./ sqrt(8),
71
linf=[
72
0.00036910287847780054,
73
0.00042659774184228283,
74
0.0004265977427213574,
75
0.00042659774250686233,
76
0.00143803344597071
77
])
78
# Ensure that we do not have excessive memory allocations
79
# (e.g., from type instabilities)
80
@test_allocations(Trixi.rhs!, semi, sol, 1000)
81
end
82
83
@trixi_testset "elixir_euler_curved.jl (Hex elements, SBP, flux differencing)" begin
84
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
85
l2=[
86
0.0019393929700612259,
87
0.003213659298633126,
88
0.003203104361527826,
89
0.0019407707245105426,
90
0.0109274471764788
91
],
92
linf=[
93
0.01914151956454324,
94
0.0270195960766606,
95
0.026891238631389536,
96
0.019817504336972602,
97
0.09645660501766873
98
])
99
# Ensure that we do not have excessive memory allocations
100
# (e.g., from type instabilities)
101
@test_allocations(Trixi.rhs!, semi, sol, 1000)
102
end
103
104
@trixi_testset "elixir_euler_curved.jl (Hex elements, GaussSBP, flux differencing)" begin
105
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
106
approximation_type=GaussSBP(),
107
l2=[
108
0.0026311315195097097, 0.002914422404496567,
109
0.0029138891106640368, 0.002615140832315232,
110
0.006881528610616624
111
],
112
linf=[
113
0.02099611487415931, 0.021314522450152307,
114
0.021288322783027613, 0.020273381695449455,
115
0.05259874039006007
116
])
117
# Ensure that we do not have excessive memory allocations
118
# (e.g., from type instabilities)
119
@test_allocations(Trixi.rhs!, semi, sol, 1000)
120
end
121
122
@trixi_testset "elixir_euler_weakform_periodic.jl" begin
123
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
124
l2=[
125
0.00036475807571383924, 0.00043404536371780537,
126
0.0003985850214093045, 0.0003683451584072326,
127
0.00143503620472638
128
],
129
linf=[
130
0.0032278615418719347, 0.005620238272054934,
131
0.0030514261010661237, 0.0039871165455998,
132
0.019282771780667396
133
])
134
# Ensure that we do not have excessive memory allocations
135
# (e.g., from type instabilities)
136
@test_allocations(Trixi.rhs!, semi, sol, 1000)
137
end
138
139
@trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements)" begin
140
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
141
element_type=Hex(),
142
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
143
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
144
l2=[
145
0.00034230612468547436,
146
0.00044397204714598747,
147
0.0004439720471461567,
148
0.0004439720471464591,
149
0.0016639410646990126
150
] ./ sqrt(8),
151
linf=[
152
0.0003674374460325147,
153
0.0004253921341716982,
154
0.0004253921340786615,
155
0.0004253921340831024,
156
0.0014333414071048267
157
])
158
# Ensure that we do not have excessive memory allocations
159
# (e.g., from type instabilities)
160
@test_allocations(Trixi.rhs!, semi, sol, 1000)
161
end
162
163
@trixi_testset "elixir_euler_weakform_periodic.jl (Hexahedral elements, SBP, EC)" begin
164
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
165
element_type=Hex(),
166
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
167
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
168
approximation_type=SBP(),
169
# division by sqrt(8.0) corresponds to normalization by the square root of the size of the domain
170
l2=[
171
0.001712443468716032,
172
0.002491315550718859,
173
0.0024913155507195303,
174
0.002491315550720031,
175
0.008585818982343299
176
] ./ sqrt(8),
177
linf=[
178
0.003810078279323559,
179
0.004998778644230928,
180
0.004998778643986235,
181
0.0049987786444081195,
182
0.016455044373650196
183
])
184
# Ensure that we do not have excessive memory allocations
185
# (e.g., from type instabilities)
186
@test_allocations(Trixi.rhs!, semi, sol, 1000)
187
end
188
189
@trixi_testset "elixir_euler_taylor_green_vortex.jl" begin
190
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"),
191
polydeg=3, tspan=(0.0, 1.0), cells_per_dimension=(2, 2, 2),
192
l2=[
193
0.00036128264902931644,
194
0.06219350570157671,
195
0.062193505701565316,
196
0.08121963725209637,
197
0.0708269605813566
198
],
199
linf=[
200
0.0007893500666786846,
201
0.14819541663164099,
202
0.14819541663231595,
203
0.148472950090691,
204
0.2131352319423172
205
])
206
# Ensure that we do not have excessive memory allocations
207
# (e.g., from type instabilities)
208
@test_allocations(Trixi.rhs!, semi, sol, 1000)
209
end
210
211
@trixi_testset "elixir_euler_taylor_green_vortex.jl (GaussSBP)" begin
212
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_taylor_green_vortex.jl"),
213
polydeg=3, approximation_type=GaussSBP(), tspan=(0.0, 1.0),
214
cells_per_dimension=(2, 2, 2),
215
l2=[
216
0.0003612826490291416,
217
0.06219350570157282,
218
0.06219350570156088,
219
0.08121963725209767,
220
0.07082696058040763
221
],
222
linf=[
223
0.0007893500666356079,
224
0.14819541663140268,
225
0.14819541663222624,
226
0.14847295009030398,
227
0.21313523192395678
228
])
229
# Ensure that we do not have excessive memory allocations
230
# (e.g., from type instabilities)
231
@test_allocations(Trixi.rhs!, semi, sol, 1000)
232
end
233
234
@trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP)" begin
235
using Trixi: SummationByPartsOperators, derivative_operator
236
global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
237
derivative_order = 1,
238
accuracy_order = 2,
239
xmin = 0.0, xmax = 1.0,
240
N = 8)
241
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
242
element_type=Hex(),
243
cells_per_dimension=(2, 2, 2),
244
approximation_type=D,
245
l2=[
246
0.0024092707138829925,
247
0.003318758964118284,
248
0.0033187589641182386,
249
0.003318758964118252,
250
0.012689348410504253
251
],
252
linf=[
253
0.006118565824207778,
254
0.008486456080185167,
255
0.008486456080180282,
256
0.008486456080185611,
257
0.035113544599208346
258
])
259
# Ensure that we do not have excessive memory allocations
260
# (e.g., from type instabilities)
261
@test_allocations(Trixi.rhs!, semi, sol, 1000)
262
end
263
264
@trixi_testset "elixir_euler_weakform_periodic.jl (FD SBP, EC)" begin
265
using Trixi: SummationByPartsOperators, derivative_operator
266
global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
267
derivative_order = 1,
268
accuracy_order = 2,
269
xmin = 0.0, xmax = 1.0,
270
N = 8)
271
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
272
element_type=Hex(),
273
cells_per_dimension=(2, 2, 2),
274
approximation_type=D,
275
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
276
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
277
l2=[
278
0.0034543609010604407,
279
0.004944363692625066,
280
0.0049443636926250435,
281
0.004944363692625037,
282
0.01788695279620914
283
],
284
linf=[
285
0.013861851418853988,
286
0.02126572106620328,
287
0.021265721066209053,
288
0.021265721066210386,
289
0.0771455289446683
290
])
291
# Ensure that we do not have excessive memory allocations
292
# (e.g., from type instabilities)
293
@test_allocations(Trixi.rhs!, semi, sol, 1000)
294
end
295
296
@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin
297
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
298
N=8,
299
l2=[
300
0.002185087935179595,
301
0.0021985878136213353,
302
0.0021985878136213588,
303
0.002198587813621343,
304
0.006911667548137964
305
],
306
linf=[
307
0.0034358445996525155,
308
0.003728543352167435,
309
0.0037285433521714317,
310
0.0037285433521709876,
311
0.011530662012638082
312
])
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
318
@trixi_testset "elixir_advection_tensor_wedge.jl" begin
319
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"),
320
l2=[0.00023048791012406786],
321
linf=[0.0006317952824828055])
322
# Ensure that we do not have excessive memory allocations
323
# (e.g., from type instabilities)
324
@test_allocations(Trixi.rhs!, semi, sol, 1000)
325
326
# Load the mesh file for code coverage.
327
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"),
328
n_cells_max = 0,
329
RealT = Float64)
330
end
331
332
@trixi_testset "elixir_advection_tensor_wedge.jl (scalar polydeg)" begin
333
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_tensor_wedge.jl"),
334
polydeg=3,
335
l2=[0.0002332063232167919],
336
linf=[0.0006597931027270132],
337
atol=1e-10) # MacOS and Ubuntu differ here
338
# Ensure that we do not have excessive memory allocations
339
# (e.g., from type instabilities)
340
@test_allocations(Trixi.rhs!, semi, sol, 1000)
341
342
# Load the mesh file for code coverage.
343
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"),
344
n_cells_max = 0,
345
RealT = Float64)
346
end
347
348
@trixi_testset "elixir_euler_shockcapturing.jl (Hex, GaussSBP)" begin
349
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"),
350
cells_per_dimension=(4, 4, 4), tspan=(0.0, 0.1),
351
l2=[1.33894396e-02, 7.62751979e-03, 7.62751979e-03,
352
7.62751979e-03, 4.93582917e-02],
353
linf=[2.18776976e-01, 1.04524872e-01, 1.04524872e-01,
354
1.04524872e-01, 8.01212059e-01])
355
# Ensure that we do not have excessive memory allocations
356
# (e.g., from type instabilities)
357
@test_allocations(Trixi.rhs!, semi, sol, 1000)
358
end
359
end
360
361
# Clean up afterwards: delete Trixi.jl output directory
362
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)
363
364
end # module
365
366