core 1.8.1
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::halo::ParticleMigrator< Dim > Class Template Reference

#include <particle_migrator.hpp>

Public Member Functions

void init (const decomp::BlockDecomposer< Dim > &dec, int rank, DomainMap< Dim > map, MPI_Comm comm=MPI_COMM_WORLD)
IVec< Dim > cellOf (const Vec< Dim > &x) const
 Global decomposition cell containing position x (after periodic wrap / boundary clamp).
int ownerOf (const Vec< Dim > &x) const
 Rank that owns the block containing position x (after periodic wrap / boundary clamp).
Vec< Dim > wrapPosition (Vec< Dim > x) const
 Wrap a position into the periodic box (no-op on non-periodic axes).
std::size_t migrate (std::vector< Vec< Dim > > &pos, std::vector< char > &payload, std::size_t stride)
 Reassign every particle to its owning rank.
std::size_t lastSent () const
std::size_t lastReceived () const
int rank () const
MPI_Comm comm () const
const decomp::BlockDecomposer< Dim > & decomposer () const
bool withinRcutOfBlock (const Vec< Dim > &x, int r, double rcut, Vec< Dim > &img) const
 True if x (via its closest periodic image) comes within rcut of block r's physical AABB.
bool boxWithinRcutOfBlock (const Vec< Dim > &bmin, const Vec< Dim > &bmax, int r, double rcut) const
 Append the shift (= image − x) of EVERY periodic image of x that comes within rcut of block r's AABB (enumerating the up-to-3^Dim images: 0 and ±L per periodic axis).
void imagesWithinRcutOfBlock (const Vec< Dim > &x, int r, double rcut, bool allowIdentity, std::vector< Vec< Dim > > &outShifts) const
std::size_t gatherGhosts (const std::vector< Vec< Dim > > &pos, const std::vector< char > &payload, std::size_t stride, double rcut, std::vector< Vec< Dim > > &ghostPos, std::vector< char > &ghostPayload)
 Gather ghost copies of particles within rcut of this rank's block boundary.

Detailed Description

template<int Dim>
class peclet::core::halo::ParticleMigrator< Dim >

Definition at line 40 of file particle_migrator.hpp.

Member Function Documentation

◆ init()

template<int Dim>
void peclet::core::halo::ParticleMigrator< Dim >::init ( const decomp::BlockDecomposer< Dim > & dec,
int rank,
DomainMap< Dim > map,
MPI_Comm comm = MPI_COMM_WORLD )
inline

Definition at line 42 of file particle_migrator.hpp.

References comm(), MPI_COMM_WORLD, and rank().

◆ cellOf()

template<int Dim>
IVec< Dim > peclet::core::halo::ParticleMigrator< Dim >::cellOf ( const Vec< Dim > & x) const
inline

Global decomposition cell containing position x (after periodic wrap / boundary clamp).

This is the binning index for weighted load-balancing — ownerOf(x) == decomposer().ownerOf(cellOf(x)).

Definition at line 53 of file particle_migrator.hpp.

References peclet::core::wrap().

Referenced by ownerOf(), and peclet::core::halo::rebalanceByParticleCount().

◆ ownerOf()

template<int Dim>
int peclet::core::halo::ParticleMigrator< Dim >::ownerOf ( const Vec< Dim > & x) const
inline

Rank that owns the block containing position x (after periodic wrap / boundary clamp).

Definition at line 70 of file particle_migrator.hpp.

References cellOf().

Referenced by migrate().

◆ wrapPosition()

template<int Dim>
Vec< Dim > peclet::core::halo::ParticleMigrator< Dim >::wrapPosition ( Vec< Dim > x) const
inline

Wrap a position into the periodic box (no-op on non-periodic axes).

Definition at line 73 of file particle_migrator.hpp.

Referenced by migrate().

◆ migrate()

template<int Dim>
std::size_t peclet::core::halo::ParticleMigrator< Dim >::migrate ( std::vector< Vec< Dim > > & pos,
std::vector< char > & payload,
std::size_t stride )
inline

Reassign every particle to its owning rank.

pos and payload (stride bytes per particle) are rewritten in place to hold exactly this rank's particles after migration. Returns the new local count. Last-migrated stats are available via lastSent()/lastReceived().

