CliMA / CliMA/ClimaCore.jl

Spectral broadcasts don't always catch mismatched spaces errors

Open
#605 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
117
Forks
19
Avg merge
3d 5h
Merged PRs (30d)
36

Description

While using spectral operations on hybrid domains, I have found that the spectral broadcasting machinery fails to catch certain mismatched spaces errors. For example, it is possible to perform a spectral operation on a face-valued space and assign the result to a center-valued space:
```
const FT = Float64
xmax = FT(1)
zmax = FT(1)
xelem = 10
zelem = 10
npoly = 4
hdomain = Domains.IntervalDomain(
Geometry.XPoint(FT(0)),
Geometry.XPoint(xmax);
periodic = true,
)
hmesh = Meshes.IntervalMesh(hdomain; nelems = xelem)
htopology = Topologies.IntervalTopology(hmesh)
quad = Spaces.Quadratures.GLL{npoly + 1}()
hspace = Spaces.SpectralElementSpace1D(htopology, quad)
vdomain = Domains.IntervalDomain(
Geometry.ZPoint(FT(0)),
Geometry.ZPoint(zmax);
boundary_tags = (:bottom, :top),
)
vmesh = Meshes.IntervalMesh(vdomain, nelems = zelem)
vspace = Spaces.CenterFiniteDifferenceSpace(vmesh)
center_space = Spaces.ExtrudedFiniteDifferenceSpace(hspace, vspace)
face_space = Spaces.FaceExtrudedFiniteDifferenceSpace(center_space)

center_field = Fields.Field(FT, center_space)
face_field = Fields.Field(FT, face_space)
face_field .= (_ -> rand(FT)).(face_field)

center_field .= Operators.WeakDivergence().(Operators.Gradient().(face_field))
actual_result = Operators.WeakDivergence().(Operators.Gradient().(face_field))
parent(center_field) == parent(actual_result)[1:zelem, :, :, :] # returns true
```
As indicated on the last line, the values at the top face of the actual result (level `zelem + 1`) are ignored when the broadcast is materialized into `center_field`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.