comparison src/Grids/tensor_grid.jl @ 1388:c0208286234e bugfix/grids/complete_interface_impl

Add `grid_and_local_dim_index`
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 15 Aug 2023 22:11:20 +0200
parents 42ecd4b3e215
children 47931bef8471
comparison
equal deleted inserted replaced
1387:3d6425c36d32 1388:c0208286234e
95 end 95 end
96 96
97 function combine_coordinates(coords...) 97 function combine_coordinates(coords...)
98 return mapreduce(SVector, vcat, coords) 98 return mapreduce(SVector, vcat, coords)
99 end 99 end
100
101 """
102 grid_and_local_dim_index(nds, d)
103
104 Given a tuple of number of dimensions `nds`, and a global dimension `d`,
105 calculate which grid index and local dimension `d` corresponds to.
106 """
107 function grid_and_local_dim_index(nds, d)
108 I = findfirst(>=(d), cumsum(nds))
109
110 if I == 1
111 return (1, d)
112 else
113 return (I, d-cumsum(nds)[I-1])
114 end
115 # TBD: Is there a cleaner way to compute this?
116 end