Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/test/test_mpi_p4est_parabolic_2d.jl
5582 views
1
module TestExamplesMPIP4estMesh2DParabolic
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 Parabolic" begin
11
@trixi_testset "P4estMesh2D: elixir_navierstokes_lid_driven_cavity.jl" begin
12
@test_trixi_include(joinpath(EXAMPLES_DIR,
13
"elixir_navierstokes_lid_driven_cavity.jl"),
14
initial_refinement_level=2, tspan=(0.0, 0.5),
15
l2=[
16
0.00028716166408816073,
17
0.08101204560401647,
18
0.02099595625377768,
19
0.05008149754143295
20
],
21
linf=[
22
0.014804500261322406,
23
0.9513271652357098,
24
0.7223919625994717,
25
1.4846907331004786
26
])
27
# Ensure that we do not have excessive memory allocations
28
# (e.g., from type instabilities)
29
@test_allocations(Trixi.rhs!, semi, sol, 1500)
30
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1500)
31
end
32
33
@trixi_testset "P4estMesh2D: elixir_navierstokes_convergence_nonperiodic.jl" begin
34
@test_trixi_include(joinpath(EXAMPLES_DIR,
35
"elixir_navierstokes_convergence_nonperiodic.jl"),
36
initial_refinement_level=1, tspan=(0.0, 0.2),
37
l2=[
38
0.0004036496258545996,
39
0.0005869762480189079,
40
0.0009148853742181908,
41
0.0011984191532764543
42
],
43
linf=[
44
0.0024993634989209923,
45
0.009487866203496731,
46
0.004505829506103787,
47
0.011634902753554499
48
])
49
# Ensure that we do not have excessive memory allocations
50
# (e.g., from type instabilities)
51
@test_allocations(Trixi.rhs!, semi, sol, 1500)
52
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1500)
53
end
54
55
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_nonperiodic_curved.jl" begin
56
@test_trixi_include(joinpath(EXAMPLES_DIR,
57
"elixir_advection_diffusion_nonperiodic_curved.jl"),
58
trees_per_dimension=(1, 1), initial_refinement_level=2,
59
tspan=(0.0, 0.5),
60
l2=[0.00919917034843865],
61
linf=[0.14186297438393505])
62
# Ensure that we do not have excessive memory allocations
63
# (e.g., from type instabilities)
64
@test_allocations(Trixi.rhs!, semi, sol, 1500)
65
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1500)
66
end
67
68
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_periodic.jl" begin
69
@test_trixi_include(joinpath(EXAMPLES_DIR,
70
"elixir_advection_diffusion_periodic.jl"),
71
trees_per_dimension=(1, 1), initial_refinement_level=2,
72
tspan=(0.0, 0.5),
73
l2=[0.0023754695605828443],
74
linf=[0.008154128363741964])
75
# Ensure that we do not have excessive memory allocations
76
# (e.g., from type instabilities)
77
@test_allocations(Trixi.rhs!, semi, sol, 1500)
78
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1500)
79
end
80
81
@trixi_testset "elixir_navierstokes_NACA0012airfoil_mach08.jl" begin
82
@test_trixi_include(joinpath(EXAMPLES_DIR,
83
"elixir_navierstokes_NACA0012airfoil_mach08.jl"),
84
l2=[0.000186486564226516,
85
0.0005076712323400374,
86
0.00038074588984354107,
87
0.002128177239782089],
88
linf=[0.5153387072802718,
89
1.199362305026636,
90
0.9077214424040279,
91
5.666071182328691], tspan=(0.0, 0.001),
92
initial_refinement_level=0)
93
94
u_ode = copy(sol.u[end])
95
du_ode = zero(u_ode) # Just a placeholder in this case
96
97
u = Trixi.wrap_array(u_ode, semi)
98
du = Trixi.wrap_array(du_ode, semi)
99
100
drag_p = Trixi.analyze(drag_coefficient, du, u, tspan[2], mesh, equations, solver,
101
semi.cache, semi)
102
lift_p = Trixi.analyze(lift_coefficient, du, u, tspan[2], mesh, equations, solver,
103
semi.cache, semi)
104
105
drag_f = Trixi.analyze(drag_coefficient_shear_force, du, u, tspan[2], mesh,
106
equations, equations_parabolic, solver,
107
semi.cache, semi, semi.cache_parabolic)
108
lift_f = Trixi.analyze(lift_coefficient_shear_force, du, u, tspan[2], mesh,
109
equations, equations_parabolic, solver,
110
semi.cache, semi, semi.cache_parabolic)
111
112
@test isapprox(drag_p, 0.17963843913309516, atol = 1e-13)
113
@test isapprox(lift_p, 0.26462588007949367, atol = 1e-13)
114
115
@test isapprox(drag_f, 1.5427441885921553, atol = 1e-13)
116
@test isapprox(lift_f, 0.005621910087395724, atol = 1e-13)
117
118
# Ensure that we do not have excessive memory allocations
119
# (e.g., from type instabilities)
120
# We move these tests here to avoid modifying values used
121
# to compute the drag/lift coefficients above.
122
@test_allocations(Trixi.rhs!, semi, sol, 1500)
123
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1500)
124
end
125
126
@trixi_testset "P4estMesh2D: elixir_advection_diffusion_amr_inverted_index.jl" begin
127
#Test that the mpi parabolic solver works for inverted node indexing from external mesh files.
128
@test_trixi_include(joinpath(EXAMPLES_DIR,
129
"elixir_advection_diffusion_amr_inverted_index.jl"),
130
tspan=(0.0, 0.5),
131
l2=[0.1717677505262361],
132
linf=[1.9925134228101835],
133
atol=1e-8,
134
rtol=1e-8)
135
# Ensure that we do not have excessive memory allocations
136
@test_allocations(Trixi.rhs!, semi, sol, 1500)
137
@test_allocations(Trixi.rhs_parabolic!, semi, sol, 1500)
138
end
139
end
140
end # module
141
142