Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_t8code_3d.jl
5582 views
1
module TestExamplesT8codeMesh3D
2
3
using Test
4
using Trixi
5
6
include("test_trixi.jl")
7
8
EXAMPLES_DIR = joinpath(examples_dir(), "t8code_3d_dgsem")
9
10
# Start with a clean environment: remove Trixi.jl output directory if it exists
11
outdir = "out"
12
isdir(outdir) && rm(outdir, recursive = true)
13
mkdir(outdir)
14
15
@testset "T8codeMesh3D" begin
16
@trixi_testset "test t8code mesh from p8est connectivity" begin
17
@test begin
18
using Trixi: Trixi, T8codeMesh
19
# Here we use the connectivity constructor from `P4est.jl` since the
20
# method dispatch works only on `Ptr{p8est_connectivity}` which
21
# actually is `Ptr{P4est.LibP4est.p8est_connectivity}`.
22
conn = Trixi.P4est.LibP4est.p8est_connectivity_new_brick(2, 3, 4, 1, 1, 1)
23
mesh = T8codeMesh(conn)
24
Trixi.p8est_connectivity_destroy(conn)
25
all(size(mesh.tree_node_coordinates) .== (3, 2, 2, 2, 24))
26
end
27
end
28
29
# This test is identical to the one in `test_p4est_3d.jl`.
30
@trixi_testset "elixir_advection_basic.jl" begin
31
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_basic.jl"),
32
# Expected errors are exactly the same as with TreeMesh!
33
l2=[0.00016263963870641478],
34
linf=[0.0014537194925779984])
35
# Ensure that we do not have excessive memory allocations
36
# (e.g., from type instabilities)
37
@test_allocations(Trixi.rhs!, semi, sol, 1000)
38
end
39
40
# This test is identical to the one in `test_p4est_3d.jl`.
41
@trixi_testset "elixir_advection_unstructured_curved.jl" begin
42
@test_trixi_include(joinpath(EXAMPLES_DIR,
43
"elixir_advection_unstructured_curved.jl"),
44
l2=[0.0004750004258546538],
45
linf=[0.026527551737137167])
46
# Ensure that we do not have excessive memory allocations
47
# (e.g., from type instabilities)
48
@test_allocations(Trixi.rhs!, semi, sol, 1000)
49
end
50
51
# This test is identical to the one in `test_p4est_3d.jl`.
52
@trixi_testset "elixir_advection_nonconforming.jl" begin
53
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_nonconforming.jl"),
54
l2=[0.00253595715323843],
55
linf=[0.016486952252155795])
56
# Ensure that we do not have excessive memory allocations
57
# (e.g., from type instabilities)
58
@test_allocations(Trixi.rhs!, semi, sol, 1000)
59
end
60
61
# This test is identical to the one in `test_p4est_3d.jl` besides minor
62
# deviations from the expected error norms.
63
@trixi_testset "elixir_advection_amr.jl" begin
64
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_amr.jl"),
65
# Expected errors are exactly the same as with TreeMesh!
66
l2=[1.1302812803902801e-5],
67
linf=[0.0007889950196294793])
68
# Ensure that we do not have excessive memory allocations
69
# (e.g., from type instabilities)
70
@test_allocations(Trixi.rhs!, semi, sol, 1000)
71
end
72
73
# This test is identical to the one in `test_p4est_3d.jl` besides minor
74
# deviations from the expected error norms.
75
@trixi_testset "elixir_advection_amr_unstructured_curved.jl" begin
76
@test_trixi_include(joinpath(EXAMPLES_DIR,
77
"elixir_advection_amr_unstructured_curved.jl"),
78
l2=[2.0535121347526814e-5],
79
linf=[0.0010586603797777504],
80
tspan=(0.0, 1.0))
81
# Ensure that we do not have excessive memory allocations
82
# (e.g., from type instabilities)
83
@test_allocations(Trixi.rhs!, semi, sol, 1000)
84
end
85
86
# This test differs from the one in `test_p4est_3d.jl` in the latitudinal and
87
# longitudinal dimensions.
88
@trixi_testset "elixir_advection_cubed_sphere.jl" begin
89
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_cubed_sphere.jl"),
90
l2=[0.002006918015656413],
91
linf=[0.027655117058380085])
92
# Ensure that we do not have excessive memory allocations
93
# (e.g., from type instabilities)
94
@test_allocations(Trixi.rhs!, semi, sol, 1000)
95
end
96
97
# This test is identical to the one in `test_p4est_3d.jl`.
98
@trixi_testset "elixir_advection_restart.jl" begin
99
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_advection_restart.jl"),
100
l2=[0.002590388934758452],
101
linf=[0.01840757696885409])
102
# Ensure that we do not have excessive memory allocations
103
# (e.g., from type instabilities)
104
@test_allocations(Trixi.rhs!, semi, sol, 1000)
105
end
106
107
# This test is identical to the one in `test_p4est_3d.jl`.
108
@trixi_testset "elixir_euler_source_terms_nonconforming_unstructured_curved.jl" begin
109
@test_trixi_include(joinpath(EXAMPLES_DIR,
110
"elixir_euler_source_terms_nonconforming_unstructured_curved.jl"),
111
l2=[
112
4.070355207909268e-5,
113
4.4993257426833716e-5,
114
5.10588457841744e-5,
115
5.102840924036687e-5,
116
0.00019986264001630542
117
],
118
linf=[
119
0.0016987332417202072,
120
0.003622956808262634,
121
0.002029576258317789,
122
0.0024206977281964193,
123
0.008526972236273522
124
],
125
tspan=(0.0, 0.01))
126
# Ensure that we do not have excessive memory allocations
127
# (e.g., from type instabilities)
128
@test_allocations(Trixi.rhs!, semi, sol, 1000)
129
end
130
131
# This test is identical to the one in `test_p4est_3d.jl`.
132
@trixi_testset "elixir_euler_source_terms_nonperiodic.jl" begin
133
@test_trixi_include(joinpath(EXAMPLES_DIR,
134
"elixir_euler_source_terms_nonperiodic.jl"),
135
l2=[
136
0.0015106060984283647,
137
0.0014733349038567685,
138
0.00147333490385685,
139
0.001473334903856929,
140
0.0028149479453087093
141
],
142
linf=[
143
0.008070806335238156,
144
0.009007245083113125,
145
0.009007245083121784,
146
0.009007245083102688,
147
0.01562861968368434
148
],
149
tspan=(0.0, 1.0))
150
# Ensure that we do not have excessive memory allocations
151
# (e.g., from type instabilities)
152
@test_allocations(Trixi.rhs!, semi, sol, 1000)
153
end
154
155
# This test is identical to the one in `test_p4est_3d.jl`.
156
@trixi_testset "elixir_euler_free_stream.jl" begin
157
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream.jl"),
158
l2=[
159
5.162664597942288e-15,
160
1.941857343642486e-14,
161
2.0232366394187278e-14,
162
2.3381518645408552e-14,
163
7.083114561232324e-14
164
],
165
linf=[
166
7.269740365245525e-13,
167
3.289868377720495e-12,
168
4.440087186807773e-12,
169
3.8686831516088205e-12,
170
9.412914891981927e-12
171
],
172
tspan=(0.0, 0.03))
173
# Ensure that we do not have excessive memory allocations
174
# (e.g., from type instabilities)
175
@test_allocations(Trixi.rhs!, semi, sol, 1000)
176
end
177
178
# This test is identical to the one in `test_p4est_3d.jl`.
179
@trixi_testset "elixir_euler_free_stream_extruded.jl" begin
180
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_free_stream_extruded.jl"),
181
l2=[
182
8.444868392439035e-16,
183
4.889826056731442e-15,
184
2.2921260987087585e-15,
185
4.268460455702414e-15,
186
1.1356712092620279e-14
187
],
188
linf=[
189
7.749356711883593e-14,
190
2.8792246364872653e-13,
191
1.1121659149182506e-13,
192
3.3228975127030935e-13,
193
9.592326932761353e-13
194
],
195
tspan=(0.0, 0.1), atol=5.0e-13)
196
# Ensure that we do not have excessive memory allocations
197
# (e.g., from type instabilities)
198
@test_allocations(Trixi.rhs!, semi, sol, 1000)
199
end
200
201
# This test is identical to the one in `test_p4est_3d.jl`.
202
@trixi_testset "elixir_euler_ec.jl" begin
203
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_ec.jl"),
204
l2=[
205
0.010380390326164493,
206
0.006192950051354618,
207
0.005970674274073704,
208
0.005965831290564327,
209
0.02628875593094754
210
],
211
linf=[
212
0.3326911600075694,
213
0.2824952141320467,
214
0.41401037398065543,
215
0.45574161423218573,
216
0.8099577682187109
217
],
218
tspan=(0.0, 0.2))
219
# Ensure that we do not have excessive memory allocations
220
# (e.g., from type instabilities)
221
@test_allocations(Trixi.rhs!, semi, sol, 1000)
222
end
223
224
# This test is identical to the one in `test_p4est_3d.jl` besides minor
225
# deviations in the expected error norms.
226
@trixi_testset "elixir_euler_sedov.jl" begin
227
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_sedov.jl"),
228
l2=[
229
7.82070951e-02,
230
4.33260474e-02,
231
4.33260474e-02,
232
4.33260474e-02,
233
3.75260911e-01
234
],
235
linf=[
236
7.45329845e-01,
237
3.21754792e-01,
238
3.21754792e-01,
239
3.21754792e-01,
240
4.76151527e+00
241
],
242
tspan=(0.0, 0.3))
243
# Ensure that we do not have excessive memory allocations
244
# (e.g., from type instabilities)
245
@test_allocations(Trixi.rhs!, semi, sol, 1000)
246
end
247
248
@trixi_testset "elixir_euler_convergence_pure_fv.jl" begin
249
using Trixi: Trixi
250
@test_trixi_include(joinpath(pkgdir(Trixi, "examples", "tree_3d_dgsem"),
251
"elixir_euler_convergence_pure_fv.jl"),
252
l2=[
253
0.037182410351406,
254
0.032062252638283974,
255
0.032062252638283974,
256
0.03206225263828395,
257
0.12228177813586687
258
],
259
linf=[
260
0.0693648413632646,
261
0.0622101894740843,
262
0.06221018947408474,
263
0.062210189474084965,
264
0.24196451799555962
265
],
266
mesh=T8codeMesh((4, 4, 4), polydeg = 3,
267
coordinates_min = (0.0, 0.0, 0.0),
268
coordinates_max = (2.0, 2.0, 2.0),
269
periodicity = true),
270
# Remove SaveSolution callback
271
callbacks=CallbackSet(summary_callback,
272
analysis_callback, alive_callback,
273
stepsize_callback))
274
# Ensure that we do not have excessive memory allocations
275
# (e.g., from type instabilities)
276
@test_allocations(Trixi.rhs!, semi, sol, 1000)
277
end
278
279
# This test is identical to the one in `test_p4est_3d.jl`.
280
@trixi_testset "elixir_euler_baroclinic_instability.jl" begin
281
@test_trixi_include(joinpath(EXAMPLES_DIR,
282
"elixir_euler_baroclinic_instability.jl"),
283
l2=[
284
6.725093801700048e-7,
285
0.00021710076010951073,
286
0.0004386796338203878,
287
0.00020836270267103122,
288
0.07601887903440395
289
],
290
linf=[
291
1.9107530539574924e-5,
292
0.02980358831035801,
293
0.048476331898047564,
294
0.02200137344113612,
295
4.848310144356219
296
],
297
tspan=(0.0, 1e2),
298
# Decrease tolerance of adaptive time stepping to get similar results across different systems
299
abstol=1.0e-9, reltol=1.0e-9)
300
# Ensure that we do not have excessive memory allocations
301
# (e.g., from type instabilities)
302
@test_allocations(Trixi.rhs!, semi, sol, 1000)
303
end
304
305
@trixi_testset "elixir_euler_weak_blast_wave_amr.jl" begin
306
@test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_euler_weak_blast_wave_amr.jl"),
307
l2=[
308
0.010014531529951328,
309
0.0176268986746271,
310
0.01817514447099777,
311
0.018271085903740675,
312
0.15193033077438198
313
],
314
linf=[
315
0.2898958869606375,
316
0.529717119064458,
317
0.5567193302705906,
318
0.570663236219957,
319
3.5496520808512027
320
],
321
tspan=(0.0, 0.025))
322
# Ensure that we do not have excessive memory allocations
323
# (e.g., from type instabilities)
324
@test_allocations(Trixi.rhs!, semi, sol, 1000)
325
# Check for conservation
326
state_integrals = Trixi.integrate(sol.u[2], semi)
327
initial_state_integrals = analysis_callback.affect!.initial_state_integrals
328
329
@test isapprox(state_integrals[1], initial_state_integrals[1], atol = 1e-13)
330
@test isapprox(state_integrals[2], initial_state_integrals[2], atol = 1e-13)
331
@test isapprox(state_integrals[3], initial_state_integrals[3], atol = 1e-13)
332
@test isapprox(state_integrals[4], initial_state_integrals[4], atol = 1e-13)
333
@test isapprox(state_integrals[5], initial_state_integrals[5], atol = 1e-13)
334
end
335
end
336
337
# Clean up afterwards: delete Trixi.jl output directory
338
@test_nowarn rm(outdir, recursive = true)
339
340
end # module
341
342