Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_dgmulti_2d.jl
2055 views
1
module TestExamplesDGMulti2D
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "dgmulti_2d")
9
10
# Start with a clean environment: remove Trixi.jl output directory if it exists
11
outdir = "out"
12
isdir(outdir) && rm(outdir, recursive = true)
13
14
@testset "DGMulti 2D" begin
15
#! format: noindent
16
17
@trixi_testset "elixir_euler_weakform.jl" begin
18
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
19
cells_per_dimension=(4, 4),
20
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
21
# division by 2.0 corresponds to normalization by the square root of the size of the domain
22
l2=[
23
0.0013536930300254945,
24
0.0014315603442106193,
25
0.001431560344211359,
26
0.0047393341007602625
27
] ./ 2.0,
28
linf=[
29
0.001514260921466004,
30
0.0020623991944839215,
31
0.002062399194485476,
32
0.004897700392503701
33
])
34
# Ensure that we do not have excessive memory allocations
35
# (e.g., from type instabilities)
36
let
37
t = sol.t[end]
38
u_ode = sol.u[end]
39
du_ode = similar(u_ode)
40
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
41
end
42
43
# Load the mesh file for code coverage
44
loaded_mesh = Trixi.load_mesh_serial(joinpath("out", "mesh.h5"),
45
n_cells_max = 0,
46
RealT = Float64)
47
end
48
49
@trixi_testset "elixir_euler_weakform.jl (SBP)" begin
50
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
51
cells_per_dimension=(4, 4),
52
approximation_type=SBP(),
53
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
54
# division by 2.0 corresponds to normalization by the square root of the size of the domain
55
l2=[
56
0.0074706882014934735,
57
0.005306220583603261,
58
0.005306220583613591,
59
0.014724842607716771
60
] ./ 2.0,
61
linf=[
62
0.021563604940952885,
63
0.01359397832530762,
64
0.013593978324845324,
65
0.03270995869587523
66
])
67
# Ensure that we do not have excessive memory allocations
68
# (e.g., from type instabilities)
69
let
70
t = sol.t[end]
71
u_ode = sol.u[end]
72
du_ode = similar(u_ode)
73
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
74
end
75
end
76
77
@trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements)" begin
78
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
79
cells_per_dimension=(4, 4),
80
element_type=Quad(),
81
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
82
# division by 2.0 corresponds to normalization by the square root of the size of the domain
83
l2=[
84
0.00031892254415307093,
85
0.00033637562986771894,
86
0.0003363756298680649,
87
0.0011100259064243145
88
] ./ 2.0,
89
linf=[
90
0.001073298211445639,
91
0.0013568139808282087,
92
0.0013568139808290969,
93
0.0032249020004324613
94
])
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_euler_weakform.jl (EC) " begin
106
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
107
cells_per_dimension=(4, 4),
108
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
109
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
110
# division by 2.0 corresponds to normalization by the square root of the size of the domain
111
l2=[
112
0.007801417730672109,
113
0.00708583561714128,
114
0.0070858356171393,
115
0.015217574294198809
116
] ./ 2.0,
117
linf=[
118
0.011572828457858897,
119
0.013965298735070686,
120
0.01396529873508534,
121
0.04227683691807904
122
])
123
# Ensure that we do not have excessive memory allocations
124
# (e.g., from type instabilities)
125
let
126
t = sol.t[end]
127
u_ode = sol.u[end]
128
du_ode = similar(u_ode)
129
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
130
end
131
end
132
133
@trixi_testset "elixir_euler_weakform.jl (SBP, EC)" begin
134
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
135
cells_per_dimension=(4, 4),
136
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
137
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
138
approximation_type=SBP(),
139
# division by 2.0 corresponds to normalization by the square root of the size of the domain
140
l2=[
141
0.01280067571168776,
142
0.010607599608273302,
143
0.010607599608239775,
144
0.026408338014056548
145
] ./ 2.0,
146
linf=[
147
0.037983023185674814,
148
0.05321027922533417,
149
0.05321027922608157,
150
0.13392025411844033
151
])
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
end
161
162
@trixi_testset "elixir_euler_weakform.jl (Quadrilateral elements, SBP, EC)" begin
163
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
164
cells_per_dimension=(4, 4),
165
element_type=Quad(),
166
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
167
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
168
approximation_type=SBP(),
169
# division by 2.0 corresponds to normalization by the square root of the size of the domain
170
l2=[
171
0.0029373718090697975,
172
0.0030629360605489465,
173
0.003062936060545615,
174
0.0068486089344859755
175
] ./ 2.0,
176
linf=[
177
0.01360165305316885,
178
0.01267402847925303,
179
0.012674028479251254,
180
0.02210545278615017
181
])
182
# Ensure that we do not have excessive memory allocations
183
# (e.g., from type instabilities)
184
let
185
t = sol.t[end]
186
u_ode = sol.u[end]
187
du_ode = similar(u_ode)
188
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
189
end
190
end
191
192
@trixi_testset "elixir_euler_bilinear.jl (Bilinear quadrilateral elements, SBP, flux differencing)" begin
193
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_bilinear.jl"),
194
l2=[
195
1.0267413589968656e-5,
196
9.03069720963081e-6,
197
9.030697209721065e-6,
198
2.7436672091049314e-5
199
],
200
linf=[
201
7.36251369879426e-5,
202
6.874041557969335e-5,
203
6.874041552329402e-5,
204
0.00019123932693609902
205
])
206
# Ensure that we do not have excessive memory allocations
207
# (e.g., from type instabilities)
208
let
209
t = sol.t[end]
210
u_ode = sol.u[end]
211
du_ode = similar(u_ode)
212
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
213
end
214
end
215
216
@trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, SBP, flux differencing)" begin
217
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
218
l2=[
219
1.7209164346836478e-5,
220
1.5928649356474767e-5,
221
1.5928649356802847e-5,
222
4.8963394546089164e-5
223
],
224
linf=[
225
0.00010525404319428056,
226
0.00010003768703326088,
227
0.00010003768694910598,
228
0.0003642622844113319
229
])
230
# Ensure that we do not have excessive memory allocations
231
# (e.g., from type instabilities)
232
let
233
t = sol.t[end]
234
u_ode = sol.u[end]
235
du_ode = similar(u_ode)
236
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
237
end
238
end
239
240
@trixi_testset "elixir_euler_curved.jl (Quadrilateral elements, GaussSBP, flux differencing)" begin
241
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
242
approximation_type=GaussSBP(),
243
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
244
l2=[
245
3.4664508443541302e-6,
246
3.4389354928807557e-6,
247
3.438935492692069e-6,
248
1.0965259031107001e-5
249
],
250
linf=[
251
1.1326776948594741e-5,
252
1.1343379410666543e-5,
253
1.1343379308081936e-5,
254
3.679395547040443e-5
255
],
256
rtol=2 * sqrt(eps()))
257
# Ensure that we do not have excessive memory allocations
258
# (e.g., from type instabilities)
259
let
260
t = sol.t[end]
261
u_ode = sol.u[end]
262
du_ode = similar(u_ode)
263
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
264
end
265
end
266
267
@trixi_testset "elixir_euler_curved.jl (Triangular elements, Polynomial, weak formulation)" begin
268
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_curved.jl"),
269
element_type=Tri(), approximation_type=Polynomial(),
270
volume_integral=VolumeIntegralWeakForm(),
271
surface_integral=SurfaceIntegralWeakForm(FluxHLL(min_max_speed_naive)),
272
l2=[
273
7.906577233358824e-6,
274
8.733496764180975e-6,
275
8.733496764698532e-6,
276
2.911852322169076e-5
277
],
278
linf=[
279
3.298755256198049e-5,
280
4.0322966492922774e-5,
281
4.032296598488472e-5,
282
0.00012013778942154829
283
])
284
# Ensure that we do not have excessive memory allocations
285
# (e.g., from type instabilities)
286
let
287
t = sol.t[end]
288
u_ode = sol.u[end]
289
du_ode = similar(u_ode)
290
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
291
end
292
end
293
294
@trixi_testset "elixir_euler_hohqmesh.jl (Quadrilateral elements, SBP, flux differencing)" begin
295
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_hohqmesh.jl"),
296
l2=[
297
0.0008153911341539523,
298
0.0007768159702011952,
299
0.0004790260681142826,
300
0.0015551846076274918
301
],
302
linf=[
303
0.002930113136531798,
304
0.003442705146861069,
305
0.002872156984277563,
306
0.011125365075300486
307
])
308
# Ensure that we do not have excessive memory allocations
309
# (e.g., from type instabilities)
310
let
311
t = sol.t[end]
312
u_ode = sol.u[end]
313
du_ode = similar(u_ode)
314
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
315
end
316
end
317
318
@trixi_testset "elixir_euler_weakform.jl (convergence)" begin
319
using Trixi: convergence_test
320
mean_convergence = convergence_test(@__MODULE__,
321
joinpath(EXAMPLES_DIR,
322
"elixir_euler_weakform.jl"), 2)
323
@test isapprox(mean_convergence[:l2],
324
[
325
4.243843382379403,
326
4.128314378833922,
327
4.128314378397532,
328
4.081366752807379
329
], rtol = 0.05)
330
# Ensure that we do not have excessive memory allocations
331
# (e.g., from type instabilities)
332
let
333
t = sol.t[end]
334
u_ode = sol.u[end]
335
du_ode = similar(u_ode)
336
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
337
end
338
end
339
340
@trixi_testset "elixir_euler_weakform_periodic.jl" begin
341
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform_periodic.jl"),
342
# division by 2.0 corresponds to normalization by the square root of the size of the domain
343
l2=[
344
0.0007492755162295128, 0.0007641875305302599,
345
0.0007641875305306243, 0.0024232389721009447
346
],
347
linf=[
348
0.0015060064614331736, 0.0019371156800773726,
349
0.0019371156800769285, 0.004742431684202408
350
])
351
# Ensure that we do not have excessive memory allocations
352
# (e.g., from type instabilities)
353
let
354
t = sol.t[end]
355
u_ode = sol.u[end]
356
du_ode = similar(u_ode)
357
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
358
end
359
end
360
361
@trixi_testset "elixir_euler_triangulate_pkg_mesh.jl" begin
362
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_triangulate_pkg_mesh.jl"),
363
l2=[
364
2.344076909832665e-6, 1.8610002398709756e-6,
365
2.4095132179484066e-6, 6.37330249340445e-6
366
],
367
linf=[
368
2.509979394305084e-5, 2.2683711321080935e-5,
369
2.6180377720841363e-5, 5.575278031910713e-5
370
])
371
# Ensure that we do not have excessive memory allocations
372
# (e.g., from type instabilities)
373
let
374
t = sol.t[end]
375
u_ode = sol.u[end]
376
du_ode = similar(u_ode)
377
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
378
end
379
end
380
381
@trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl" begin
382
@test_trixi_include(joinpath(EXAMPLES_DIR,
383
"elixir_euler_kelvin_helmholtz_instability.jl"),
384
cells_per_dimension=(32, 32), tspan=(0.0, 0.2),
385
# division by 2.0 corresponds to normalization by the square root of the size of the domain
386
l2=[
387
0.11140378947116614,
388
0.06598161188703612,
389
0.10448953167839563,
390
0.16023209181809595
391
] ./ 2.0,
392
linf=[
393
0.24033843177853664,
394
0.1659992245272325,
395
0.1235468309508845,
396
0.26911424973147735
397
])
398
# Ensure that we do not have excessive memory allocations
399
# (e.g., from type instabilities)
400
let
401
t = sol.t[end]
402
u_ode = sol.u[end]
403
du_ode = similar(u_ode)
404
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
405
end
406
end
407
408
@trixi_testset "elixir_euler_kelvin_helmholtz_instability.jl (Quadrilateral elements, GaussSBP)" begin
409
@test_trixi_include(joinpath(EXAMPLES_DIR,
410
"elixir_euler_kelvin_helmholtz_instability.jl"),
411
cells_per_dimension=(32, 32), element_type=Quad(),
412
approximation_type=GaussSBP(), tspan=(0.0, 0.2),
413
# division by 2.0 corresponds to normalization by the square root of the size of the domain
414
l2=[
415
0.11141270656347146,
416
0.06598888014584121,
417
0.1044902203749932,
418
0.16023037364774995
419
] ./ 2.0,
420
linf=[
421
0.2414760062126462,
422
0.1662111846065654,
423
0.12344140473946856,
424
0.26978428189564774
425
])
426
# Ensure that we do not have excessive memory allocations
427
# (e.g., from type instabilities)
428
let
429
t = sol.t[end]
430
u_ode = sol.u[end]
431
du_ode = similar(u_ode)
432
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
433
end
434
end
435
436
@trixi_testset "elixir_euler_rayleigh_taylor_instability.jl" begin
437
@test_trixi_include(joinpath(EXAMPLES_DIR,
438
"elixir_euler_rayleigh_taylor_instability.jl"),
439
cells_per_dimension=(8, 8), tspan=(0.0, 0.2),
440
l2=[
441
0.07097806924106471,
442
0.005168545523460976,
443
0.013820905434253445,
444
0.03243358478653133
445
],
446
linf=[
447
0.4783395366569936,
448
0.022446258588973853,
449
0.04023354591166624,
450
0.08515791118082117
451
])
452
# Ensure that we do not have excessive memory allocations
453
# (e.g., from type instabilities)
454
let
455
t = sol.t[end]
456
u_ode = sol.u[end]
457
du_ode = similar(u_ode)
458
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
459
end
460
end
461
462
@trixi_testset "elixir_euler_brown_minion_vortex.jl" begin
463
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_brown_minion_vortex.jl"),
464
cells_per_dimension=4, tspan=(0.0, 0.1),
465
l2=[
466
0.006680001611078062,
467
0.02151676347585447,
468
0.010696524235364626,
469
0.15052841129694647
470
],
471
linf=[
472
0.01544756362800248,
473
0.09517304772476806,
474
0.021957154972646383,
475
0.33773439650806303
476
])
477
# Ensure that we do not have excessive memory allocations
478
# (e.g., from type instabilities)
479
let
480
t = sol.t[end]
481
u_ode = sol.u[end]
482
du_ode = similar(u_ode)
483
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
484
end
485
end
486
487
@trixi_testset "elixir_euler_shockcapturing.jl" begin
488
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing.jl"),
489
cells_per_dimension=4, tspan=(0.0, 0.1),
490
l2=[
491
0.05685180852320552,
492
0.04308097439005265,
493
0.04308097439005263,
494
0.21098250258804
495
],
496
linf=[
497
0.2360805191601203,
498
0.16684117462697776,
499
0.16684117462697767,
500
0.8573034682049414
501
])
502
# Ensure that we do not have excessive memory allocations
503
# (e.g., from type instabilities)
504
let
505
t = sol.t[end]
506
u_ode = sol.u[end]
507
du_ode = similar(u_ode)
508
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
509
end
510
end
511
512
@trixi_testset "elixir_euler_shockcapturing_curved.jl" begin
513
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_shockcapturing_curved.jl"),
514
cells_per_dimension=4, tspan=(0.0, 0.1),
515
l2=[
516
0.055659339125865195,
517
0.042323245380073364,
518
0.042323245380073315,
519
0.20642426004746467
520
],
521
linf=[
522
0.23633597150568753,
523
0.16929779869845438,
524
0.16929779869845438,
525
0.8587814448153765
526
])
527
# Ensure that we do not have excessive memory allocations
528
# (e.g., from type instabilities)
529
let
530
t = sol.t[end]
531
u_ode = sol.u[end]
532
du_ode = similar(u_ode)
533
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
534
end
535
end
536
537
@trixi_testset "elixir_euler_weakform.jl (FD SBP)" begin
538
using Trixi: SummationByPartsOperators, derivative_operator
539
global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
540
derivative_order = 1,
541
accuracy_order = 4,
542
xmin = 0.0, xmax = 1.0,
543
N = 12)
544
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
545
cells_per_dimension=(2, 2),
546
element_type=Quad(),
547
cfl=1.0,
548
approximation_type=D,
549
# division by 2.0 corresponds to normalization by the square root of the size of the domain
550
l2=[
551
0.0008966318978421226,
552
0.0011418826379110242,
553
0.001141882637910878,
554
0.0030918374335671393
555
] ./ 2.0,
556
linf=[
557
0.0015281525343109337,
558
0.00162430960401716,
559
0.0016243096040242655,
560
0.004447503691245913
561
])
562
# Ensure that we do not have excessive memory allocations
563
# (e.g., from type instabilities)
564
let
565
t = sol.t[end]
566
u_ode = sol.u[end]
567
du_ode = similar(u_ode)
568
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
569
end
570
end
571
572
@trixi_testset "elixir_euler_weakform.jl (FD SBP, EC)" begin
573
using Trixi: SummationByPartsOperators, derivative_operator
574
global D = derivative_operator(SummationByPartsOperators.MattssonNordström2004(),
575
derivative_order = 1,
576
accuracy_order = 4,
577
xmin = 0.0, xmax = 1.0,
578
N = 12)
579
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weakform.jl"),
580
cells_per_dimension=(2, 2),
581
element_type=Quad(),
582
cfl=1.0,
583
approximation_type=D,
584
volume_integral=VolumeIntegralFluxDifferencing(flux_ranocha),
585
surface_integral=SurfaceIntegralWeakForm(flux_ranocha),
586
# division by 2.0 corresponds to normalization by the square root of the size of the domain
587
l2=[
588
0.0014018725496871129,
589
0.0015887007320868913,
590
0.001588700732086329,
591
0.003870926821031202
592
] ./ 2.0,
593
linf=[
594
0.0029541996523780867,
595
0.0034520465226108854,
596
0.003452046522624652,
597
0.007677153211004928
598
])
599
# Ensure that we do not have excessive memory allocations
600
# (e.g., from type instabilities)
601
let
602
t = sol.t[end]
603
u_ode = sol.u[end]
604
du_ode = similar(u_ode)
605
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
606
end
607
end
608
609
@trixi_testset "elixir_euler_fdsbp_periodic.jl" begin
610
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
611
l2=[
612
1.333332033888785e-6, 2.044834627786368e-6,
613
2.0448346278315884e-6, 5.282189803437435e-6
614
],
615
linf=[
616
2.7000151703315822e-6, 3.988595025372632e-6,
617
3.9885950240403645e-6, 8.848583036513702e-6
618
])
619
# Ensure that we do not have excessive memory allocations
620
# (e.g., from type instabilities)
621
let
622
t = sol.t[end]
623
u_ode = sol.u[end]
624
du_ode = similar(u_ode)
625
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
626
end
627
end
628
629
@trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference domain)" begin
630
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
631
xmin=-200.0, xmax=100.0, #= parameters for reference interval =#
632
surface_flux=FluxHLL(min_max_speed_naive),
633
l2=[
634
1.333332034149886e-6,
635
2.0448346280892024e-6,
636
2.0448346279766305e-6,
637
5.282189803510037e-6
638
],
639
linf=[
640
2.700015170553627e-6,
641
3.988595024262409e-6,
642
3.988595024928543e-6,
643
8.84858303740188e-6
644
])
645
# Ensure that we do not have excessive memory allocations
646
# (e.g., from type instabilities)
647
let
648
t = sol.t[end]
649
u_ode = sol.u[end]
650
du_ode = similar(u_ode)
651
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
652
end
653
end
654
655
@trixi_testset "elixir_euler_fdsbp_periodic.jl (arbitrary reference and physical domains)" begin
656
using Trixi: periodic_derivative_operator
657
global D = periodic_derivative_operator(derivative_order = 1,
658
accuracy_order = 4,
659
xmin = -200.0,
660
xmax = 100.0,
661
N = 100)
662
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
663
approximation_type=D,
664
coordinates_min=(-3.0, -4.0), coordinates_max=(0.0, -1.0),
665
surface_flux=FluxHLL(min_max_speed_naive),
666
l2=[
667
0.07318831033918516,
668
0.10039910610067465,
669
0.1003991061006748,
670
0.2642450566234564
671
],
672
linf=[
673
0.36081081739439735,
674
0.5244468027020845,
675
0.5244468027020814,
676
1.2210130256735705
677
])
678
# Ensure that we do not have excessive memory allocations
679
# (e.g., from type instabilities)
680
let
681
t = sol.t[end]
682
u_ode = sol.u[end]
683
du_ode = similar(u_ode)
684
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
685
end
686
end
687
688
@trixi_testset "elixir_euler_fdsbp_periodic.jl (CGSEM)" begin
689
using Trixi: SummationByPartsOperators
690
D_local = SummationByPartsOperators.legendre_derivative_operator(xmin = 0.0,
691
xmax = 1.0,
692
N = 4)
693
mesh_local = SummationByPartsOperators.UniformPeriodicMesh1D(xmin = -1.0,
694
xmax = 1.0,
695
Nx = 10)
696
global D = SummationByPartsOperators.couple_continuously(D_local, mesh_local)
697
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_fdsbp_periodic.jl"),
698
approximation_type=D,
699
surface_flux=FluxHLL(min_max_speed_naive),
700
l2=[
701
1.5440402410017893e-5,
702
1.4913189903083485e-5,
703
1.4913189902797073e-5,
704
2.6104615985156992e-5
705
],
706
linf=[
707
4.16334345412217e-5,
708
5.067812788173143e-5,
709
5.067812786885284e-5,
710
9.887976803746312e-5
711
])
712
# Ensure that we do not have excessive memory allocations
713
# (e.g., from type instabilities)
714
let
715
t = sol.t[end]
716
u_ode = sol.u[end]
717
du_ode = similar(u_ode)
718
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
719
end
720
end
721
722
@trixi_testset "elixir_mhd_weak_blast_wave.jl (Quad)" begin
723
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"),
724
cells_per_dimension=4,
725
l2=[0.03906769915509508, 0.04923079758984701,
726
0.049230797589847136, 0.02660348840973283,
727
0.18054907061740028, 0.019195256934309846,
728
0.019195256934310016, 0.027856113419468087,
729
0.0016567799774264065],
730
linf=[0.16447597822733662, 0.244157345789029,
731
0.24415734578903472, 0.11982440036793476,
732
0.7450328339751362, 0.06357382685763713, 0.0635738268576378,
733
0.1058830287485999,
734
0.005740591170062146])
735
# Ensure that we do not have excessive memory allocations
736
# (e.g., from type instabilities)
737
let
738
t = sol.t[end]
739
u_ode = sol.u[end]
740
du_ode = similar(u_ode)
741
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
742
end
743
end
744
745
@trixi_testset "elixir_mhd_weak_blast_wave.jl (Tri)" begin
746
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_weak_blast_wave.jl"),
747
cells_per_dimension=4, element_type=Tri(),
748
l2=[0.03372468091254386, 0.03971626483409167,
749
0.03971626483409208, 0.021427571421535722,
750
0.15079331840847413, 0.015716300366650286,
751
0.015716300366652128, 0.022365252076279075,
752
0.0009232971979900358],
753
linf=[0.16290247390873458, 0.2256891306641319,
754
0.2256891306641336, 0.09476017042552534,
755
0.6906308908961734, 0.05349939593012487,
756
0.05349939593013042, 0.08830587480616725,
757
0.0029551359803035027])
758
# Ensure that we do not have excessive memory allocations
759
# (e.g., from type instabilities)
760
let
761
t = sol.t[end]
762
u_ode = sol.u[end]
763
du_ode = similar(u_ode)
764
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
765
end
766
end
767
768
@trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Quad)" begin
769
# These setups do not pass CI reliably, see
770
# https://github.com/trixi-framework/Trixi.jl/pull/880 and
771
# https://github.com/trixi-framework/Trixi.jl/issues/881
772
@test_skip @test_trixi_include(joinpath(EXAMPLES_DIR,
773
"elixir_mhd_weak_blast_wave_SBP.jl"),
774
cells_per_dimension=4,
775
# division by 2.0 corresponds to normalization by the square root of the size of the domain
776
l2=[0.15825983698241494, 0.19897219694837923,
777
0.19784182473275247, 0.10482833997417325,
778
0.7310752391255246, 0.07374056714564853,
779
0.07371172293240634, 0.10782032253431281,
780
0.004921676235111545] ./ 2.0,
781
linf=[0.1765644464978685, 0.2627803272865769,
782
0.26358136695848144, 0.12347681727447984,
783
0.7733289736898254, 0.06695360844467957,
784
0.06650382120802623, 0.10885097000919097,
785
0.007212567638078835])
786
end
787
788
@trixi_testset "elixir_mhd_weak_blast_wave_SBP.jl (Tri)" begin
789
# These setups do not pass CI reliably, see
790
# https://github.com/trixi-framework/Trixi.jl/pull/880 and
791
# https://github.com/trixi-framework/Trixi.jl/issues/881
792
@test_skip @test_trixi_include(joinpath(EXAMPLES_DIR,
793
"elixir_mhd_weak_blast_wave_SBP.jl"),
794
cells_per_dimension=4, element_type=Tri(),
795
tspan=(0.0, 0.2),
796
# division by 2.0 corresponds to normalization by the square root of the size of the domain
797
l2=[0.13825044764021147, 0.15472815448314997,
798
0.1549093274293255, 0.053103596213755405,
799
0.7246162776815603, 0.07730777596615901,
800
0.07733438386480523, 0.109893463921706,
801
0.00617678167062838] ./ 2.0,
802
linf=[0.22701306227317952, 0.2905255794821543,
803
0.2912409425436937, 0.08051361477962096,
804
1.0842974228656006, 0.07866000368926784,
805
0.0786646354518149, 0.1614896380292925,
806
0.010358210347485542])
807
end
808
809
@trixi_testset "elixir_mhd_reflective_wall.jl (Quad)" begin
810
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_reflective_wall.jl"),
811
cells_per_dimension=4,
812
l2=[
813
0.0036019562526881602,
814
0.0017340971255535853,
815
0.00837522167692243,
816
0.0,
817
0.028596802654003512,
818
0.0018573697892233679,
819
0.0020807798940528956,
820
0.0,
821
5.301259762428258e-5
822
],
823
linf=[
824
0.016925983823703028,
825
0.009369659529710701,
826
0.04145170727840005,
827
0.0,
828
0.1156990108418654,
829
0.009849648257876749,
830
0.011417088537145403,
831
0.0,
832
0.0002992621756946904
833
])
834
# Ensure that we do not have excessive memory allocations
835
# (e.g., from type instabilities)
836
let
837
t = sol.t[end]
838
u_ode = sol.u[end]
839
du_ode = similar(u_ode)
840
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
841
end
842
end
843
end
844
# Clean up afterwards: delete Trixi.jl output directory
845
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)
846
847
end # module
848
849