Spaces

A space is a grid together with the information a field needs to live on it: for a vertical grid, the staggering (cell centers or cell faces). Two discretizations are provided, spectral elements (continuous or discontinuous Galerkin) in the horizontal and staggered finite differences in the vertical, and their product is an extruded (hybrid) space.

3D hybrid discretization in a Cartesian domain

An extruded space on a box: spectral elements with their quadrature nodes in the horizontal, stacked over the cells of a staggered vertical grid.

ClimaCore.SpacesModule
Spaces

Function spaces on which fields are defined. A space combines a grid (domain, topology, coordinates, metric terms, and quadrature rules and weights) with a vertical staggering.

Notes

References: CEED and the ClimateMachine sphere helpers.

source
ClimaCore.Spaces.AbstractSpaceType
AbstractSpace

Abstract supertype of spaces. Subtypes define grid(space), staggering(space), and the constructor space(grid, staggering).

source
ClimaCore.Spaces.Δz_dataFunction
Δz_data(space::AbstractSpace)

Return a DataLayout containing the vertical extent Δz = ∂z/∂ξ³ of each cell of space [m].

source

Finite Difference Spaces

A finite-difference space holds one value per cell of an interval mesh, either at the cell centers (CenterFiniteDifferenceSpace) or at the faces between cells (FaceFiniteDifferenceSpace). Construct one of the two from the mesh and derive the other from it with Spaces.face_space or Spaces.center_space; the two share one grid and no geometry is allocated twice.

ClimaCore.Spaces.FiniteDifferenceSpaceType
FiniteDifferenceSpace(grid::Grids.FiniteDifferenceGrid, staggering::Staggering)
FiniteDifferenceSpace(topology::Topologies.IntervalTopology, staggering::Staggering)

One-dimensional finite-difference space, located at either

source

Spectral Element Spaces

ClimaCore.Spaces.SpectralElementSpace1DType
SpectralElementSpace1D(grid::Grids.SpectralElementGrid1D)
SpectralElementSpace1D(
    topology::Topologies.IntervalTopology,
    quadrature_style::Quadratures.QuadratureStyle;
    discretization = nothing,
    kwargs...
)

A one-dimensional spectral-element space. The second form builds the Grids.SpectralElementGrid1D and forwards kwargs to it; discretization = Grids.DG() makes the space discontinuous across element boundaries, and omitting it follows the quadrature. Read the choice back with Spaces.discretization.

source
ClimaCore.Spaces.SpectralElementSpace2DType
SpectralElementSpace2D(grid::Grids.SpectralElementGrid2D)
SpectralElementSpace2D(
    topology::Topologies.Topology2D,
    quadrature_style::Quadratures.QuadratureStyle;
    discretization = nothing,
    kwargs...,
)

A two-dimensional spectral-element space. The second form builds the Grids.SpectralElementGrid2D and forwards kwargs to it (discretization, enable_bubble, enable_mask, autodiff_metric, VIJH); discretization = Grids.DG() makes the space discontinuous across element boundaries, so Spaces.weighted_dss! is a no-op and inter-element coupling goes through numerical fluxes. Omitting it follows the quadrature. Read the choice back with Spaces.discretization.

Examples

space = Spaces.SpectralElementSpace2D(topology, Quadratures.GLL{4}())
dg_space = Spaces.SpectralElementSpace2D(
    topology,
    Quadratures.GLL{4}();
    discretization = Grids.DG(),
)
source

Discretization: CG or DG

The Galerkin discretization of a spectral-element grid is a type parameter of the grid, set with the discretization keyword of the grid and space constructors and read back from the space (Choose CG or DG).

The types and accessors are documented on the Grids page: Grids.Discretization, Grids.CG, Grids.DG, Grids.discretization, Grids.is_continuous. Spaces.discretization and Spaces.is_continuous are the same functions applied to a space.

Extruded Finite Difference Spaces

