Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in DSS of level Fields #2194

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ClimaCore.jl Release Notes
main
-------

- Fixed bug in DSS for level fields. PR [2194](https://github.com/CliMA/ClimaCore.jl/pull/2194).
Closed [2193](https://github.com/CliMA/ClimaCore.jl/issues/2193).

v0.14.25
-------

Expand Down
5 changes: 3 additions & 2 deletions src/Grids/extruded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ vertical_topology(grid::ExtrudedFiniteDifferenceGrid) =

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

local_geometry_data(grid::AbstractExtrudedFiniteDifferenceGrid, ::CellCenter) =
Expand Down
8 changes: 4 additions & 4 deletions src/Grids/level.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ level(

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

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

local_geometry_type(::Type{LevelGrid{G, L}}) where {G, L} =
local_geometry_type(G)
Expand Down
5 changes: 4 additions & 1 deletion test/Spaces/unit_dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ end
space_kwargs = (; context, topography, deep, autodiff_metric)
center_space =
TU.CenterExtrudedFiniteDifferenceSpace(FT; space_kwargs...)
for space in (center_space, Spaces.face_space(center_space))
face_space = Spaces.face_space(center_space)
level_space1 = Spaces.level(center_space, 2)
level_space2 = Spaces.level(face_space, 1 + Spaces.half)
for space in (center_space, face_space, level_space1, level_space2)
test_dss_conservation(space)
end
end
Expand Down
Loading