6#ifndef PECLET_CORE_DECOMP_BLOCK_INDEXER_HPP
7#define PECLET_CORE_DECOMP_BLOCK_INDEXER_HPP
21 for (
int i = 0; i < Dim; ++i) {
24 sizeInner_[i] = size[i];
36 for (
int i = 0; i < Dim; ++i)
43 Index idx = g[Dim - 1] - originGhost_[Dim - 1];
44 for (
int i = Dim - 2; i >= 0; --i) {
46 idx += (g[i] - originGhost_[i]);
53 Index idx = l[Dim - 1];
54 for (
int i = Dim - 2; i >= 0; --i) {
64 for (
int i = 0; i < Dim; ++i) {
65 l[i] = idx % sizeGhost_[i];
74 for (
int i = 0; i < Dim; ++i) {
75 g[i] = idx % sizeGhost_[i] + originGhost_[i];
83 for (
int i = 0; i < Dim; ++i) {
84 if (l[i] < ghostWidth_ || l[i] >= ghostWidth_ + sizeInner_[i])
91 template <
typename Func>
94 for (
int i = 0; i < Dim; ++i) {
96 end[i] = sizeGhost_[i] - ghostWidth_;
98 forEachInBox<Dim>(bgn, end, func);
102 template <
typename Func>
105 for (
int i = 0; i < Dim; ++i) {
107 end[i] = sizeGhost_[i];
109 forEachInBox<Dim>(bgn, end, func);
115 IVec<Dim> sizeInner_{};
void forEachInner(Func &&func) const
Visit every inner cell (func receives const IVec<Dim>& local multi-index).
BlockIndexer(IVec< Dim > origin, IVec< Dim > size, int ghostWidth)
void forEachAll(Func &&func) const
Visit every cell including ghosts.
const IVec< Dim > & originInclGhost() const
IVec< Dim > localToLocalMd(Index idx) const
Local linear index -> local multi-index (extended array coordinates, 0 at ghost corner).
Index numCellsInclGhost() const
Total number of cells in the extended (inner + ghost) array.
IVec< Dim > localToGlobalMd(Index idx) const
Local linear index -> global multi-index.
const IVec< Dim > & sizeInner() const
Index globalToLocal(const IVec< Dim > &g) const
Global multi-index -> local linear index in the extended array (x-fastest).
const IVec< Dim > & sizeInclGhost() const
bool isInner(const IVec< Dim > &l) const
True if a local multi-index lies in the inner (non-ghost) region.
void init(IVec< Dim > origin, IVec< Dim > size, int ghostWidth)
Index localMdToLocal(const IVec< Dim > &l) const
Local multi-index (in extended array, ghost included) -> local linear index (x-fastest).
std::array< Index, Dim > IVec
Multi-dimensional integer index / coordinate (x-fastest order by convention).
std::int64_t Index
Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).