core
Shared MPI block decomposition + asynchronous ghost-layer exchange (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.
 
void imagesWithinRcutOfBlock (const Vec< Dim > &x, int r, double rcut, bool allowIdentity, std::vector< Vec< Dim > > &outShifts) 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).
 
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()

◆ 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 peclet::core::halo::ParticleMigrator< Dim >::ownerOf().

◆ 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 peclet::core::halo::ParticleMigrator< Dim >::cellOf().

Referenced by peclet::core::halo::ParticleMigrator< Dim >::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 peclet::core::halo::ParticleMigrator< Dim >::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::ParticleMigrator< Dim >::ownerOf(), and peclet::core::halo::ParticleMigrator< Dim >::wrapPosition().

◆ 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

◆ comm()

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

◆ 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 peclet::core::halo::ParticleMigrator< Dim >::gatherGhosts().

◆ 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

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).

Definition at line 202 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 251 of file particle_migrator.hpp.

References MPI_Comm_size(), and peclet::core::halo::ParticleMigrator< Dim >::withinRcutOfBlock().


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