13#ifndef CD_PARTICLEGHOSTMASKIMPLEM_H
14#define CD_PARTICLEGHOSTMASKIMPLEM_H
18#include <CD_NamespaceHeader.H>
25 m_count.resize(a_box, 1);
27 m_start.resize(a_box, 1);
35 m_count(a_iv, 0) += 1;
42 for (BoxIterator bit(
m_box); bit.ok(); ++bit) {
43 const int c =
m_count(bit(), 0);
61 CH_assert(m_start(a_iv, 0) >= 0);
62 CH_assert(m_start(a_iv, 0) <
static_cast<int>(m_flat.size()));
65 m_flat[m_start(a_iv, 0)] = a_target;
66 m_start(a_iv, 0) += 1;
72 CH_assert(m_flatBox.size() == m_flat.size());
73 CH_assert(m_start(a_iv, 0) >= 0 && m_start(a_iv, 0) <
static_cast<int>(m_flatBox.size()));
77 m_flatBox[m_start(a_iv, 0)] = a_targetBox;
78 this->addTarget(a_iv, a_target);
84 for (BoxIterator bit(
m_box); bit.ok(); ++bit) {
94 CH_assert(!
m_box.isEmpty());
102 CH_assert(!m_box.isEmpty());
104 return m_count(a_iv, 0);
110 CH_assert(a_i >= 0 && a_i < m_count(a_iv, 0));
112 return m_flat[m_start(a_iv, 0) + a_i];
118 return this->target(a_iv, a_i).first;
124 return this->target(a_iv, a_i).second;
130 CH_assert(a_i >= 0 && a_i < m_count(a_iv, 0));
131 CH_assert(m_flatBox.size() == m_flat.size());
133 return m_flatBox[m_start(a_iv, 0) + a_i];
142#include <CD_NamespaceFooter.H>
Declaration of ParticleGhostMask, a per-box CSR lookup of particle ghost scatter targets.
std::pair< unsigned int, unsigned int > BoxIDs
alias type alias.
Definition CD_LevelTiles.H:46
void define(const Box &a_box) noexcept
Reset to an empty table over a box (every cell has zero targets).
Definition CD_ParticleGhostMaskImplem.H:21
const Box & box() const noexcept
Get the box that the source cells live on.
Definition CD_ParticleGhostMaskImplem.H:90
unsigned int targetGridIndex(const IntVect &a_iv, const int a_i) const noexcept
Get the destination grid index of the i-th target for a cell.
Definition CD_ParticleGhostMaskImplem.H:116
const Box & targetBox(const IntVect &a_iv, const int a_i) const noexcept
Get the acceptance box of the i-th target for a cell.
Definition CD_ParticleGhostMaskImplem.H:128
int numTargets(const IntVect &a_iv) const noexcept
Get the number of scatter targets for a cell.
Definition CD_ParticleGhostMaskImplem.H:100
void allocate() noexcept
Build step between the passes: turn the per-cell counts into CSR offsets and size the packed target a...
Definition CD_ParticleGhostMaskImplem.H:39
const LevelTiles::BoxIDs & target(const IntVect &a_iv, const int a_i) const noexcept
Get the i-th scatter target for a cell.
Definition CD_ParticleGhostMaskImplem.H:108
unsigned int targetRank(const IntVect &a_iv, const int a_i) const noexcept
Get the receiving rank of the i-th target for a cell.
Definition CD_ParticleGhostMaskImplem.H:122
void allocateTargetBoxes() noexcept
Optional build step: size the per-target acceptance-box array to match the packed target array.
Definition CD_ParticleGhostMaskImplem.H:53
std::vector< LevelTiles::BoxIDs > m_flat
Packed targets, size == sum(m_count).
Definition CD_ParticleGhostMask.H:199
bool hasTargetBoxes() const noexcept
Whether this mask carries per-target acceptance boxes.
Definition CD_ParticleGhostMaskImplem.H:137
void addTarget(const IntVect &a_iv, const LevelTiles::BoxIDs &a_target) noexcept
Build pass 2: append one target for cell a_iv.
Definition CD_ParticleGhostMaskImplem.H:59
BaseFab< int > m_start
Per cell: first index into m_flat, or -1 if the cell has no targets.
Definition CD_ParticleGhostMask.H:189
BaseFab< int > m_count
Per cell: number of targets.
Definition CD_ParticleGhostMask.H:194
void finalize() noexcept
Finish the build: rewind m_start (advanced by addTarget) back to the CSR start offsets.
Definition CD_ParticleGhostMaskImplem.H:82
Box m_box
Box that the source cells (and m_start/m_count) live on.
Definition CD_ParticleGhostMask.H:184
void incrementCount(const IntVect &a_iv) noexcept
Build pass 1: register that cell a_iv gains one more target.
Definition CD_ParticleGhostMaskImplem.H:33
std::vector< Box > m_flatBox
Packed per-target acceptance boxes, parallel to m_flat. Empty unless the mask carries them.
Definition CD_ParticleGhostMask.H:204