CliMA / CliMA/ClimaCore.jl

Clarify 2d spaces

Open
#1,578 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
117
Forks
19
Avg merge
3d 8h
Merged PRs (30d)
38

Description

**Is your feature request related to a problem? Please describe.**
Currently, there are two types of 2d fields
- 1. ones that were defined directly using `SpectralElementSpace2D`
- 2. ones that were defined using `ExtrudedFiniteDifferenceSpace` and then indexed into using `Fields.level`

when queried, both print the same info, e.g.:
```
SpectralElementSpace2D:
context: SingletonCommsContext using CPUSingleThreaded
mesh: 4×4×6-element EquiangularCubedSphere of SphereDomain: radius = 6.371e6
quadrature: 4-point Gauss-Legendre-Lobatto quadrature
```
but 2. still contains it's original 3d info and jacobian, etc. This may cause problems when dispatching on space type and/or calculating area integrals using sum.

**Describe the solution you'd like**
It would be good to make 2. a 3d space and allow an additional 2d reduction from that.

**Min demo example**
```
using ClimaCore: Fields, Domains, Meshes, Topologies, Spaces, Geometry, Utilities
function create_space(
FT;
comms_ctx = ClimaComms.SingletonCommsContext(),
R = FT(6371e3),
ne = 4,
polynomial_degree = 3,
nz = 1,
)
domain = Domains.SphereDomain(R)
mesh = Meshes.EquiangularCubedSphere(domain, ne)

if comms_ctx isa ClimaComms.SingletonCommsContext
topology = Topologies.Topology2D(mesh, Topologies.spacefillingcurve(mesh))
else
topology = Topologies.DistributedTopology2D(comms_ctx, mesh, Topologies.spacefillingcurve(mesh))
end

Nq = polynomial_degree + 1
quad = Spaces.Quadratures.GLL{Nq}()
sphere_space = Spaces.SpectralElementSpace2D(topology, quad)

if nz > 1
vertdomain =
Domains.IntervalDomain(Geometry.ZPoint{FT}(0), Geometry.ZPoint{FT}(100); boundary_tags = (:bottom, :top))
vertmesh = Meshes.IntervalMesh(vertdomain, nelems = nz)
vert_center_space = Spaces.CenterFiniteDifferenceSpace(vertmesh)
return Spaces.ExtrudedFiniteDifferenceSpace(sphere_space, vert_center_space)
else
return sphere_space
end
end

FT = Float64
space_2d = create_space(FT, nz = 1, R = 6371e3)
space_3d = create_space(FT, nz = 3, R = 6371e3)
space_2d_from_3d = Fields.level(space_3d, 1)

space_2d isa Spaces.SpectralElementSpace2D # true
space_2d_from_3d isa Spaces.SpectralElementSpace2D # true

expected_sum = 4π * 6371e3^2 # 5.1006447190978825e14
sum(ones(space_2d)) # 5.100617440612155e14
sum(ones(space_2d_from_3d)) # 1.700205813537382e16

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the create_space demo and the behavior of Spaces.ExtrudedFiniteDifferenceSpace, Fields.level, and sum for space_2d_from_3d. Clarify how the 3D space should remain distinct while allowing a 2D reduction, then verify that the reduced space has correct dispatch and produces the expected area integral.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.