CliMA / CliMA/ClimaCore.jl

Add simple compile-time way to determine the number of dimensions of a `Space`

Open
#2,206 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
117
Forks
19
Avg merge
3d 4h
Merged PRs (30d)
41

Description

The number of spatial dimensions (1-3) of a Space is fully determined by its type.

For example, a `CenterFiniteDifferenceSpace` is guarenteed to have 1 dimension.
```julia
ndims(::CenterFiniteDifferenceSpace) = 1
```
An `ExtrudedFiniteDifferenceSpace` could have 2 or 3, and we can find which one of the two by looking at the type of grid
```julia
ndims(::ExtrudedFiniteDifferenceSpace{G}) where {G <: ExtrudedSpectralElementGrid1D} = 2`
ndims(::ExtrudedFiniteDifferenceSpace{G}) where {G <: ExtrudedSpectralElementGrid2D} = 3`
```

An alternative to this might to return a tuple with `(n_horizontal, n_vertical)` dimensions

This would help with writing code that more easily supports more configurations.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the Space types named in the issue, especially CenterFiniteDifferenceSpace and ExtrudedFiniteDifferenceSpace, and inspect how their grid type parameters are defined. Check existing dimension-related APIs and tests before deciding whether the result should be a scalar or a horizontal/vertical tuple; done means the supported Space configurations expose compile-time dimension information with coverage for the listed cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.