Skip to content

Commit b55387b

Browse files
Use @test_allocations from TrixiTest.jl (#112)
* use at-test_allocations from TrixiTest.jl * bump TrixiTest.jl to v0.1.3
1 parent 5508aa7 commit b55387b

File tree

7 files changed

+30
-175
lines changed

7 files changed

+30
-175
lines changed

test/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ OrdinaryDiffEqLowStorageRK = "1.2"
1414
OrdinaryDiffEqSSPRK = "1.2"
1515
Test = "1"
1616
Trixi = "0.13"
17-
TrixiTest = "0.1.2"
17+
TrixiTest = "0.1.3"

test/test_2d_moist_euler.jl

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ include("test_trixiatmo.jl")
2424
tspan=(0.0, 0.1))
2525
# Ensure that we do not have excessive memory allocations
2626
# (e.g., from type instabilities)
27-
let
28-
t = sol.t[end]
29-
u_ode = sol.u[end]
30-
du_ode = similar(u_ode)
31-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
32-
end
27+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
3328
end
3429

3530
@trixi_testset "elixir_moist_euler_EC_bubble" begin
@@ -55,12 +50,7 @@ end
5550
tspan=(0.0, 0.1))
5651
# Ensure that we do not have excessive memory allocations
5752
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
63-
end
53+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
6454
end
6555

6656
@trixi_testset "elixir_moist_euler_moist_bubble" begin
@@ -86,12 +76,7 @@ end
8676
tspan=(0.0, 0.1))
8777
# Ensure that we do not have excessive memory allocations
8878
# (e.g., from type instabilities)
89-
let
90-
t = sol.t[end]
91-
u_ode = sol.u[end]
92-
du_ode = similar(u_ode)
93-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
94-
end
79+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
9580
end
9681

9782
@trixi_testset "elixir_moist_euler_nonhydrostatic_gravity_waves" begin
@@ -118,12 +103,7 @@ end
118103
tspan=(0.0, 0.1))
119104
# Ensure that we do not have excessive memory allocations
120105
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
126-
end
106+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
127107
end
128108

129109
@trixi_testset "elixir_moist_euler_source_terms_dry" begin
@@ -149,12 +129,7 @@ end
149129
tspan=(0.0, 0.1))
150130
# Ensure that we do not have excessive memory allocations
151131
# (e.g., from type instabilities)
152-
let
153-
t = sol.t[end]
154-
u_ode = sol.u[end]
155-
du_ode = similar(u_ode)
156-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
157-
end
132+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
158133
end
159134

160135
@trixi_testset "elixir_moist_euler_source_terms_moist" begin
@@ -180,12 +155,7 @@ end
180155
tspan=(0.0, 0.1))
181156
# Ensure that we do not have excessive memory allocations
182157
# (e.g., from type instabilities)
183-
let
184-
t = sol.t[end]
185-
u_ode = sol.u[end]
186-
du_ode = similar(u_ode)
187-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
188-
end
158+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
189159
end
190160

191161
@trixi_testset "elixir_moist_euler_source_terms_split_moist" begin
@@ -212,12 +182,7 @@ end
212182
tspan=(0.0, 0.1))
213183
# Ensure that we do not have excessive memory allocations
214184
# (e.g., from type instabilities)
215-
let
216-
t = sol.t[end]
217-
u_ode = sol.u[end]
218-
du_ode = similar(u_ode)
219-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
220-
end
185+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
221186
end
222187

223188
end # module

test/test_2d_shallow_water_covariant.jl

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ include("test_trixiatmo.jl")
2020
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
2121
# Ensure that we do not have excessive memory allocations
2222
# (e.g., from type instabilities)
23-
let
24-
t = sol.t[end]
25-
u_ode = sol.u[end]
26-
du_ode = similar(u_ode)
27-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
28-
end
23+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
2924
end
3025

3126
@trixi_testset "elixir_shallowwater_covariant_rossby_haurwitz" begin
@@ -39,12 +34,7 @@ end
3934
metric_terms=MetricTermsCovariantSphere(christoffel_symbols = ChristoffelSymbolsCollocationDerivative()))
4035
# Ensure that we do not have excessive memory allocations
4136
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
47-
end
37+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
4838
end
4939

