Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_threaded.jl
5582 views
1
module TestExamplesThreaded
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = examples_dir()
9
10
# Start with a clean environment: remove Trixi.jl output directory if it exists
11
outdir = "out"
12
Trixi.mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true)
13
Trixi.MPI.Barrier(Trixi.mpi_comm())
14
15
@testset "Threaded tests" begin
16
#! format: noindent
17
18
@testset "TreeMesh" begin
19
@trixi_testset "elixir_advection_restart.jl" begin
20
elixir = joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
21
"elixir_advection_extended.jl")
22
mpi_isroot() && println("═"^100)
23
mpi_isroot() && println(elixir)
24
trixi_include(@__MODULE__, elixir, tspan = (0.0, 10.0))
25
l2_expected, linf_expected = analysis_callback(sol)
26
27
elixir = joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
28
"elixir_advection_restart.jl")
29
mpi_isroot() && println("═"^100)
30
mpi_isroot() && println(elixir)
31
# Errors are exactly the same as in the elixir_advection_extended.jl
32
trixi_include(@__MODULE__, elixir)
33
l2_actual, linf_actual = analysis_callback(sol)
34
35
mpi_isroot() && @test l2_actual == l2_expected
36
mpi_isroot() && @test linf_actual == linf_expected
37
38
# Ensure that we do not have excessive memory allocations
39
# (e.g., from type instabilities)
40
@test_allocations(Trixi.rhs!, semi, sol, 5000)
41
end
42
43
@trixi_testset "elixir_advection_restart.jl with threaded time integration" begin
44
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
45
"elixir_advection_restart.jl"),
46
alg=CarpenterKennedy2N54(williamson_condition = false,
47
thread = Trixi.True()),
48
# Expected errors are exactly the same as in the serial test!
49
l2=[8.005068880114254e-6],
50
linf=[6.39093577996519e-5])
51
end
52
53
@trixi_testset "elixir_advection_amr_refine_twice.jl" begin
54
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
55
"elixir_advection_amr_refine_twice.jl"),
56
l2=[0.00020547512522578292],
57
linf=[0.007831753383083506])
58
59
# Ensure that we do not have excessive memory allocations
60
# (e.g., from type instabilities)
61
@test_allocations(Trixi.rhs!, semi, sol, 5000)
62
end
63
64
@trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin
65
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
66
"elixir_advection_amr_coarsen_twice.jl"),
67
l2=[0.0014321062757891826],
68
linf=[0.0253454486893413])
69
70
# Ensure that we do not have excessive memory allocations
71
# (e.g., from type instabilities)
72
@test_allocations(Trixi.rhs!, semi, sol, 5000)
73
end
74
75
@trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin
76
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
77
"elixir_euler_source_terms_nonperiodic.jl"),
78
l2=[
79
2.259440511766445e-6,
80
2.318888155713922e-6,
81
2.3188881557894307e-6,
82
6.3327863238858925e-6
83
],
84
linf=[
85
1.498738264560373e-5,
86
1.9182011928187137e-5,
87
1.918201192685487e-5,
88
6.0526717141407005e-5
89
],
90
rtol=0.001)
91
92
# Ensure that we do not have excessive memory allocations
93
# (e.g., from type instabilities)
94
if VERSION >= v"1.12"
95
@test_allocations(Trixi.rhs!, semi, sol, 7500)
96
else
97
@test_allocations(Trixi.rhs!, semi, sol, 5000)
98
end
99
end
100
101
@trixi_testset "elixir_euler_ec.jl" begin
102
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
103
"elixir_euler_ec.jl"),
104
l2=[
105
0.061751715597716854,
106
0.05018223615408711,
107
0.05018989446443463,
108
0.225871559730513
109
],
110
linf=[
111
0.29347582879608825,
112
0.31081249232844693,
113
0.3107380389947736,
114
1.0540358049885143
115
])
116
117
# Ensure that we do not have excessive memory allocations
118
# (e.g., from type instabilities)
119
@test_allocations(Trixi.rhs!, semi, sol, 5000)
120
end
121
122
@trixi_testset "elixir_euler_positivity.jl" begin
123
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
124
"elixir_euler_positivity.jl"),
125
l2=[
126
0.48862067511841695,
127
0.16787541578869494,
128
0.16787541578869422,
129
0.6184319933114926
130
],
131
linf=[
132
2.6766520821013002,
133
1.2910938760258996,
134
1.2910938760258899,
135
6.473385481404865
136
],
137
tspan=(0.0, 1.0))
138
# Ensure that we do not have excessive memory allocations
139
# (e.g., from type instabilities)
140
if VERSION >= v"1.12"
141
@test_allocations(Trixi.rhs!, semi, sol, 7500)
142
else
143
@test_allocations(Trixi.rhs!, semi, sol, 5000)
144
end
145
end
146
147
@trixi_testset "elixir_advection_diffusion.jl" begin
148
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
149
"elixir_advection_diffusion.jl"),
150
initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5,
151
alg=RDPK3SpFSAL49(thread = Trixi.True()),
152
l2=[4.0915532997994255e-6],
153
linf=[2.3040850347877395e-5])
154
155
# Ensure that we do not have excessive memory allocations
156
# (e.g., from type instabilities)
157
@test_allocations(Trixi.rhs!, semi, sol, 5000)
158
end
159
160
@trixi_testset "FDSBP, elixir_advection_extended.jl" begin
161
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_fdsbp",
162
"elixir_advection_extended.jl"),
163
l2=[2.898644263922225e-6],
164
linf=[8.491517930142578e-6],
165
rtol=1.0e-7) # These results change a little bit and depend on the CI system
166
167
# Ensure that we do not have excessive memory allocations
168
# (e.g., from type instabilities)
169
@test_allocations(Trixi.rhs!, semi, sol, 5000)
170
end
171
172
@trixi_testset "FDSBP, elixir_euler_convergence.jl" begin
173
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_fdsbp",
174
"elixir_euler_convergence.jl"),
175
l2=[
176
1.7088389997042244e-6,
177
1.7437997855125774e-6,
178
1.7437997855350776e-6,
179
5.457223460127621e-6
180
],
181
linf=[
182
9.796504903736292e-6,
183
9.614745892783105e-6,
184
9.614745892783105e-6,
185
4.026107182575345e-5
186
],
187
tspan=(0.0, 0.1))
188
189
# Ensure that we do not have excessive memory allocations
190
# (e.g., from type instabilities)
191
if VERSION >= v"1.12"
192
@test_allocations(Trixi.rhs!, semi, sol, 15000)
193
else
194
@test_allocations(Trixi.rhs!, semi, sol, 5000)
195
end
196
end
197
end
198
199
@testset "StructuredMesh" begin
200
@trixi_testset "elixir_advection_restart.jl with waving flag mesh" begin
201
@test_trixi_include(joinpath(EXAMPLES_DIR, "structured_2d_dgsem",
202
"elixir_advection_restart.jl"),
203
l2=[0.00016265538265929818],
204
linf=[0.0015194252169410394],
205
rtol=5.0e-5, # Higher tolerance to make tests pass in CI (in particular with macOS)
206
elixir_file="elixir_advection_waving_flag.jl",
207
restart_file="restart_000000021.h5")
208
209
# Ensure that we do not have excessive memory allocations
210
# (e.g., from type instabilities)
211
@test_allocations(Trixi.rhs!, semi, sol, 5000)
212
end
213
214
@trixi_testset "elixir_mhd_ec.jl" begin
215
@test_trixi_include(joinpath(EXAMPLES_DIR, "structured_2d_dgsem",
216
"elixir_mhd_ec.jl"),
217
l2=[0.04937478399958968, 0.0611701500558669,
218
0.06099805934392425, 0.031551737882277144,
219
0.23191853685798858, 0.02476297013104899,
220
0.024482975007695532, 0.035440179203707095,
221
0.0016002328034991635],
222
linf=[0.24744671083295033, 0.2990591185187605,
223
0.3968520446251412, 0.2226544553988576,
224
0.9752669317263143, 0.12117894533967843,
225
0.12845218263379432, 0.17795590713819576,
226
0.0348517136607105],
227
tspan=(0.0, 0.3))
228
229
# Ensure that we do not have excessive memory allocations
230
# (e.g., from type instabilities)
231
@test_allocations(Trixi.rhs!, semi, sol, 5000)
232
end
233
end
234
235
@testset "UnstructuredMesh" begin
236
@trixi_testset "elixir_acoustics_gauss_wall.jl" begin
237
@test_trixi_include(joinpath(EXAMPLES_DIR, "unstructured_2d_dgsem",
238
"elixir_acoustics_gauss_wall.jl"),
239
l2=[0.029330394861252995, 0.029345079728907965,
240
0.03803795043486467, 0.0,
241
7.175152371650832e-16, 1.4350304743301665e-15,
242
1.4350304743301665e-15],
243
linf=[0.36236334472179443, 0.3690785638275256,
244
0.8475748723784078, 0.0,
245
8.881784197001252e-16, 1.7763568394002505e-15,
246
1.7763568394002505e-15],
247
tspan=(0.0, 5.0))
248
249
# Ensure that we do not have excessive memory allocations
250
# (e.g., from type instabilities)
251
@test_allocations(Trixi.rhs!, semi, sol, 5000)
252
end
253
end
254
255
@testset "P4estMesh" begin
256
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin
257
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
258
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
259
l2=[
260
0.0034516244508588046,
261
0.0023420334036925493,
262
0.0024261923964557187,
263
0.004731710454271893
264
],
265
linf=[
266
0.04155789011775046,
267
0.024772109862748914,
268
0.03759938693042297,
269
0.08039824959535657
270
])
271
272
# Ensure that we do not have excessive memory allocations
273
# (e.g., from type instabilities)
274
if VERSION >= v"1.12"
275
@test_allocations(Trixi.rhs!, semi, sol, 7500)
276
else
277
@test_allocations(Trixi.rhs!, semi, sol, 5000)
278
end
279
end
280
281
@trixi_testset "elixir_eulergravity_convergence.jl" begin
282
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
283
"elixir_eulergravity_convergence.jl"),
284
l2=[
285
0.00024871265138964204,
286
0.0003370077102132591,
287
0.0003370077102131964,
288
0.0007231525513793697
289
],
290
linf=[
291
0.0015813032944647087,
292
0.0020494288423820173,
293
0.0020494288423824614,
294
0.004793821195083758
295
],
296
tspan=(0.0, 0.1))
297
end
298
end
299
300
@testset "T8codeMesh" begin
301
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin
302
@test_trixi_include(joinpath(EXAMPLES_DIR, "t8code_2d_dgsem",
303
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
304
l2=[
305
0.0034516244508588046,
306
0.0023420334036925493,
307
0.0024261923964557187,
308
0.004731710454271893
309
],
310
linf=[
311
0.04155789011775046,
312
0.024772109862748914,
313
0.03759938693042297,
314
0.08039824959535657
315
])
316
end
317
318
@trixi_testset "elixir_eulergravity_convergence.jl" begin
319
@test_trixi_include(joinpath(EXAMPLES_DIR, "t8code_2d_dgsem",
320
"elixir_eulergravity_convergence.jl"),
321
l2=[
322
0.00024871265138964204,
323
0.0003370077102132591,
324
0.0003370077102131964,
325
0.0007231525513793697
326
],
327
linf=[
328
0.0015813032944647087,
329
0.0020494288423820173,
330
0.0020494288423824614,
331
0.004793821195083758
332
],
333
tspan=(0.0, 0.1))
334
end
335
end
336
337
@testset "DGMulti" begin
338
@trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin
339
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
340
"elixir_euler_weakform.jl"),
341
cells_per_dimension=(4, 4),
342
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
343
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
344
approximation_type=SBP(),
345
l2=[
346
0.006400337855843578,
347
0.005303799804137764,
348
0.005303799804119745,
349
0.013204169007030144
350
],
351
linf=[
352
0.03798302318566282,
353
0.05321027922532284,
354
0.05321027922605448,
355
0.13392025411839015
356
])
357
358
# Ensure that we do not have excessive memory allocations
359
# (e.g., from type instabilities)
360
@test_allocations(Trixi.rhs!, semi, sol, 5000)
361
end
362
363
@trixi_testset "elixir_euler_curved.jl with threaded time integration" begin
364
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
365
"elixir_euler_curved.jl"),
366
alg=RDPK3SpFSAL49(thread = Trixi.True()),
367
l2=[
368
1.720916434676505e-5,
369
1.5928649356300228e-5,
370
1.5928649356913923e-5,
371
4.896339454587786e-5
372
],
373
linf=[
374
0.00010525404319960963,
375
0.00010003768703459315,
376
0.00010003768696797977,
377
0.0003642622844073351
378
])
379
380
# Ensure that we do not have excessive memory allocations
381
# (e.g., from type instabilities)
382
@test_allocations(Trixi.rhs!, semi, sol, 5000)
383
end
384
385
@trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin
386
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
387
"elixir_euler_triangulate_pkg_mesh.jl"),
388
l2=[
389
2.344076909832665e-6,
390
1.8610002398709756e-6,
391
2.4095132179484066e-6,
392
6.37330249340445e-6
393
],
394
linf=[
395
2.509979394305084e-5,
396
2.2683711321080935e-5,
397
2.6180377720841363e-5,
398
5.575278031910713e-5
399
])
400
401
# Ensure that we do not have excessive memory allocations
402
# (e.g., from type instabilities)
403
@test_allocations(Trixi.rhs!, semi, sol, 5000)
404
end
405
406
@trixi_testset "elixir_euler_fdsbp_periodic.jl (2D)" begin
407
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
408
"elixir_euler_fdsbp_periodic.jl"),
409
l2=[
410
1.3333320340010056e-6,
411
2.044834627970641e-6,
412
2.044834627855601e-6,
413
5.282189803559564e-6
414
],
415
linf=[
416
2.7000151718858945e-6,
417
3.988595028259212e-6,
418
3.9885950273710336e-6,
419
8.848583042286862e-6
420
])
421
422
# Ensure that we do not have excessive memory allocations
423
# (e.g., from type instabilities)
424
@test_allocations(Trixi.rhs!, semi, sol, 5000)
425
end
426
427
@trixi_testset "elixir_euler_fdsbp_periodic.jl (3D)" begin
428
@test_trixi_include(joinpath(EXAMPLES_DIR,
429
"dgmulti_3d/elixir_euler_fdsbp_periodic.jl"),
430
l2=[
431
7.561468750241556e-5,
432
6.882819932057486e-5,
433
6.882819932056578e-5,
434
6.882819932056221e-5,
435
0.0002010869398143227
436
],
437
linf=[
438
0.00013375688549710496,
439
0.00011568674101658516,
440
0.00011568674101614107,
441
0.00011568674101658516,
442
0.0003446273444156489
443
])
444
# Ensure that we do not have excessive memory allocations
445
# (e.g., from type instabilities)
446
@test_allocations(Trixi.rhs!, semi, sol, 1000)
447
end
448
end
449
end
450
451
# Clean up afterwards: delete Trixi.jl output directory
452
Trixi.mpi_isroot() && isdir(outdir) && @test_nowarn rm(outdir, recursive = true)
453
Trixi.MPI.Barrier(Trixi.mpi_comm())
454
455
end # module
456
457