13#ifndef CD_PARTICLEMANAGEMENT_H
14#define CD_PARTICLEMANAGEMENT_H
29#include <CD_NamespaceHeader.H>
82template <
class P,
class Traits = ParticleTraits<P>>
134template <
class P, Real P::*weight, RealVect P::*position>
137 const int a_maxLeaves,
139 std::vector<std::pair<const P*, const P*>>& a_leaves)
noexcept;
156template <
class P, RealVect P::*position>
159 const std::size_t a_target,
160 const std::function<
void(P&,
const P&)>& a_combine)
noexcept;
198template <
class Packed,
199 Real Packed::*packWeight,
200 RealVect Packed::*packPosition,
203inline ParticleMerger<P, Traits>
205 std::function<
void(Packed&,
const Packed&)> a_combine,
242template <
class Packed,
243 Real Packed::*packWeight,
244 RealVect Packed::*packPosition,
247inline ParticleMerger<P, Traits>
250 BinaryParticleReconcile<Packed> a_reconcile,
283template <
class Context,
class P,
class Traits = ParticleTraits<P>>
284inline ParticleMerger<P, Traits>
287 std::function<RealVect()> a_probLo)
noexcept;
298template <typename P, typename Traits, typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
309template <
typename P,
typename Traits>
319template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
320static inline std::vector<T>
321partitionParticleWeights(
const T a_numPhysicalParticles,
const T a_maxCompParticles)
noexcept;
336template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
338partitionParticles(
const T a_numParticles);
356template <typename P, typename Traits, typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
359 const T a_numParticles,
360 const std::function<RealVect()>& a_distribution);
374template <typename P, typename Traits, typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
377 const T a_numParticles,
378 const RealVect& a_center,
379 const Real a_radius)
noexcept;
393template <typename P, typename Traits, typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
396 const T a_numParticles,
397 const RealVect& a_loCorner,
398 const RealVect& a_hiCorner)
noexcept;
412template <typename P, typename Traits, typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
415 const T a_numParticles,
416 const RealVect& a_center,
417 const Real a_radius)
noexcept;
428template <
typename Packed>
479#include <CD_NamespaceFooter.H>
Simple class for holding some quantities relevant in a grid cell.
Implementation of CD_ParticleManagement.H.
Declaration of ParticleSoA, an arena-backed Struct-of-Arrays particle container.
std::int32_t RankID
Owning-rank identifier type (container-owned metadata column; fixed-width for I/O).
Definition CD_ParticleSoA.H:166
std::int64_t ParticleID
Global particle identifier type (container-owned metadata column; fixed-width for I/O).
Definition CD_ParticleSoA.H:161
Class for the cell-information that is often queried when merging particles inside a cell.
Definition CD_CellInfo.H:26
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
void mergeAdjacentNearest(std::vector< P > &a_particles, const std::size_t a_target, const std::function< void(P &, const P &)> &a_combine) noexcept
Merge an already spatially-ordered particle list down to a target count by repeatedly combining the n...
Definition CD_ParticleManagementImplem.H:320
void buildEqualWeightKDLeaves(const std::vector< P > &a_particles, const int a_maxLeaves, const BinaryParticleReconcile< P > &a_particleReconcile, std::vector< std::pair< const P *, const P * > > &a_leaves) noexcept
Build an equal-weight KD partition of a list of particles and return the leaf particle ranges.
Definition CD_ParticleManagementImplem.H:87
Namespace for various particle management tools.
Definition CD_KDParticleMerge.H:33
std::function< void(ParticleSoA< P, Traits > &a_particles, const CellInfo &a_cellInfo, const int a_numTargetParticles)> ParticleMerger
Concept for splitting/merging particles.
Definition CD_ParticleManagement.H:84
void drawBoxParticles(ParticleSoA< P, Traits > &a_particles, const T a_numParticles, const RealVect &a_loCorner, const RealVect &a_hiCorner) noexcept
Draw box-distributed particles into an SoA container (unit weight; positions only).
Definition CD_ParticleManagementImplem.H:839
std::function< void(P &p1, P &p2, const P &p0)> BinaryParticleReconcile
Declaration of a reconciliation function when splitting particles.
Definition CD_ParticleManagement.H:94
void drawSphereParticles(ParticleSoA< P, Traits > &a_particles, const T a_numParticles, const RealVect &a_center, const Real a_radius) noexcept
Draw sphere-distributed particles into an SoA container (unit weight; positions only).
Definition CD_ParticleManagementImplem.H:859
ParticleMerger< P, Traits > makeReinitializeMerger(std::function< std::pair< long long, Context >(const ParticleSoA< P, Traits > &)> a_aggregate, std::function< void(ParticleSoA< P, Traits > &, const RealVect &, long long, const Context &)> a_emit, std::function< RealVect()> a_probLo) noexcept
Create a reinitialize super-particle merger as a reusable ParticleMerger.
Definition CD_ParticleManagementImplem.H:611
ParticleMerger< P, Traits > makeSfcNearestNeighborMerger(std::function< Packed(const ParticleSoA< P, Traits > &, std::size_t)> a_gather, std::function< void(Packed &, const Packed &)> a_combine, std::function< void(ParticleSoA< P, Traits > &, const Packed &)> a_scatter) noexcept
Create a space-filling-curve nearest-neighbor super-particle merger as a reusable ParticleMerger.
Definition CD_ParticleManagementImplem.H:441
void drawGaussianParticles(ParticleSoA< P, Traits > &a_particles, const T a_numParticles, const RealVect &a_center, const Real a_radius) noexcept
Draw Gaussian-distributed particles into an SoA container (unit weight; positions only).
Definition CD_ParticleManagementImplem.H:821
ParticleMergeMethod
The specific super-particle merge methods.
Definition CD_ParticleManagement.H:40
@ NnSfc
Cell: makeSfcNearestNeighborMerger.
@ KdSkinNn
AMR: mergeKDInterior for the uncontested tier, nearest-neighbor pairs for the skin.
@ NnPairTree
AMR: mergeNearestNeighborsTree (whole-patch PointCloudBVH search).
@ KdPatch
AMR: mergeKDPatch (same build, patch-local – no ghosts, no contested particles).
@ NnPairOneCell
AMR: mergeNearestNeighborsOneCell (per-cell PointCloudBVH search, Chebyshev distance 1 only).
@ External
Cell: caller-supplied per-cell merger.
@ Reinitialize
Cell: makeReinitializeMerger.
@ EqualWeightKD
Cell: makeEqualWeightKDMerger.
@ KdCarve
AMR: mergeKDCarve (whole-patch kd-tree build, arbitrated patch boundaries).
@ ReinitializeBVH
Cell: makeEqualWeightKDMerger with reinitialized leaf positions.
@ NnPairHash
AMR: mergeNearestNeighborsHash (whole-patch PointCloudHashGrid search).
void drawRandomParticles(ParticleSoA< P, Traits > &a_particles, const T a_numParticles, const std::function< RealVect()> &a_distribution)
Draw random SoA particles into a free buffer, distributed according to a predefined distribution.
Definition CD_ParticleManagementImplem.H:804
ParticleMergeMethod mergeMethodFromString(const std::string &a_str) noexcept
Map a merge-algorithm selector string to a ParticleMergeMethod.
Definition CD_ParticleManagementImplem.H:38
ParticleMerger< P, Traits > makeEqualWeightKDMerger(std::function< Packed(const ParticleSoA< P, Traits > &, std::size_t)> a_gather, BinaryParticleReconcile< Packed > a_reconcile, std::function< void(ParticleSoA< P, Traits > &, const Packed *, const Packed *, const CellInfo &)> a_scatterLeaf) noexcept
Create an equal-weight KD-tree super-particle merger as a reusable ParticleMerger.
Definition CD_ParticleManagementImplem.H:564
Minimal, payload-agnostic description of one particle as input to a distributed merge.
Definition CD_ParticleManagement.H:430
bool isGhost
True iff this is a ghost copy in the patch currently holding it, i.e. not physically stored there....
Definition CD_ParticleManagement.H:462
RealVect position
Particle position.
Definition CD_ParticleManagement.H:434
Packed payload
Opaque, caller-defined payload. Never inspected by the merge logic – only carried through to the comb...
Definition CD_ParticleManagement.H:474
Real weight
Particle weight. Not required to be an integer.
Definition CD_ParticleManagement.H:439
int level
The AMR level this particle lives on. Used by the nearest-neighbor mergers, whose cell keys are level...
Definition CD_ParticleManagement.H:468
ParticleID globalID
Globally unique particle id, unique within one merge round across every rank.
Definition CD_ParticleManagement.H:448
RankID ownerRank
The rank owning this particle. Always read from the particle's own data, never inferred from MPI tran...
Definition CD_ParticleManagement.H:454
Traits class that a user specializes to describe the PAYLOAD columns of a particle type....
Definition CD_ParticleSoA.H:192