15#ifndef PECLET_CORE_HALO_PARTICLE_REBALANCE_HPP
16#define PECLET_CORE_HALO_PARTICLE_REBALANCE_HPP
49 std::vector<char>& payload, std::size_t stride,
51 std::vector<double>* weightOut =
nullptr) {
54 std::size_t ncells = 1;
55 for (
int d = 0; d < Dim; ++d)
56 ncells *=
static_cast<std::size_t
>(gsize[d]);
57 std::vector<double> localCount(ncells, 0.0), weight(ncells, 0.0);
66 dec.
init(
static_cast<std::size_t
>(sz), gsize, weight);
68 *weightOut = std::move(weight);
72 return mig.
migrate(pos, payload, stride);
Orthogonal recursive bisection of a Dim-dimensional global cell grid into numBlocks axis-aligned bloc...
void init(std::size_t numBlocks, IVec< Dim > globalSize)
Build the decomposition of a globalSize cell grid into numBlocks blocks (equal cell count).
const IVec< Dim > & globalSize() const
Global grid size in cells per axis.
Index linearGlobal(const IVec< Dim > &g) const
Global multi-index -> global linear index (x-fastest: I = x + y*nx + z*nx*ny).
IVec< Dim > cellOf(const Vec< Dim > &x) const
Global decomposition cell containing position x (after periodic wrap / boundary clamp).
std::size_t migrate(std::vector< Vec< Dim > > &pos, std::vector< char > &payload, std::size_t stride)
Reassign every particle to its owning rank.
int MPI_Comm_size(MPI_Comm, int *s)
int MPI_Allreduce(const void *sbuf, void *rbuf, int count, MPI_Datatype dt, MPI_Op, MPI_Comm)
std::size_t rebalanceByParticleCount(decomp::BlockDecomposer< Dim > &dec, ParticleMigrator< Dim > &mig, std::vector< typename detail::NonDeduced< Vec< Dim > >::type > &pos, std::vector< char > &payload, std::size_t stride, MPI_Comm comm=MPI_COMM_WORLD, std::vector< double > *weightOut=nullptr)
Re-decompose dec so each block holds a near-equal particle count, then migrate the particles (positio...
std::array< Real, Dim > Vec
Multi-dimensional real vector.
std::array< Index, Dim > IVec
Multi-dimensional integer index / coordinate (x-fastest order by convention).
Identity alias that blocks template argument deduction through it (C++20 std::type_identity).
T type
T itself, in a non-deduced context