Skip to content

Commit d0649d9

Browse files
committed
Fix bug in DSS of level Fields (#2193)
1 parent 557e755 commit d0649d9

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

NEWS.md

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ClimaCore.jl Release Notes
44
main
55
-------
66

7+
- Fixed bug in DSS for level fields. PR [2194](https://github.com/CliMA/ClimaCore.jl/pull/2194).
8+
Closed [2193](https://github.com/CliMA/ClimaCore.jl/issues/2193).
9+
710
v0.14.25
811
-------
912

src/Grids/extruded.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ vertical_topology(grid::ExtrudedFiniteDifferenceGrid) =
131131

132132
# Since ∂z/∂ξ₃ and r are continuous across element boundaries, we can reuse
133133
# the horizontal weights instead of calling compute_dss_weights on the
134-
# extruded local geometry.
135-
dss_weights(grid::AbstractExtrudedFiniteDifferenceGrid, ::Staggering) =
134+
# extruded local geometry. If we ever need to use extruded weights, this method
135+
# will need to distinguish between weights on centers and weights on faces.
136+
dss_weights(grid::AbstractExtrudedFiniteDifferenceGrid, _) =
136137
dss_weights(grid.horizontal_grid, nothing)
137138

138139
local_geometry_data(grid::AbstractExtrudedFiniteDifferenceGrid, ::CellCenter) =

src/Grids/level.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ level(
1616

1717
topology(levelgrid::LevelGrid) = topology(levelgrid.full_grid)
1818

19-
dss_weights(levelgrid::LevelGrid{<:Any, Int}, ::Nothing) =
20-
level(dss_weights(levelgrid.full_grid, CellCenter()), levelgrid.level)
21-
dss_weights(levelgrid::LevelGrid{<:Any, PlusHalf{Int}}, ::Nothing) =
22-
level(dss_weights(levelgrid.full_grid, CellFace()), levelgrid.level + half)
19+
# The DSS weights for extruded spaces are currently the same as the weights for
20+
# horizontal spaces. If we ever need to use extruded weights, this method will
21+
# need to extract the weights at a particular level.
22+
dss_weights(levelgrid::LevelGrid, _) = dss_weights(levelgrid.full_grid, nothing)
2323

2424
local_geometry_type(::Type{LevelGrid{G, L}}) where {G, L} =
2525
local_geometry_type(G)

test/Spaces/unit_dss.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ end
138138
space_kwargs = (; context, topography, deep, autodiff_metric)
139139
center_space =
140140
TU.CenterExtrudedFiniteDifferenceSpace(FT; space_kwargs...)
141-
for space in (center_space, Spaces.face_space(center_space))
141+
face_space = Spaces.face_space(center_space)
142+
level_space1 = Spaces.level(center_space, 2)
143+
level_space2 = Spaces.level(face_space, 1 + Spaces.half)
144+
for space in (center_space, face_space, level_space1, level_space2)
142145
test_dss_conservation(space)
143146
end
144147
end

0 commit comments

Comments
 (0)