Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_parabolic_1d.jl
5582 views
1
module TestExamplesParabolic1D
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 output directory if it exists
11
outdir = "out"
12
isdir(outdir) && rm(outdir, recursive = true)
13
14
@testset "SemidiscretizationHyperbolicParabolic (1D)" begin
15
#! format: noindent
16
17
@trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl" begin
18
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
19
"elixir_advection_diffusion.jl"),
20
initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3,
21
l2=[8.40483031802723e-6],
22
linf=[2.8990878868540015e-5])
23
# Ensure that we do not have excessive memory allocations
24
# (e.g., from type instabilities)
25
@test_allocations(Trixi.rhs!, semi, sol, 1000)
26
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
27
end
28
29
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_ldg.jl" begin
30
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
31
"elixir_advection_diffusion_ldg.jl"),
32
initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3,
33
l2=[9.234438322146518e-6], linf=[5.425491770139068e-5])
34
# Ensure that we do not have excessive memory allocations
35
# (e.g., from type instabilities)
36
@test_allocations(Trixi.rhs!, semi, sol, 1000)
37
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
38
end
39
40
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_ldg.jl" begin
41
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
42
"elixir_advection_diffusion_ldg.jl"),
43
solver=DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs,
44
basis_type = GaussLegendreBasis),
45
tspan=(0.0, 0.4),
46
l2=[4.126471023759558e-6], linf=[1.4470099431229677e-5])
47
# Ensure that we do not have excessive memory allocations
48
# (e.g., from type instabilities)
49
@test_allocations(Trixi.rhs!, semi, sol, 1000)
50
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
51
end
52
53
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_gradient_source_terms.jl" begin
54
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
55
"elixir_advection_diffusion_gradient_source_terms.jl"),
56
initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3,
57
l2=[1.0990454698899562e-5], linf=[6.469747978055107e-5])
58
# Ensure that we do not have excessive memory allocations
59
# (e.g., from type instabilities)
60
@test_allocations(Trixi.rhs!, semi, sol, 1000)
61
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
62
end
63
64
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_restart.jl" begin
65
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
66
"elixir_advection_diffusion_restart.jl"),
67
l2=[1.0679933947301556e-5],
68
linf=[3.910500545667439e-5])
69
# Ensure that we do not have excessive memory allocations
70
# (e.g., from type instabilities)
71
@test_allocations(Trixi.rhs!, semi, sol, 1000)
72
end
73
74
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_cfl.jl" begin
75
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
76
"elixir_advection_diffusion_cfl.jl"),
77
l2=[6.763177530985864e-5], linf=[0.0002344578097126515])
78
# Ensure that we do not have excessive memory allocations
79
# (e.g., from type instabilities)
80
@test_allocations(Trixi.rhs!, semi, sol, 1000)
81
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
82
end
83
84
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_dirichlet_amr.jl" begin
85
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
86
"elixir_advection_diffusion_dirichlet_amr.jl"),
87
l2=[3.668679081538521e-6], linf=[0.0001053981743872842])
88
# Ensure that we do not have excessive memory allocations
89
# (e.g., from type instabilities)
90
@test_allocations(Trixi.rhs!, semi, sol, 1000)
91
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
92
end
93
94
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_neumann_amr.jl" begin
95
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
96
"elixir_advection_diffusion_neumann_amr.jl"),
97
l2=[0.9974473329813947], linf=[1.0000064761980827])
98
# Ensure that we do not have excessive memory allocations
99
# (e.g., from type instabilities)
100
@test_allocations(Trixi.rhs!, semi, sol, 1000)
101
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
102
end
103
104
@trixi_testset "TreeMesh1D: elixir_advection_diffusion.jl (AMR)" begin
105
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
106
"elixir_advection_diffusion.jl"),
107
tspan=(0.0, 0.0), initial_refinement_level=5)
108
tspan = (0.0, 1.0)
109
ode = semidiscretize(semi, tspan)
110
amr_controller = ControllerThreeLevel(semi, IndicatorMax(semi, variable = first),
111
base_level = 4,
112
med_level = 5, med_threshold = 0.1,
113
max_level = 6, max_threshold = 0.6)
114
amr_callback = AMRCallback(semi, amr_controller,
115
interval = 5,
116
adapt_initial_condition = true)
117
118
# Create a CallbackSet to collect all callbacks such that they can be passed to the ODE solver
119
callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback,
120
amr_callback)
121
sol = solve(ode, ode_alg;
122
abstol = time_abs_tol, reltol = time_int_tol,
123
ode_default_options()..., callback = callbacks)
124
l2_error, linf_error = analysis_callback(sol)
125
@test l2_error [6.487940740394583e-6]
126
@test linf_error [3.262867898701227e-5]
127
# Ensure that we do not have excessive memory allocations
128
# (e.g., from type instabilities)
129
@test_allocations(Trixi.rhs!, semi, sol, 1000)
130
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
131
end
132
133
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_implicit_sparse_jacobian.jl" begin
134
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
135
"elixir_advection_diffusion_implicit_sparse_jacobian.jl"),
136
tspan=(0.0, 0.4),
137
l2=[0.05240130204342638], linf=[0.07407444680136666])
138
# Ensure that we do not have excessive memory allocations
139
# (e.g., from type instabilities)
140
@test_allocations(Trixi.rhs!, semi, sol, 1000)
141
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
142
end
143
144
@trixi_testset "TreeMesh1D: elixir_advection_diffusion_implicit_sparse_jacobian_restart.jl" begin
145
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
146
"elixir_advection_diffusion_implicit_sparse_jacobian_restart.jl"),
147
l2=[0.08292233849124372], linf=[0.11726345328639576])
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 "elixir_advection_implicit_sparse_jacobian_restart.jl (no colorvec)" begin
155
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
156
"elixir_advection_diffusion_implicit_sparse_jacobian_restart.jl"),
157
colorvec_parabolic=nothing,
158
l2=[0.08292233849124372], linf=[0.11726345328639576])
159
# Ensure that we do not have excessive memory allocations
160
# (e.g., from type instabilities)
161
@test_allocations(Trixi.rhs!, semi, sol, 1000)
162
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
163
end
164
165
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_periodic.jl" begin
166
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
167
"elixir_navierstokes_convergence_periodic.jl"),
168
l2=[
169
0.0001133835907077494,
170
6.226282245610444e-5,
171
0.0002820171699999139
172
],
173
linf=[
174
0.0006255102377159538,
175
0.00036195501456059986,
176
0.0016147729485886941
177
])
178
# Ensure that we do not have excessive memory allocations
179
# (e.g., from type instabilities)
180
@test_allocations(Trixi.rhs!, semi, sol, 1000)
181
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
182
end
183
184
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_periodic_cfl.jl" begin
185
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
186
"elixir_navierstokes_convergence_periodic_cfl.jl"),
187
l2=[
188
0.00011582226718630047,
189
6.277345250542003e-5,
190
0.0002822257163816253
191
],
192
linf=[
193
0.0006389893469918029,
194
0.0003608325914101762,
195
0.0016369657641206459
196
])
197
# Ensure that we do not have excessive memory allocations
198
# (e.g., from type instabilities)
199
@test_allocations(Trixi.rhs!, semi, sol, 1000)
200
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
201
end
202
203
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_periodic.jl: GradientVariablesEntropy" begin
204
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
205
"elixir_navierstokes_convergence_periodic.jl"),
206
equations_parabolic=CompressibleNavierStokesDiffusion1D(equations,
207
mu = mu(),
208
Prandtl = prandtl_number(),
209
gradient_variables = GradientVariablesEntropy()),
210
l2=[
211
0.00011310615871043463,
212
6.216495207074201e-5,
213
0.00028195843110817814
214
],
215
linf=[
216
0.0006240837363233886,
217
0.0003616694320713876,
218
0.0016147339542413874
219
])
220
# Ensure that we do not have excessive memory allocations
221
# (e.g., from type instabilities)
222
@test_allocations(Trixi.rhs!, semi, sol, 1000)
223
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
224
end
225
226
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls.jl" begin
227
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
228
"elixir_navierstokes_convergence_walls.jl"),
229
l2=[
230
0.0004702331100298379,
231
0.0003218173539588441,
232
0.001496626616191212
233
],
234
linf=[
235
0.0029963751636357117,
236
0.0028639041695096433,
237
0.012691132694550689
238
],
239
atol=1e-10)
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 "TreeMesh1D: elixir_navierstokes_convergence_walls.jl: GradientVariablesEntropy" begin
247
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
248
"elixir_navierstokes_convergence_walls.jl"),
249
equations_parabolic=CompressibleNavierStokesDiffusion1D(equations,
250
mu = mu(),
251
Prandtl = prandtl_number(),
252
gradient_variables = GradientVariablesEntropy()),
253
l2=[
254
0.00046085004909354776,
255
0.0003243109084492897,
256
0.0015159733164383632
257
],
258
linf=[
259
0.0027548031865172184,
260
0.0028567713569609024,
261
0.012941793735691931
262
],
263
atol=1e-9)
264
# Ensure that we do not have excessive memory allocations
265
# (e.g., from type instabilities)
266
@test_allocations(Trixi.rhs!, semi, sol, 1000)
267
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
268
end
269
270
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls.jl (Gauss-Legendre)" begin
271
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
272
"elixir_navierstokes_convergence_walls.jl"),
273
solver=DGSEM(polydeg = 3, surface_flux = flux_hll,
274
basis_type = GaussLegendreBasis),
275
time_int_tol=1e-10,
276
l2=[
277
4.201445769104007e-5,
278
9.758279535510314e-5,
279
0.0004199990641561288
280
],
281
linf=[
282
0.00015356293659607445,
283
0.0004198436005902785,
284
0.0016946745322332646
285
],
286
atol=1e-10)
287
# Ensure that we do not have excessive memory allocations
288
# (e.g., from type instabilities)
289
@test_allocations(Trixi.rhs!, semi, sol, 1000)
290
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
291
end
292
293
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls_amr.jl" begin
294
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
295
"elixir_navierstokes_convergence_walls_amr.jl"),
296
equations_parabolic=CompressibleNavierStokesDiffusion1D(equations,
297
mu = mu(),
298
Prandtl = prandtl_number()),
299
l2=[
300
2.5278845598681636e-5,
301
2.5540145802666872e-5,
302
0.0001211867535580826
303
],
304
linf=[
305
0.0001466387202588848,
306
0.00019422419092429135,
307
0.0009556449835592673
308
],
309
atol=1e-9)
310
# Ensure that we do not have excessive memory allocations
311
# (e.g., from type instabilities)
312
@test_allocations(Trixi.rhs!, semi, sol, 1000)
313
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
314
end
315
316
@trixi_testset "TreeMesh1D: elixir_navierstokes_convergence_walls_amr.jl: GradientVariablesEntropy" begin
317
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
318
"elixir_navierstokes_convergence_walls_amr.jl"),
319
equations_parabolic=CompressibleNavierStokesDiffusion1D(equations,
320
mu = mu(),
321
Prandtl = prandtl_number(),
322
gradient_variables = GradientVariablesEntropy()),
323
l2=[
324
2.4593521887223632e-5,
325
2.3928212900127102e-5,
326
0.00011252332663824173
327
],
328
linf=[
329
0.00011850494672183132,
330
0.00018987676556476442,
331
0.0009597423024825247
332
],
333
atol=1e-9)
334
# Ensure that we do not have excessive memory allocations
335
# (e.g., from type instabilities)
336
@test_allocations(Trixi.rhs!, semi, sol, 1000)
337
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
338
end
339
340
@trixi_testset "TreeMesh1D: elixir_navierstokes_viscous_shock.jl" begin
341
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
342
"elixir_navierstokes_viscous_shock.jl"),
343
l2=[
344
0.00025762354103445303,
345
0.0001433692781569829,
346
0.00017369861968287976
347
],
348
linf=[
349
0.0016731940030498826,
350
0.0010638575921477766,
351
0.0011495207677434394
352
])
353
# Ensure that we do not have excessive memory allocations
354
# (e.g., from type instabilities)
355
@test_allocations(Trixi.rhs!, semi, sol, 1000)
356
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
357
end
358
359
@trixi_testset "TreeMesh1D: elixir_navierstokes_viscous_shock.jl (Gauss-Legendre)" begin
360
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
361
"elixir_navierstokes_viscous_shock.jl"),
362
solver=DGSEM(polydeg = 3, surface_flux = flux_hlle,
363
basis_type = GaussLegendreBasis),
364
l2=[
365
0.00010415910094963455,
366
7.569570282227496e-5,
367
8.643799824895884e-5
368
],
369
linf=[
370
0.0004795456761867989,
371
0.0003525509032139551,
372
0.0004044657250887873
373
])
374
# Ensure that we do not have excessive memory allocations
375
# (e.g., from type instabilities)
376
@test_allocations(Trixi.rhs!, semi, sol, 1000)
377
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
378
end
379
380
@trixi_testset "TreeMesh1D: elixir_navierstokes_viscous_shock_imex.jl" begin
381
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
382
"elixir_navierstokes_viscous_shock_imex.jl"),
383
atol_lin_solve=1e-11, rtol_lin_solve=1e-10,
384
l2=[
385
0.0016637028933384878,
386
0.0014571255711373966,
387
0.0014843783212282159
388
],
389
linf=[
390
0.00545660697650141,
391
0.003950431201790283,
392
0.004092051414554598
393
],
394
# Relax error tols to avoid stochastic CI failures
395
atol=1e-7)
396
# Ensure that we do not have excessive memory allocations
397
# (e.g., from type instabilities)
398
@test_allocations(Trixi.rhs!, semi, sol, 1000)
399
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
400
end
401
402
@trixi_testset "TreeMesh1D: elixir_viscous_burgers_n_wave.jl" begin
403
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
404
"elixir_viscous_burgers_n_wave.jl"),
405
l2=[0.03005971517609335], linf=[0.08174614630359545])
406
# Ensure that we do not have excessive memory allocations
407
# (e.g., from type instabilities)
408
@test_allocations(Trixi.rhs!, semi, sol, 1000)
409
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
410
end
411
412
@trixi_testset "TreeMesh1D: elixir_viscous_burgers_shock.jl" begin
413
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
414
"elixir_viscous_burgers_shock.jl"),
415
l2=[0.0025484696686361645], linf=[0.028069313915933147])
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
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
420
end
421
422
@trixi_testset "DGMulti: elixir_advection_diffusion_gradient_source_terms.jl" begin
423
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_1d",
424
"elixir_advection_diffusion_gradient_source_terms.jl"),
425
l2=[0.01889578192611483],
426
linf=[0.03572728414418691])
427
# Ensure that we do not have excessive memory allocations
428
# (e.g., from type instabilities)
429
@test_allocations(Trixi.rhs!, semi, sol, 1000)
430
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
431
end
432
433
@trixi_testset "DGMulti: elixir_advection_diffusion_sbp.jl" begin
434
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_1d",
435
"elixir_advection_diffusion_sbp.jl"),
436
l2=[2.027026825559297e-5],
437
linf=[3.1997648799242384e-5])
438
# Ensure that we do not have excessive memory allocations
439
# (e.g., from type instabilities)
440
@test_allocations(Trixi.rhs!, semi, sol, 1000)
441
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
442
end
443
444
@trixi_testset "DGMulti: elixir_navierstokes_convergence_periodic.jl" begin
445
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_1d",
446
"elixir_navierstokes_convergence_periodic.jl"),
447
l2=[
448
3.7943372542675425e-5,
449
4.078766566292102e-5,
450
0.00024524952267207235
451
],
452
linf=[
453
0.00010969455084941515,
454
9.183113730193426e-5,
455
0.0005450421812014383
456
])
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 "DGMulti: elixir_navierstokes_convergence_periodic.jl (Diff. CFL)" begin
463
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_1d",
464
"elixir_navierstokes_convergence_periodic.jl"),
465
callbacks=CallbackSet(summary_callback, alive_callback,
466
analysis_callback,
467
StepsizeCallback(cfl = 0.5,
468
cfl_parabolic = 0.1)),
469
adaptive=false,
470
l2=[
471
3.804624387087144e-5,
472
4.0776239664045585e-5,
473
0.0002452796554181002
474
],
475
linf=[
476
0.00010899905841177393,
477
9.108558032178138e-5,
478
0.0005277952647766426
479
])
480
# Ensure that we do not have excessive memory allocations
481
# (e.g., from type instabilities)
482
@test_allocations(Trixi.rhs!, semi, sol, 1000)
483
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
484
end
485
486
@trixi_testset "DGMulti: elixir_navierstokes_convergence_periodic.jl (GradientVariablesEntropy)" begin
487
@test_trixi_include(joinpath(EXAMPLES_DIR, "dgmulti_1d",
488
"elixir_navierstokes_convergence_periodic.jl"),
489
gradient_variables=GradientVariablesEntropy(),
490
l2=[
491
3.855011159752911e-5,
492
4.077230736638483e-5,
493
0.0002457818746735199
494
],
495
linf=[
496
0.00011052974882530542,
497
9.179337892284423e-5,
498
0.00054534178933352
499
])
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
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
504
end
505
end
506
507
@testset "SemidiscretizationParabolic (1D)" begin
508
#! format: noindent
509
510
@trixi_testset "TreeMesh1D: elixir_diffusion_ldg.jl" begin
511
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
512
"elixir_diffusion_ldg.jl"),
513
initial_refinement_level=4, tspan=(0.0, 0.4), polydeg=3,
514
l2=[9.235894939144276e-6], linf=[5.402550135213957e-5])
515
# Ensure that we do not have excessive memory allocations
516
# (e.g., from type instabilities)
517
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
518
end
519
520
@trixi_testset "TreeMesh1D: elixir_diffusion_ldg_newton_krylov.jl" begin
521
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
522
"elixir_diffusion_ldg_newton_krylov.jl"),
523
atol_lin_solve=1e-11, rtol_lin_solve=1e-10,
524
atol_ode_solve=1e-10, rtol_ode_solve=1e-9,
525
l2=[4.14999791227157e-6], linf=[2.424658410971059e-5],
526
# Relax error tols to avoid stochastic CI failures
527
atol=1e-12)
528
# Ensure that we do not have excessive memory allocations
529
# (e.g., from type instabilities)
530
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
531
end
532
533
@trixi_testset "TreeMesh1D: elixir_diffusion_ldg_amr_boundary_layer.jl" begin
534
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
535
"elixir_diffusion_ldg_amr_boundary_layer.jl"),
536
l2=[0.5881457102264551], linf=[0.9302621795999283])
537
# Ensure that we do not have excessive memory allocations
538
# (e.g., from type instabilities)
539
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
540
541
# Test `show` method not exercised in elixirs
542
@trixi_test_nowarn show(IOContext(stdout, :compact => true), MIME"text/plain"(),
543
semi)
544
545
# Test basic semidiscretization dispatches
546
@test ndims(semi) == ndims(semi.mesh)
547
@test nvariables(semi) == nvariables(semi.equations)
548
@test real(semi) == real(semi.solver)
549
550
# Test that `remake` works for `SemidiscretizationParabolic`
551
semi_remade = remake(semi)
552
@test semi_remade isa SemidiscretizationParabolic
553
@test semi_remade !== semi
554
@test semi_remade.mesh === semi.mesh
555
@test Trixi.ndofsglobal(semi_remade) == Trixi.ndofsglobal(semi)
556
end
557
558
@trixi_testset "TreeMesh1D consistency check: elixir_diffusion_ldg_dirichlet.jl" begin
559
# Run the Dirichlet-Dirichlet elixir (uses `SemidiscretizationParabolic`)
560
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
561
"elixir_diffusion_ldg_dirichlet.jl"),
562
tspan=(0.0, 0.1),
563
analysis_callback=AnalysisCallback(semi,
564
interval = 100,
565
extra_analysis_errors = (:l2_error_primitive,
566
:linf_error_primitive),
567
extra_analysis_integrals = (entropy,)),
568
l2=[2.3481439150004898e-6], linf=[2.4576876189230656e-5])
569
# Ensure that we do not have excessive memory allocations
570
# (e.g., from type instabilities)
571
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1000)
572
573
# Store reference solution for comparison
574
reference_solution = copy(sol.u[end])
575
576
# Run again using an advection-diffusion equation with advection velocity zero
577
@test_trixi_include(joinpath(EXAMPLES_DIR, "tree_1d_dgsem",
578
"elixir_diffusion_ldg_dirichlet.jl"),
579
tspan=(0.0, 0.1),
580
equations=LinearScalarAdvectionEquation1D(0.0),
581
semi=SemidiscretizationHyperbolicParabolic(mesh,
582
(equations,
583
LaplaceDiffusion1D(diffusivity(),
584
equations)),
585
initial_condition,
586
solver;
587
solver_parabolic = solver_parabolic,
588
boundary_conditions = (boundary_conditions,
589
boundary_conditions)))
590
# Check if the solutions for `SemidiscretizationParabolic` match those from
591
# `SemidiscretizationHyperbolicParabolic` using the same Float64 tolerance defaults as
592
# `@test_trixi_include` in TrixiTest.jl.
593
@test sol.u[end]≈reference_solution atol=500 * eps(Float64) rtol=sqrt(eps(Float64))
594
end
595
end
596
597
# Clean up afterwards: delete Trixi output directory
598
@test_nowarn isdir(outdir) && rm(outdir, recursive = true)
599
600
end # module
601
602