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