Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_parabolic_2d.jl
5582 views
1
module TestExamplesParabolic2D
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
isdir(outdir) && rm(outdir, recursive = true)
13
14
@testset "SemidiscretizationHyperbolicParabolic (2D)" begin
15
#! format: noindent
16
17
@trixi_testset "DGMulti 2D rhs_parabolic!" begin
18
using Trixi
19
dg = DGMulti(polydeg = 2, element_type = Quad(), approximation_type = Polynomial(),
20
surface_integral = SurfaceIntegralWeakForm(flux_central),
21
volume_integral = VolumeIntegralWeakForm())
22
cells_per_dimension = (2, 2)
23
mesh = DGMultiMesh(dg, cells_per_dimension)
24
25
# test with polynomial initial condition x^2 * y
26
# test if we recover the exact second derivative
27
initial_condition = (x, t, equations) -> SVector(x[1]^2 * x[2])
28
29
equations = LinearScalarAdvectionEquation2D(1.0, 1.0)
30
equations_parabolic = LaplaceDiffusion2D(1.0, equations)
31
32
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
33
initial_condition, dg;
34
boundary_conditions = (boundary_condition_periodic,
35
boundary_condition_periodic))
36
@trixi_test_nowarn show(stdout, semi)
37
@trixi_test_nowarn show(stdout, MIME"text/plain"(), semi)
38
@trixi_test_nowarn show(stdout, boundary_condition_do_nothing)
39
40
@test nvariables(semi) == nvariables(equations)
41
@test Base.ndims(semi) == Base.ndims(mesh)
42
@test Base.real(semi) == Base.real(dg)
43
44
ode = semidiscretize(semi, (0.0, 0.01))
45
u0 = similar(ode.u0)
46
Trixi.compute_coefficients!(u0, 0.0, semi)
47
@test u0 ode.u0
48
49
# test "do nothing" BC just returns first argument
50
@test boundary_condition_do_nothing(u0, nothing) == u0
51
52
(; cache, cache_parabolic, equations_parabolic) = semi
53
(; gradients) = cache_parabolic
54
for dim in eachindex(gradients)
55
fill!(gradients[dim], zero(eltype(gradients[dim])))
56
end
57
58
# unpack VectorOfArray
59
u0 = Base.parent(ode.u0)
60
t = 0.0
61
# pass in `boundary_condition_periodic` to skip boundary flux/integral evaluation
62
parabolic_scheme = semi.solver_parabolic
63
Trixi.calc_gradient!(gradients, u0, t, mesh, equations_parabolic,
64
boundary_condition_periodic, dg, parabolic_scheme,
65
cache, cache_parabolic)
66
(; x, y, xq, yq) = mesh.md
67
@test getindex.(gradients[1], 1) 2 * xq .* yq
68
@test getindex.(gradients[2], 1) xq .^ 2
69
70
u_flux = similar.(gradients)
71
Trixi.calc_parabolic_fluxes!(u_flux, u0, gradients, mesh,
72
equations_parabolic,
73
dg, cache, cache_parabolic)
74
@test u_flux[1] gradients[1]
75
@test u_flux[2] gradients[2]
76
77
du = similar(u0)
78
Trixi.calc_divergence!(du, u0, t, u_flux, mesh,
79
equations_parabolic,
80
boundary_condition_periodic,
81
dg, semi.solver_parabolic, cache, cache_parabolic)
82
Trixi.invert_jacobian!(du, mesh, equations_parabolic, dg, cache; scaling = 1.0)
83
@test getindex.(du, 1) 2 * y
84
end
85
86
@trixi_testset "DGMulti: elixir_advection_diffusion.jl" begin
87
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
88
"elixir_advection_diffusion.jl"),
89
cells_per_dimension=(4, 4), tspan=(0.0, 0.1),
90
l2=[0.2485803335154642],
91
linf=[1.079606969242132])
92
# Ensure that we do not have excessive memory allocations
93
# (e.g., from type instabilities)
94
@test_allocations(Trixi.rhs!, semi, sol, 1000)
95
# TODO: We would like to call
96
# @test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
97
# However, we currently observe allocations that shall we
98
# investigate and fix in a future PR.
99
let
100
t = sol.t[end]
101
u_ode = copy(sol.u[end])
102
du_ode = similar(u_ode)
103
Trixi.rhs_parabolic!(du_ode, u_ode, semi, t)
104
@test_broken (@allocated Trixi.rhs_parabolic!(du_ode, u_ode, semi, t) < 1000)
105
end
106
end
107
108
@trixi_testset "DGMulti: elixir_advection_diffusion_periodic.jl" begin
109
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
110
"elixir_advection_diffusion_periodic.jl"),
111
cells_per_dimension=(4, 4), tspan=(0.0, 0.1),
112
l2=[0.03180371984888462],
113
linf=[0.2136821621370909])
114
# Ensure that we do not have excessive memory allocations
115
# (e.g., from type instabilities)
116
@test_allocations(Trixi.rhs!, semi, sol, 1000)
117
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
118
end
119
120
@trixi_testset "DGMulti: elixir_advection_diffusion_nonperiodic.jl" begin
121
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
122
"elixir_advection_diffusion_nonperiodic.jl"),
123
cells_per_dimension=(4, 4), tspan=(0.0, 0.1),
124
l2=[0.002123168335604323],
125
linf=[0.00963640423513712])
126
# Ensure that we do not have excessive memory allocations
127
# (e.g., from type instabilities)
128
@test_allocations(Trixi.rhs!, semi, sol, 1000)
129
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
130
end
131
132
@trixi_testset "DGMulti: elixir_navierstokes_convergence.jl" begin
133
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
134
"elixir_navierstokes_convergence.jl"),
135
cells_per_dimension=(4, 4), tspan=(0.0, 0.1),
136
l2=[
137
0.0015355076237431118,
138
0.003384316785885901,
139
0.0036531858026850757,
140
0.009948436101649498
141
],
142
linf=[
143
0.005522560543588462,
144
0.013425258431728926,
145
0.013962115936715924,
146
0.027483099961148838
147
])
148
# Ensure that we do not have excessive memory allocations
149
# (e.g., from type instabilities)
150
@test_allocations(Trixi.rhs!, semi, sol, 1000)
151
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
152
end
153
154
@trixi_testset "DGMulti: elixir_navierstokes_convergence_curved.jl" begin
155
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
156
"elixir_navierstokes_convergence_curved.jl"),
157
cells_per_dimension=(4, 4), tspan=(0.0, 0.1),
158
l2=[
159
0.0042551020940351444,
160
0.011118489080358264,
161
0.011281831362358863,
162
0.035736565778376306
163
],
164
linf=[
165
0.015071709836357083,
166
0.04103131887989486,
167
0.03990424032494211,
168
0.13094018584692968
169
])
170
# Ensure that we do not have excessive memory allocations
171
# (e.g., from type instabilities)
172
@test_allocations(Trixi.rhs!, semi, sol, 1000)
173
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
174
end
175
176
@trixi_testset "DGMulti: elixir_navierstokes_lid_driven_cavity.jl" begin
177
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_2d",
178
"elixir_navierstokes_lid_driven_cavity.jl"),
179
cells_per_dimension=(4, 4), tspan=(0.0, 0.5),
180
l2=[
181
0.0002215612357465129,
182
0.028318325887331217,
183
0.009509168805093485,
184
0.028267893004691534
185
],
186
linf=[
187
0.0015622793960574644,
188
0.1488665309341318,
189
0.07163235778907852,
190
0.19472797949052278
191
])
192
# Ensure that we do not have excessive memory allocations
193
# (e.g., from type instabilities)
194
@test_allocations(Trixi.rhs!, semi, sol, 1000)
195
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
196
end
197
198
@trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl" begin
199
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
200
"elixir_advection_diffusion.jl"),
201
initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5,
202
l2=[4.0915532997994255e-6],
203
linf=[2.3040850347877395e-5])
204
# Ensure that we do not have excessive memory allocations
205
# (e.g., from type instabilities)
206
@test_allocations(Trixi.rhs!, semi, sol, 1000)
207
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
208
end
209
210
@trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl (Gauss-Legendre)" begin
211
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
212
"elixir_advection_diffusion.jl"),
213
solver=DGSEM(polydeg = 5, surface_flux = flux_lax_friedrichs,
214
basis_type = GaussLegendreBasis),
215
initial_refinement_level=2, tspan=(0.0, 0.4),
216
l2=[2.8254621369070895e-6], linf=[6.914648264633172e-6])
217
# Ensure that we do not have excessive memory allocations
218
# (e.g., from type instabilities)
219
@test_allocations(Trixi.rhs!, semi, sol, 1000)
220
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
221
end
222
223
@trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl (LDG)" begin
224
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
225
"elixir_advection_diffusion.jl"),
226
solver_parabolic=ParabolicFormulationLocalDG(),
227
initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=5,
228
l2=[6.193056910594806e-6], linf=[4.918855889635143e-5])
229
# Ensure that we do not have excessive memory allocations
230
# (e.g., from type instabilities)
231
@test_allocations(Trixi.rhs!, semi, sol, 1000)
232
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
233
end
234
235
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_gradient_source_terms.jl" begin
236
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
237
"elixir_advection_diffusion_gradient_source_terms.jl"),
238
initial_refinement_level=2, tspan=(0.0, 0.4), polydeg=3,
239
l2=[0.0015151641634070158], linf=[0.00956001376594895])
240
# Ensure that we do not have excessive memory allocations
241
# (e.g., from type instabilities)
242
@test_allocations(Trixi.rhs!, semi, sol, 1000)
243
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
244
end
245
246
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_gradient_source_terms.jl (Fixed timestep)" begin
247
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
248
"elixir_advection_diffusion_gradient_source_terms.jl"),
249
initial_refinement_level=2, tspan=(0.0, 0.4),
250
solver_parabolic=ParabolicFormulationBassiRebay1(), nu=1e-3,
251
stepsize_callback=TrivialCallback(), dt=1e-1,
252
l2=[0.0017395186758592685], linf=[0.007481527467476025])
253
# Ensure that we do not have excessive memory allocations
254
# (e.g., from type instabilities)
255
@test_allocations(Trixi.rhs!, semi, sol, 1000)
256
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
257
end
258
259
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_gradient_source_terms.jl" begin
260
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
261
"elixir_advection_diffusion_gradient_source_terms.jl"),
262
mesh=P4estMesh((4, 4), polydeg = 1,
263
coordinates_min = coordinates_min,
264
coordinates_max = coordinates_max,
265
periodicity = true),
266
tspan=(0.0, 0.4),
267
solver_parabolic=ParabolicFormulationBassiRebay1(), nu=1e-3,
268
stepsize_callback=TrivialCallback(), dt=1e-1,
269
l2=[0.0017395186758592685], linf=[0.007481527467476025])
270
# Ensure that we do not have excessive memory allocations
271
# (e.g., from type instabilities)
272
@test_allocations(Trixi.rhs!, semi, sol, 1000)
273
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
274
end
275
276
@trixi_testset "TreeMesh2D: elixir_advection_diffusion.jl (Refined mesh)" begin
277
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
278
"elixir_advection_diffusion.jl"),
279
tspan=(0.0, 0.0))
280
LLID = Trixi.local_leaf_cells(mesh.tree)
281
num_leaves = length(LLID)
282
@assert num_leaves % 8 == 0
283
Trixi.refine!(mesh.tree, LLID[1:Int(num_leaves / 8)])
284
tspan = (0.0, 1.5)
285
semi = SemidiscretizationHyperbolicParabolic(mesh,
286
(equations, equations_parabolic),
287
initial_condition, solver;
288
boundary_conditions = (boundary_conditions,
289
boundary_conditions_parabolic))
290
ode = semidiscretize(semi, tspan)
291
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
292
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)
293
sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol,
294
ode_default_options()..., callback = callbacks)
295
l2_error, linf_error = analysis_callback(sol)
296
@test l2_error [1.67452550744728e-6]
297
@test linf_error [7.905059166368744e-6]
298
299
# Ensure that we do not have excessive memory allocations
300
# (e.g., from type instabilities)
301
@test_allocations(Trixi.rhs!, semi, sol, 100)
302
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 100)
303
end
304
305
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_amr.jl" begin
306
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
307
"elixir_advection_diffusion_amr.jl"),
308
initial_refinement_level=2,
309
base_level=2,
310
med_level=3,
311
max_level=4,
312
l2=[0.0009662045510830027],
313
linf=[0.006121646998993091])
314
# Ensure that we do not have excessive memory allocations
315
# (e.g., from type instabilities)
316
@test_allocations(Trixi.rhs!, semi, sol, 1000)
317
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
318
end
319
320
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl" begin
321
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
322
"elixir_advection_diffusion_nonperiodic.jl"),
323
initial_refinement_level=2, tspan=(0.0, 0.1),
324
l2=[0.007646800618485118],
325
linf=[0.10067621050468958])
326
# Ensure that we do not have excessive memory allocations
327
# (e.g., from type instabilities)
328
@test_allocations(Trixi.rhs!, semi, sol, 1000)
329
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
330
end
331
332
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl (Gauss-Legendre)" begin
333
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
334
"elixir_advection_diffusion_nonperiodic.jl"),
335
solver=DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs,
336
basis_type = GaussLegendreBasis),
337
initial_refinement_level=2, tspan=(0.0, 0.1),
338
l2=[0.005916696880764326],
339
linf=[0.034212013224034776])
340
# Ensure that we do not have excessive memory allocations
341
# (e.g., from type instabilities)
342
@test_allocations(Trixi.rhs!, semi, sol, 1000)
343
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
344
end
345
346
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic_amr.jl" begin
347
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
348
"elixir_advection_diffusion_nonperiodic_amr.jl"),
349
tspan=(0.0, 0.01),
350
l2=[0.0007711488519400885],
351
linf=[0.015254743335726637])
352
# Ensure that we do not have excessive memory allocations
353
# (e.g., from type instabilities)
354
@test_allocations(Trixi.rhs!, semi, sol, 1000)
355
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
356
end
357
358
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic_amr.jl (LDG)" begin
359
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
360
"elixir_advection_diffusion_nonperiodic_amr.jl"),
361
solver_parabolic=ParabolicFormulationLocalDG(),
362
tspan=(0.0, 0.01),
363
l2=[0.000684755734524055],
364
linf=[0.01141444199847298])
365
# Ensure that we do not have excessive memory allocations
366
# (e.g., from type instabilities)
367
@test_allocations(Trixi.rhs!, semi, sol, 1000)
368
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
369
end
370
371
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_imex_operator.jl" begin
372
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
373
"elixir_advection_diffusion_imex_operator.jl"),
374
l2=[7.542670562162156e-8], linf=[3.972014046560446e-7])
375
# Ensure that we do not have excessive memory allocations
376
# (e.g., from type instabilities)
377
@test_allocations(Trixi.rhs!, semi, sol, 1000)
378
# Compile Trixi.rhs_parabolic! by calling it once before checking
379
# allocations
380
Trixi.rhs_parabolic!(similar(sol.u[end]), copy(sol.u[end]), semi, sol.t[end])
381
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
382
end
383
384
@trixi_testset "TreeMesh2D: elixir_advection_diffusion_nonperiodic.jl (LDG)" begin
385
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
386
"elixir_advection_diffusion_nonperiodic.jl"),
387
initial_refinement_level=2, tspan=(0.0, 0.1),
388
solver_parabolic=ParabolicFormulationLocalDG(),
389
l2=[0.007009146246373517], linf=[0.09535203925012649])
390
# Ensure that we do not have excessive memory allocations
391
# (e.g., from type instabilities)
392
@test_allocations(Trixi.rhs!, semi, sol, 1000)
393
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
394
end
395
396
@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl" begin
397
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
398
"elixir_navierstokes_convergence.jl"),
399
initial_refinement_level=2, tspan=(0.0, 0.1),
400
analysis_callback=AnalysisCallback(semi,
401
interval = analysis_interval,
402
extra_analysis_integrals = (energy_kinetic,
403
energy_internal,
404
enstrophy)),
405
l2=[
406
0.0021116725306624543,
407
0.003432235149083229,
408
0.003874252819605527,
409
0.012469246082535005
410
],
411
linf=[
412
0.012006418939279007,
413
0.03552087120962882,
414
0.02451274749189282,
415
0.11191122588626357
416
])
417
# Ensure that we do not have excessive memory allocations
418
# (e.g., from type instabilities)
419
@test_allocations(Trixi.rhs!, semi, sol, 1000)
420
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
421
end
422
423
@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (isothermal walls)" begin
424
using Trixi: Trixi
425
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
426
"elixir_navierstokes_convergence.jl"),
427
initial_refinement_level=2, tspan=(0.0, 0.1),
428
heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x,
429
t,
430
equations),
431
equations)),
432
l2=[
433
0.0021036296503840883,
434
0.003435843933397192,
435
0.003867359878114748,
436
0.012670355349293195
437
],
438
linf=[
439
0.01200626179308184,
440
0.03550212518997239,
441
0.025107947320178275,
442
0.11647078036751068
443
])
444
# Ensure that we do not have excessive memory allocations
445
# (e.g., from type instabilities)
446
@test_allocations(Trixi.rhs!, semi, sol, 1000)
447
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
448
end
449
450
@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables)" begin
451
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
452
"elixir_navierstokes_convergence.jl"),
453
initial_refinement_level=2, tspan=(0.0, 0.1),
454
gradient_variables=GradientVariablesEntropy(),
455
l2=[
456
0.002140374251729127,
457
0.003425828709496601,
458
0.0038915122887358097,
459
0.012506862342858291
460
],
461
linf=[
462
0.012244412004772665,
463
0.03507559186131113,
464
0.02458089234472249,
465
0.11425600758024679
466
])
467
# Ensure that we do not have excessive memory allocations
468
# (e.g., from type instabilities)
469
@test_allocations(Trixi.rhs!, semi, sol, 1000)
470
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
471
end
472
473
@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Entropy gradient variables, isothermal walls)" begin
474
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
475
"elixir_navierstokes_convergence.jl"),
476
initial_refinement_level=2, tspan=(0.0, 0.1),
477
gradient_variables=GradientVariablesEntropy(),
478
heat_bc_top_bottom=Isothermal((x, t, equations) -> Trixi.temperature(initial_condition_navier_stokes_convergence_test(x,
479
t,
480
equations),
481
equations)),
482
l2=[
483
0.0021349737347923716,
484
0.0034301388278178365,
485
0.0038928324473968836,
486
0.012693611436338
487
],
488
linf=[
489
0.012244236275761766,
490
0.03505406631430898,
491
0.025099598505644406,
492
0.11795616324985403
493
])
494
# Ensure that we do not have excessive memory allocations
495
# (e.g., from type instabilities)
496
@test_allocations(Trixi.rhs!, semi, sol, 1000)
497
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
498
end
499
500
@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (flux differencing)" begin
501
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
502
"elixir_navierstokes_convergence.jl"),
503
initial_refinement_level=2, tspan=(0.0, 0.1),
504
volume_integral=VolumeIntegralFluxDifferencing(flux_central),
505
l2=[
506
0.0021116725306612075,
507
0.0034322351490838703,
508
0.0038742528196011594,
509
0.012469246082545557
510
],
511
linf=[
512
0.012006418939262131,
513
0.0355208712096602,
514
0.024512747491999436,
515
0.11191122588669522
516
])
517
# Ensure that we do not have excessive memory allocations
518
# (e.g., from type instabilities)
519
@test_allocations(Trixi.rhs!, semi, sol, 1000)
520
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
521
end
522
523
@trixi_testset "TreeMesh2D: elixir_navierstokes_convergence.jl (Refined mesh)" begin
524
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
525
"elixir_navierstokes_convergence.jl"),
526
tspan=(0.0, 0.0), initial_refinement_level=3)
527
LLID = Trixi.local_leaf_cells(mesh.tree)
528
num_leaves = length(LLID)
529
@assert num_leaves % 4 == 0
530
Trixi.refine!(mesh.tree, LLID[1:Int(num_leaves / 4)])
531
tspan = (0.0, 0.5)
532
semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic),
533
initial_condition, solver;
534
boundary_conditions = (boundary_conditions,
535
boundary_conditions_parabolic),
536
source_terms = source_terms_navier_stokes_convergence_test)
537
ode = semidiscretize(semi, tspan)
538
analysis_callback = AnalysisCallback(semi, interval = analysis_interval)
539
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)
540
sol = solve(ode, RDPK3SpFSAL49(); abstol = time_int_tol, reltol = time_int_tol,
541
dt = 1e-5,
542
ode_default_options()..., callback = callbacks)
543
l2_error, linf_error = analysis_callback(sol)
544
@test l2_error
545
[0.00024296959174050973;
546
0.00020932631586399853;
547
0.0005390572390981241;
548
0.00026753561391316933]
549
@test linf_error
550
[0.0016210102053486608;
551
0.0025932876486537016;
552
0.0029539073438284817;
553
0.0020771191202548778]
554
# Ensure that we do not have excessive memory allocations
555
# (e.g., from type instabilities)
556
@test_allocations(Trixi.rhs!, semi, sol, 1000)
557
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
558
end
559
560
@trixi_testset "TreeMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin
561
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
562
"elixir_navierstokes_lid_driven_cavity.jl"),
563
initial_refinement_level=2, tspan=(0.0, 0.5),
564
l2=[
565
0.00015144571529699053,
566
0.018766076072331623,
567
0.007065070765652574,
568
0.0208399005734258
569
],
570
linf=[
571
0.0014523369373669048,
572
0.12366779944955864,
573
0.05532450997115432,
574
0.16099927805328207
575
])
576
# Ensure that we do not have excessive memory allocations
577
# (e.g., from type instabilities)
578
@test_allocations(Trixi.rhs!, semi, sol, 1000)
579
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
580
end
581
582
@trixi_testset "TreeMesh2D: elixir_navierstokes_shearlayer_amr.jl" begin
583
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
584
"elixir_navierstokes_shearlayer_amr.jl"),
585
l2=[
586
0.0003791330378826807,
587
0.09969310227471417,
588
0.021308426486134697,
589
0.09122052535455805
590
],
591
linf=[
592
0.001566286906820924,
593
0.6899677733045734,
594
0.0643250936249398,
595
0.5512608650028881
596
],
597
tspan=(0.0, 0.2))
598
# Ensure that we do not have excessive memory allocations
599
# (e.g., from type instabilities)
600
@test_allocations(Trixi.rhs!, semi, sol, 1000)
601
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
602
end
603
604
@trixi_testset "TreeMesh2D: elixir_navierstokes_shearlayer_nonconforming.jl" begin
605
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
606
"elixir_navierstokes_shearlayer_nonconforming.jl"),
607
l2=[
608
0.005392265705768764,
609
0.577092995962308,
610
0.6217677551929198,
611
1.18789128045329
612
],
613
linf=[
614
0.02761149200829227,
615
1.2597266873423871,
616
1.3269424500005702,
617
6.780348096271325
618
])
619
# Ensure that we do not have excessive memory allocations
620
# (e.g., from type instabilities)
621
@test_allocations(Trixi.rhs!, semi, sol, 1000)
622
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
623
end
624
625
@trixi_testset "TreeMesh2D: elixir_navierstokes_shearlayer_nonconforming.jl (LDG)" begin
626
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
627
"elixir_navierstokes_shearlayer_nonconforming.jl"),
628
solver_parabolic=ParabolicFormulationLocalDG(),
629
l2=[
630
0.005352370793583371,
631
0.5969444914287823,
632
0.6317300073130132,
633
1.1794786369127415
634
],
635
linf=[
636
0.027301485183723107,
637
1.418851037417376,
638
1.3376325628056016,
639
6.713351975092763
640
])
641
# Ensure that we do not have excessive memory allocations
642
# (e.g., from type instabilities)
643
@test_allocations(Trixi.rhs!, semi, sol, 1000)
644
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
645
end
646
647
@trixi_testset "TreeMesh2D: elixir_navierstokes_taylor_green_vortex_sutherland.jl" begin
648
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
649
"elixir_navierstokes_taylor_green_vortex_sutherland.jl"),
650
l2=[
651
0.001452856280034929,
652
0.0007538775539989481,
653
0.0007538775539988681,
654
0.011035506549989587
655
],
656
linf=[
657
0.003291912841311362,
658
0.002986462478096974,
659
0.0029864624780958637,
660
0.0231954665514138
661
],
662
tspan=(0.0, 1.0))
663
# Ensure that we do not have excessive memory allocations
664
# (e.g., from type instabilities)
665
@test_allocations(Trixi.rhs!, semi, sol, 1000)
666
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
667
end
668
669
@trixi_testset "TreeMesh2D: elixir_navierstokes_viscous_shock.jl" begin
670
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
671
"elixir_navierstokes_viscous_shock.jl"),
672
l2=[
673
2.817640352994614e-5,
674
1.3827801939742e-5,
675
3.1001993851549174e-17,
676
1.7535689010948764e-5
677
],
678
linf=[
679
0.0002185837290411552,
680
0.00013405261969601234,
681
1.8273738729889617e-16,
682
0.00015782934605046428
683
])
684
# Ensure that we do not have excessive memory allocations
685
# (e.g., from type instabilities)
686
@test_allocations(Trixi.rhs!, semi, sol, 1000)
687
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
688
end
689
690
@trixi_testset "TreeMesh2D: elixir_navierstokes_viscous_shock.jl (Gauss-Legendre, LDG)" begin
691
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
692
"elixir_navierstokes_viscous_shock.jl"),
693
solver=DGSEM(polydeg = 3, surface_flux = flux_hlle,
694
basis_type = GaussLegendreBasis),
695
solver_parabolic=ParabolicFormulationLocalDG(),
696
cfl_parabolic=0.04,
697
l2=[
698
6.599006355897759e-6,
699
4.514805201434994e-6,
700
6.54834144833621e-17,
701
4.882545625516753e-6
702
],
703
linf=[
704
3.7580718253771295e-5,
705
2.6691756676799905e-5,
706
3.560074538214949e-16,
707
2.989434893274634e-5
708
])
709
# Ensure that we do not have excessive memory allocations
710
# (e.g., from type instabilities)
711
@test_allocations(Trixi.rhs!, semi, sol, 1000)
712
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
713
end
714
715
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin
716
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
717
"elixir_advection_diffusion_periodic.jl"),
718
trees_per_dimension=(1, 1), initial_refinement_level=2,
719
tspan=(0.0, 0.5),
720
l2=[0.0023754695605828443],
721
linf=[0.008154128363741964])
722
# Ensure that we do not have excessive memory allocations
723
# (e.g., from type instabilities)
724
@test_allocations(Trixi.rhs!, semi, sol, 1000)
725
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
726
end
727
728
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin
729
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
730
"elixir_advection_diffusion_periodic.jl"),
731
trees_per_dimension=(1, 1), initial_refinement_level=2,
732
tspan=(0.0, 0.5),
733
l2=[0.0023754695605828443],
734
linf=[0.008154128363741964])
735
# Ensure that we do not have excessive memory allocations
736
# (e.g., from type instabilities)
737
@test_allocations(Trixi.rhs!, semi, sol, 1000)
738
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
739
end
740
741
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_rotated.jl" begin
742
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
743
"elixir_advection_diffusion_rotated.jl"),
744
l2=[4.8533724384822306e-5], linf=[0.0006284491001110615])
745
# Ensure that we do not have excessive memory allocations
746
# (e.g., from type instabilities)
747
@test_allocations(Trixi.rhs!, semi, sol, 1000)
748
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
749
end
750
751
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_curved.jl" begin
752
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
753
"elixir_advection_diffusion_periodic_curved.jl"),
754
trees_per_dimension=(1, 1), initial_refinement_level=2,
755
tspan=(0.0, 0.5),
756
l2=[0.006708147442490916],
757
linf=[0.04807038397976693])
758
# Ensure that we do not have excessive memory allocations
759
# (e.g., from type instabilities)
760
@test_allocations(Trixi.rhs!, semi, sol, 1000)
761
end
762
763
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic_amr.jl" begin
764
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
765
"elixir_advection_diffusion_periodic_amr.jl"),
766
tspan=(0.0, 0.01),
767
l2=[4.49813737871379e-5],
768
linf=[0.0001874702347290924])
769
# Ensure that we do not have excessive memory allocations
770
# (e.g., from type instabilities)
771
@test_allocations(Trixi.rhs!, semi, sol, 1000)
772
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
773
end
774
775
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_amr.jl" begin
776
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
777
"elixir_advection_diffusion_nonperiodic_amr.jl"),
778
tspan=(0.0, 0.01),
779
l2=[0.0007711488519390165],
780
linf=[0.015254743335703765])
781
# Ensure that we do not have excessive memory allocations
782
# (e.g., from type instabilities)
783
@test_allocations(Trixi.rhs!, semi, sol, 1000)
784
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
785
end
786
787
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_amr.jl (Parabolic CFL)" begin
788
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
789
"elixir_advection_diffusion_nonperiodic_amr.jl"),
790
initial_refinement_level=2,
791
callbacks=CallbackSet(summary_callback, analysis_callback,
792
alive_callback,
793
StepsizeCallback(cfl = 1.6,
794
cfl_parabolic = 0.2)),
795
ode_alg=CarpenterKennedy2N54(williamson_condition = false),
796
dt=1.0, # will be overwritten
797
l2=[0.00010850375815619432],
798
linf=[0.0024081141187764932])
799
# Ensure that we do not have excessive memory allocations
800
# (e.g., from type instabilities)
801
@test_allocations(Trixi.rhs!, semi, sol, 1000)
802
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
803
end
804
805
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_amr.jl (LDG)" begin
806
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
807
"elixir_advection_diffusion_nonperiodic_amr.jl"),
808
solver_parabolic=ParabolicFormulationLocalDG(),
809
tspan=(0.0, 0.01),
810
l2=[0.0006847533999311489],
811
linf=[0.01141430509080712])
812
# Ensure that we do not have excessive memory allocations
813
# (e.g., from type instabilities)
814
@test_allocations(Trixi.rhs!, semi, sol, 1000)
815
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
816
end
817
818
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_curved.jl" begin
819
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
820
"elixir_advection_diffusion_nonperiodic_curved.jl"),
821
trees_per_dimension=(1, 1), initial_refinement_level=2,
822
tspan=(0.0, 0.5),
823
l2=[0.00919917034843865],
824
linf=[0.14186297438393505])
825
# Ensure that we do not have excessive memory allocations
826
# (e.g., from type instabilities)
827
@test_allocations(Trixi.rhs!, semi, sol, 1000)
828
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
829
end
830
831
@trixi_testset "P4estMesh2D: elixir_navierstokes_convergence.jl" begin
832
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
833
"elixir_navierstokes_convergence.jl"),
834
initial_refinement_level=1, tspan=(0.0, 0.2),
835
l2=[
836
0.0003811978986531135,
837
0.0005874314969137914,
838
0.0009142898787681551,
839
0.0011613918893790497
840
],
841
linf=[
842
0.0021633623985426453,
843
0.009484348273965089,
844
0.0042315720663082534,
845
0.011661660264076446
846
])
847
# Ensure that we do not have excessive memory allocations
848
# (e.g., from type instabilities)
849
@test_allocations(Trixi.rhs!, semi, sol, 1000)
850
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
851
end
852
853
@trixi_testset "P4estMesh2D: elixir_navierstokes_convergence_nonperiodic.jl" begin
854
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
855
"elixir_navierstokes_convergence_nonperiodic.jl"),
856
initial_refinement_level=1, tspan=(0.0, 0.2),
857
l2=[
858
0.0004036496258545996,
859
0.0005869762480189079,
860
0.0009148853742181908,
861
0.0011984191532764543
862
],
863
linf=[
864
0.0024993634989209923,
865
0.009487866203496731,
866
0.004505829506103787,
867
0.011634902753554499
868
])
869
# Ensure that we do not have excessive memory allocations
870
# (e.g., from type instabilities)
871
@test_allocations(Trixi.rhs!, semi, sol, 1000)
872
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
873
end
874
875
@trixi_testset "P4estMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin
876
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
877
"elixir_navierstokes_lid_driven_cavity.jl"),
878
initial_refinement_level=2, tspan=(0.0, 0.5),
879
l2=[
880
0.00028716166408816073,
881
0.08101204560401647,
882
0.02099595625377768,
883
0.05008149754143295
884
],
885
linf=[
886
0.014804500261322406,
887
0.9513271652357098,
888
0.7223919625994717,
889
1.4846907331004786
890
])
891
# Ensure that we do not have excessive memory allocations
892
# (e.g., from type instabilities)
893
@test_allocations(Trixi.rhs!, semi, sol, 1000)
894
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
895
end
896
897
@trixi_testset "P4estMesh2D: elixir_navierstokes_lid_driven_cavity_amr.jl" begin
898
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
899
"elixir_navierstokes_lid_driven_cavity_amr.jl"),
900
tspan=(0.0, 1.0),
901
l2=[
902
0.0005305062668392406, 0.07898766423138423,
903
0.02928291476915143, 0.11715767702870489
904
],
905
linf=[
906
0.005950675379011616, 0.9254051903170974,
907
0.7991033306362262, 1.694659748457326
908
])
909
# Ensure that we do not have excessive memory allocations
910
# (e.g., from type instabilities)
911
@test_allocations(Trixi.rhs!, semi, sol, 1000)
912
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
913
end
914
915
@trixi_testset "P4estMesh2D: elixir_navierstokes_lid_driven_cavity_amr.jl" begin
916
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
917
"elixir_navierstokes_lid_driven_cavity_amr.jl"),
918
tspan=(0.0, 2.5),
919
amr_indicator=IndicatorNodalFunction((u, x, t) -> ((x[1] <
920
sin(π * t)) &&
921
(x[2] <
922
sin(π * t))) ?
923
1.0 : 0.0,
924
semi),
925
l2=[
926
0.000751796085921976,
927
0.10544344448905413,
928
0.05559123730159854,
929
0.13538844542176662
930
],
931
linf=[
932
0.018687948537448595,
933
0.9693988005334362,
934
0.6314735963971362,
935
1.9961130828380647
936
],
937
atol=1e-4,
938
rtol=1e-6)
939
# Ensure that the mesh size did not change to test IndicatorNodalFunction
940
#expected N_ele(t=2.5) = 576, N_ele(t=5) = 303, N_ele(t=7.5) = 51, N_ele(t=10) = 111
941
@test nelements(semi.cache.elements) == 576
942
# Ensure that we do not have excessive memory allocations
943
# (e.g., from type instabilities)
944
@test_allocations(Trixi.rhs!, semi, sol, 1000)
945
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
946
end
947
948
@trixi_testset "P4estMesh2D: elixir_navierstokes_shearlayer_nonconforming.jl" begin
949
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
950
"elixir_navierstokes_shearlayer_nonconforming.jl"),
951
l2=[
952
0.005392265705780167,
953
0.5770929959613263,
954
0.6217677551915209,
955
1.1878912804557846
956
],
957
linf=[
958
0.027611492008346672,
959
1.2597266873187805,
960
1.3269424500029385,
961
6.7803480962822675
962
])
963
# Ensure that we do not have excessive memory allocations
964
# (e.g., from type instabilities)
965
@test_allocations(Trixi.rhs!, semi, sol, 1000)
966
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
967
end
968
969
@trixi_testset "P4estMesh2D: elixir_navierstokes_shearlayer_nonconforming.jl (LDG)" begin
970
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
971
"elixir_navierstokes_shearlayer_nonconforming.jl"),
972
solver_parabolic=ParabolicFormulationLocalDG(),
973
l2=[
974
0.0053523707935916025,
975
0.5969444914278867,
976
0.6317300073116101,
977
1.1794786369145007
978
],
979
linf=[
980
0.027301485183779173,
981
1.4188510374095429,
982
1.3376325628060792,
983
6.7133519750896085
984
])
985
# Ensure that we do not have excessive memory allocations
986
# (e.g., from type instabilities)
987
@test_allocations(Trixi.rhs!, semi, sol, 1000)
988
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
989
end
990
991
@trixi_testset "elixir_navierstokes_NACA0012airfoil_mach08.jl" begin
992
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
993
"elixir_navierstokes_NACA0012airfoil_mach08.jl"),
994
l2=[0.000186486564226516,
995
0.0005076712323400374,
996
0.00038074588984354107,
997
0.002128177239782089],
998
linf=[0.5153387072802718,
999
1.199362305026636,
1000
0.9077214424040279,
1001
5.666071182328691], tspan=(0.0, 0.001),
1002
initial_refinement_level=0)
1003
1004
u_ode = copy(sol.u[end])
1005
du_ode = zero(u_ode) # Just a placeholder in this case
1006
1007
u = Trixi.wrap_array(u_ode, semi)
1008
du = Trixi.wrap_array(du_ode, semi)
1009
1010
drag_p = Trixi.analyze(drag_coefficient, du, u, tspan[2], mesh, equations, solver,
1011
semi.cache, semi)
1012
lift_p = Trixi.analyze(lift_coefficient, du, u, tspan[2], mesh, equations, solver,
1013
semi.cache, semi)
1014
1015
drag_f = Trixi.analyze(drag_coefficient_shear_force, du, u, tspan[2], mesh,
1016
equations, equations_parabolic, solver,
1017
semi.cache, semi, semi.cache_parabolic)
1018
lift_f = Trixi.analyze(lift_coefficient_shear_force, du, u, tspan[2], mesh,
1019
equations, equations_parabolic, solver,
1020
semi.cache, semi, semi.cache_parabolic)
1021
1022
@test isapprox(drag_p, 0.17963843913309516, atol = 1e-13)
1023
@test isapprox(lift_p, 0.26462588007949367, atol = 1e-13)
1024
1025
@test isapprox(drag_f, 1.5427441885921553, atol = 1e-13)
1026
@test isapprox(lift_f, 0.005621910087395724, atol = 1e-13)
1027
1028
# Ensure that we do not have excessive memory allocations
1029
# (e.g., from type instabilities)
1030
# We move these tests here to avoid modifying values used
1031
# to compute the drag/lift coefficients above.
1032
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1033
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1034
end
1035
1036
@trixi_testset "elixir_navierstokes_NACA0012airfoil_mach085_restart.jl" begin
1037
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1038
"elixir_navierstokes_NACA0012airfoil_mach085_restart.jl"),
1039
l2=[
1040
6.18393805678897e-6,
1041
0.00011581268033979716,
1042
0.00011900457244798095,
1043
0.006464813560434434
1044
],
1045
linf=[
1046
0.0017386607519724257,
1047
0.07164832711649055,
1048
0.03699801158450292,
1049
1.4385095221954427
1050
], tspan=(0.0, 0.01))
1051
# Ensure that we do not have excessive memory allocations
1052
# (e.g., from type instabilities)
1053
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1054
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1055
end
1056
1057
@trixi_testset "P4estMesh2D: elixir_navierstokes_viscous_shock.jl" begin
1058
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1059
"elixir_navierstokes_viscous_shock.jl"),
1060
l2=[
1061
0.0002576236264053728,
1062
0.00014336949098706463,
1063
7.189100338239794e-17,
1064
0.00017369905124642074
1065
],
1066
linf=[
1067
0.0016731940983241156,
1068
0.0010638640749656147,
1069
5.59044079947959e-16,
1070
0.001149532023891009
1071
])
1072
# Ensure that we do not have excessive memory allocations
1073
# (e.g., from type instabilities)
1074
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1075
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1076
end
1077
1078
@trixi_testset "P4estMesh2D: elixir_navierstokes_viscous_shock_newton_krylov.jl" begin
1079
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1080
"elixir_navierstokes_viscous_shock_newton_krylov.jl"),
1081
tspan=(0.0, 0.1),
1082
atol_lin_solve=1e-11,
1083
rtol_lin_solve=1e-11,
1084
atol_ode_solve=1e-10,
1085
rtol_ode_solve=1e-10,
1086
l2=[
1087
3.428501006908931e-5,
1088
2.5967418005884837e-5,
1089
2.7084890458524478e-17,
1090
2.855861765163304e-5
1091
],
1092
linf=[
1093
0.00018762342908784646,
1094
0.0001405900207752664,
1095
3.661971738081151e-16,
1096
0.00014510700486747297
1097
])
1098
# Ensure that we do not have excessive memory allocations
1099
# (e.g., from type instabilities)
1100
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1101
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1102
end
1103
1104
@trixi_testset "elixir_navierstokes_SD7003airfoil.jl" begin
1105
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1106
"elixir_navierstokes_SD7003airfoil.jl"),
1107
l2=[
1108
9.292899618740586e-5,
1109
0.0001350510200255721,
1110
7.964907891113045e-5,
1111
0.0002336568736996096
1112
],
1113
linf=[
1114
0.2845637352223691,
1115
0.295808392241858,
1116
0.19309201225626166,
1117
0.7188927326929244
1118
],
1119
tspan=(0.0, 5e-3))
1120
# Ensure that we do not have excessive memory allocations
1121
# (e.g., from type instabilities)
1122
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1123
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1124
end
1125
1126
@trixi_testset "elixir_navierstokes_SD7003airfoil.jl (CFL-Interval)" begin
1127
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1128
"elixir_navierstokes_SD7003airfoil.jl"),
1129
l2=[
1130
9.292895651912815e-5,
1131
0.0001350510066877861,
1132
7.964905098170568e-5,
1133
0.00023365678706785303
1134
],
1135
linf=[
1136
0.2845614660523972,
1137
0.29577255454711177,
1138
0.19307666048254143,
1139
0.7188872358580256
1140
],
1141
tspan=(0.0, 5e-3),
1142
stepsize_callback=StepsizeCallback(cfl = 2.2, interval = 5))
1143
# Ensure that we do not have excessive memory allocations
1144
# (e.g., from type instabilities)
1145
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1146
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1147
end
1148
1149
@trixi_testset "elixir_navierstokes_RAE2822airfoil_separation.jl" begin
1150
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1151
"elixir_navierstokes_RAE2822airfoil_separation.jl"),
1152
l2=[
1153
4.825503683000652e-5,
1154
5.9311607940124866e-5,
1155
4.275960940632988e-5,
1156
0.00013394505065590255
1157
],
1158
linf=[
1159
1.303552961776984,
1160
1.1021933490327356,
1161
0.8733558923919265,
1162
3.6025810936812412
1163
],
1164
tspan=(0.0, 5e-5))
1165
# Ensure that we do not have excessive memory allocations
1166
# (e.g., from type instabilities)
1167
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1168
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1169
end
1170
1171
@trixi_testset "elixir_navierstokes_vortex_street.jl" begin
1172
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1173
"elixir_navierstokes_vortex_street.jl"),
1174
tspan=(0.0, 0.5),
1175
Re=20, # Render flow diffusion-dominated
1176
callbacks=CallbackSet(summary_callback, analysis_callback,
1177
alive_callback,
1178
StepsizeCallback(cfl = 2.3,
1179
cfl_parabolic = 1.0)),
1180
adaptive=false, # respect CFL
1181
ode_alg=CKLLSRK95_4S(),
1182
l2=[
1183
0.011916725799140692,
1184
0.027926098816747836,
1185
0.01902700347912797,
1186
0.11793406377747188
1187
],
1188
linf=[
1189
0.3546113252441576,
1190
1.0152021857472098,
1191
0.5811488174143082,
1192
3.207373092525428
1193
])
1194
# Ensure that we do not have excessive memory allocations
1195
# (e.g., from type instabilities)
1196
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1197
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1198
end
1199
1200
@trixi_testset "elixir_navierstokes_vortex_street.jl" begin
1201
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1202
"elixir_navierstokes_vortex_street.jl"),
1203
l2=[
1204
0.012420217727434794,
1205
0.028935260981567217,
1206
0.023078384429351353,
1207
0.11317643179072025
1208
],
1209
linf=[
1210
0.4484833725983406,
1211
1.268913882714608,
1212
0.7071821629898418,
1213
3.643975012834931
1214
],
1215
tspan=(0.0, 1.0))
1216
# Ensure that we do not have excessive memory allocations
1217
# (e.g., from type instabilities)
1218
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1219
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1220
end
1221
1222
@trixi_testset "elixir_navierstokes_vortex_street.jl (GradientVariablesEntropy)" begin
1223
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1224
"elixir_navierstokes_vortex_street.jl"),
1225
gradient_variables=GradientVariablesEntropy(),
1226
l2=[
1227
0.01242797973116292,
1228
0.02892502142448505,
1229
0.0230829131666028,
1230
0.11323126134096527
1231
],
1232
linf=[
1233
0.4544189333202735,
1234
1.269315313304855,
1235
0.7082067255956892,
1236
3.6951068269010645
1237
],
1238
tspan=(0.0, 1.0))
1239
# Ensure that we do not have excessive memory allocations
1240
# (e.g., from type instabilities)
1241
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1242
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1243
end
1244
1245
@trixi_testset "elixir_navierstokes_poiseuille_flow.jl" begin
1246
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1247
"elixir_navierstokes_poiseuille_flow.jl"),
1248
l2=[
1249
0.028671228188785286,
1250
0.2136420195921885,
1251
0.009953689550858224,
1252
0.13216036594768157
1253
],
1254
linf=[
1255
0.30901218409540543,
1256
1.3488655161645846,
1257
0.1304661713119874,
1258
1.2094591729756736],
1259
tspan=(0.0, 1.0))
1260
# Ensure that we do not have excessive memory allocations
1261
# (e.g., from type instabilities)
1262
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1263
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1264
end
1265
1266
@trixi_testset "elixir_navierstokes_kelvin_helmholtz_instability_sc_subcell.jl" begin
1267
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
1268
"elixir_navierstokes_kelvin_helmholtz_instability_sc_subcell.jl"),
1269
l2=[
1270
0.1987691550257618,
1271
0.1003336666735962,
1272
0.1599420846677608,
1273
0.07314642823482713
1274
],
1275
linf=[
1276
0.8901520920065688,
1277
0.47421178500575756,
1278
0.38859478648621326,
1279
0.3247497921546598
1280
],
1281
tspan=(0.0, 1.0))
1282
# Ensure that we do not have excessive memory allocations
1283
# (e.g., from type instabilities)
1284
# Larger values for allowed allocations due to usage of custom
1285
# integrator which are not *recorded* for the methods from
1286
# OrdinaryDiffEq.jl
1287
# Corresponding issue: https://github.com/trixi-framework/Trixi.jl/issues/1877
1288
@test_allocations(Trixi.rhs!, semi, sol, 15000)
1289
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 20_500)
1290
end
1291
1292
@trixi_testset "elixir_navierstokes_freestream_symmetry.jl" begin
1293
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1294
"elixir_navierstokes_freestream_symmetry.jl"),
1295
l2=[
1296
4.37868326434923e-15,
1297
7.002449644031901e-16,
1298
1.0986677074164136e-14,
1299
1.213800745067394e-14
1300
],
1301
linf=[
1302
2.531308496145357e-14,
1303
3.8367543336926215e-15,
1304
4.9960036108132044e-14,
1305
6.705747068735946e-14
1306
])
1307
# Ensure that we do not have excessive memory allocations
1308
# (e.g., from type instabilities)
1309
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1310
end
1311
1312
@trixi_testset "elixir_navierstokes_freestream_ldg.jl" begin
1313
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1314
"elixir_navierstokes_freestream_ldg.jl"),
1315
tspan=(0.0, 0.2),
1316
l2=[
1317
9.421780256792343e-17,
1318
3.597722377997839e-15,
1319
4.626519294383959e-15,
1320
1.4160796757846855e-13
1321
],
1322
linf=[
1323
1.5543122344752192e-15,
1324
1.2378986724570495e-13,
1325
1.7111312367035225e-13,
1326
1.5727863456049818e-11
1327
])
1328
# Ensure that we do not have excessive memory allocations
1329
# (e.g., from type instabilities)
1330
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1331
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1332
end
1333
1334
@trixi_testset "elixir_navierstokes_couette_flow.jl" begin
1335
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1336
"elixir_navierstokes_couette_flow.jl"),
1337
l2=[
1338
0.009585252225488753,
1339
0.007939233099864973,
1340
0.0007617512688442657,
1341
0.027229870237669436
1342
],
1343
linf=[
1344
0.027230029149270862,
1345
0.027230451118692933,
1346
0.0038642959675975713,
1347
0.04738248734987671
1348
])
1349
# Ensure that we do not have excessive memory allocations
1350
# (e.g., from type instabilities)
1351
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1352
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1353
end
1354
1355
@trixi_testset "elixir_navierstokes_blast_reflective.jl" begin
1356
@test_trixi_include(joinpath(EXAMPLES_DIR, "p4est_2d_dgsem",
1357
"elixir_navierstokes_blast_reflective.jl"),
1358
l2=[
1359
0.013077652405653456,
1360
0.03267271241679693,
1361
0.03267271241679689,
1362
0.19993587690609887
1363
],
1364
linf=[
1365
0.232863088636711,
1366
0.5958991303183211,
1367
0.5958991303183204,
1368
3.0621202120365467
1369
],
1370
tspan=(0.0, 0.01),
1371
sol=solve(ode, ode_alg;
1372
adaptive = false, dt = 1e-4,
1373
ode_default_options()..., callback = callbacks))
1374
# Ensure that we do not have excessive memory allocations
1375
# (e.g., from type instabilities)
1376
@test_allocations(Trixi.rhs!, semi, sol, 1000)
1377
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1378
end
1379
end
1380
1381
@testset "SemidiscretizationParabolic (2D)" begin
1382
#! format: noindent
1383
1384
@trixi_testset "TreeMesh2D: elixir_diffusion_steady_state_linear_map.jl" begin
1385
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_2d_dgsem",
1386
"elixir_diffusion_steady_state_linear_map.jl"),
1387
tspan=(0.0, 1.0e-4),
1388
analysis_callback=AnalysisCallback(semi,
1389
interval = 1,
1390
extra_analysis_errors = (:l2_error_primitive,
1391
:linf_error_primitive),
1392
extra_analysis_integrals = (entropy,)),
1393
l2=[2.9029827892716424e-5], linf=[0.0003022506331279151],
1394
# Relax error tols to avoid stochastic CI failures
1395
atol=1e-10)
1396
# Ensure that we do not have excessive memory allocations
1397
# (e.g., from type instabilities)
1398
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
1399
end
1400
end
1401
1402
# Clean up afterwards: delete Trixi.jl output directory
1403
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)
1404
1405
end # module
1406
1407