Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_p4est_2d.jl
2055 views
1
module TestExamplesP4estMesh2D
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_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 "P4estMesh2D" 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=[8.311947673061856e-6],
21
linf=[6.627000273229378e-5])
22
# Ensure that we do not have excessive memory allocations
23
# (e.g., from type instabilities)
24
let
25
t = sol.t[end]
26
u_ode = sol.u[end]
27
du_ode = similar(u_ode)
28
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
29
end
30
semi32 = Trixi.trixi_adapt(Array, Float32, semi)
31
@test real(semi32.solver) == Float32
32
@test real(semi32.solver.basis) == Float32
33
@test real(semi32.solver.mortar) == Float32
34
# TODO: remake ignores the mesh itself as well
35
@test real(semi32.mesh) == Float64
36
end
37
38
@trixi_testset "elixir_advection_basic.jl (Float32)" begin
39
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic_gpu.jl"),
40
# Expected errors are exactly the same as with TreeMesh!
41
l2=[Float32(8.311947673061856e-6)],
42
linf=[Float32(6.627000273229378e-5)],
43
RealT=Float32,
44
real_type=Float32)
45
# Ensure that we do not have excessive memory allocations
46
# (e.g., from type instabilities)
47
let
48
t = sol.t[end]
49
u_ode = sol.u[end]
50
du_ode = similar(u_ode)
51
@test_broken (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
52
end
53
@test real(ode.p.solver) == Float32
54
@test real(ode.p.solver.basis) == Float32
55
@test real(ode.p.solver.mortar) == Float32
56
# TODO: remake ignores the mesh itself as well
57
@test real(ode.p.mesh) == Float64
58
end
59
60
@trixi_testset "elixir_advection_nonconforming_flag.jl" begin
61
@test_trixi_include(joinpath(EXAMPLES_DIR,
62
"elixir_advection_nonconforming_flag.jl"),
63
l2=[3.198940059144588e-5],
64
linf=[0.00030636069494005547])
65
# Ensure that we do not have excessive memory allocations
66
# (e.g., from type instabilities)
67
let
68
t = sol.t[end]
69
u_ode = sol.u[end]
70
du_ode = similar(u_ode)
71
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
72
end
73
end
74
75
@trixi_testset "elixir_advection_unstructured_flag.jl" begin
76
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_unstructured_flag.jl"),
77
l2=[0.0005379687442422346],
78
linf=[0.007438525029884735])
79
# Ensure that we do not have excessive memory allocations
80
# (e.g., from type instabilities)
81
let
82
t = sol.t[end]
83
u_ode = sol.u[end]
84
du_ode = similar(u_ode)
85
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
86
end
87
end
88
89
@trixi_testset "elixir_advection_amr_solution_independent.jl" begin
90
@test_trixi_include(joinpath(EXAMPLES_DIR,
91
"elixir_advection_amr_solution_independent.jl"),
92
# Expected errors are exactly the same as with StructuredMesh!
93
l2=[4.949660644033807e-5],
94
linf=[0.0004867846262313763])
95
# Ensure that we do not have excessive memory allocations
96
# (e.g., from type instabilities)
97
let
98
t = sol.t[end]
99
u_ode = sol.u[end]
100
du_ode = similar(u_ode)
101
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
102
end
103
end
104
105
@trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin
106
@test_trixi_include(joinpath(EXAMPLES_DIR,
107
"elixir_advection_amr_unstructured_flag.jl"),
108
l2=[0.0012808538770535593],
109
linf=[0.01752690016659812])
110
# Ensure that we do not have excessive memory allocations
111
# (e.g., from type instabilities)
112
let
113
t = sol.t[end]
114
u_ode = sol.u[end]
115
du_ode = similar(u_ode)
116
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
117
end
118
end
119
120
@trixi_testset "elixir_advection_restart.jl" begin
121
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
122
l2=[4.507575525876275e-6],
123
linf=[6.21489667023134e-5])
124
# Ensure that we do not have excessive memory allocations
125
# (e.g., from type instabilities)
126
let
127
t = sol.t[end]
128
u_ode = sol.u[end]
129
du_ode = similar(u_ode)
130
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
131
end
132
end
133
134
@trixi_testset "elixir_advection_restart_amr.jl" begin
135
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart_amr.jl"),
136
l2=[2.869137983727866e-6],
137
linf=[3.8353423270964804e-5])
138
# Ensure that we do not have excessive memory allocations
139
# (e.g., from type instabilities)
140
let
141
t = sol.t[end]
142
u_ode = sol.u[end]
143
du_ode = similar(u_ode)
144
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
145
end
146
end
147
148
@trixi_testset "elixir_advection_meshview.jl" begin
149
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_meshview.jl"),
150
l2=[0.00013773915040249946],
151
linf=[0.0010140184322192658])
152
# Ensure that we do not have excessive memory allocations
153
# (e.g., from type instabilities)
154
let
155
t = sol.t[end]
156
u_ode = sol.u[end]
157
du_ode = similar(u_ode)
158
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
159
end
160
161
# Ensure we cover the calculation of the node coordinates
162
node_coordinates = typeof(parent_mesh.tree_node_coordinates)(undef, 2,
163
ntuple(_ -> length(parent_mesh.nodes),
164
2)...,
165
length(mesh.cell_ids))
166
result = Trixi.calc_node_coordinates!(node_coordinates, mesh, parent_mesh.nodes)
167
@test parent_mesh.tree_node_coordinates == result
168
169
# Load the mesh file for code coverage.
170
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"); n_cells_max = 0,
171
RealT = typeof(parent_mesh).parameters[3])
172
end
173
174
@trixi_testset "elixir_advection_basic.jl" begin
175
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
176
# Expected errors are exactly the same as with P4estMeshView!
177
l2=[0.00013773915040249946],
178
linf=[0.0010140184322192658],
179
initial_refinement_level=0)
180
# Ensure that we do not have excessive memory allocations
181
# (e.g., from type instabilities)
182
let
183
t = sol.t[end]
184
u_ode = sol.u[end]
185
du_ode = similar(u_ode)
186
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
187
end
188
end
189
190
@trixi_testset "elixir_euler_subsonic_constant.jl" begin
191
@test_trixi_include(joinpath(EXAMPLES_DIR,
192
"elixir_euler_subsonic_constant.jl"),
193
l2=[
194
9.268884363640194e-14,
195
1.0689589615395477e-13,
196
1.0408994850535984e-13,
197
1.7032684855598177e-13
198
],
199
linf=[
200
1.6986412276764895e-13,
201
2.2503592098759465e-12,
202
1.7696906239744284e-12,
203
3.623767952376511e-13
204
],
205
initial_refinement_level=7,
206
tspan=(0.0, 0.1))
207
# Ensure that we do not have excessive memory allocations
208
# (e.g., from type instabilities)
209
let
210
t = sol.t[end]
211
u_ode = sol.u[end]
212
du_ode = similar(u_ode)
213
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
214
end
215
end
216
217
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin
218
@test_trixi_include(joinpath(EXAMPLES_DIR,
219
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
220
l2=[
221
0.0034516244508588046,
222
0.0023420334036925493,
223
0.0024261923964557187,
224
0.004731710454271893
225
],
226
linf=[
227
0.04155789011775046,
228
0.024772109862748914,
229
0.03759938693042297,
230
0.08039824959535657
231
])
232
# Ensure that we do not have excessive memory allocations
233
# (e.g., from type instabilities)
234
let
235
t = sol.t[end]
236
u_ode = sol.u[end]
237
du_ode = similar(u_ode)
238
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
239
end
240
end
241
242
@trixi_testset "elixir_euler_free_stream.jl" begin
243
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"),
244
l2=[
245
2.063350241405049e-15,
246
1.8571016296925367e-14,
247
3.1769447886391905e-14,
248
1.4104095258528071e-14
249
],
250
linf=[1.9539925233402755e-14, 2e-12, 4.8e-12, 4e-12],
251
atol=2.0e-12,)
252
# Ensure that we do not have excessive memory allocations
253
# (e.g., from type instabilities)
254
let
255
t = sol.t[end]
256
u_ode = sol.u[end]
257
du_ode = similar(u_ode)
258
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
259
end
260
end
261
262
@trixi_testset "elixir_euler_free_stream_hybrid_mesh.jl" begin
263
@test_trixi_include(joinpath(EXAMPLES_DIR,
264
"elixir_euler_free_stream_hybrid_mesh.jl"),
265
l2=[
266
1.0174922714929637e-15,
267
5.053352600778435e-15,
268
7.358169131303026e-15,
269
5.999843977180112e-15
270
],
271
linf=[
272
4.440892098500626e-15,
273
2.6117996654306808e-14,
274
4.246603069191224e-14,
275
5.861977570020827e-14
276
],
277
atol=2.0e-12,)
278
# Ensure that we do not have excessive memory allocations
279
# (e.g., from type instabilities)
280
let
281
t = sol.t[end]
282
u_ode = sol.u[end]
283
du_ode = similar(u_ode)
284
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
285
end
286
end
287
288
@trixi_testset "elixir_euler_shockcapturing_ec.jl" begin
289
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"),
290
l2=[
291
9.53984675e-02,
292
1.05633455e-01,
293
1.05636158e-01,
294
3.50747237e-01
295
],
296
linf=[
297
2.94357464e-01,
298
4.07893014e-01,
299
3.97334516e-01,
300
1.08142520e+00
301
],
302
tspan=(0.0, 1.0))
303
# Ensure that we do not have excessive memory allocations
304
# (e.g., from type instabilities)
305
let
306
t = sol.t[end]
307
u_ode = sol.u[end]
308
du_ode = similar(u_ode)
309
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
310
end
311
end
312
313
@trixi_testset "elixir_euler_shockcapturing_ec.jl (flux_chandrashekar)" begin
314
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_ec.jl"),
315
l2=[
316
0.09527896382082567,
317
0.10557894830184737,
318
0.10559379376154387,
319
0.3503791205165925
320
],
321
linf=[
322
0.2733486454092644,
323
0.3877283966722886,
324
0.38650482703821426,
325
1.0053712251056308
326
],
327
tspan=(0.0, 1.0),
328
volume_flux=flux_chandrashekar)
329
# Ensure that we do not have excessive memory allocations
330
# (e.g., from type instabilities)
331
let
332
t = sol.t[end]
333
u_ode = sol.u[end]
334
du_ode = similar(u_ode)
335
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
336
end
337
end
338
339
@trixi_testset "elixir_euler_shockcapturing_ec_float32.jl" begin
340
@test_trixi_include(joinpath(EXAMPLES_DIR,
341
"elixir_euler_shockcapturing_ec_float32.jl"),
342
l2=[
343
0.09539953f0,
344
0.10563527f0,
345
0.105637245f0,
346
0.3507514f0
347
],
348
linf=[
349
0.2930063f0,
350
0.4079147f0,
351
0.3972956f0,
352
1.0764117f0
353
],
354
tspan=(0.0f0, 1.0f0),
355
rtol=10 * sqrt(eps(Float32)), # to make CI pass
356
RealT=Float32)
357
# Ensure that we do not have excessive memory allocations
358
# (e.g., from type instabilities)
359
let
360
t = sol.t[end]
361
u_ode = sol.u[end]
362
du_ode = similar(u_ode)
363
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
364
end
365
end
366
367
@trixi_testset "elixir_euler_sedov.jl" begin
368
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"),
369
l2=[
370
3.76149952e-01,
371
2.46970327e-01,
372
2.46970327e-01,
373
1.28889042e+00
374
],
375
linf=[
376
1.22139001e+00,
377
1.17742626e+00,
378
1.17742626e+00,
379
6.20638482e+00
380
],
381
tspan=(0.0, 0.3))
382
# Ensure that we do not have excessive memory allocations
383
# (e.g., from type instabilities)
384
let
385
t = sol.t[end]
386
u_ode = sol.u[end]
387
du_ode = similar(u_ode)
388
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
389
end
390
end
391
392
@trixi_testset "elixir_euler_sedov_blast_wave_sc_subcell.jl" begin
393
using Trixi: Trixi, DGSEM, SemidiscretizationHyperbolic, semidiscretize, CallbackSet
394
@test_trixi_include(joinpath(EXAMPLES_DIR,
395
"elixir_euler_sedov_blast_wave_sc_subcell.jl"),
396
l2=[
397
0.4573787784168518,
398
0.28520972760728397,
399
0.28527281808006966,
400
1.2881460122982442
401
],
402
linf=[
403
1.644411040701827,
404
1.6743368119653912,
405
1.6760847977977988,
406
6.268843623142863
407
],
408
tspan=(0.0, 0.3))
409
# Ensure that we do not have excessive memory allocations
410
# (e.g., from type instabilities)
411
let
412
t = sol.t[end]
413
u_ode = sol.u[end]
414
du_ode = similar(u_ode)
415
# Larger values for allowed allocations due to usage of custom
416
# integrator which are not *recorded* for the methods from
417
# OrdinaryDiffEq.jl
418
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
419
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000
420
end
421
422
# Test `resize!`
423
ode_alg = Trixi.SimpleSSPRK33(stage_callbacks = stage_callbacks)
424
integrator = Trixi.init(ode, ode_alg, dt = 42.0, callback = callbacks)
425
426
resize!(integrator, 42)
427
@test length(integrator.u) == 42
428
@test length(integrator.du) == 42
429
@test length(integrator.u_tmp) == 42
430
431
# Test `resize!` for non `VolumeIntegralSubcellLimiting`
432
let
433
solver = DGSEM(basis, surface_flux)
434
semi = SemidiscretizationHyperbolic(mesh, equations, initial_condition, solver)
435
436
ode = semidiscretize(semi, tspan)
437
ode_alg = Trixi.SimpleSSPRK33(stage_callbacks = (;))
438
callbacks = CallbackSet(summary_callback)
439
integrator = Trixi.init(ode, ode_alg, dt = 11.0, callback = callbacks)
440
441
resize!(integrator, 4711)
442
@test length(integrator.u) == 4711
443
@test length(integrator.du) == 4711
444
@test length(integrator.u_tmp) == 4711
445
end
446
end
447
448
@trixi_testset "elixir_euler_sedov.jl with HLLC Flux" begin
449
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"),
450
l2=[
451
0.4229948321239887,
452
0.2559038337457483,
453
0.2559038337457484,
454
1.2990046683564136
455
],
456
linf=[
457
1.4989357969730492,
458
1.325456585141623,
459
1.3254565851416251,
460
6.331283015053501
461
],
462
surface_flux=flux_hllc,
463
tspan=(0.0, 0.3))
464
# Ensure that we do not have excessive memory allocations
465
# (e.g., from type instabilities)
466
let
467
t = sol.t[end]
468
u_ode = sol.u[end]
469
du_ode = similar(u_ode)
470
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
471
end
472
end
473
474
@trixi_testset "elixir_euler_sedov.jl (HLLE)" begin
475
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"),
476
l2=[
477
0.40853279043747015,
478
0.25356771650524296,
479
0.2535677165052422,
480
1.2984601729572691
481
],
482
linf=[
483
1.3840909333784284,
484
1.3077772519086124,
485
1.3077772519086157,
486
6.298798630968632
487
],
488
surface_flux=flux_hlle,
489
tspan=(0.0, 0.3))
490
# Ensure that we do not have excessive memory allocations
491
# (e.g., from type instabilities)
492
let
493
t = sol.t[end]
494
u_ode = sol.u[end]
495
du_ode = similar(u_ode)
496
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
497
end
498
end
499
500
@trixi_testset "elixir_euler_blast_wave_amr.jl" begin
501
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_blast_wave_amr.jl"),
502
l2=[
503
0.6321850210104147,
504
0.38691446170269167,
505
0.3868695626809587,
506
1.0657553825683956
507
],
508
linf=[
509
2.7602280007469666,
510
2.3265993814913672,
511
2.3258078438689673,
512
2.1577683028925416
513
],
514
tspan=(0.0, 0.3),)
515
# Ensure that we do not have excessive memory allocations
516
# (e.g., from type instabilities)
517
let
518
t = sol.t[end]
519
u_ode = sol.u[end]
520
du_ode = similar(u_ode)
521
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
522
end
523
end
524
525
@trixi_testset "elixir_euler_wall_bc_amr.jl" begin
526
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"),
527
l2=[
528
0.02026685991647352,
529
0.017467584076280237,
530
0.011378371604813321,
531
0.05138942558296091
532
],
533
linf=[
534
0.35924402060711524,
535
0.32068389566068806,
536
0.2361141752119986,
537
0.9289840057748628
538
],
539
tspan=(0.0, 0.15))
540
# Ensure that we do not have excessive memory allocations
541
# (e.g., from type instabilities)
542
let
543
t = sol.t[end]
544
u_ode = sol.u[end]
545
du_ode = similar(u_ode)
546
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
547
end
548
end
549
550
@trixi_testset "elixir_euler_forward_step_amr.jl" begin
551
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_forward_step_amr.jl"),
552
l2=[
553
0.004191480950848891,
554
0.003781298410569231,
555
0.0013470418422981045,
556
0.03262817609394949
557
],
558
linf=[
559
2.0581500751947113,
560
2.2051301367971288,
561
3.8502467979250254,
562
17.750333649853616
563
],
564
tspan=(0.0, 0.0001),
565
rtol=1.0e-7,)
566
# Ensure that we do not have excessive memory allocations
567
# (e.g., from type instabilities)
568
let
569
t = sol.t[end]
570
u_ode = sol.u[end]
571
du_ode = similar(u_ode)
572
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
573
end
574
end
575
576
@trixi_testset "elixir_euler_double_mach_amr.jl" begin
577
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_double_mach_amr.jl"),
578
l2=[
579
0.051359355290192046,
580
0.4266034859911273,
581
0.2438304855475594,
582
4.11487176105527
583
],
584
linf=[
585
6.902000373057003,
586
53.95714139820832,
587
24.241610279839758,
588
561.0630401858057
589
],
590
tspan=(0.0, 0.0001),)
591
# Ensure that we do not have excessive memory allocations
592
# (e.g., from type instabilities)
593
let
594
t = sol.t[end]
595
u_ode = sol.u[end]
596
du_ode = similar(u_ode)
597
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
598
end
599
end
600
601
@trixi_testset "elixir_euler_supersonic_cylinder.jl" begin
602
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_supersonic_cylinder.jl"),
603
l2=[
604
0.02676082999794676,
605
0.05110830068968181,
606
0.03205164257040607,
607
0.1965981012724311
608
],
609
linf=[
610
3.6830683476364476,
611
4.284442685012427,
612
6.857777546171545,
613
31.749285097390576
614
],
615
tspan=(0.0, 0.001),)
616
# Ensure that we do not have excessive memory allocations
617
# (e.g., from type instabilities)
618
let
619
t = sol.t[end]
620
u_ode = sol.u[end]
621
du_ode = similar(u_ode)
622
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
623
end
624
end
625
626
@trixi_testset "elixir_euler_supersonic_cylinder_sc_subcell.jl" begin
627
@test_trixi_include(joinpath(EXAMPLES_DIR,
628
"elixir_euler_supersonic_cylinder_sc_subcell.jl"),
629
l2=[
630
0.11085870166618325,
631
0.23309905989870722,
632
0.13505351590735631,
633
0.7932047512585592
634
],
635
linf=[
636
2.9808773737943564,
637
4.209364526217892,
638
6.265341002817672,
639
24.077904874883338
640
],
641
tspan=(0.0, 0.02),
642
atol=1e-7)
643
# Ensure that we do not have excessive memory allocations
644
# (e.g., from type instabilities)
645
let
646
t = sol.t[end]
647
u_ode = sol.u[end]
648
du_ode = similar(u_ode)
649
# Larger values for allowed allocations due to usage of custom
650
# integrator which are not *recorded* for the methods from
651
# OrdinaryDiffEq.jl
652
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
653
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 15000
654
end
655
end
656
657
@trixi_testset "elixir_euler_NACA6412airfoil_mach2.jl" begin
658
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_NACA6412airfoil_mach2.jl"),
659
l2=[
660
0.19107654776276498, 0.3545913719444839,
661
0.18492730895077583, 0.817927213517244
662
],
663
linf=[
664
2.5397624311491946, 2.7075156425517917, 2.200980534211764,
665
9.031153939238115
666
],
667
tspan=(0.0, 0.1))
668
# Ensure that we do not have excessive memory allocations
669
# (e.g., from type instabilities)
670
let
671
t = sol.t[end]
672
u_ode = sol.u[end]
673
du_ode = similar(u_ode)
674
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
675
end
676
end
677
678
@trixi_testset "elixir_eulergravity_convergence.jl" begin
679
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_eulergravity_convergence.jl"),
680
l2=[
681
0.00024871265138964204,
682
0.0003370077102132591,
683
0.0003370077102131964,
684
0.0007231525513793697
685
],
686
linf=[
687
0.0015813032944647087,
688
0.0020494288423820173,
689
0.0020494288423824614,
690
0.004793821195083758
691
],
692
tspan=(0.0, 0.1))
693
# Ensure that we do not have excessive memory allocations
694
# (e.g., from type instabilities)
695
let
696
t = sol.t[end]
697
u_ode = sol.u[end]
698
du_ode = similar(u_ode)
699
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
700
end
701
end
702
703
@trixi_testset "elixir_mhd_alfven_wave.jl" begin
704
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave.jl"),
705
l2=[1.0513414461545583e-5, 1.0517900957166411e-6,
706
1.0517900957304043e-6, 1.511816606372376e-6,
707
1.0443997728645063e-6, 7.879639064990798e-7,
708
7.879639065049896e-7, 1.0628631669056271e-6,
709
4.3382328912336153e-7],
710
linf=[4.255466285174592e-5, 1.0029706745823264e-5,
711
1.0029706747467781e-5, 1.2122265939010224e-5,
712
5.4791097160444835e-6, 5.18922042269665e-6,
713
5.189220422141538e-6, 9.552667261422676e-6,
714
1.4237578427628152e-6])
715
# Ensure that we do not have excessive memory allocations
716
# (e.g., from type instabilities)
717
let
718
t = sol.t[end]
719
u_ode = sol.u[end]
720
du_ode = similar(u_ode)
721
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
722
end
723
end
724
725
@trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin
726
@test_trixi_include(joinpath(EXAMPLES_DIR,
727
"elixir_mhd_alfven_wave_nonconforming.jl"),
728
l2=[
729
0.0322570437144848,
730
0.03598284801272945,
731
0.03562228071357411,
732
0.05288641880143085,
733
0.040752873778199326,
734
0.04207276835260492,
735
0.04171391252403866,
736
0.05289242879893149,
737
0.0016038935411812223
738
],
739
linf=[
740
0.175984910510666,
741
0.13999726708245439,
742
0.13336032728399658,
743
0.21248359539637798,
744
0.133294808938885,
745
0.17934684696413217,
746
0.1831567822932948,
747
0.21575881133569155,
748
0.01967917976620703
749
],
750
tspan=(0.0, 0.25))
751
# Ensure that we do not have excessive memory allocations
752
# (e.g., from type instabilities)
753
let
754
t = sol.t[end]
755
u_ode = sol.u[end]
756
du_ode = similar(u_ode)
757
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
758
end
759
end
760
761
@trixi_testset "elixir_mhd_rotor.jl" begin
762
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor.jl"),
763
l2=[0.4551839744017604, 0.8917986079085971, 0.832474072904728,
764
0.0,
765
0.98015167453983, 0.10475978783943254,
766
0.15551175906375883,
767
0.0,
768
2.026208477271868e-5],
769
linf=[10.19496728149964, 18.23726813972206,
770
10.04367783820621,
771
0.0,
772
19.63022306543678, 1.3952679820406384, 1.8716515525771589,
773
0.0,
774
0.0017266639582675424],
775
tspan=(0.0, 0.02))
776
# Ensure that we do not have excessive memory allocations
777
# (e.g., from type instabilities)
778
let
779
t = sol.t[end]
780
u_ode = sol.u[end]
781
du_ode = similar(u_ode)
782
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
783
end
784
end
785
786
@trixi_testset "elixir_mhd_rotor_cfl_ramp.jl" begin
787
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_rotor_cfl_ramp.jl"),
788
l2=[
789
0.45519051169507474,
790
0.8917985468745363,
791
0.8324681609772325,
792
0.0,
793
0.9801426190285389,
794
0.10476233464125001,
795
0.15551270692826116,
796
0.0,
797
2.0201603821472296e-5
798
],
799
linf=[
800
10.196786739705292,
801
18.267539012179128,
802
10.046104290498878,
803
0.0,
804
19.668302849210974,
805
1.395022093528294,
806
1.8717844606331189,
807
0.0,
808
0.001651262488701531
809
],
810
tspan=(0.0, 0.02))
811
# Ensure that we do not have excessive memory allocations
812
# (e.g., from type instabilities)
813
let
814
t = sol.t[end]
815
u_ode = sol.u[end]
816
du_ode = similar(u_ode)
817
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
818
end
819
end
820
821
@trixi_testset "elixir_linearizedeuler_gaussian_source.jl" begin
822
@test_trixi_include(joinpath(EXAMPLES_DIR,
823
"elixir_linearizedeuler_gaussian_source.jl"),
824
l2=[
825
0.006047938590548741,
826
0.0040953286019907035,
827
0.004222698522497298,
828
0.006269492499336128
829
],
830
linf=[
831
0.06386175207349379,
832
0.0378926444850457,
833
0.041759728067967065,
834
0.06430136016259067
835
])
836
# Ensure that we do not have excessive memory allocations
837
# (e.g., from type instabilities)
838
let
839
t = sol.t[end]
840
u_ode = sol.u[end]
841
du_ode = similar(u_ode)
842
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
843
end
844
end
845
846
@trixi_testset "elixir_euler_subsonic_cylinder.jl" begin
847
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_subsonic_cylinder.jl"),
848
l2=[
849
0.00011914390523852561,
850
0.00010776028621724485,
851
6.139954358305467e-5,
852
0.0003067693731825959
853
],
854
linf=[
855
0.1653075586200805,
856
0.1868437275544909,
857
0.09772818519679008,
858
0.4311796171737692
859
], tspan=(0.0, 0.001))
860
# Ensure that we do not have excessive memory allocations
861
# (e.g., from type instabilities)
862
let
863
t = sol.t[end]
864
u_ode = sol.u[end]
865
du_ode = similar(u_ode)
866
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
867
end
868
869
u_ode = copy(sol.u[end])
870
du_ode = zero(u_ode) # Just a placeholder in this case
871
872
u = Trixi.wrap_array(u_ode, semi)
873
du = Trixi.wrap_array(du_ode, semi)
874
drag = Trixi.analyze(drag_coefficient, du, u, tspan[2], mesh, equations, solver,
875
semi.cache, semi)
876
lift = Trixi.analyze(lift_coefficient, du, u, tspan[2], mesh, equations, solver,
877
semi.cache, semi)
878
879
@test isapprox(lift, -6.501138753497174e-15, atol = 1e-13)
880
@test isapprox(drag, 2.588589856781827, atol = 1e-13)
881
end
882
883
# Forces computation test in an AMR code
884
@trixi_testset "elixir_euler_NACA0012airfoil_mach085.jl" begin
885
@test_trixi_include(joinpath(EXAMPLES_DIR,
886
"elixir_euler_NACA0012airfoil_mach085.jl"),
887
l2=[
888
5.56114097044427e-7, 6.62284247153255e-6,
889
1.0823259724601275e-5, 0.000659804574787503
890
],
891
linf=[
892
0.002157589754528455, 0.039163189253511164,
893
0.038386804399707625, 2.6685831417913914
894
],
895
amr_interval=1,
896
base_level=0, med_level=1, max_level=1,
897
tspan=(0.0, 0.0001),
898
adapt_initial_condition=false,
899
adapt_initial_condition_only_refine=false,)
900
901
# Ensure that we do not have excessive memory allocations
902
# (e.g., from type instabilities)
903
let
904
t = sol.t[end]
905
u_ode = sol.u[end]
906
du_ode = similar(u_ode)
907
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
908
end
909
910
u_ode = copy(sol.u[end])
911
du_ode = zero(u_ode) # Just a placeholder in this case
912
913
u = Trixi.wrap_array(u_ode, semi)
914
du = Trixi.wrap_array(du_ode, semi)
915
drag = Trixi.analyze(drag_coefficient, du, u, tspan[2], mesh, equations, solver,
916
semi.cache, semi)
917
lift = Trixi.analyze(lift_coefficient, du, u, tspan[2], mesh, equations, solver,
918
semi.cache, semi)
919
920
@test isapprox(lift, 0.029094009322876882, atol = 1e-13)
921
@test isapprox(drag, 0.13579200776643238, atol = 1e-13)
922
end
923
924
@trixi_testset "elixir_euler_blast_wave_pure_fv.jl" begin
925
using Trixi: Trixi
926
@test_trixi_include(joinpath(pkgdir(Trixi, "examples", "tree_2d_dgsem"),
927
"elixir_euler_blast_wave_pure_fv.jl"),
928
l2=[
929
0.39957047631960346,
930
0.21006912294983154,
931
0.21006903549932,
932
0.6280328163981136
933
],
934
linf=[
935
2.20417889887697,
936
1.5487238480003327,
937
1.5486788679247812,
938
2.4656795949035857
939
],
940
tspan=(0.0, 0.5),
941
mesh=P4estMesh((64, 64), polydeg = 3,
942
coordinates_min = (-2.0, -2.0),
943
coordinates_max = (2.0, 2.0)))
944
# Ensure that we do not have excessive memory allocations
945
# (e.g., from type instabilities)
946
let
947
t = sol.t[end]
948
u_ode = sol.u[end]
949
du_ode = similar(u_ode)
950
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
951
end
952
end
953
954
@trixi_testset "elixir_euler_weak_blast_wave_amr.jl" begin
955
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weak_blast_wave_amr.jl"),
956
l2=[
957
0.11134260363848127,
958
0.11752357091804219,
959
0.11829112104640764,
960
0.7557891142955036
961
],
962
linf=[
963
0.5728647031475109,
964
0.8353132977670252,
965
0.8266797080712205,
966
3.9792506230548317
967
],
968
tspan=(0.0, 0.1),)
969
# Ensure that we do not have excessive memory allocations
970
# (e.g., from type instabilities)
971
let
972
t = sol.t[end]
973
u_ode = sol.u[end]
974
du_ode = similar(u_ode)
975
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
976
end
977
# Check for conservation
978
state_integrals = Trixi.integrate(sol.u[2], semi)
979
initial_state_integrals = analysis_callback.affect!.initial_state_integrals
980
981
@test isapprox(state_integrals[1], initial_state_integrals[1], atol = 1e-13)
982
@test isapprox(state_integrals[2], initial_state_integrals[2], atol = 1e-13)
983
@test isapprox(state_integrals[3], initial_state_integrals[3], atol = 1e-13)
984
@test isapprox(state_integrals[4], initial_state_integrals[4], atol = 1e-13)
985
end
986
987
@trixi_testset "elixir_euler_SD7003airfoil.jl" begin
988
using Trixi: SemidiscretizationHyperbolic, AnalysisCallback
989
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_navierstokes_SD7003airfoil.jl"),
990
semi=SemidiscretizationHyperbolic(mesh, equations,
991
initial_condition, solver;
992
boundary_conditions = boundary_conditions_hyp),
993
analysis_callback=AnalysisCallback(semi,
994
interval = analysis_interval,
995
output_directory = "out",
996
save_analysis = true),
997
l2=[
998
9.316117984455285e-5,
999
4.539266936628966e-5,
1000
8.381576796590632e-5,
1001
0.00023437941500203496
1002
],
1003
linf=[
1004
0.31274105032407307,
1005
0.2793016762668701,
1006
0.22256470161743136,
1007
0.7906704256076251
1008
],
1009
tspan=(0.0, 5e-3))
1010
# Ensure that we do not have excessive memory allocations
1011
# (e.g., from type instabilities)
1012
let
1013
t = sol.t[end]
1014
u_ode = sol.u[end]
1015
du_ode = similar(u_ode)
1016
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
1017
end
1018
end
1019
1020
@trixi_testset "elixir_euler_density_wave_tracers.jl" begin
1021
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_density_wave_tracers.jl"),
1022
l2=[
1023
0.0012704690524147188,
1024
0.00012704690527390463,
1025
0.00025409381047976197,
1026
3.17617263147723e-5,
1027
0.0527467468452892,
1028
0.052788143280791185
1029
],
1030
linf=[
1031
0.0071511674295154926,
1032
0.0007151167435655859,
1033
0.0014302334865533006,
1034
0.00017877918656949987,
1035
0.2247919517756231,
1036
0.2779841048041337
1037
])
1038
# Ensure that we do not have excessive memory allocations
1039
# (e.g., from type instabilities)
1040
let
1041
t = sol.t[end]
1042
u_ode = sol.u[end]
1043
du_ode = similar(u_ode)
1044
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
1045
end
1046
end
1047
1048
@trixi_testset "elixir_euler_cylinder_bowshock_mach3.jl" begin
1049
@test_trixi_include(joinpath(EXAMPLES_DIR,
1050
"elixir_euler_cylinder_bowshock_mach3.jl"),
1051
tspan=(0.0, 1e-3),
1052
l2=[
1053
0.03787745781612722,
1054
0.03339276348608649,
1055
0.05301001151898993,
1056
0.2868802674001281
1057
],
1058
linf=[
1059
2.5347156069842978,
1060
2.6657123832452414,
1061
3.786891603220761,
1062
21.305497055838977
1063
])
1064
# Ensure that we do not have excessive memory allocations
1065
# (e.g., from type instabilities)
1066
let
1067
t = sol.t[end]
1068
u_ode = sol.u[end]
1069
du_ode = similar(u_ode)
1070
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
1071
end
1072
end
1073
end
1074
1075
# Clean up afterwards: delete Trixi.jl output directory
1076
@test_nowarn rm(outdir, recursive = true)
1077
1078
end # module
1079
1080