Mercurial > repos > public > sbplib_julia
comparison src/Grids/tensor_grid.jl @ 1415:18e21601da2d bugfix/grids/complete_interface_impl
Attempt to clearify docs for `grid_and_local_dim_index`
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 23 Aug 2023 15:35:01 +0200 |
parents | adbdbf1c3480 |
children | e82240df974d |
comparison
equal
deleted
inserted
replaced
1414:1aa8adbf13d5 | 1415:18e21601da2d |
---|---|
102 end | 102 end |
103 | 103 |
104 """ | 104 """ |
105 grid_and_local_dim_index(nds, d) | 105 grid_and_local_dim_index(nds, d) |
106 | 106 |
107 Given a tuple of number of dimensions `nds`, and a global dimension `d`, | 107 Given a tuple of number of dimensions `nds`, and a global dimension index `d`, |
108 calculate which grid index and local dimension `d` corresponds to. | 108 calculate which grid index, and local dimension, `d` corresponds to. |
109 | |
110 `nds` would come from broadcasting `ndims` on the grids tuple of a | |
111 `TensorGrid`. If you are interested in a dimension `d` of a tensor grid `g` | |
112 ```julia | |
113 gi, ldi = grid_and_local_dim_index(ndims.(g.grids), d) | |
114 ``` | |
115 tells you which grid it belongs to (`gi`) and wich index it is at within that | |
116 grid (`ldi`). | |
109 """ | 117 """ |
110 function grid_and_local_dim_index(nds, d) | 118 function grid_and_local_dim_index(nds, d) |
111 I = findfirst(>=(d), cumsum(nds)) | 119 I = findfirst(>=(d), cumsum(nds)) |
112 | 120 |
113 if I == 1 | 121 if I == 1 |