ClimaCore.Spaces.ExtrudedFiniteDifferenceSpaceType
ExtrudedFiniteDifferenceSpace(grid, staggering)

ExtrudedFiniteDifferenceSpace(
    horizontal_space::AbstractSpace,
    vertical_space::FiniteDifferenceSpace,
    hypsography::Grids.HypsographyAdaption = Grids.Flat();
    deep::Bool = false,
)

Extruded finite-difference space: a horizontal space extruded along a staggered vertical direction, with grid information at either

The second constructor takes the staggering from vertical_space; deep = true selects deep-atmosphere spherical geometry.

source

Point Spaces

ClimaCore.Spaces.PointSpaceType
PointSpace <: AbstractSpace

A zero-dimensional space: a single point, the horizontal space of one column (Spaces.level of a FiniteDifferenceSpace). For N disconnected horizontal points see MultiPointSpace, and for N independent columns see MultiColumnFiniteDifferenceSpace.

Constructor

PointSpace(context::ClimaComms.AbstractCommsContext, local_geometry::Geometry.LocalGeometry)
PointSpace(context::ClimaComms.AbstractCommsContext, coord::Geometry.Abstract1DPoint)
PointSpace(device::ClimaComms.AbstractDevice, x)
PointSpace(x)

Construct a PointSpace from a LocalGeometry, or from a 1D coordinate with unit metric terms. Without a context, the default ClimaComms.context() is used.

source

Multi-column Spaces

ClimaCore.Spaces.MultiPointSpaceType
MultiPointSpace(grid)

Horizontal space of N independent (lat, lon) points. This is the N-column analog of PointSpace, which is the single-column level space.

Like SpectralElementSpace2D, the wrapped grid is either

  • a Grids.MultiPointGrid, the level-agnostic horizontal grid of a MultiColumnFiniteDifferenceSpace (returned by Spaces.horizontal_space), or
  • a Grids.LevelGrid of the extruded multi-column grid at a single vertical level (returned by Spaces.level), carrying full 3D local geometry.
source
ClimaCore.Spaces.MultiColumnFiniteDifferenceSpaceType
MultiColumnFiniteDifferenceSpace(grid, staggering)

Space of N independent vertical columns at arbitrary horizontal (lat, lon) locations on a sphere. This is the N-column generalization of Spaces.FiniteDifferenceSpace, the single-column space:

  • The data layout is VIJFH{LG, Nv, 1, 1, N}: the same vertical structure for every column, with full 3D local geometry including lat, lon, and z coordinates.
  • Spaces.level returns a MultiPointSpace (N points at that level) rather than a spectral element horizontal space.
  • Spaces.column returns a single-column Spaces.FiniteDifferenceSpace.
  • Fields.bycolumn iterates over each column independently.

There is no horizontal connectivity between columns; DSS is not supported, and horizontal spectral-element derivative operators evaluate to zero, as on a single column.

source

Accessors

The grid underlying a space, and accessors for its parameters and indices. Accessors that a space forwards to its grid are documented on the Grids page and are called with the Grids qualifier: Grids.topology(space), Grids.quadrature_style(space), Grids.global_geometry(space), Grids.vertical_topology(space), Grids.dss_weights(space), Grids.set_mask!(space, …), Grids.get_mask(space), and Grids.hypsography(space). Likewise with accessors that are forwarded to lower-level modules: Domains.z_min(space), Domains.z_max(space), Meshes.n_elements_per_panel_direction(space), Topologies.create_dss_buffer(field), ClimaCore.level(space, i), and ClimaCore.column(space, i, j, h).

ClimaCore.Spaces.gridFunction
Spaces.grid(space::AbstractSpace)

Return the Grids.AbstractGrid underlying space: the domain, topology, coordinates, metric terms, and quadrature, without the vertical staggering.

source
ClimaCore.Spaces.horizontal_gridFunction
Spaces.horizontal_grid(grid::Grids.AbstractGrid)

