Skip to content

Commit 660894d

Browse files
Merge pull request #3799 from CliMA/ck/peeloff
Use space instead of field, improve docs
2 parents 9975dda + 3ee6ecb commit 660894d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/cache/precomputed_quantities.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ end
283283
function surface_velocity(ᶠu₃, ᶠuₕ³)
284284
sfc_u₃ = Fields.level(ᶠu₃.components.data.:1, half)
285285
sfc_uₕ³ = Fields.level(ᶠuₕ³.components.data.:1, half)
286-
sfc_g³³ = g³³_field(sfc_u₃)
286+
sfc_g³³ = g³³_field(axes(sfc_u₃))
287287
return @. lazy(-sfc_uₕ³ / sfc_g³³) # u³ = uₕ³ + w³ = uₕ³ + w₃ * g³³
288288
end
289289

src/utils/utilities.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ function compute_strain_rate_face(u::Fields.Field)
117117
end
118118

119119
"""
120-
g³³_field(field)
120+
g³³_field(space)
121121
122-
Extracts the value of `g³³` from `Fields.local_geometry_field(field)`.
122+
Extracts the value of `g³³`, the 3rd component of the metric terms that convert
123+
Covariant AxisTensors to Contravariant AxisTensors, from the given space.
123124
"""
124-
function g³³_field(field)
125-
g_field = Fields.local_geometry_field(field).gⁱʲ.components.data
125+
function g³³_field(space)
126+
g_field = Fields.local_geometry_field(space).gⁱʲ.components.data
126127
end_index = fieldcount(eltype(g_field)) # This will be 4 in 2D and 9 in 3D.
127128
return g_field.:($end_index) # For both 2D and 3D spaces, g³³ = g[end].
128129
end

test/utilities.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,8 @@ end
166166
(; cent_space, face_space) = get_cartesian_spaces()
167167
lg_gⁱʲ = cent_space.grid.center_local_geometry.gⁱʲ
168168
lg_g³³ = lg_gⁱʲ.components.data.:9
169-
@test Fields.field_values(
170-
CA.g³³_field(Fields.coordinate_field(cent_space).x),
171-
) == lg_g³³
169+
(; x) = Fields.coordinate_field(cent_space)
170+
@test Fields.field_values(CA.g³³_field(axes(x))) == lg_g³³
172171
@test maximum(abs.(lg_g³³ .- CA.g³³.(lg_gⁱʲ).components.data.:1)) == 0
173172
@test maximum(abs.(CA.g³ʰ.(lg_gⁱʲ).components.data.:1)) == 0
174173
@test maximum(abs.(CA.g³ʰ.(lg_gⁱʲ).components.data.:2)) == 0

0 commit comments

Comments
 (0)