Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_mpi_p4est_2d.jl
2055 views
1
module TestExamplesMPIP4estMesh2D
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "p4est_2d_dgsem")
9
10
@testset "P4estMesh MPI 2D" begin
11
#! format: noindent
12
13
# Run basic tests
14
@testset "Examples 2D" begin
15
# Linear scalar advection
16
@trixi_testset "elixir_advection_basic.jl" begin
17
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
18
# Expected errors are exactly the same as with TreeMesh!
19
l2=[8.311947673061856e-6],
20
linf=[6.627000273229378e-5])
21
22
@testset "error-based step size control" begin
23
mpi_isroot() && println("-"^100)
24
mpi_isroot() &&
25
println("elixir_advection_basic.jl with error-based step size control")
26
27
# Use callbacks without stepsize_callback to test error-based step size control
28
callbacks = CallbackSet(summary_callback, analysis_callback, save_solution)
29
sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4,
30
ode_default_options()..., callback = callbacks)
31
summary_callback()
32
errors = analysis_callback(sol)
33
if mpi_isroot()
34
@test errors.l2≈[3.3022040342579066e-5] rtol=1.0e-4
35
@test errors.linf≈[0.00011787417954578494] rtol=1.0e-4
36
end
37
end
38
39
# Ensure that we do not have excessive memory allocations
40
# (e.g., from type instabilities)
41
let
42
t = sol.t[end]
43
u_ode = sol.u[end]
44
du_ode = similar(u_ode)
45
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
46
end
47
end
48
49
@trixi_testset "elixir_advection_nonconforming_flag.jl" begin
50
@test_trixi_include(joinpath(EXAMPLES_DIR,
51
"elixir_advection_nonconforming_flag.jl"),
52
l2=[3.198940059144588e-5],
53
linf=[0.00030636069494005547])
54
55
# Ensure that we do not have excessive memory allocations
56
# (e.g., from type instabilities)
57
let
58
t = sol.t[end]
59
u_ode = sol.u[end]
60
du_ode = similar(u_ode)
61
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
62
end
63
end
64
65
@trixi_testset "elixir_advection_unstructured_flag.jl" begin
66
@test_trixi_include(joinpath(EXAMPLES_DIR,
67
"elixir_advection_unstructured_flag.jl"),
68
l2=[0.0005379687442422346],
69
linf=[0.007438525029884735])
70
71
# Ensure that we do not have excessive memory allocations
72
# (e.g., from type instabilities)
73
let
74
t = sol.t[end]
75
u_ode = sol.u[end]
76
du_ode = similar(u_ode)
77
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
78
end
79
end
80
81
@trixi_testset "elixir_advection_amr_solution_independent.jl" begin
82
@test_trixi_include(joinpath(EXAMPLES_DIR,
83
"elixir_advection_amr_solution_independent.jl"),
84
# Expected errors are exactly the same as with TreeMesh!
85
l2=[4.949660644033807e-5],
86
linf=[0.0004867846262313763])
87
88
# Ensure that we do not have excessive memory allocations
89
# (e.g., from type instabilities)
90
let
91
t = sol.t[end]
92
u_ode = sol.u[end]
93
du_ode = similar(u_ode)
94
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
95
end
96
end
97
98
@trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR,
100
"elixir_advection_amr_unstructured_flag.jl"),
101
l2=[0.0012808538770535593],
102
linf=[0.01752690016659812])
103
104
# Ensure that we do not have excessive memory allocations
105
# (e.g., from type instabilities)
106
let
107
t = sol.t[end]
108
u_ode = sol.u[end]
109
du_ode = similar(u_ode)
110
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
111
end
112
end
113
114
@trixi_testset "elixir_advection_restart.jl" begin
115
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
116
l2=[4.507575525876275e-6],
117
linf=[6.21489667023134e-5])
118
119
# Ensure that we do not have excessive memory allocations
120
# (e.g., from type instabilities)
121
let
122
t = sol.t[end]
123
u_ode = sol.u[end]
124
du_ode = similar(u_ode)
125
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
126
end
127
end
128
129
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin
130
@test_trixi_include(joinpath(EXAMPLES_DIR,
131
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
132
l2=[
133
0.0034516244508588046,
134
0.0023420334036925493,
135
0.0024261923964557187,
136
0.004731710454271893
137
],
138
linf=[
139
0.04155789011775046,
140
0.024772109862748914,
141
0.03759938693042297,
142
0.08039824959535657
143
])
144
145
# Ensure that we do not have excessive memory allocations
146
# (e.g., from type instabilities)
147
let
148
t = sol.t[end]
149
u_ode = sol.u[end]
150
du_ode = similar(u_ode)
151
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
152
end
153
end
154
155
# Test MPI-parallel handling of .inp meshes generated by HOHQMesh
156
@trixi_testset "elixir_euler_wall_bc_amr.jl" begin
157
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"),
158
l2=[
159
0.02026685991647352,
160
0.017467584076280237,
161
0.011378371604813321,
162
0.05138942558296091
163
],
164
linf=[
165
0.35924402060711524,
166
0.32068389566068806,
167
0.2361141752119986,
168
0.9289840057748628
169
],
170
tspan=(0.0, 0.15))
171
# Ensure that we do not have excessive memory allocations
172
# (e.g., from type instabilities)
173
let
174
t = sol.t[end]
175
u_ode = sol.u[end]
176
du_ode = similar(u_ode)
177
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
178
end
179
end
180
181
# Test MPI-parallel handling of .inp meshes NOT generated by HOHQMesh
182
@trixi_testset "elixir_euler_SD7003airfoil.jl" begin
183
using Trixi: SemidiscretizationHyperbolic, AnalysisCallback
184
@test_trixi_include(joinpath(EXAMPLES_DIR,
185
"elixir_navierstokes_SD7003airfoil.jl"),
186
semi=SemidiscretizationHyperbolic(mesh, equations,
187
initial_condition, solver;
188
boundary_conditions = boundary_conditions_hyp),
189
analysis_callback=AnalysisCallback(semi,
190
interval = analysis_interval,
191
output_directory = "out",
192
save_analysis = true),
193
l2=[
194
9.316117984455285e-5,
195
4.539266936628966e-5,
196
8.381576796590632e-5,
197
0.00023437941500203496
198
],
199
linf=[
200
0.31274105032407307,
201
0.2793016762668701,
202
0.22256470161743136,
203
0.7906704256076251
204
],
205
tspan=(0.0, 5e-3))
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_mhd_alfven_wave_nonconforming.jl" begin
217
@test_trixi_include(joinpath(EXAMPLES_DIR,
218
"elixir_mhd_alfven_wave_nonconforming.jl"),
219
l2=[
220
0.0322570437144848,
221
0.03598284801272945,
222
0.03562228071357411,
223
0.05288641880143085,
224
0.040752873778199326,
225
0.04207276835260492,
226
0.04171391252403866,
227
0.05289242879893149,
228
0.0016038935411812223
229
],
230
linf=[
231
0.175984910510666,
232
0.13999726708245439,
233
0.13336032728399658,
234
0.21248359539637798,
235
0.133294808938885,
236
0.17934684696413217,
237
0.1831567822932948,
238
0.21575881133569155,
239
0.01967917976620703
240
],
241
tspan=(0.0, 0.25),)
242
# Ensure that we do not have excessive memory allocations
243
# (e.g., from type instabilities)
244
let
245
t = sol.t[end]
246
u_ode = sol.u[end]
247
du_ode = similar(u_ode)
248
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
249
end
250
end
251
252
# Same test as above but with only one tree in the mesh
253
# We use it to test meshes with elements of different size in each partition
254
@test_trixi_include(joinpath(EXAMPLES_DIR,
255
"elixir_mhd_alfven_wave_nonconforming.jl"),
256
l2=[
257
0.02918489280986591,
258
0.03430197485998593,
259
0.033958258414233555,
260
0.05015261058202805,
261
0.03823791246217151,
262
0.04013747495809935,
263
0.039752335789428925,
264
0.05021821589628951,
265
0.002332549196680272
266
],
267
linf=[
268
0.1031205532032593,
269
0.1408724803980772,
270
0.1377071548888711,
271
0.24265946222482881,
272
0.12403522681540824,
273
0.19380378175033763,
274
0.19743139999820714,
275
0.2453908414271658,
276
0.019597656830548395
277
],
278
tspan=(0.0, 0.25), trees_per_dimension=(1, 1),)
279
# Ensure that we do not have excessive memory allocations
280
# (e.g., from type instabilities)
281
let
282
t = sol.t[end]
283
u_ode = sol.u[end]
284
du_ode = similar(u_ode)
285
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
286
end
287
end
288
end # P4estMesh MPI
289
290
end # module
291
292