5040
@trixi_testset "elixir_shallowwater_covariant_isolated_mountain" begin
@@ -57,12 +47,7 @@ end
5747
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
5848
# Ensure that we do not have excessive memory allocations
5949
# (e.g., from type instabilities)
60-
let
61-
t = sol.t[end]
62-
u_ode = sol.u[end]
63-
du_ode = similar(u_ode)
64-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
65-
end
50+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
6651
end
6752

6853
@trixi_testset "elixir_shallowwater_covariant_unsteady_solid_body_rotation_EC" begin
@@ -85,12 +70,7 @@ end
8570
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
8671
# Ensure that we do not have excessive memory allocations
8772
# (e.g., from type instabilities)
88-
let
89-
t = sol.t[end]
90-
u_ode = sol.u[end]
91-
du_ode = similar(u_ode)
92-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
93-
end
73+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
9474
end
9575

9676
@trixi_testset "elixir_shallowwater_covariant_barotropic_instability" begin
@@ -103,12 +83,7 @@ end
10383
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
10484
# Ensure that we do not have excessive memory allocations
10585
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
111-
end
86+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
11287
end
11388

11489
@trixi_testset "elixir_shallowwater_covariant_well_balanced" begin
@@ -120,12 +95,7 @@ end
12095
tspan=(0.0, 1.0 * SECONDS_PER_DAY), atol=1e-11)
12196
# Ensure that we do not have excessive memory allocations
12297
# (e.g., from type instabilities)
123-
let
124-
t = sol.t[end]
125-
u_ode = sol.u[end]
126-
du_ode = similar(u_ode)
127-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
128-
end
98+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
12999
end
130100

131101
end # module

test/test_3d_shallow_water.jl

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ include("test_trixiatmo.jl")
2424
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
2525
# Ensure that we do not have excessive memory allocations
2626
# (e.g., from type instabilities)
27-
let
28-
t = sol.t[end]
29-
u_ode = sol.u[end]
30-
du_ode = similar(u_ode)
31-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
32-
end
27+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
3328
end
3429

3530
@trixi_testset "elixir_shallowwater_cartesian_unsteady_solid_body_rotation_EC_projection" begin
@@ -54,12 +49,7 @@ end
5449
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
5550
# Ensure that we do not have excessive memory allocations
5651
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
62-
end
52+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
6353
end
6454

6555
@trixi_testset "elixir_shallowwater_cartesian_unsteady_solid_body_rotation_EC_projection (ES)" begin
@@ -87,12 +77,7 @@ end
8777
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
8878
# Ensure that we do not have excessive memory allocations
8979
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
95-
end
80+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
9681
end
9782

9883
@trixi_testset "elixir_shallowwater_cartesian_well_balanced" begin
@@ -103,12 +88,7 @@ end
10388
atol=8.0e-11) # Needs a slightly larger tolerance for linf
10489
# Ensure that we do not have excessive memory allocations
10590
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
111-
end
91+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
11292
end
11393

11494
@trixi_testset "elixir_shallowwater_cartesian_geostrophic_balance (naive)" begin
@@ -131,12 +111,7 @@ end
131111
flux_nonconservative_wintermeyer_etal)) # use "naive" wave speed estimate for coverage
132112
# Ensure that we do not have excessive memory allocations
133113
# (e.g., from type instabilities)
134-
let
135-
t = sol.t[end]
136-
u_ode = sol.u[end]
137-
du_ode = similar(u_ode)
138-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
139-
end
114+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
140115
end
141116

142117
@trixi_testset "elixir_shallowwater_cartesian_isolated_mountain" begin
@@ -161,12 +136,7 @@ end
161136
tspan=(0.0, 1.0 * SECONDS_PER_DAY))
162137
# Ensure that we do not have excessive memory allocations
163138
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
169-
end
139+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
170140
end
171141

172142
end # module

test/test_mpi.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,7 @@ CI_ON_WINDOWS = (get(ENV, "GITHUB_ACTIONS", false) == "true") && Sys.iswindows()
3939
tspan=(0.0, 0.1))
4040
# Ensure that we do not have excessive memory allocations
4141
# (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 TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
47-
end
42+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 1000)
4843
end
4944
end
5045

