CliMA / CliMA/ClimaCore.jl

Encapsulate AxisTensor components

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

Description

A common pattern for users is to dive all the way into the backing SArray's `data` of an `AxisTensor`. For example, in ClimaAtmos: `ᶠϵ₂₃ = ᶠϵ.components.data.:6`.

We should probably internalize these data accesses with some API.

One reason that this is problematic is that it could also depend on the DataLayout. For example:

```julia
ᶜΔz = Fields.local_geometry_field(Y.c).∂x∂ξ.components.data.:9
```
is only correct for certain geometric points. ClimaCore has a general version of this:

```julia
Δz_metric_component(::Type{<:Geometry.LatLongZPoint}) = 9
Δz_metric_component(::Type{<:Geometry.Cartesian3Point}) = 1
Δz_metric_component(::Type{<:Geometry.Cartesian13Point}) = 4
Δz_metric_component(::Type{<:Geometry.Cartesian123Point}) = 9
Δz_metric_component(::Type{<:Geometry.XYZPoint}) = 9
Δz_metric_component(::Type{<:Geometry.ZPoint}) = 1
Δz_metric_component(::Type{<:Geometry.XZPoint}) = 4

"""
Δz_data(space::AbstractSpace)

A DataLayout containing the `Δz` on a given space `space`.
"""
function Δz_data(space::AbstractSpace)
lg = local_geometry_data(space)
data_layout_type = eltype(lg.coordinates)
return getproperty(
lg.∂x∂ξ.components.data,
Δz_metric_component(data_layout_type),
)
end
```

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.