Return the horizontal grid underlying grid: a spectral element grid is its own horizontal grid, and a Grids.LevelGrid returns the horizontal grid of the extruded grid it is a level of. Used to decide whether two horizontal spaces share a grid (see Spaces.issubspace).

source
ClimaCore.Spaces.vertical_gridFunction
Spaces.vertical_grid(grid::Grids.AbstractGrid)

Return the vertical (finite difference) grid underlying grid: a finite difference grid is its own vertical grid, an extruded grid returns its vertical_grid, and a Grids.ColumnGrid returns the vertical grid of the extruded grid it is a column of. Used to decide whether two vertical spaces share a grid (see Spaces.issubspace).

source
ClimaCore.Spaces.center_spaceFunction
center_space(space::FiniteDifferenceSpace)

Return the cell-centered space corresponding to space. If space is already cell-centered, return an equal space.

source
center_space(space::ExtrudedFiniteDifferenceSpace)

Return the cell-centered space corresponding to space. If space is already cell-centered, return an equal space.

source
ClimaCore.Spaces.face_spaceFunction
face_space(space::FiniteDifferenceSpace)

Return the face-centered space corresponding to space. If space is already face-centered, return an equal space.

source
face_space(space::ExtrudedFiniteDifferenceSpace)

Return the face-centered space corresponding to space. If space is already face-centered, return an equal space.

source
ClimaCore.Spaces.nlevelsFunction
nlevels(space::AbstractSpace)

Return the number of vertical levels of space at its staggering: the number of cell centers or cell faces for a staggered space, and 1 for a horizontal space.

source
ClimaCore.Spaces.ncolumnsFunction
ncolumns(space::AbstractSpace)

Return the number of columns of space on the local process.

source
ncolumns(::Field)

Return the number of columns of the space of field.

source
ClimaCore.Spaces.undertypeFunction
Spaces.undertype(space::AbstractSpace)

Return the underlying floating-point type of space, i.e. the number type of the coordinates and metric terms of its local geometry.

source
ClimaCore.Spaces.coordinates_dataFunction
Spaces.coordinates_data(space::AbstractSpace)
Spaces.coordinates_data(grid::Grids.AbstractGrid)
Spaces.coordinates_data(staggering, grid::Grids.AbstractGrid)

Return the DataLayout of coordinates of space (or of grid at the given staggering): the coordinates of its local geometry.

source
ClimaCore.Spaces.radiusFunction
Spaces.radius(space::AbstractSpace)

Return the radius [m] of the sphere on which space is defined, read from the radius of its global geometry (Spaces.global_geometry(space)). Throws an ArgumentError if the global geometry is not spherical, e.g. for spaces on planar or interval domains.

source
ClimaCore.Spaces.issubspaceFunction
Spaces.issubspace(subspace::AbstractSpace, space::AbstractSpace)

Return true if fields on subspace can be broadcast against fields on space: subspace is space itself, the horizontal space or a level of an extruded space, or the vertical space or a column of it. Two spaces built on the same grid with different staggering are not subspaces of each other.

source
ClimaCore.Spaces.eachslabindexFunction
Spaces.eachslabindex(space::AbstractSpace)

Return an iterator over the indices of the slabs (single elements at a single level) of space: element indices h for a spectral element space, and (v, h) tuples of level and element indices for an Spaces.ExtrudedFiniteDifferenceSpace. Each index can be passed to slab(space, index...).

source

Utilities

ClimaCore.Spaces.areaFunction
Spaces.area(space::Spaces.AbstractSpace)

Return the length, area, or volume of space, computed as the sum of the quadrature weights $W_i$ multiplied by the Jacobian determinants $J_i$:

\[\sum_i W_i J_i \approx \int_\Omega \, d \Omega\]

If space is distributed, this uses a ClimaComms.allreduce operation.

source