test/test_spherical_advection.jl

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ include("test_trixiatmo.jl")
2222
# and small reference values
2323
# Ensure that we do not have excessive memory allocations
2424
# (e.g., from type instabilities)
25-
let
26-
t = sol.t[end]
27-
u_ode = sol.u[end]
28-
du_ode = similar(u_ode)
29-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
30-
end
25+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
3126
end
3227

3328
@trixi_testset "Spherical advection (quad icosahedron), Cartesian weak form, LLF surface flux" begin
@@ -50,12 +45,7 @@ end
5045
# and small reference values
5146
# Ensure that we do not have excessive memory allocations
5247
# (e.g., from type instabilities)
53-
let
54-
t = sol.t[end]
55-
u_ode = sol.u[end]
56-
du_ode = similar(u_ode)
57-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
58-
end
48+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
5949
end
6050

6151
@trixi_testset "Spherical advection, Cartesian weak form, element-local mapping" begin
@@ -78,12 +68,7 @@ end
7868
# and small reference values
7969
# Ensure that we do not have excessive memory allocations
8070
# (e.g., from type instabilities)
81-
let
82-
t = sol.t[end]
83-
u_ode = sol.u[end]
84-
du_ode = similar(u_ode)
85-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
86-
end
71+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
8772
end
8873

8974
@trixi_testset "Spherical advection, covariant weak form, LLF surface flux" begin
@@ -93,12 +78,7 @@ end
9378
linf=[14.235905681508598, 0.0, 0.0])
9479
# Ensure that we do not have excessive memory allocations
9580
# (e.g., from type instabilities)
96-
let
97-
t = sol.t[end]
98-
u_ode = sol.u[end]
99-
du_ode = similar(u_ode)
100-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
101-
end
81+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
10282
end
10383

10484
@trixi_testset "Spherical advection, covariant weak form, LLF surface flux, global spherical coords" begin
@@ -109,12 +89,7 @@ end
10989
global_coordinate_system=GlobalSphericalCoordinates())
11090
# Ensure that we do not have excessive memory allocations
11191
# (e.g., from type instabilities)
112-
let
113-
t = sol.t[end]
114-
u_ode = sol.u[end]
115-
du_ode = similar(u_ode)
116-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
117-
end
92+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
11893
end
11994

12095
# The covariant flux-differencing form should be equivalent to the weak form when the
@@ -127,12 +102,7 @@ end
127102
volume_integral=VolumeIntegralFluxDifferencing(flux_central))
128103
# Ensure that we do not have excessive memory allocations
129104
# (e.g., from type instabilities)
130-
let
131-
t = sol.t[end]
132-
u_ode = sol.u[end]
133-
du_ode = similar(u_ode)
134-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
135-
end
105+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
136106
end
137107

138108
# Version with arithmetic mean used for both the volume and surface fluxes
@@ -145,12 +115,7 @@ end
145115
surface_flux=flux_central)
146116
# Ensure that we do not have excessive memory allocations
147117
# (e.g., from type instabilities)
148-
let
149-
t = sol.t[end]
150-
u_ode = sol.u[end]
151-
du_ode = similar(u_ode)
152-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
153-
end
118+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
154119
end
155120

156121
@trixi_testset "Spherical advection on icosahedral grid, covariant weak form, LLF surface flux" begin
@@ -160,12 +125,7 @@ end
160125
linf=[13.54834739856517, 0.0, 0.0])
161126
# Ensure that we do not have excessive memory allocations
162127
# (e.g., from type instabilities)
163-
let
164-
t = sol.t[end]
165-
u_ode = sol.u[end]
166-
du_ode = similar(u_ode)
167-
@test (@allocated TrixiAtmo.Trixi.rhs!(du_ode, u_ode, semi, t)) < 100
168-
end
128+
@test_allocations(TrixiAtmo.Trixi.rhs!, semi, sol, 100)
169129
end
170130

171131
end # module

0 commit comments

Comments
 (0)