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
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),
146 m_finestLevel(-1),
148 m_isDefined(false),
150 {}
151
156
161
167 operator=(const ParticleContainer&) = delete;
168
192 void
193 define(const Vector<DisjointBoxLayout>& a_grids,
194 const Vector<ProblemDomain>& a_domains,
195 const Vector<Real>& a_dx,
196 const Vector<int>& a_refRat,
197 const RealVect& a_probLo,
198 const int a_minBlockSize,
199 const Vector<RefCountedPtr<LevelTiles>>& a_levelTiles,
200 const int a_finestLevel,
201 const std::string& a_realm,
202 const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>* a_validCells)
203 {
204 CH_TIME("ParticleContainer::define");
205
206 CH_assert(a_grids.size() > a_finestLevel);
207 CH_assert(a_domains.size() > a_finestLevel);
208 CH_assert(a_dx.size() > a_finestLevel);
209 CH_assert(a_refRat.size() > a_finestLevel);
210 CH_assert(a_levelTiles.size() > a_finestLevel);
211
212 m_grids = a_grids;
213 m_domains = a_domains;
214 m_refRat = a_refRat;
215 m_probLo = a_probLo;
216 m_minBlockSize = a_minBlockSize;
217 m_finestLevel = a_finestLevel;
218 m_realm = a_realm;
219 m_validCells = a_validCells;
221
222 m_dx.resize(a_finestLevel + 1);
223 for (int lvl = 0; lvl <= a_finestLevel; lvl++) {
224 m_dx[lvl] = a_dx[lvl] * RealVect::Unit;
225 }
226
227 // Alias the Realm's per-level tile->box maps (the single source of truth); never build our own.
228 m_levelTiles = a_levelTiles;
229
230 m_particles.resize(a_finestLevel + 1);
231 m_maskParticles.resize(a_finestLevel + 1);
232 for (int lvl = 0; lvl <= a_finestLevel; lvl++) {
233 m_particles[lvl] = RefCountedPtr<LevelParticles>(new LevelParticles(a_grids[lvl]));
234 m_maskParticles[lvl] = RefCountedPtr<LevelParticles>(new LevelParticles(a_grids[lvl]));
235 }
236
237 // Buffer particles live on the grown grids (boxes grown by the refinement factor on finer levels).
238 this->setupGrownGrids();
239 m_bufferParticles.resize(a_finestLevel + 1);
240 for (int lvl = 0; lvl <= a_finestLevel; lvl++) {
241 m_bufferParticles[lvl] = RefCountedPtr<LevelParticles>(new LevelParticles(m_grownGrids[lvl]));
242 }
243
244 m_isOrganizedByCell = false;
245 m_isDefined = true;
246 }
247
249
254
259 const Vector<DisjointBoxLayout>&
260 getGrids() const
261 {
262 return m_grids;
263 }
264
269 Vector<RealVect>
270 getDx() const
271 {
272 return m_dx;
273 }
274
279 RealVect
280 getProbLo() const
281 {
282 return m_probLo;
283 }
284
289 int
291 {
292 return m_finestLevel;
293 }
294
299 std::string
300 getRealm() const
301 {
302 return m_realm;
303 }
304
306
311
318 {
319 return m_particles;
320 }
321
328 {
329 return m_particles;
330 }
331
338 {
339 return m_maskParticles;
340 }
341
348 {
349 return m_maskParticles;
350 }
351
358 {
359 return m_bufferParticles;
360 }
361
368 {
369 return m_bufferParticles;
370 }
371
382 operator[](const int a_lvl)
383 {
384 CH_assert(m_isDefined);
385 CH_assert(a_lvl >= 0 && a_lvl <= m_finestLevel);
386
387 return *m_particles[a_lvl];
388 }
389
395 const LevelParticles&
396 operator[](const int a_lvl) const
397 {
398 CH_assert(m_isDefined);
399 CH_assert(a_lvl >= 0 && a_lvl <= m_finestLevel);
400
401 return *m_particles[a_lvl];
402 }
403
405
410
415 bool
417 {
418 return m_isOrganizedByCell;
419 }
420
425 bool
426 isDefined() const
427 {
428 return m_isDefined;
429 }
430
432
437
441 void
443 {
444 CH_TIME("ParticleContainer::clearParticles");
445
446 CH_assert(m_isDefined);
447
448 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
449 LevelParticles& level = *m_particles[lvl];
450 const DisjointBoxLayout& dbl = m_grids[lvl];
451 const DataIterator& dit = dbl.dataIterator();
452 const int nbox = dit.size();
453
454#pragma omp parallel for schedule(runtime)
455 for (int mybox = 0; mybox < nbox; mybox++) {
456 const DataIndex& din = dit[mybox];
457
458 level[din].clear();
459 }
460 }
461 }
462
477 void
479 {
480 CH_TIME("ParticleContainer::addParticlesDestructive");
481
482 CH_assert(m_isDefined);
483
484 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
485 DataIterator dit = m_grids[lvl].dataIterator();
486 if (dit.ok()) {
487 (*m_particles[lvl])[dit()].catenate(a_particles); // move the buffer onto a local leaf
488 break;
489 }
490 }
491
492 this->remap(); // route every ingested particle to its owning patch/level/rank
493 }
494
496
501
508 unsigned long long
510 {
511 CH_TIME("ParticleContainer::getNumberOfValidParticlesLocal");
512
513 CH_assert(m_isDefined);
514
515 unsigned long long n = 0;
516 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
517 const LevelParticles& level = *m_particles[lvl];
518 const DisjointBoxLayout& dbl = m_grids[lvl];
519 const DataIterator& dit = dbl.dataIterator();
520 const int nbox = dit.size();
521
522#pragma omp parallel for schedule(runtime) reduction(+ : n)
523 for (int mybox = 0; mybox < nbox; mybox++) {
524 const DataIndex& din = dit[mybox];
525 const Leaf& leaf = level[din];
526
527 for (std::size_t i = 0; i < leaf.size(); i++) {
528 if (!leaf.isGhost(i)) {
529 n++;
530 }
531 }
532 }
533 }
534
535 return n;
536 }
537
542 unsigned long long
544 {
545 CH_TIME("ParticleContainer::getNumberOfValidParticlesGlobal");
546
547 CH_assert(m_isDefined);
548
550 }
551
556 unsigned long long
561
566 unsigned long long
571
573
578
587 void
588 remap();
589
596 void
597 preRegrid();
598
615 void
616 regrid(const Vector<DisjointBoxLayout>& a_grids,
617 const Vector<ProblemDomain>& a_domains,
618 const Vector<Real>& a_dx,
619 const Vector<int>& a_refRat,
620 const int a_minBlockSize,
621 const Vector<RefCountedPtr<LevelTiles>>& a_levelTiles,
622 const int a_newFinestLevel);
623
625
630
650 void
652 const AMRParticleGhostMask& a_maskCoarToFine,
653 const AMRParticleGhostMask& a_maskFineToCoar);
654
660 void
662
672 void
673 claimOwnership(const bool a_onlyValidRegion);
674
689 long long
690 resetParticleIDs(const bool a_onlyValidRegion, const ParticleID a_startID);
691
693
698
703 void
704 copyMaskParticles(const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>& a_mask);
705
713 void
714 copyMaskParticles(const int a_level, const LevelData<BaseFab<bool>>& a_mask);
715
720 void
721 transferMaskParticles(const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>& a_mask);
722
730 void
731 transferMaskParticles(const int a_level, const LevelData<BaseFab<bool>>& a_mask);
732
736 void
738 {
739 CH_TIME("ParticleContainer::clearMaskParticles");
740
741 CH_assert(m_isDefined);
742
743 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
744 LevelParticles& level = *m_maskParticles[lvl];
745 const DisjointBoxLayout& dbl = m_grids[lvl];
746 const DataIterator& dit = dbl.dataIterator();
747
748 const int nbox = dit.size();
749
750#pragma omp parallel for schedule(runtime)
751 for (int mybox = 0; mybox < nbox; mybox++) {
752 const DataIndex& din = dit[mybox];
753
754 level[din].clear();
755 }
756 }
757 }
758
762 void
764 {
765 CH_TIME("ParticleContainer::clearBufferParticles");
766
767 CH_assert(m_isDefined);
768
769 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
770 LevelParticles& level = *m_bufferParticles[lvl];
771 const BoxLayout& dbl = m_grownGrids[lvl];
772 const DataIterator& dit = dbl.dataIterator();
773
774 const int nbox = dit.size();
775
776#pragma omp parallel for schedule(runtime)
777 for (int mybox = 0; mybox < nbox; mybox++) {
778 const DataIndex& din = dit[mybox];
779
780 level[din].clear();
781 }
782 }
783 }
784
789 const Vector<BoxLayout>&
791 {
792 return m_grownGrids;
793 }
794
803 void
805 {
806 CH_TIME("ParticleContainer::transferParticles");
807
808 CH_assert(m_isDefined);
809
810 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
811 LevelParticles& src = *a_source[lvl];
812 LevelParticles& dst = *m_particles[lvl];
813
814 const DisjointBoxLayout& dbl = m_grids[lvl];
815 const DataIterator& dit = dbl.dataIterator();
816
817 const int nbox = dit.size();
818
819#pragma omp parallel for schedule(runtime)
820 for (int mybox = 0; mybox < nbox; mybox++) {
821 const DataIndex& din = dit[mybox];
822
823 dst[din].catenate(src[din]); // bulk move (id/rank preserved); empty dst -> O(1) swap
824 }
825 }
826
827 m_isOrganizedByCell = false;
828 }
829
831
836
842 void
844 {
845 CH_TIME("ParticleContainer::organizeParticlesByCell");
846
847 CH_assert(m_isDefined);
848
849 for (int lvl = 0; lvl <= m_finestLevel; lvl++) {
850 LevelParticles& level = *m_particles[lvl];
851
852 const DisjointBoxLayout& dbl = m_grids[lvl];
853 const DataIterator& dit = dbl.dataIterator();
854
855 const int nbox = dit.size();
856
857#pragma omp parallel for schedule(runtime)
858 for (int mybox = 0; mybox < nbox; mybox++) {
859 const DataIndex& din = dit[mybox];
860
861 level[din].sortByCell(dbl[din], m_dx[lvl], m_probLo);
862 }
863 }
864
865 m_isOrganizedByCell = true;
866 }
867
873 void
875 {
876 CH_TIME("ParticleContainer::organizeParticlesByPatch");
877
878 m_isOrganizedByCell = false;
879 }
880
882
894 findDestination(const RealVect& a_pos) const;
895
896protected:
900 void
902
906 using PoolKey = std::pair<int, unsigned int>;
907
911 using MoverPool = std::vector<std::map<PoolKey, Leaf>>;
912
923 gatherToPool(AMRParticlesSoA<P, Traits>& a_source, const Vector<DisjointBoxLayout>& a_sourceGrids);
924
937
951 const AMRParticleGhostMask& a_maskCoarToFine,
952 const AMRParticleGhostMask& a_maskFineToCoar);
953
962 void
963 distributeFromPool(MoverPool& a_pool, const bool a_setOwnerToReceiver);
964
968 Vector<DisjointBoxLayout> m_grids;
969
973 Vector<ProblemDomain> m_domains;
974
978 Vector<RealVect> m_dx;
979
983 Vector<int> m_refRat;
984
988 Vector<RefCountedPtr<LevelTiles>> m_levelTiles;
989
993 RealVect m_probLo;
994
999
1004
1008 unsigned long long m_numOutcastLocal;
1009
1013 std::string m_realm;
1014
1022 const Vector<RefCountedPtr<LevelData<BaseFab<bool>>>>* m_validCells = nullptr;
1023
1028
1033
1038
1043
1047 Vector<DisjointBoxLayout> m_cacheGrids;
1048
1053
1058
1062 Vector<BoxLayout> m_grownGrids;
1063
1070 inline IntVect
1071 cellIndex(const int a_lvl, const RealVect& a_pos) const
1072 {
1073 IntVect iv;
1074 for (int dir = 0; dir < SpaceDim; dir++) {
1075 iv[dir] = static_cast<int>(std::floor((a_pos[dir] - m_probLo[dir]) / m_dx[a_lvl][dir]));
1076 }
1077 return iv;
1078 }
1079
1089 inline bool
1090 inValidBox(const int a_lvl, const Box& a_box, const RealVect& a_pos) const
1091 {
1092 return a_box.contains(this->cellIndex(a_lvl, a_pos));
1093 }
1094};
1095
1096#include <CD_NamespaceFooter.H>
1097
1099
1100#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
AMR-hierarchy container of computational particles, stored per patch in Struct-of-Arrays form.
Definition CD_ParticleContainer.H:123
const LevelParticles & operator[](const int a_lvl) const
Valid particles on one level (const).
Definition CD_ParticleContainer.H:396
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:856
bool isDefined() const
Whether define() has been called.
Definition CD_ParticleContainer.H:426
const Vector< BoxLayout > & getGrownGrids() const
Per-level grown grids that the buffer particles live on.
Definition CD_ParticleContainer.H:790
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:540
void clearParticles()
Drop all valid particles on every level (keeps each leaf's arena capacity).
Definition CD_ParticleContainer.H:442
AMRParticlesSoA< P, Traits > m_maskParticles
Halo/mask particles per level.
Definition CD_ParticleContainer.H:1052
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:1071
Vector< RealVect > getDx() const
Per-level grid spacing.
Definition CD_ParticleContainer.H:270
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:962
AMRParticlesSoA< P, Traits > m_cacheParticles
Regrid cache: the pre-regrid valid holders, kept alive over the old layout by preRegrid().
Definition CD_ParticleContainer.H:1042
int m_finestLevel
Finest AMR level index.
Definition CD_ParticleContainer.H:1003
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:877
MoverPool gatherMoversToPool()
Mask fast path for remap(): pool ONLY the movers, leaving stayers in place.
Definition CD_ParticleContainerImplem.H:143
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:874
void clearGhostParticles()
Remove every ghost particle (any non-Valid GhostType) from all levels and patches.
Definition CD_ParticleContainerImplem.H:598
Vector< BoxLayout > m_grownGrids
Per-level grown grids (boxes grown by the refinement factor on finer levels) for the buffer.
Definition CD_ParticleContainer.H:1062
unsigned long long getNumberOfValidParticlesGlobal() const
Number of valid particles across all ranks.
Definition CD_ParticleContainer.H:543
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:911
void preRegrid()
Cache the current valid particles ahead of a regrid.
Definition CD_ParticleContainerImplem.H:525
AMRParticlesSoA< P, Traits > m_bufferParticles
Grown-grid buffer particles per level (on m_grownGrids; filled during halo deposition).
Definition CD_ParticleContainer.H:1057
const AMRParticlesSoA< P, Traits > & getBufferParticles() const
The grown-grid buffer particles on all levels (const).
Definition CD_ParticleContainer.H:367
int getFinestLevel() const
Finest AMR level index.
Definition CD_ParticleContainer.H:290
Vector< int > m_refRat
Per-level refinement ratios (entry l is the ratio between level l and l+1).
Definition CD_ParticleContainer.H:983
void organizeParticlesByCell()
Cell-sort every valid leaf (counting sort into Fortran cell order + CSR cell offsets).
Definition CD_ParticleContainer.H:843
unsigned long long getNumberOfOutcastParticlesGlobal() const
Number of particles dropped off-domain by the most recent remap(), across all ranks.
Definition CD_ParticleContainer.H:567
const AMRParticlesSoA< P, Traits > & getMaskParticles() const
The halo/mask particles on all levels (const).
Definition CD_ParticleContainer.H:347
AMRParticlesSoA< P, Traits > m_particles
Valid particles: one ParticleSoA leaf per box, per level.
Definition CD_ParticleContainer.H:1037
LevelParticles & operator[](const int a_lvl)
Valid particles on one level (index by DataIndex to reach a patch's Leaf).
Definition CD_ParticleContainer.H:382
unsigned long long getNumberOfOutcastParticlesLocal() const
Number of particles dropped off-domain by the most recent remap() on this rank.
Definition CD_ParticleContainer.H:557
void claimOwnership(const bool a_onlyValidRegion)
Claim ownership of this rank's particles by stamping their owner rank (rankID = procID()).
Definition CD_ParticleContainerImplem.H:634
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:193
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:1022
bool isOrganizedByCell() const
Whether the valid leaves are currently cell-sorted.
Definition CD_ParticleContainer.H:416
const Vector< DisjointBoxLayout > & getGrids() const
Per-level AMR grids.
Definition CD_ParticleContainer.H:260
bool m_isOrganizedByCell
Whether the valid leaves are currently cell-sorted.
Definition CD_ParticleContainer.H:1032
std::string m_realm
Realm label (diagnostics only).
Definition CD_ParticleContainer.H:1013
void distributeFromPool(MoverPool &a_pool, const bool a_setOwnerToReceiver)
Assign a pool into the valid holders: local appends + MPI scatter.
Definition CD_ParticleContainerImplem.H:262
unsigned long long m_numOutcastLocal
Particles dropped off-domain by the most recent remap() (local count).
Definition CD_ParticleContainer.H:1008
RealVect getProbLo() const
Lower-left corner of the physical domain.
Definition CD_ParticleContainer.H:280
int m_minBlockSize
Grid blocking factor (tile size).
Definition CD_ParticleContainer.H:998
AMRParticlesSoA< P, Traits > & getBufferParticles()
The grown-grid buffer particles on all levels.
Definition CD_ParticleContainer.H:357
RealVect m_probLo
Lower-left corner of the physical domain.
Definition CD_ParticleContainer.H:993
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:671
std::string getRealm() const
Realm label.
Definition CD_ParticleContainer.H:300
void remap()
Redistribute every valid particle to the patch/level/rank that owns its cell.
Definition CD_ParticleContainerImplem.H:494
void clearMaskParticles()
Drop all mask/halo particles on every level (keeps capacity).
Definition CD_ParticleContainer.H:737
Vector< RefCountedPtr< LevelTiles > > m_levelTiles
Per-level tile-ownership maps (cell tile -> owning grid index / rank), used by remap().
Definition CD_ParticleContainer.H:988
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:478
void clearBufferParticles()
Drop all buffer particles on every level (keeps capacity).
Definition CD_ParticleContainer.H:763
const AMRParticlesSoA< P, Traits > & getParticles() const
The valid particles on all levels (const).
Definition CD_ParticleContainer.H:327
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:509
Vector< ProblemDomain > m_domains
Per-level problem domains.
Definition CD_ParticleContainer.H:973
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:901
~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:804
Vector< RealVect > m_dx
Per-level grid spacing (isotropic, stored as RealVect).
Definition CD_ParticleContainer.H:978
Vector< DisjointBoxLayout > m_grids
Per-level AMR grids.
Definition CD_ParticleContainer.H:968
std::pair< int, unsigned int > PoolKey
Pool key identifying a destination patch: (level, grid index within the level).
Definition CD_ParticleContainer.H:906
bool m_isDefined
Whether define() has been called.
Definition CD_ParticleContainer.H:1027
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:1090
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:754
AMRParticlesSoA< P, Traits > & getMaskParticles()
The halo/mask particles on all levels.
Definition CD_ParticleContainer.H:337
Vector< DisjointBoxLayout > m_cacheGrids
The old (pre-regrid) grids the cache holders are defined on (for iterating the cache).
Definition CD_ParticleContainer.H:1047
AMRParticlesSoA< P, Traits > & getParticles()
The valid particles on all levels.
Definition CD_ParticleContainer.H:317
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:1331
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