Mercurial > repos > public > sbplib_julia
comparison src/Grids/grid.jl @ 1474:276c38a48aac feature/grids/componentview
Start implementing componentview
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Fri, 01 Dec 2023 13:34:03 +0100 |
parents | a863aef1f799 |
children | 76b190ca9a27 |
comparison
equal
deleted
inserted
replaced
1473:869a40cda18c | 1474:276c38a48aac |
---|---|
35 """ | 35 """ |
36 component_type(g) | 36 component_type(g) |
37 | 37 |
38 The type of the components of the coordinate vector of `Grid` `g`. | 38 The type of the components of the coordinate vector of `Grid` `g`. |
39 """ | 39 """ |
40 component_type(::Type{<:Grid{T}}) where T = eltype(T) | 40 component_type(::Type{<:Grid{T}}) where T = eltype(T) #TBD: removable? |
41 component_type(g::Grid) = component_type(typeof(g)) | 41 component_type(g::Grid) = component_type(typeof(g)) |
42 component_type(T::Type) = eltype(eltype(T)) | |
43 component_type(t) = component_type(typeof(t)) | |
44 | |
45 function componentview(gf, component_index...) | |
46 A = reinterpret(reshape, component_type(gf), gf) | |
47 | |
48 component_linear_index = LinearIndices(first(gf))[component_index...] | |
49 return @view A[component_linear_index,:,:] | |
50 end | |
42 | 51 |
43 """ | 52 """ |
44 refine(g::Grid, r) | 53 refine(g::Grid, r) |
45 | 54 |
46 The grid where `g` is refined by the factor `r`. | 55 The grid where `g` is refined by the factor `r`. |