Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_mpi_p4est_3d.jl
2055 views
1
module TestExamplesMPIP4estMesh3D
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "p4est_3d_dgsem")
9
10
@testset "P4estMesh MPI 3D" begin
11
#! format: noindent
12
13
# Run basic tests
14
@testset "Examples 3D" 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=[0.00016263963870641478],
20
linf=[0.0014537194925779984])
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_restart,
29
save_solution)
30
sol = solve(ode, RDPK3SpFSAL35(); abstol = 1.0e-4, reltol = 1.0e-4,
31
ode_default_options()..., callback = callbacks)
32
summary_callback()
33
errors = analysis_callback(sol)
34
if mpi_isroot()
35
@test errors.l2≈[0.00016800412839949264] rtol=1.0e-4
36
@test errors.linf≈[0.0014548839020096516] rtol=1.0e-4
37
end
38
end
39
40
# Ensure that we do not have excessive memory allocations
41
# (e.g., from type instabilities)
42
let
43
t = sol.t[end]
44
u_ode = sol.u[end]
45
du_ode = similar(u_ode)
46
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
47
end
48
end
49
50
@trixi_testset "elixir_advection_amr.jl" begin
51
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
52
# Expected errors are exactly the same as with TreeMesh!
53
l2=[9.773852895157622e-6],
54
linf=[0.0005853874124926162])
55
56
# Ensure that we do not have excessive memory allocations
57
# (e.g., from type instabilities)
58
let
59
t = sol.t[end]
60
u_ode = sol.u[end]
61
du_ode = similar(u_ode)
62
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
63
end
64
end
65
66
@trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin
67
@test_trixi_include(joinpath(EXAMPLES_DIR,
68
"elixir_advection_amr_unstructured_curved.jl"),
69
l2=[1.6163120948209677e-5],
70
linf=[0.0010572201890564834],
71
tspan=(0.0, 1.0),)
72
73
# Ensure that we do not have excessive memory allocations
74
# (e.g., from type instabilities)
75
let
76
t = sol.t[end]
77
u_ode = sol.u[end]
78
du_ode = similar(u_ode)
79
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
80
end
81
end
82
83
@trixi_testset "elixir_advection_restart.jl" begin
84
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
85
l2=[0.002590388934758452],
86
linf=[0.01840757696885409])
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_cubed_sphere.jl" begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"),
100
l2=[0.002006918015656413],
101
linf=[0.027655117058380085])
102
103
# Ensure that we do not have excessive memory allocations
104
# (e.g., from type instabilities)
105
let
106
t = sol.t[end]
107
u_ode = sol.u[end]
108
du_ode = similar(u_ode)
109
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
110
end
111
end
112
113
# Compressible Euler
114
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin
115
@test_trixi_include(joinpath(EXAMPLES_DIR,
116
"elixir_euler_source_terms_nonconforming_unstructured_curved.jl"),
117
l2=[
118
4.070355207909268e-5,
119
4.4993257426833716e-5,
120
5.10588457841744e-5,
121
5.102840924036687e-5,
122
0.00019986264001630542
123
],
124
linf=[
125
0.0016987332417202072,
126
0.003622956808262634,
127
0.002029576258317789,
128
0.0024206977281964193,
129
0.008526972236273522
130
],
131
tspan=(0.0, 0.01))
132
133
# Ensure that we do not have excessive memory allocations
134
# (e.g., from type instabilities)
135
let
136
t = sol.t[end]
137
u_ode = sol.u[end]
138
du_ode = similar(u_ode)
139
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
140
end
141
end
142
143
@trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin
144
@test_trixi_include(joinpath(EXAMPLES_DIR,
145
"elixir_euler_source_terms_nonperiodic.jl"),
146
l2=[
147
0.0015106060984283647,
148
0.0014733349038567685,
149
0.00147333490385685,
150
0.001473334903856929,
151
0.0028149479453087093
152
],
153
linf=[
154
0.008070806335238156,
155
0.009007245083113125,
156
0.009007245083121784,
157
0.009007245083102688,
158
0.01562861968368434
159
],
160
tspan=(0.0, 1.0))
161
162
# Ensure that we do not have excessive memory allocations
163
# (e.g., from type instabilities)
164
let
165
t = sol.t[end]
166
u_ode = sol.u[end]
167
du_ode = similar(u_ode)
168
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
169
end
170
end
171
172
@trixi_testset "elixir_euler_ec.jl" begin
173
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"),
174
l2=[
175
0.010380390326164493,
176
0.006192950051354618,
177
0.005970674274073704,
178
0.005965831290564327,
179
0.02628875593094754
180
],
181
linf=[
182
0.3326911600075694,
183
0.2824952141320467,
184
0.41401037398065543,
185
0.45574161423218573,
186
0.8099577682187109
187
],
188
tspan=(0.0, 0.2),)
189
190
# Ensure that we do not have excessive memory allocations
191
# (e.g., from type instabilities)
192
let
193
t = sol.t[end]
194
u_ode = sol.u[end]
195
du_ode = similar(u_ode)
196
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
197
end
198
end
199
200
@trixi_testset "elixir_euler_source_terms_nonperiodic_hohqmesh.jl" begin
201
@test_trixi_include(joinpath(EXAMPLES_DIR,
202
"elixir_euler_source_terms_nonperiodic_hohqmesh.jl"),
203
l2=[
204
0.0042023406458005464,
205
0.004122532789279737,
206
0.0042448149597303616,
207
0.0036361316700401765,
208
0.007389845952982495
209
],
210
linf=[
211
0.04530610539892499,
212
0.02765695110527666,
213
0.05670295599308606,
214
0.048396544302230504,
215
0.1154589758186293
216
])
217
218
# Ensure that we do not have excessive memory allocations
219
# (e.g., from type instabilities)
220
let
221
t = sol.t[end]
222
u_ode = sol.u[end]
223
du_ode = similar(u_ode)
224
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
225
end
226
end
227
228
@trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin
229
@test_trixi_include(joinpath(EXAMPLES_DIR,
230
"elixir_mhd_alfven_wave_nonconforming.jl"),
231
l2=[
232
0.0001788543743594658,
233
0.000624334205581902,
234
0.00022892869974368887,
235
0.0007223464581156573,
236
0.0006651366626523314,
237
0.0006287275014743352,
238
0.000344484339916008,
239
0.0007179788287557142,
240
8.632896980651243e-7
241
],
242
linf=[
243
0.0010730565632763867,
244
0.004596749809344033,
245
0.0013235269262853733,
246
0.00468874234888117,
247
0.004719267084104306,
248
0.004228339352211896,
249
0.0037503625505571625,
250
0.005104176909383168,
251
9.738081186490818e-6
252
],
253
tspan=(0.0, 0.25),)
254
# Ensure that we do not have excessive memory allocations
255
# (e.g., from type instabilities)
256
let
257
t = sol.t[end]
258
u_ode = sol.u[end]
259
du_ode = similar(u_ode)
260
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
261
end
262
end
263
264
# Same test as above but with only one tree in the mesh
265
# We use it to test meshes with elements of different size in each partition
266
@test_trixi_include(joinpath(EXAMPLES_DIR,
267
"elixir_mhd_alfven_wave_nonconforming.jl"),
268
l2=[
269
0.0019054118500017054,
270
0.006957977226608083,
271
0.003429930594167365,
272
0.009051598556176287,
273
0.0077261662742688425,
274
0.008210851821439208,
275
0.003763030674412298,
276
0.009175470744760567,
277
2.881690753923244e-5
278
],
279
linf=[
280
0.010983704624623503,
281
0.04584128974425262,
282
0.02022630484954286,
283
0.04851342295826149,
284
0.040710154751363525,
285
0.044722299260292586,
286
0.036591209423654236,
287
0.05701669133068068,
288
0.00024182906501186622
289
],
290
tspan=(0.0, 0.25), trees_per_dimension=(1, 1, 1),)
291
# Ensure that we do not have excessive memory allocations
292
# (e.g., from type instabilities)
293
let
294
t = sol.t[end]
295
u_ode = sol.u[end]
296
du_ode = similar(u_ode)
297
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
298
end
299
end
300
end # P4estMesh MPI
301
302
end # module
303
304