comparison src/Grids/grid.jl @ 1518:0cd6cf62af93 feature/grids/componentview

Merge refactor/component_type
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 21 Mar 2024 15:51:29 +0100
parents 7ee7df7d9b61 b6f6425e34ac
children 2fa325f08b66
comparison
equal deleted inserted replaced
1517:7ee7df7d9b61 1518:0cd6cf62af93
25 Base.getindex(g::Grid, I::CartesianIndex) = g[Tuple(I)...] 25 Base.getindex(g::Grid, I::CartesianIndex) = g[Tuple(I)...]
26 26
27 """ 27 """
28 coordinate_size(g) 28 coordinate_size(g)
29 29
30 The lenght of the coordinate vector of `Grid` `g`. 30 The length of the coordinate vector of `Grid` `g`.
31 """ 31 """
32 coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T) 32 coordinate_size(::Type{<:Grid{T}}) where T = _ncomponents(T)
33 coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?! 33 coordinate_size(g::Grid) = coordinate_size(typeof(g)) # TBD: Name of this function?!
34 34
35 """ 35 """
36 component_type(gf) 36 component_type(gf)
37 37
38 The type of the components of the elements of `gf`. 38 The type of the components of the elements of `gf`. I.e if `gf` is a vector
39 valued grid function, `component_view(gf)` is the element type of the vectors
40 at each grid point.
41
42 # Examples
43 ```julia-repl
44 julia> component_type([[1,2], [2,3], [3,4]])
45 Int64
46 ```
39 """ 47 """
40 component_type(T::Type) = eltype(eltype(T)) 48 component_type(T::Type) = eltype(eltype(T))
41 component_type(t) = component_type(typeof(t)) 49 component_type(t) = component_type(typeof(t))
42 50
43 componentview(gf, component_index...) = ArrayComponentView(gf, component_index) 51 componentview(gf, component_index...) = ArrayComponentView(gf, component_index)