Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encapsulate AxisTensor components #1870

Open
charleskawczynski opened this issue Jul 5, 2024 · 1 comment
Open

Encapsulate AxisTensor components #1870

charleskawczynski opened this issue Jul 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@charleskawczynski
Copy link
Member

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:

ᶜΔ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:

Δ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
@charleskawczynski charleskawczynski added the enhancement New feature or request label Jul 5, 2024
@charleskawczynski
Copy link
Member Author

charleskawczynski commented Jul 5, 2024

Another pattern that we should probably fix/internalize is:

        ∂x∂ξ_level = local_geometry_level.∂x∂ξ.components.data
        end_index = fieldcount(eltype(∂x∂ξ_level)) # This will be 4 in 2D and 9 in 3D.
        ∂x³∂ξ³_level = ∂x∂ξ_level.:($end_index)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant