comparison 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
comparison
equal deleted inserted replaced
1580:fdee60ab8c4e 1581:f77c5309dd2b
64 return Simplex((z,verticies...)) 64 return Simplex((z,verticies...))
65 end 65 end
66 unitsimplex(D) = unitsimplex(Float64, D) 66 unitsimplex(D) = unitsimplex(Float64, D)
67 67
68 """ 68 """
69 Chart{D}
69 70
70 A parametrized description of a manifold or part of a manifold. 71 A parametrized description of a manifold or part of a manifold.
71
72 Should implement a methods for
73 * `parameterspace`
74 * `(::Chart)(ξs...)`
75 """ 72 """
76 abstract type Chart{D} end 73 struct Chart{D, PST<:ParameterSpace{D}, MT}
77 # abstract type Chart{D,R} end
78
79 domain_dim(::Chart{D}) where D = D
80 # range_dim(::Chart{D,R}) where {D,R} = R
81
82 """
83 The parameterspace of a chart
84 """
85 function parameterspace end
86
87
88 # TODO: Add trait for if there is a jacobian available?
89 # Add package extension to allow calling the getter function anyway if it's not available
90 # And can we add an informative error that ForwardDiff could be loaded to make it work?
91 # Or can we handle this be custom implementations? For sometypes in the library it can be implemented explicitly.
92 # And as an example for ConcreteChart it can be implemented by the user like
93 # c = ConcreteChart(...)
94 # jacobian(c::typeof(c)) = ...
95
96 struct ConcreteChart{D, PST<:ParameterSpace{D}, MT} <: Chart{D}
97 mapping::MT 74 mapping::MT
98 parameterspace::PST 75 parameterspace::PST
99 end 76 end
100 77
101 (c::ConcreteChart)(ξ) = c.mapping(ξ) 78 domain_dim(::Chart{D}) where D = D
102 parameterspace(c::ConcreteChart) = c.parameterspace 79 (c::Chart)(ξ) = c.mapping(ξ)
80 parameterspace(c::Chart) = c.parameterspace
103 81
104 jacobian(c::ConcreteChart, ξ) = jacobian(c.mapping, ξ) 82 """
83 jacobian(c::Chart, ξ)
84
85 The jacobian of the mapping evaluated at `ξ`. This defers to the
86 implementation of `jacobian` for the mapping itself. If no implementation is
87 available one can easily be specified for either the mapping function or the
88 chart itself.
89 ```julia
90 c = Chart(f, ps)
91 jacobian(f::typeof(f), ξ) = f′(ξ)
92 ```
93 or
94 ```julia
95 c = Chart(f, ps)
96 jacobian(c::typeof(c),ξ) = f′(ξ)
97 ```
98 which will both allow calling `jacobian(c,ξ)`.
99 """
100 jacobian(c::Chart, ξ) = jacobian(c.mapping, ξ)
101
105 102
106 """ 103 """
107 Atlas 104 Atlas
108 105
109 A collection of charts and their connections. 106 A collection of charts and their connections.