Definition at line 89 of file particle_migrator.hpp.

References peclet::core::halo::NbxEngine::exchange(), ownerOf(), and wrapPosition().

Referenced by peclet::core::halo::rebalanceByParticleCount().

◆ lastSent()

template<int Dim>
std::size_t peclet::core::halo::ParticleMigrator< Dim >::lastSent ( ) const
inline

Definition at line 154 of file particle_migrator.hpp.

◆ lastReceived()

template<int Dim>
std::size_t peclet::core::halo::ParticleMigrator< Dim >::lastReceived ( ) const
inline

Definition at line 155 of file particle_migrator.hpp.

◆ rank()

template<int Dim>
int peclet::core::halo::ParticleMigrator< Dim >::rank ( ) const
inline

Definition at line 157 of file particle_migrator.hpp.

Referenced by init().

◆ comm()

template<int Dim>
MPI_Comm peclet::core::halo::ParticleMigrator< Dim >::comm ( ) const
inline

Definition at line 158 of file particle_migrator.hpp.

Referenced by init().

◆ decomposer()

template<int Dim>
const decomp::BlockDecomposer< Dim > & peclet::core::halo::ParticleMigrator< Dim >::decomposer ( ) const
inline

Definition at line 159 of file particle_migrator.hpp.

◆ withinRcutOfBlock()

template<int Dim>
bool peclet::core::halo::ParticleMigrator< Dim >::withinRcutOfBlock ( const Vec< Dim > & x,
int r,
double rcut,
Vec< Dim > & img ) const
inline

True if x (via its closest periodic image) comes within rcut of block r's physical AABB.

On success img is that closest image — the position to ship so rank r has correct coords.

Definition at line 163 of file particle_migrator.hpp.

Referenced by gatherGhosts().

◆ boxWithinRcutOfBlock()

template<int Dim>
bool peclet::core::halo::ParticleMigrator< Dim >::boxWithinRcutOfBlock ( const Vec< Dim > & bmin,
const Vec< Dim > & bmax,
int r,
double rcut ) const
inline

Append the shift (= image − x) of EVERY periodic image of x that comes within rcut of block r's AABB (enumerating the up-to-3^Dim images: 0 and ±L per periodic axis).

Unlike withinRcutOfBlock (which keeps only the single nearest image), this yields all qualifying images — the owner-based view a ghost layer needs when one rank borders ITSELF across a periodic face (an undecomposed periodic axis, or np=1). allowIdentity=false drops the un-shifted image, so r==self yields only the periodic self-wrap copies (a particle is never its own ghost). True iff some point of the box [bmin, bmax] (a periodic image of it included) lies within rcut of rank r's block. A point of the box has, per axis and per image, a gap no smaller than the box's, so false proves that NO point of the box qualifies for r – a candidate filter that is a superset of every per-particle test (withinRcutOfBlock, imagesWithinRcutOfBlock).

Definition at line 206 of file particle_migrator.hpp.

◆ imagesWithinRcutOfBlock()

template<int Dim>
void peclet::core::halo::ParticleMigrator< Dim >::imagesWithinRcutOfBlock ( const Vec< Dim > & x,
int r,
double rcut,
bool allowIdentity,
std::vector< Vec< Dim > > & outShifts ) const
inline

Definition at line 228 of file particle_migrator.hpp.

◆ gatherGhosts()

template<int Dim>
std::size_t peclet::core::halo::ParticleMigrator< Dim >::gatherGhosts ( const std::vector< Vec< Dim > > & pos,
const std::vector< char > & payload,
std::size_t stride,
double rcut,
std::vector< Vec< Dim > > & ghostPos,
std::vector< char > & ghostPayload )
inline

Gather ghost copies of particles within rcut of this rank's block boundary.

For each particle this rank owns, a copy (the periodic image closest to the target block) is sent to every OTHER rank whose block comes within rcut. Received ghosts are written to ghostPos/ghostPayload (cleared first). Returns the number of ghosts received. This is the Lagrangian halo: after it, each rank's neighbour search runs locally over its owned + ghost particles.

Definition at line 298 of file particle_migrator.hpp.

References peclet::core::halo::NbxEngine::exchange(), MPI_Comm_size(), and withinRcutOfBlock().


The documentation for this class was generated from the following file: