Mercurial > repos > public > sbplib_julia
diff src/Grids/manifolds.jl @ 1581:f77c5309dd2b feature/grids/manifolds
Rename ConcreteChart to Chart and remove the abstarct chart type
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 25 Apr 2024 22:32:54 +0200 |
parents | fdee60ab8c4e |
children | 84c3b9d71218 |
line wrap: on
line diff
--- a/src/Grids/manifolds.jl Thu Apr 25 22:15:12 2024 +0200 +++ b/src/Grids/manifolds.jl Thu Apr 25 22:32:54 2024 +0200 @@ -66,42 +66,39 @@ unitsimplex(D) = unitsimplex(Float64, D) """ + Chart{D} A parametrized description of a manifold or part of a manifold. - -Should implement a methods for -* `parameterspace` -* `(::Chart)(ξs...)` """ -abstract type Chart{D} end -# abstract type Chart{D,R} end - -domain_dim(::Chart{D}) where D = D -# range_dim(::Chart{D,R}) where {D,R} = R - -""" -The parameterspace of a chart -""" -function parameterspace end - - -# TODO: Add trait for if there is a jacobian available? -# Add package extension to allow calling the getter function anyway if it's not available -# And can we add an informative error that ForwardDiff could be loaded to make it work? -# Or can we handle this be custom implementations? For sometypes in the library it can be implemented explicitly. -# And as an example for ConcreteChart it can be implemented by the user like -# c = ConcreteChart(...) -# jacobian(c::typeof(c)) = ... - -struct ConcreteChart{D, PST<:ParameterSpace{D}, MT} <: Chart{D} +struct Chart{D, PST<:ParameterSpace{D}, MT} mapping::MT parameterspace::PST end -(c::ConcreteChart)(ξ) = c.mapping(ξ) -parameterspace(c::ConcreteChart) = c.parameterspace +domain_dim(::Chart{D}) where D = D +(c::Chart)(ξ) = c.mapping(ξ) +parameterspace(c::Chart) = c.parameterspace + +""" + jacobian(c::Chart, ξ) -jacobian(c::ConcreteChart, ξ) = jacobian(c.mapping, ξ) +The jacobian of the mapping evaluated at `ξ`. This defers to the +implementation of `jacobian` for the mapping itself. If no implementation is +available one can easily be specified for either the mapping function or the +chart itself. +```julia +c = Chart(f, ps) +jacobian(f::typeof(f), ξ) = f′(ξ) +``` +or +```julia +c = Chart(f, ps) +jacobian(c::typeof(c),ξ) = f′(ξ) +``` +which will both allow calling `jacobian(c,ξ)`. +""" +jacobian(c::Chart, ξ) = jacobian(c.mapping, ξ) + """ Atlas