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