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
5582 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
@test_allocations(Trixi.rhs!, semi, sol, 1000)
42
end
43
44
@trixi_testset "elixir_advection_nonconforming_flag.jl" begin
45
@test_trixi_include(joinpath(EXAMPLES_DIR,
46
"elixir_advection_nonconforming_flag.jl"),
47
l2=[3.198940059144588e-5],
48
linf=[0.00030636069494005547])
49
50
# Ensure that we do not have excessive memory allocations
51
# (e.g., from type instabilities)
52
@test_allocations(Trixi.rhs!, semi, sol, 1000)
53
end
54
55
@trixi_testset "elixir_advection_unstructured_flag.jl" begin
56
@test_trixi_include(joinpath(EXAMPLES_DIR,
57
"elixir_advection_unstructured_flag.jl"),
58
l2=[0.0005379687442422346],
59
linf=[0.007438525029884735])
60
61
# Ensure that we do not have excessive memory allocations
62
# (e.g., from type instabilities)
63
@test_allocations(Trixi.rhs!, semi, sol, 1000)
64
end
65
66
@trixi_testset "elixir_advection_amr_solution_independent.jl" begin
67
@test_trixi_include(joinpath(EXAMPLES_DIR,
68
"elixir_advection_amr_solution_independent.jl"),
69
# Expected errors are exactly the same as with TreeMesh!
70
l2=[4.949660644033807e-5],
71
linf=[0.0004867846262313763])
72
73
# Ensure that we do not have excessive memory allocations
74
# (e.g., from type instabilities)
75
@test_allocations(Trixi.rhs!, semi, sol, 1000)
76
end
77
78
@trixi_testset "elixir_advection_amr_unstructured_flag.jl" begin
79
@test_trixi_include(joinpath(EXAMPLES_DIR,
80
"elixir_advection_amr_unstructured_flag.jl"),
81
l2=[0.0012808538770535593],
82
linf=[0.01752690016659812])
83
84
# Ensure that we do not have excessive memory allocations
85
# (e.g., from type instabilities)
86
@test_allocations(Trixi.rhs!, semi, sol, 1000)
87
end
88
89
@trixi_testset "elixir_advection_restart.jl" begin
90
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
91
l2=[4.507575525876275e-6],
92
linf=[6.21489667023134e-5])
93
94
# Ensure that we do not have excessive memory allocations
95
# (e.g., from type instabilities)
96
@test_allocations(Trixi.rhs!, semi, sol, 1000)
97
end
98
99
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_flag.jl" begin
100
@test_trixi_include(joinpath(EXAMPLES_DIR,
101
"elixir_euler_source_terms_nonconforming_unstructured_flag.jl"),
102
l2=[
103
0.0034516244508588046,
104
0.0023420334036925493,
105
0.0024261923964557187,
106
0.004731710454271893
107
],
108
linf=[
109
0.04155789011775046,
110
0.024772109862748914,
111
0.03759938693042297,
112
0.08039824959535657
113
])
114
115
# Ensure that we do not have excessive memory allocations
116
# (e.g., from type instabilities)
117
@test_allocations(Trixi.rhs!, semi, sol, 1000)
118
end
119
120
# Test MPI-parallel handling of .inp meshes generated by HOHQMesh
121
@trixi_testset "elixir_euler_wall_bc_amr.jl" begin
122
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_wall_bc_amr.jl"),
123
l2=[
124
0.020266970819461425,
125
0.01746740120890609,
126
0.011378393090609054,
127
0.05138965928352185
128
],
129
linf=[
130
0.3593492062888952,
131
0.32077672777509403,
132
0.23600493584887167,
133
0.9291837711500472
134
],
135
tspan=(0.0, 0.15))
136
# Ensure that we do not have excessive memory allocations
137
# (e.g., from type instabilities)
138
@test_allocations(Trixi.rhs!, semi, sol, 1000)
139
end
140
141
# Test MPI-parallel handling of .inp meshes NOT generated by HOHQMesh
142
@trixi_testset "elixir_euler_SD7003airfoil.jl" begin
143
using Trixi: SemidiscretizationHyperbolic, AnalysisCallback
144
@test_trixi_include(joinpath(EXAMPLES_DIR,
145
"elixir_navierstokes_SD7003airfoil.jl"),
146
semi=SemidiscretizationHyperbolic(mesh, equations,
147
initial_condition, solver;
148
boundary_conditions = boundary_conditions_hyp),
149
analysis_callback=AnalysisCallback(semi,
150
interval = analysis_interval,
151
output_directory = "out",
152
save_analysis = true),
153
l2=[
154
9.316117984455285e-5,
155
4.539266936628966e-5,
156
8.381576796590632e-5,
157
0.00023437941500203496
158
],
159
linf=[
160
0.31274105032407307,
161
0.2793016762668701,
162
0.22256470161743136,
163
0.7906704256076251
164
],
165
tspan=(0.0, 5e-3))
166
# Ensure that we do not have excessive memory allocations
167
# (e.g., from type instabilities)
168
@test_allocations(Trixi.rhs!, semi, sol, 1000)
169
end
170
171
@trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin
172
@test_trixi_include(joinpath(EXAMPLES_DIR,
173
"elixir_mhd_alfven_wave_nonconforming.jl"),
174
l2=[
175
0.0322570437144848,
176
0.03598284801272945,
177
0.03562228071357411,
178
0.05288641880143085,
179
0.040752873778199326,
180
0.04207276835260492,
181
0.04171391252403866,
182
0.05289242879893149,
183
0.0016038935411812223
184
],
185
linf=[
186
0.175984910510666,
187
0.13999726708245439,
188
0.13336032728399658,
189
0.21248359539637798,
190
0.133294808938885,
191
0.17934684696413217,
192
0.1831567822932948,
193
0.21575881133569155,
194
0.01967917976620703
195
],
196
tspan=(0.0, 0.25))
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
end
201
202
# Same test as above but with only one tree in the mesh
203
# We use it to test meshes with elements of different size in each partition
204
@test_trixi_include(joinpath(EXAMPLES_DIR,
205
"elixir_mhd_alfven_wave_nonconforming.jl"),
206
l2=[
207
0.02918489280986591,
208
0.03430197485998593,
209
0.033958258414233555,
210
0.05015261058202805,
211
0.03823791246217151,
212
0.04013747495809935,
213
0.039752335789428925,
214
0.05021821589628951,
215
0.002332549196680272
216
],
217
linf=[
218
0.1031205532032593,
219
0.1408724803980772,
220
0.1377071548888711,
221
0.24265946222482881,
222
0.12403522681540824,
223
0.19380378175033763,
224
0.19743139999820714,
225
0.2453908414271658,
226
0.019597656830548395
227
],
228
tspan=(0.0, 0.25), trees_per_dimension=(1, 1))
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
end
233
end # P4estMesh MPI
234
235
end # module
236
237