Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_mpi_tree.jl
2055 views
1
module TestExamplesMPITreeMesh
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "tree_2d_dgsem")
9
10
# Needed to skip certain tests on Windows CI
11
CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
12
13
@testset "TreeMesh MPI" begin
14
#! format: noindent
15
16
# Run basic tests
17
@testset "Examples 2D" begin
18
# Linear scalar advection
19
@trixi_testset "elixir_advection_basic.jl" begin
20
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
21
# Expected errors are exactly the same as in the serial test!
22
l2=[8.311947673061856e-6],
23
linf=[6.627000273229378e-5])
24
end
25
26
@trixi_testset "elixir_advection_restart.jl" begin
27
using OrdinaryDiffEqLowStorageRK: RDPK3SpFSAL49
28
mpi_isroot() && println("═"^100)
29
mpi_isroot() &&
30
println(joinpath(EXAMPLES_DIR,
31
"elixir_advection_timeintegration_adaptive.jl"))
32
trixi_include(@__MODULE__,
33
joinpath(EXAMPLES_DIR,
34
"elixir_advection_timeintegration_adaptive.jl"),
35
alg = RDPK3SpFSAL49(), tspan = (0.0, 10.0))
36
l2_expected, linf_expected = analysis_callback(sol)
37
38
mpi_isroot() && println("═"^100)
39
mpi_isroot() &&
40
println(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"))
41
# Errors are exactly the same as in the elixir_advection_extended.jl
42
trixi_include(@__MODULE__,
43
joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
44
alg = RDPK3SpFSAL49(),
45
base_elixir = "elixir_advection_timeintegration_adaptive.jl")
46
l2_actual, linf_actual = analysis_callback(sol)
47
48
mpi_isroot() && @test l2_actual == l2_expected
49
mpi_isroot() && @test linf_actual == linf_expected
50
end
51
52
@trixi_testset "elixir_advection_mortar.jl" begin
53
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_mortar.jl"),
54
# Expected errors are exactly the same as in the serial test!
55
l2=[0.0015188466707237375],
56
linf=[0.008446655719187679])
57
end
58
59
@trixi_testset "elixir_advection_amr.jl" begin
60
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
61
# Expected errors are exactly the same as in the serial test!
62
l2=[4.913300828257469e-5],
63
linf=[0.00045263895394385967])
64
end
65
66
@trixi_testset "elixir_advection_amr_nonperiodic.jl" begin
67
@test_trixi_include(joinpath(EXAMPLES_DIR,
68
"elixir_advection_amr_nonperiodic.jl"),
69
# Expected errors are exactly the same as in the serial test!
70
l2=[3.2207388565869075e-5],
71
linf=[0.0007508059772436404])
72
end
73
74
@trixi_testset "elixir_advection_restart_amr.jl" begin
75
@test_trixi_include(joinpath(EXAMPLES_DIR,
76
"elixir_advection_restart_amr.jl"),
77
l2=[8.018498574373939e-5],
78
linf=[0.0007307237754662355])
79
end
80
81
# Linear scalar advection with AMR
82
# These example files are only for testing purposes and have no practical use
83
@trixi_testset "elixir_advection_amr_refine_twice.jl" begin
84
using Trixi: Trixi
85
# Here, we also test that SaveSolutionCallback prints multiple mesh files with AMR
86
# Start with a clean environment: remove Trixi.jl output directory if it exists
87
outdir = "out"
88
mpi_isroot() && isdir(outdir) && rm(outdir, recursive = true)
89
Trixi.MPI.Barrier(Trixi.mpi_comm())
90
@test_trixi_include(joinpath(EXAMPLES_DIR,
91
"elixir_advection_amr_refine_twice.jl"),
92
l2=[0.00020547512522578292],
93
linf=[0.007831753383083506])
94
meshfiles = filter(file -> endswith(file, ".h5") && startswith(file, "mesh"),
95
readdir(outdir))
96
@test length(meshfiles) > 1
97
end
98
99
@trixi_testset "elixir_advection_amr_coarsen_twice.jl" begin
100
@test_trixi_include(joinpath(EXAMPLES_DIR,
101
"elixir_advection_amr_coarsen_twice.jl"),
102
l2=[0.0014321062757891826],
103
linf=[0.0253454486893413])
104
end
105
106
# Hyperbolic diffusion
107
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
108
@trixi_testset "elixir_hypdiff_lax_friedrichs.jl" begin
109
@test_trixi_include(joinpath(EXAMPLES_DIR,
110
"elixir_hypdiff_lax_friedrichs.jl"),
111
l2=[
112
0.00015687751816056159,
113
0.001025986772217084,
114
0.0010259867722169909
115
],
116
linf=[
117
0.0011986956416591976,
118
0.006423873516411049,
119
0.006423873516411049
120
])
121
end
122
end
123
124
@trixi_testset "elixir_hypdiff_harmonic_nonperiodic.jl" begin
125
@test_trixi_include(joinpath(EXAMPLES_DIR,
126
"elixir_hypdiff_harmonic_nonperiodic.jl"),
127
l2=[
128
8.61813235543625e-8,
129
5.619399844542781e-7,
130
5.6193998447443e-7
131
],
132
linf=[
133
1.124861862180196e-6,
134
8.622436471039663e-6,
135
8.622436470151484e-6
136
])
137
end
138
139
@trixi_testset "elixir_hypdiff_nonperiodic.jl" begin
140
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_nonperiodic.jl"),
141
l2=[
142
8.523077653955306e-6,
143
2.8779323653065056e-5,
144
5.4549427691297846e-5
145
],
146
linf=[
147
5.5227409524905013e-5,
148
0.0001454489597927185,
149
0.00032396328684569653
150
])
151
end
152
153
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
154
@trixi_testset "elixir_hypdiff_godunov.jl" begin
155
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_hypdiff_godunov.jl"),
156
l2=[
157
5.868147556427088e-6,
158
3.80517927324465e-5,
159
3.805179273249344e-5
160
],
161
linf=[
162
3.701965498725812e-5,
163
0.0002122422943138247,
164
0.00021224229431116015
165
],
166
atol=2.0e-12) #= required for CI on macOS =#
167
end
168
end
169
170
# Compressible Euler
171
# Note: Some tests here have manually increased relative tolerances since reduction via MPI can
172
# slightly change the L2 error norms (different floating point truncation errors)
173
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
174
@trixi_testset "elixir_euler_source_terms.jl" begin
175
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_source_terms.jl"),
176
l2=[
177
9.321181253186009e-7,
178
1.4181210743438511e-6,
179
1.4181210743487851e-6,
180
4.824553091276693e-6
181
],
182
linf=[
183
9.577246529612893e-6,
184
1.1707525976012434e-5,
185
1.1707525976456523e-5,
186
4.8869615580926506e-5
187
],
188
rtol=2000 * sqrt(eps()))
189
end
190
end
191
192
# This example file is only for testing purposes and has no practical use
193
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
194
@trixi_testset "elixir_euler_source_terms_amr_refine_coarsen.jl" begin
195
@test_trixi_include(joinpath(EXAMPLES_DIR,
196
"elixir_euler_source_terms_amr_refine_coarsen.jl"),
197
l2=[
198
4.8226610349853444e-5,
199
4.117706709270575e-5,
200
4.1177067092959676e-5,
201
0.00012205252427437389
202
],
203
linf=[
204
0.0003543874851490436,
205
0.0002973166773747593,
206
0.0002973166773760916,
207
0.001154106793870291
208
])
209
end
210
end
211
212
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
213
@trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin
214
@test_trixi_include(joinpath(EXAMPLES_DIR,
215
"elixir_euler_source_terms_nonperiodic.jl"),
216
l2=[
217
2.259440511766445e-6,
218
2.318888155713922e-6,
219
2.3188881557894307e-6,
220
6.3327863238858925e-6
221
],
222
linf=[
223
1.498738264560373e-5,
224
1.9182011928187137e-5,
225
1.918201192685487e-5,
226
6.0526717141407005e-5
227
],
228
rtol=0.001)
229
end
230
end
231
232
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
233
@trixi_testset "elixir_euler_ec.jl" begin
234
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"),
235
l2=[
236
0.061751715597716854,
237
0.05018223615408711,
238
0.05018989446443463,
239
0.225871559730513
240
],
241
linf=[
242
0.29347582879608825,
243
0.31081249232844693,
244
0.3107380389947736,
245
1.0540358049885143
246
])
247
248
@testset "error-based step size control" begin
249
mpi_isroot() && println("-"^100)
250
mpi_isroot() &&
251
println("elixir_euler_ec.jl with error-based step size control")
252
253
# Use callbacks without stepsize_callback to test error-based step size control
254
callbacks = CallbackSet(summary_callback,
255
analysis_callback, alive_callback,
256
save_solution)
257
sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4,
258
ode_default_options()..., callback = callbacks)
259
summary_callback()
260
errors = analysis_callback(sol)
261
if mpi_isroot()
262
@test errors.l2≈[
263
0.061653630426688116,
264
0.05006930431098764,
265
0.05007694316484242,
266
0.22550689872331683
267
] rtol=1.0e-4
268
@test errors.linf≈[
269
0.28516937484583693,
270
0.2983633696512788,
271
0.297812036335975,
272
1.027368795517512
273
] rtol=1.0e-4
274
end
275
end
276
end
277
end
278
279
@trixi_testset "elixir_euler_vortex.jl" begin
280
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex.jl"),
281
l2=[
282
0.00013492249515826863,
283
0.006615696236378061,
284
0.006782108219800376,
285
0.016393831451740604
286
],
287
linf=[
288
0.0020782600954247776,
289
0.08150078921935999,
290
0.08663621974991986,
291
0.2829930622010579
292
],
293
rtol=0.001)
294
end
295
296
@trixi_testset "elixir_euler_vortex_mortar.jl" begin
297
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_mortar.jl"),
298
# Expected errors are exactly the same as in the serial test!
299
l2=[
300
0.0017208369388227673,
301
0.09628684992237334,
302
0.09620157717330868,
303
0.1758809552387432
304
],
305
linf=[
306
0.021869936355319086,
307
0.9956698009442038,
308
1.0002507727219028,
309
2.223249697515648
310
])
311
end
312
313
@trixi_testset "elixir_euler_vortex_amr.jl" begin
314
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_vortex_amr.jl"),
315
# Expected errors are exactly the same as in the serial test!
316
l2=[
317
5.051719943432265e-5,
318
0.0022574259317084747,
319
0.0021755998463189713,
320
0.004346492398617521
321
],
322
linf=[
323
0.0012880114865917447,
324
0.03857193149447702,
325
0.031090457959835893,
326
0.12125130332971423
327
])
328
end
329
330
if !CI_ON_WINDOWS # see comment on `CI_ON_WINDOWS` in `test/test_mpi.jl`
331
@trixi_testset "elixir_euler_vortex_shockcapturing.jl" begin
332
@test_trixi_include(joinpath(EXAMPLES_DIR,
333
"elixir_euler_vortex_shockcapturing.jl"),
334
l2=[
335
0.0017158367642679273,
336
0.09619888722871434,
337
0.09616432767924141,
338
0.17553381166255197
339
],
340
linf=[
341
0.021853862449723982,
342
0.9878047229255944,
343
0.9880191167111795,
344
2.2154030488035588
345
],
346
rtol=0.001)
347
end
348
end
349
end
350
end # TreeMesh MPI
351
352
end # module
353
354