chombo-discharge
Loading...
Searching...
No Matches
CD_ParticleContainer.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
12
13#ifndef CD_PARTICLECONTAINER_H
14#define CD_PARTICLECONTAINER_H
15
16// Std includes
17#include <cmath>
18#include <cstdint>
19#include <map>
20#include <string>
21#include <utility>
22#include <vector>
23
24// Chombo includes
25#include <REAL.H>
26#include <SPACE.H>
27#include <RealVect.H>
28#include <IntVect.H>
29#include <Box.H>
30#include <ProblemDomain.H>
31#include <DisjointBoxLayout.H>
32#include <BoxLayout.H>
33#include <DataIterator.H>
34#include <LayoutData.H>
35#include <LevelData.H>
36#include <BaseFab.H>
37#include <RefCountedPtr.H>
38#include <Vector.H>
39#include <SPMD.H>
40#include <CH_Timer.H>
41#include <CH_assert.H>
42
43// Our includes
44#include <CD_LevelTiles.H>
46#include <CD_ParallelOps.H>
47#include <CD_ParticleSoA.H>
48#include <CD_NamespaceHeader.H>
49
55template <typename P, typename Traits>
56using AMRParticlesSoA = Vector<RefCountedPtr<LayoutData<ParticleSoA<P, Traits>>>>;
57
121template <typename P = NoPayload, typename Traits = ParticleTraits<P>>
123{
124public:
129
133 using LevelParticles = LayoutData<Leaf>;
134
139
144 : m_probLo(RealVect::Zero),
145 m_probHi(RealVect::Zero),
147 m_finestLevel(-1),
149 m_isDefined(false),
151 {}
152
157
162
168 operator=(const ParticleContainer&) = delete;
169
193 void
194 define(const Vector<DisjointBoxLayout>& a_grids,
195 const Vector<ProblemDomain>& a_domains,
196 const Vector<Real>& a_dx,
197 const Vector<int>& a_refRat,
198 const RealVect& a_probLo,
199 const int a_minBlockSize,
200 const Vector<RefCountedPtr<LevelTiles>>& a_levelTiles,
201 const int a_finestLevel,
202 const std::string& a_realm,
203 const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>* a_validCells)
204 {
205 CH_TIME("ParticleContainer::define");
206
207 CH_assert(a_grids.size() > a_finestLevel);
208 CH_assert(a_domains.size() > a_finestLevel);
209 CH_assert(a_dx.size() > a_finestLevel);
210 CH_assert(a_refRat.size() > a_finestLevel);
211 CH_assert(a_levelTiles.size() > a_finestLevel);
212
213 m_grids = a_grids;
214 m_domains = a_domains;
215 m_refRat = a_refRat;
216 m_probLo = a_probLo;
217 m_minBlockSize = a_minBlockSize;
218 m_finestLevel = a_finestLevel;
219 m_realm = a_realm;
220 m_validCells = a_validCells;
222
223 m_dx.resize(a_finestLevel + 1);
224 for (int lvl = 0; lvl <= a_finestLevel; lvl++) {
225 m_dx[lvl] = a_dx[lvl] * RealVect::Unit;
226 }
227
228 for (int dir = 0; dir < SpaceDim; dir++) {
229 m_probHi[dir] = m_probLo[dir] + a_domains[0].domainBox().size(dir) * a_dx[0];
230 }
231
232 // Alias the Realm's per-level tile->box maps (the single source of truth); never build our own.
233 m_levelTiles = a_levelTiles;
234
235 m_particles.resize(a_finestLevel + 1);
236 m_maskParticles.resize(a_finestLevel + 1);
237 for (int lvl = 0; lvl <= a_finestLevel; lvl++) {
238 m_particles[lvl] = RefCountedPtr<LevelParticles>(new LevelParticles(a_grids[lvl]));
239 m_maskParticles[lvl] = RefCountedPtr<LevelParticles>(new LevelParticles(a_grids[lvl]));
240 }
241
242 // Buffer particles live on the grown grids (boxes grown by the refinement factor on finer levels).
243 this->setupGrownGrids();
244 m_bufferParticles.resize(a_finestLevel + 1);
245 for (int lvl = 0; lvl <= a_finestLevel; lvl++) {
246 m_bufferParticles[lvl] = RefCountedPtr<LevelParticles>(new LevelParticles(m_grownGrids[lvl]));
247 }
248
249 m_isOrganizedByCell = false;
250 m_isDefined = true;
251 }
252
254
259
264 const Vector<DisjointBoxLayout>&
265 getGrids() const
266 {
267 return m_grids;
268 }
269
274 Vector<RealVect>
275 getDx() const
276 {
277 return m_dx;
278 }
279
284 RealVect
285 getProbLo() const
286 {
287 return m_probLo;
288 }
289
294 int
296 {
297 return m_finestLevel;
298 }
299
304 std::string
305 getRealm() const
306 {
307 return m_realm;
308 }
309
311
316
323 {
324 return m_particles;
325 }
326
333 {
334 return m_particles;
335 }
336
343 {
344 return m_maskParticles;
345 }
346
353 {
354 return m_maskParticles;
355 }
356
363 {
364 return m_bufferParticles;
365 }
366
373 {
374 return m_bufferParticles;
375 }
376
387 operator[](const int a_lvl)
388 {
389 CH_assert(m_isDefined);
390 CH_assert(a_lvl >= 0 && a_lvl <= m_finestLevel);
391
392 return *m_particles[a_lvl];
393 }
394
400 const LevelParticles&
401 operator[](const int a_lvl) const
402 {
403 CH_assert(m_isDefined);
404 CH_assert(a_lvl >= 0 && a_lvl <= m_finestLevel);
405
406 return *m_particles[a_lvl];
407 }
408
410
415
420 bool
422 {
423 return m_isOrganizedByCell;
424 }
425
430 bool
431 isDefined() const
432 {
433 return m_isDefined;
434 }
435
437
442
446 void
448 {
449 CH_TIME("ParticleContainer::clearParticles");
450
451 CH_assert(m_isDefined);
452
453 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
454 LevelParticles& level = *m_particles[lvl];
455 const DisjointBoxLayout& dbl = m_grids[lvl];
456 const DataIterator& dit = dbl.dataIterator();
457 const int nbox = dit.size();
458
459#pragma omp parallel for schedule(runtime)
460 for (int mybox = 0; mybox < nbox; mybox++) {
461 const DataIndex& din = dit[mybox];
462
463 level[din].clear();
464 }
465 }
466 }
467
482 void
484 {
485 CH_TIME("ParticleContainer::addParticlesDestructive");
486
487 CH_assert(m_isDefined);
488
489 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
490 DataIterator dit = m_grids[lvl].dataIterator();
491 if (dit.ok()) {
492 (*m_particles[lvl])[dit()].catenate(a_particles); // move the buffer onto a local leaf
493 break;
494 }
495 }
496
497 this->remap(); // route every ingested particle to its owning patch/level/rank
498 }
499
501
506
513 unsigned long long
515 {
516 CH_TIME("ParticleContainer::getNumberOfValidParticlesLocal");
517
518 CH_assert(m_isDefined);
519
520 unsigned long long n = 0;
521 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
522 const LevelParticles& level = *m_particles[lvl];
523 const DisjointBoxLayout& dbl = m_grids[lvl];
524 const DataIterator& dit = dbl.dataIterator();
525 const int nbox = dit.size();
526
527#pragma omp parallel for schedule(runtime) reduction(+ : n)
528 for (int mybox = 0; mybox < nbox; mybox++) {
529 const DataIndex& din = dit[mybox];
530 const Leaf& leaf = level[din];
531
532 for (std::size_t i = 0; i < leaf.size(); i++) {
533 if (!leaf.isGhost(i)) {
534 n++;
535 }
536 }
537 }
538 }
539
540 return n;
541 }
542
547 unsigned long long
549 {
550 CH_TIME("ParticleContainer::getNumberOfValidParticlesGlobal");
551
552 CH_assert(m_isDefined);
553
555 }
556
561 unsigned long long
566
571 unsigned long long
576
578
583
593 void
594 remap();
595
602 void
603 preRegrid();
604
621 void
622 regrid(const Vector<DisjointBoxLayout>& a_grids,
623 const Vector<ProblemDomain>& a_domains,
624 const Vector<Real>& a_dx,
625 const Vector<int>& a_refRat,
626 const int a_minBlockSize,
627 const Vector<RefCountedPtr<LevelTiles>>& a_levelTiles,
628 const int a_newFinestLevel);
629
631
636
656 void
658 const AMRParticleGhostMask& a_maskCoarToFine,
659 const AMRParticleGhostMask& a_maskFineToCoar);
660
666 void
668
678 void
679 claimOwnership(const bool a_onlyValidRegion);
680
695 long long
696 resetParticleIDs(const bool a_onlyValidRegion, const ParticleID a_startID);
697
699
704
709 void
710 copyMaskParticles(const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>& a_mask);
711
719 void
720 copyMaskParticles(const int a_level, const LevelData<BaseFab<bool>>& a_mask);
721
726 void
727 transferMaskParticles(const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>& a_mask);
728
736 void
737 transferMaskParticles(const int a_level, const LevelData<BaseFab<bool>>& a_mask);
738
742 void
744 {
745 CH_TIME("ParticleContainer::clearMaskParticles");
746
747 CH_assert(m_isDefined);
748
749 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
750 LevelParticles& level = *m_maskParticles[lvl];
751 const DisjointBoxLayout& dbl = m_grids[lvl];
752 const DataIterator& dit = dbl.dataIterator();
753
754 const int nbox = dit.size();
755
756#pragma omp parallel for schedule(runtime)
757 for (int mybox = 0; mybox < nbox; mybox++) {
758 const DataIndex& din = dit[mybox];
759
760 level[din].clear();
761 }
762 }
763 }
764
768 void
770 {
771 CH_TIME("ParticleContainer::clearBufferParticles");
772
773 CH_assert(m_isDefined);
774
775 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
776 LevelParticles& level = *m_bufferParticles[lvl];
777 const BoxLayout& dbl = m_grownGrids[lvl];
778 const DataIterator& dit = dbl.dataIterator();
779
780 const int nbox = dit.size();
781
782#pragma omp parallel for schedule(runtime)
783 for (int mybox = 0; mybox < nbox; mybox++) {
784 const DataIndex& din = dit[mybox];
785
786 level[din].clear();
787 }
788 }
789 }
790
795 const Vector<BoxLayout>&
797 {
798 return m_grownGrids;
799 }
800
809 void
811 {
812 CH_TIME("ParticleContainer::transferParticles");
813
814 CH_assert(m_isDefined);
815
816 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
817 LevelParticles& src = *a_source[lvl];
818 LevelParticles& dst = *m_particles[lvl];
819
820 const DisjointBoxLayout& dbl = m_grids[lvl];
821 const DataIterator& dit = dbl.dataIterator();
822
823 const int nbox = dit.size();
824
825#pragma omp parallel for schedule(runtime)
826 for (int mybox = 0; mybox < nbox; mybox++) {
827 const DataIndex& din = dit[mybox];
828
829 dst[din].catenate(src[din]); // bulk move (id/rank preserved); empty dst -> O(1) swap
830 }
831 }
832
833 m_isOrganizedByCell = false;
834 }
835
837
842
848 void
850 {
851 CH_TIME("ParticleContainer::organizeParticlesByCell");
852
853 CH_assert(m_isDefined);
854
855 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
856 LevelParticles& level = *m_particles[lvl];
857
858 const DisjointBoxLayout& dbl = m_grids[lvl];
859 const DataIterator& dit = dbl.dataIterator();
860
861 const int nbox = dit.size();
862
863#pragma omp parallel for schedule(runtime)
864 for (int mybox = 0; mybox < nbox; mybox++) {
865 const DataIndex& din = dit[mybox];
866
867 level[din].sortByCell(dbl[din], m_dx[lvl], m_probLo);
868 }
869 }
870
871 m_isOrganizedByCell = true;
872 }
873
879 void
881 {
882 CH_TIME("ParticleContainer::organizeParticlesByPatch");
883
884 m_isOrganizedByCell = false;
885 }
886
888
900 findDestination(const RealVect& a_pos) const;
901
902protected:
906 void
908
912 using PoolKey = std::pair<int, unsigned int>;
913
917 using MoverPool = std::vector<std::map<PoolKey, Leaf>>;
918
929 gatherToPool(AMRParticlesSoA<P, Traits>& a_source, const Vector<DisjointBoxLayout>& a_sourceGrids);
930
943
957 const AMRParticleGhostMask& a_maskCoarToFine,
958 const AMRParticleGhostMask& a_maskFineToCoar);
959
968 void
969 distributeFromPool(MoverPool& a_pool, const bool a_setOwnerToReceiver);
970
974 Vector<DisjointBoxLayout> m_grids;
975
979 Vector<ProblemDomain> m_domains;
980
984 Vector<RealVect> m_dx;
985
989 Vector<int> m_refRat;
990
994 Vector<RefCountedPtr<LevelTiles>> m_levelTiles;
995
999 RealVect m_probLo;
1000
1004 RealVect m_probHi;
1005
1010
1015
1019 unsigned long long m_numOutcastLocal;
1020
1024 std::string m_realm;
1025
1033 const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>* m_validCells = nullptr;
1034
1039
1044
1049
1054
1058 Vector<DisjointBoxLayout> m_cacheGrids;
1059
1064
1069
1073 Vector<BoxLayout> m_grownGrids;
1074
1081 inline IntVect
1082 cellIndex(const int a_lvl, const RealVect& a_pos) const
1083 {
1084 IntVect iv;
1085 for (int dir = 0; dir < SpaceDim; dir++) {
1086 iv[dir] = static_cast<int>(std::floor((a_pos[dir] - m_probLo[dir]) / m_dx[a_lvl][dir]));
1087 }
1088 return iv;
1089 }
1090
1101 inline bool
1102 moveInsideDomain(RealVect& a_pos) const noexcept
1103 {
1104 const Real margin = 1.E-6 * m_dx[m_finestLevel][0];
1105
1106 bool moved = false;
1107
1108 for (int dir = 0; dir < SpaceDim; dir++) {
1109 if (a_pos[dir] < m_probLo[dir] && a_pos[dir] >= m_probLo[dir] - margin) {
1110 a_pos[dir] = m_probLo[dir] + margin;
1111 moved = true;
1112 }
1113 else if (a_pos[dir] >= m_probHi[dir] - margin && a_pos[dir] <= m_probHi[dir] + margin) {
1114 a_pos[dir] = m_probHi[dir] - margin;
1115 moved = true;
1116 }
1117 }
1118
1119 return moved;
1120 }
1121
1131 inline bool
1132 inValidBox(const int a_lvl, const Box& a_box, const RealVect& a_pos) const
1133 {
1134 return a_box.contains(this->cellIndex(a_lvl, a_pos));
1135 }
1136};
1137
1138#include <CD_NamespaceFooter.H>
1139
1141
1142#endif
Declaration of LevelTiles.
Agglomeration of basic MPI reductions.
Implementation of CD_ParticleContainer.H.
Vector< RefCountedPtr< LayoutData< ParticleSoA< P, Traits > > > > AMRParticlesSoA
Per-level holder vector: one ParticleSoA leaf container per box, per level.
Definition CD_ParticleContainer.H:56
Declaration of ParticleGhostMask, a per-box CSR lookup of particle ghost scatter targets.
Vector< RefCountedPtr< LayoutData< ParticleGhostMask > > > AMRParticleGhostMask
AMR-wide particle ghost-target lookup: one per-box CSR table per level, indexed by SOURCE level.
Definition CD_ParticleGhostMask.H:210
Declaration of ParticleSoA, an arena-backed Struct-of-Arrays particle container.
std::int64_t ParticleID
Global particle identifier type (container-owned metadata column; fixed-width for I/O).
Definition CD_ParticleSoA.H:161
const LevelParticles & operator[](const int a_lvl) const
Valid particles on one level (const).
Definition CD_ParticleContainer.H:401
void fillGhostParticles(const AMRParticleGhostMask &a_maskSame, const AMRParticleGhostMask &a_maskCoarToFine, const AMRParticleGhostMask &a_maskFineToCoar)
Fill each patch's ghost halo from prebuilt Realm particle ghost masks.
Definition CD_ParticleContainerImplem.H:864
bool isDefined() const
Whether define() has been called.
Definition CD_ParticleContainer.H:431
const Vector< BoxLayout > & getGrownGrids() const
Per-level grown grids that the buffer particles live on.
Definition CD_ParticleContainer.H:796
std::vector< std::map< PoolKey, Leaf > > MoverPool
Per-rank pool of movers: pool[rank] maps a destination patch to a small SoA of particles.
Definition CD_ParticleContainer.H:917
void regrid(const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const Vector< int > &a_refRat, const int a_minBlockSize, const Vector< RefCountedPtr< LevelTiles > > &a_levelTiles, const int a_newFinestLevel)
Rebuild over a new AMR layout and redistribute the preRegrid()-cached particles onto it.
Definition CD_ParticleContainerImplem.H:548
void clearParticles()
Drop all valid particles on every level (keeps each leaf's arena capacity).
Definition CD_ParticleContainer.H:447
AMRParticlesSoA< P, Traits > m_maskParticles
Halo/mask particles per level.
Definition CD_ParticleContainer.H:1063
IntVect cellIndex(const int a_lvl, const RealVect &a_pos) const
Cell index containing a position on a given level (floor((x - probLo)/dx)).
Definition CD_ParticleContainer.H:1082
Vector< RealVect > getDx() const
Per-level grid spacing.
Definition CD_ParticleContainer.H:275
void transferMaskParticles(const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > &a_mask)
Move the valid particles selected by a per-cell mask into the mask holder, all levels.
Definition CD_ParticleContainerImplem.H:970
AMRParticlesSoA< P, Traits > m_cacheParticles
Regrid cache: the pre-regrid valid holders, kept alive over the old layout by preRegrid().
Definition CD_ParticleContainer.H:1053
int m_finestLevel
Finest AMR level index.
Definition CD_ParticleContainer.H:1014
ParticleContainer & operator=(const ParticleContainer &)=delete
Copy assignment is deleted (move-only ownership).
void setupGrownGrids()
Build the grown grids (buffer-particle layout): boxes grown by the refinement factor.
Definition CD_ParticleContainerImplem.H:885
MoverPool gatherMoversToPool()
Mask fast path for remap(): pool ONLY the movers, leaving stayers in place.
Definition CD_ParticleContainerImplem.H:147
ParticleContainer()
Construct an empty, undefined container. Call define() before use.
Definition CD_ParticleContainer.H:143
void organizeParticlesByPatch()
Return to a by-patch view (the leaves remain a single contiguous array per patch).
Definition CD_ParticleContainer.H:880
void clearGhostParticles()
Remove every ghost particle (any non-Valid GhostType) from all levels and patches.
Definition CD_ParticleContainerImplem.H:606
Vector< BoxLayout > m_grownGrids
Per-level grown grids (boxes grown by the refinement factor on finer levels) for the buffer.
Definition CD_ParticleContainer.H:1073
unsigned long long getNumberOfValidParticlesGlobal() const
Number of valid particles across all ranks.
Definition CD_ParticleContainer.H:548
void preRegrid()
Cache the current valid particles ahead of a regrid.
Definition CD_ParticleContainerImplem.H:533
AMRParticlesSoA< P, Traits > m_bufferParticles
Grown-grid buffer particles per level (on m_grownGrids; filled during halo deposition).
Definition CD_ParticleContainer.H:1068
const AMRParticlesSoA< P, Traits > & getBufferParticles() const
The grown-grid buffer particles on all levels (const).
Definition CD_ParticleContainer.H:372
int getFinestLevel() const
Finest AMR level index.
Definition CD_ParticleContainer.H:295
Vector< int > m_refRat
Per-level refinement ratios (entry l is the ratio between level l and l+1).
Definition CD_ParticleContainer.H:989
void organizeParticlesByCell()
Cell-sort every valid leaf (counting sort into Fortran cell order + CSR cell offsets).
Definition CD_ParticleContainer.H:849
unsigned long long getNumberOfOutcastParticlesGlobal() const
Number of particles dropped off-domain by the most recent remap(), across all ranks.
Definition CD_ParticleContainer.H:572
const AMRParticlesSoA< P, Traits > & getMaskParticles() const
The halo/mask particles on all levels (const).
Definition CD_ParticleContainer.H:352
AMRParticlesSoA< P, Traits > m_particles
Valid particles: one ParticleSoA leaf per box, per level.
Definition CD_ParticleContainer.H:1048
LevelParticles & operator[](const int a_lvl)
Valid particles on one level (index by DataIndex to reach a patch's Leaf).
Definition CD_ParticleContainer.H:387
unsigned long long getNumberOfOutcastParticlesLocal() const
Number of particles dropped off-domain by the most recent remap() on this rank.
Definition CD_ParticleContainer.H:562
void claimOwnership(const bool a_onlyValidRegion)
Claim ownership of this rank's particles by stamping their owner rank (rankID = procID()).
Definition CD_ParticleContainerImplem.H:642
void define(const Vector< DisjointBoxLayout > &a_grids, const Vector< ProblemDomain > &a_domains, const Vector< Real > &a_dx, const Vector< int > &a_refRat, const RealVect &a_probLo, const int a_minBlockSize, const Vector< RefCountedPtr< LevelTiles > > &a_levelTiles, const int a_finestLevel, const std::string &a_realm, const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > *a_validCells)
Allocate the per-level holders and the per-level tile-ownership maps over the AMR grids.
Definition CD_ParticleContainer.H:194
const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > * m_validCells
Optional alias to the realm's valid-cell mask (true = cell not covered by a finer level).
Definition CD_ParticleContainer.H:1033
bool isOrganizedByCell() const
Whether the valid leaves are currently cell-sorted.
Definition CD_ParticleContainer.H:421
const Vector< DisjointBoxLayout > & getGrids() const
Per-level AMR grids.
Definition CD_ParticleContainer.H:265
bool m_isOrganizedByCell
Whether the valid leaves are currently cell-sorted.
Definition CD_ParticleContainer.H:1043
std::string m_realm
Realm label (diagnostics only).
Definition CD_ParticleContainer.H:1024
void distributeFromPool(MoverPool &a_pool, const bool a_setOwnerToReceiver)
Assign a pool into the valid holders: local appends + MPI scatter.
Definition CD_ParticleContainerImplem.H:270
ParticleSoA< P, Traits > Leaf
The per-patch leaf type owned at every (level, box).
Definition CD_ParticleContainer.H:128
RealVect m_probHi
Upper-right corner of the physical domain, computed from the coarsest domain box and grid spacing.
Definition CD_ParticleContainer.H:1004
unsigned long long m_numOutcastLocal
Particles dropped off-domain by the most recent remap() (local count).
Definition CD_ParticleContainer.H:1019
RealVect getProbLo() const
Lower-left corner of the physical domain.
Definition CD_ParticleContainer.H:285
int m_minBlockSize
Grid blocking factor (tile size).
Definition CD_ParticleContainer.H:1009
AMRParticlesSoA< P, Traits > & getBufferParticles()
The grown-grid buffer particles on all levels.
Definition CD_ParticleContainer.H:362
RealVect m_probLo
Lower-left corner of the physical domain.
Definition CD_ParticleContainer.H:999
long long resetParticleIDs(const bool a_onlyValidRegion, const ParticleID a_startID)
Assign globally-unique, contiguous particle IDs to the owned particles.
Definition CD_ParticleContainerImplem.H:679
bool moveInsideDomain(RealVect &a_pos) const noexcept
Move a position that lies on, or within roundoff of, a domain face to just inside it.
Definition CD_ParticleContainer.H:1102
std::string getRealm() const
Realm label.
Definition CD_ParticleContainer.H:305
void remap()
Redistribute every valid particle to the patch/level/rank that owns its cell.
Definition CD_ParticleContainerImplem.H:502
void clearMaskParticles()
Drop all mask/halo particles on every level (keeps capacity).
Definition CD_ParticleContainer.H:743
Vector< RefCountedPtr< LevelTiles > > m_levelTiles
Per-level tile-ownership maps (cell tile -> owning grid index / rank), used by remap().
Definition CD_ParticleContainer.H:994
MoverPool gatherToPool(AMRParticlesSoA< P, Traits > &a_source, const Vector< DisjointBoxLayout > &a_sourceGrids)
Gather every particle of a source holder into a per-rank, per-destination-patch pool.
Definition CD_ParticleContainerImplem.H:49
void addParticlesDestructive(ParticleSoA< P, Traits > &a_particles)
Add a free-standing buffer of particles to the container, routing each to its owner.
Definition CD_ParticleContainer.H:483
void clearBufferParticles()
Drop all buffer particles on every level (keeps capacity).
Definition CD_ParticleContainer.H:769
const AMRParticlesSoA< P, Traits > & getParticles() const
The valid particles on all levels (const).
Definition CD_ParticleContainer.H:332
LayoutData< Leaf > LevelParticles
The per-level holder type (one Leaf per box on the level's DisjointBoxLayout).
Definition CD_ParticleContainer.H:133
unsigned long long getNumberOfValidParticlesLocal() const
Number of valid particles owned by this rank.
Definition CD_ParticleContainer.H:514
Vector< ProblemDomain > m_domains
Per-level problem domains.
Definition CD_ParticleContainer.H:979
ParticleContainer(const ParticleContainer &)=delete
Copy construction is deleted (holders are shared RefCountedPtr – a copy would alias).
LevelTiles::LevelAndBox findDestination(const RealVect &a_pos) const
Map a position to its owning (level, grid index, rank) via the finest containing tile.
Definition CD_ParticleContainerImplem.H:42
void copyMaskParticles(const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > &a_mask)
Copy the valid particles selected by a per-cell mask into the mask holder, all levels.
Definition CD_ParticleContainerImplem.H:909
~ParticleContainer()=default
Destructor.
void transferParticles(AMRParticlesSoA< P, Traits > &a_source)
Move all particles from another holder (on the same valid grids) into the valid holder.
Definition CD_ParticleContainer.H:810
Vector< RealVect > m_dx
Per-level grid spacing (isotropic, stored as RealVect).
Definition CD_ParticleContainer.H:984
Vector< DisjointBoxLayout > m_grids
Per-level AMR grids.
Definition CD_ParticleContainer.H:974
std::pair< int, unsigned int > PoolKey
Pool key identifying a destination patch: (level, grid index within the level).
Definition CD_ParticleContainer.H:912
bool m_isDefined
Whether define() has been called.
Definition CD_ParticleContainer.H:1038
bool inValidBox(const int a_lvl, const Box &a_box, const RealVect &a_pos) const
True if a position's cell lies inside a (grid) box on a given level.
Definition CD_ParticleContainer.H:1132
MoverPool gatherGhostsFromMasks(const AMRParticleGhostMask &a_maskSame, const AMRParticleGhostMask &a_maskCoarToFine, const AMRParticleGhostMask &a_maskFineToCoar)
Gather ghost copies into a per-rank pool using prebuilt particle ghost masks.
Definition CD_ParticleContainerImplem.H:762
AMRParticlesSoA< P, Traits > & getMaskParticles()
The halo/mask particles on all levels.
Definition CD_ParticleContainer.H:342
Vector< DisjointBoxLayout > m_cacheGrids
The old (pre-regrid) grids the cache holders are defined on (for iterating the cache).
Definition CD_ParticleContainer.H:1058
AMRParticlesSoA< P, Traits > & getParticles()
The valid particles on all levels.
Definition CD_ParticleContainer.H:322
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
bool isGhost(const std::size_t a_index) const noexcept
Whether particle i is a ghost particle (any non-Valid designation).
Definition CD_ParticleSoA.H:1338
std::size_t size() const noexcept
Number of particles currently stored.
Definition CD_ParticleSoA.H:882
Real sum(const Real &a_value) noexcept
Compute the sum across all MPI ranks.
Definition CD_ParallelOpsImplem.H:354
Result of a point->block query. See findDestination.
Definition CD_LevelTiles.H:123