Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_ParticleContainerI.H
Go to the documentation of this file.
2
3#include <algorithm>
4#include <iterator>
5#include <set>
6#include <stdexcept>
7#include <string>
8#include <type_traits>
9#include <vector>
10
11namespace amrex {
12
13template <typename ParticleType, int NArrayReal, int NArrayInt,
14 template<class> class Allocator, class CellAssignor>
15void
17{
18 num_real_comm_comps = 0;
19 int comm_comps_start = 0;
20 if constexpr (!ParticleType::is_soa_particle) {
21 comm_comps_start += AMREX_SPACEDIM + NStructReal;
22 }
23 for (int i = comm_comps_start; i < comm_comps_start + NumRealComps(); ++i) {
24 if (h_redistribute_real_comp[i]) {++num_real_comm_comps;}
25 }
26
27 num_int_comm_comps = 0;
28 comm_comps_start = 2 + NStructInt;
29 for (int i = comm_comps_start; i < comm_comps_start + NumIntComps(); ++i) {
30 if (h_redistribute_int_comp[i]) {++num_int_comm_comps;}
31 }
32
33 if constexpr (ParticleType::is_soa_particle) {
34 particle_size = sizeof(uint64_t); // idcpu
35 } else {
36 particle_size = sizeof(ParticleType);
37 }
38 superparticle_size = particle_size +
39 num_real_comm_comps*sizeof(ParticleReal) + num_int_comm_comps*sizeof(int);
40}
41
42template <typename ParticleType, int NArrayReal, int NArrayInt,
43 template<class> class Allocator, class CellAssignor>
44void
46{
47 levelDirectoriesCreated = false;
48 usePrePost = false;
49 doUnlink = true;
50
51 // by default communicate all components
52 if constexpr (ParticleType::is_soa_particle)
53 {
54 h_redistribute_real_comp.resize(NArrayReal, true);
55 } else {
56 h_redistribute_real_comp.resize(AMREX_SPACEDIM + NStructReal + NArrayReal, true);
57 }
58 h_redistribute_int_comp.resize(2 + NStructInt + NArrayInt, true);
59
60 SetParticleSize();
61
62 // add default names for SoA Real and Int compile-time arguments
63 m_soa_rdata_names.clear();
64 for (int i=0; i<NArrayReal; ++i)
65 {
66 m_soa_rdata_names.push_back(getDefaultCompNameReal<ParticleType>(i));
67 }
68 m_soa_idata_names.clear();
69 for (int i=0; i<NArrayInt; ++i)
70 {
71 m_soa_idata_names.push_back(getDefaultCompNameInt<ParticleType>(i));
72 }
73
74 static bool initialized = false;
75 if ( ! initialized)
76 {
77 static_assert(sizeof(ParticleType)%sizeof(RealType) == 0,
78 "sizeof ParticleType is not a multiple of sizeof RealType");
79
80 ParmParse pp("particles");
81 pp.queryAdd("do_tiling", do_tiling);
82 Vector<int> tilesize(AMREX_SPACEDIM);
83 if (pp.queryarr("tile_size", tilesize, 0, AMREX_SPACEDIM)) {
84 for (int i=0; i<AMREX_SPACEDIM; ++i) { tile_size[i] = tilesize[i]; }
85 }
86
87 static_assert(std::is_standard_layout_v<ParticleType>,
88 "Particle type must be standard layout");
89 // && std::is_trivial<ParticleType>::value,
90 // "Particle type must be standard layout and trivial.");
91
92 pp.query("use_prepost", usePrePost);
93 pp.query("do_unlink", doUnlink);
94 pp.queryAdd("do_mem_efficient_sort", memEfficientSort);
95 pp.queryAdd("use_comms_arena", use_comms_arena);
96
97 initialized = true;
98 }
99}
100
101template<
102 typename ParticleType,
103 int NArrayReal,
104 int NArrayInt,
105 template<class> class Allocator,
106 class CellAssignor
107>
108void
110 std::vector<std::string> const & rdata_name, std::vector<std::string> const & idata_name
111)
112{
113 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(rdata_name.size() == NArrayReal, "rdata_name must be equal to NArrayReal");
114 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(idata_name.size() == NArrayInt, "idata_name must be equal to NArrayInt");
115
116 // ensure names for components are unique
117 std::set<std::string> const unique_r_names(rdata_name.begin(), rdata_name.end());
118 std::set<std::string> const unique_i_names(idata_name.begin(), idata_name.end());
119 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(rdata_name.size() == unique_r_names.size(), "SetSoACompileTimeNames: Provided names in rdata_name are not unique!");
120 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(idata_name.size() == unique_i_names.size(), "SetSoACompileTimeNames: Provided names in idata_name are not unique!");
121
122 for (int i=0; i<NArrayReal; ++i)
123 {
124 m_soa_rdata_names.at(i) = rdata_name.at(i);
125 }
126 for (int i=0; i<NArrayInt; ++i)
127 {
128 m_soa_idata_names.at(i) = idata_name.at(i);
129 }
130}
131
132template<
133 typename ParticleType,
134 int NArrayReal,
135 int NArrayInt,
136 template<class> class Allocator,
137 class CellAssignor
138>
139bool
141{
142 return std::find(m_soa_rdata_names.begin(), m_soa_rdata_names.end(), name) != std::end(m_soa_rdata_names);
143}
144
145template <typename ParticleType, int NArrayReal, int NArrayInt,
146 template<class> class Allocator, class CellAssignor>
147bool
149{
150 return std::find(m_soa_idata_names.begin(), m_soa_idata_names.end(), name) != std::end(m_soa_idata_names);
151}
152
153template<
154 typename ParticleType,
155 int NArrayReal,
156 int NArrayInt,
157 template<class> class Allocator,
158 class CellAssignor
159>
160int
162{
163 const auto it = std::find(m_soa_rdata_names.begin(), m_soa_rdata_names.end(), name);
164
165 if (it == m_soa_rdata_names.end())
166 {
167 throw std::runtime_error("GetRealCompIndex: Component " + name + " does not exist!");
168 }
169 else
170 {
171 return std::distance(m_soa_rdata_names.begin(), it);
172 }
173}
174
175template<
176 typename ParticleType,
177 int NArrayReal,
178 int NArrayInt,
179 template<class> class Allocator,
180 class CellAssignor
181>
182int
184{
185 const auto it = std::find(m_soa_idata_names.begin(), m_soa_idata_names.end(), name);
186
187 if (it == m_soa_idata_names.end())
188 {
189 throw std::runtime_error("GetIntCompIndex: Component " + name + " does not exist!");
190 }
191 else
192 {
193 return std::distance(m_soa_idata_names.begin(), it);
194 }
195}
196
197template <typename ParticleType, int NArrayReal, int NArrayInt,
198 template<class> class Allocator, class CellAssignor>
199template <typename P, typename Assignor>
202{
203 const Geometry& geom = Geom(lev);
204 const auto& domain = geom.Domain();
205 const auto& plo = geom.ProbLoArray();
206 const auto& dxi = geom.InvCellSizeArray();
207
208 return Assignor{}(p, plo, dxi, domain);
209}
210
211template <typename ParticleType, int NArrayReal, int NArrayInt,
212 template<class> class Allocator, class CellAssignor>
213template <typename P>
214bool
216::Where (const P& p,
217 ParticleLocData& pld,
218 int lev_min,
219 int lev_max,
220 int nGrow,
221 int local_grid) const
222{
223
224 AMREX_ASSERT(m_gdb != nullptr);
225
226 if (lev_max == -1) {
227 lev_max = finestLevel();
228 }
229
230 AMREX_ASSERT(lev_max <= finestLevel());
231
232 AMREX_ASSERT(nGrow == 0 || (nGrow >= 0 && lev_min == lev_max));
233
234 std::vector< std::pair<int, Box> > isects;
235
236 for (int lev = lev_max; lev >= lev_min; lev--) {
237 const IntVect& iv = Index(p, lev);
238 if (lev == pld.m_lev) {
239 // The fact that we are here means this particle does not belong to any finer grids.
240 if (pld.m_grid >= 0) {
241 if (pld.m_grown_gridbox.contains(iv)) {
242 pld.m_cell = iv;
243 if (!pld.m_tilebox.contains(iv)) {
244 pld.m_tile = getTileIndex(iv, pld.m_gridbox, do_tiling, tile_size, pld.m_tilebox);
245 }
246 return true;
247 }
248 }
249 }
250
251 int grid;
252 const BoxArray& ba = ParticleBoxArray(lev);
254
255 if (local_grid < 0) {
256 bool findfirst = (nGrow == 0) ? true : false;
257 ba.intersections(Box(iv, iv), isects, findfirst, nGrow);
258 grid = isects.empty() ? -1 : isects[0].first;
259 if (nGrow > 0 && isects.size() > 1) {
260 for (auto & isect : isects) {
261 Box bx = ba.getCellCenteredBox(isect.first);
262 for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
263 Box gbx = bx;
265 gr[dir] = nGrow;
266 gbx.grow(gr);
267 if (gbx.contains(iv)) {
268 grid = isect.first;
269 }
270 }
271 }
272 }
273 } else {
274 grid = (*redistribute_mask_ptr)[local_grid](iv, 0);
275 }
276
277 if (grid >= 0) {
278 const Box& bx = ba.getCellCenteredBox(grid);
279 pld.m_lev = lev;
280 pld.m_grid = grid;
281 pld.m_tile = getTileIndex(iv, bx, do_tiling, tile_size, pld.m_tilebox);
282 pld.m_cell = iv;
283 pld.m_gridbox = bx;
284 pld.m_grown_gridbox = amrex::grow(bx, nGrow);
285 return true;
286 }
287 }
288
289 return false;
290}
291
292template <typename ParticleType, int NArrayReal, int NArrayInt,
293 template<class> class Allocator, class CellAssignor>
294template <typename P>
295bool
298 ParticleLocData& pld,
299 int lev_min,
300 int lev_max,
301 int local_grid) const
302{
303
304 AMREX_ASSERT(m_gdb != nullptr);
305
306 if (!Geom(0).isAnyPeriodic()) { return false; }
307
308 if (lev_max == -1) {
309 lev_max = finestLevel();
310 }
311
312 AMREX_ASSERT(lev_max <= finestLevel());
313
314 // Create a copy "dummy" particle to check for periodic outs.
315 Particle<0, 0> p_prime;
316 AMREX_D_TERM(p_prime.pos(0) = p.pos(0);,
317 p_prime.pos(1) = p.pos(1);,
318 p_prime.pos(2) = p.pos(2));
319 if (PeriodicShift(p_prime)) {
320 std::vector< std::pair<int,Box> > isects;
321 for (int lev = lev_max; lev >= lev_min; lev--) {
322
323 int grid;
324 IntVect iv;
325 const BoxArray& ba = ParticleBoxArray(lev);
327
328 if (local_grid < 0) {
329 iv = Index<amrex::Particle<0, 0>, DefaultAssignor>(p_prime, lev);
330 ba.intersections(Box(iv, iv), isects, true, 0);
331 grid = isects.empty() ? -1 : isects[0].first;
332 } else {
333 iv = Index<amrex::Particle<0, 0>, DefaultAssignor>(p_prime, lev);
334 if (ba[local_grid].contains(iv))
335 {
336 grid = local_grid;
337 }
338 else
339 {
340 ba.intersections(Box(iv, iv), isects, true, 0);
341 grid = isects.empty() ? -1 : isects[0].first;
342 if(grid == -1)
343 {
344 grid = (*redistribute_mask_ptr)[local_grid](Index(p, lev), 0);
345 }
346 }
347 }
348
349 if (grid >= 0) {
350 AMREX_D_TERM(p.pos(0) = p_prime.pos(0);,
351 p.pos(1) = p_prime.pos(1);,
352 p.pos(2) = p_prime.pos(2););
353
354 const Box& bx = ba.getCellCenteredBox(grid);
355
356 pld.m_lev = lev;
357 pld.m_grid = grid;
358 pld.m_tile = getTileIndex(iv, bx, do_tiling, tile_size, pld.m_tilebox);
359 pld.m_cell = iv;
360 pld.m_gridbox = bx;
361 pld.m_grown_gridbox = bx;
362 return true;
363 }
364 }
365 }
366
367 return false;
368}
369
370
371template <typename ParticleType, int NArrayReal, int NArrayInt,
372 template<class> class Allocator, class CellAssignor>
373template <typename P>
374bool
376::PeriodicShift (P& p) const
377{
378 const auto& geom = Geom(0);
379 const auto plo = geom.ProbLoArray();
380 const auto phi = geom.ProbHiArray();
381 const auto rlo = geom.ProbLoArrayInParticleReal();
382 const auto rhi = geom.ProbHiArrayInParticleReal();
383 const auto is_per = geom.isPeriodicArray();
384
385 return enforcePeriodic(p, plo, phi, rlo, rhi, is_per);
386}
387
388template <typename ParticleType, int NArrayReal, int NArrayInt,
389 template<class> class Allocator, class CellAssignor>
393 bool /*update*/,
394 bool verbose,
395 ParticleLocData pld) const
396{
397 AMREX_ASSERT(m_gdb != nullptr);
398
399 bool ok = Where(p, pld);
400
401 if (!ok && Geom(0).isAnyPeriodic())
402 {
403 // Attempt to shift the particle back into the domain if it
404 // crossed a periodic boundary.
405 PeriodicShift(p);
406 ok = Where(p, pld);
407 }
408
409 if (!ok) {
410 // invalidate the particle.
411 if (verbose) {
412 amrex::AllPrint()<< "Invalidating out-of-domain particle: " << p << '\n';
413 }
414
415 AMREX_ASSERT(p.id().is_valid());
416
417 p.id().make_invalid();
418 }
419
420 return pld;
421}
422
423template <typename ParticleType, int NArrayReal, int NArrayInt,
424 template<class> class Allocator, class CellAssignor>
425void
431
432template <typename ParticleType, int NArrayReal, int NArrayInt,
433 template<class> class Allocator, class CellAssignor>
434void
436{
438 int nlevs = std::max(0, finestLevel()+1);
439 m_particles.resize(nlevs);
440}
441
442template <typename ParticleType, int NArrayReal, int NArrayInt,
443 template<class> class Allocator, class CellAssignor>
444template <typename P>
445void
447 int lev_min, int lev_max, int nGrow, int local_grid) const
448{
449 bool success;
450 if (Geom(0).outsideRoundoffDomain(AMREX_D_DECL(p.pos(0), p.pos(1), p.pos(2))))
451 {
452 // Note that EnforcePeriodicWhere may shift the particle if it is successful.
453 success = EnforcePeriodicWhere(p, pld, lev_min, lev_max, local_grid);
454 if (!success && lev_min == 0)
455 {
456 // The particle has left the domain; invalidate it.
457 p.id().make_invalid();
458 success = true;
459 }
460 }
461 else
462 {
463 success = Where(p, pld, lev_min, lev_max, 0, local_grid);
464 }
465
466 if (!success)
467 {
468 success = (nGrow > 0) && Where(p, pld, lev_min, lev_min, nGrow);
469 pld.m_grown_gridbox = pld.m_gridbox; // reset grown box for subsequent calls.
470 }
471
472 if (!success)
473 {
474 amrex::Abort("ParticleContainer::locateParticle(): invalid particle.");
475 }
476}
477
478template <typename ParticleType, int NArrayReal, int NArrayInt,
479 template<class> class Allocator, class CellAssignor>
480Long
482{
483 Long nparticles = 0;
484 for (int lev = 0; lev <= finestLevel(); lev++) {
485 nparticles += NumberOfParticlesAtLevel(lev,only_valid,true);
486 }
487 if (!only_local) {
489 }
490 return nparticles;
491}
492
493template <typename ParticleType, int NArrayReal, int NArrayInt,
494 template<class> class Allocator, class CellAssignor>
497{
498 AMREX_ASSERT(lev >= 0 && lev < int(m_particles.size()));
499
500 LayoutData<Long> np_per_grid_local(ParticleBoxArray(lev),
501 ParticleDistributionMap(lev));
502
503 for (ParConstIterType pti(*this, lev); pti.isValid(); ++pti)
504 {
505 int gid = pti.index();
506 if (only_valid)
507 {
508 const auto& ptile = ParticlesAt(lev, pti);
509 const int np = ptile.numParticles();
510 auto const ptd = ptile.getConstParticleTileData();
511
512 ReduceOps<ReduceOpSum> reduce_op;
513 ReduceData<int> reduce_data(reduce_op);
514 using ReduceTuple = typename decltype(reduce_data)::Type;
515
516 reduce_op.eval(np, reduce_data,
517 [=] AMREX_GPU_DEVICE (int i) -> ReduceTuple
518 {
519 return (ptd.id(i).is_valid()) ? 1 : 0;
520 });
521
522 int np_valid = amrex::get<0>(reduce_data.value(reduce_op));
523 np_per_grid_local[gid] += np_valid;
524 } else
525 {
526 np_per_grid_local[gid] += pti.numParticles();
527 }
528 }
530 Vector<Long> nparticles(np_per_grid_local.size(), 0);
531 if (only_local)
532 {
533 for (ParConstIterType pti(*this, lev); pti.isValid(); ++pti)
534 {
535 nparticles[pti.index()] = np_per_grid_local[pti.index()];
536 }
537 }
538 else
539 {
540 ParallelDescriptor::GatherLayoutDataToVector(np_per_grid_local, nparticles,
542 ParallelDescriptor::Bcast(nparticles.data(), nparticles.size(),
544 }
546 return nparticles;
547}
548
549template <typename ParticleType, int NArrayReal, int NArrayInt,
550 template<class> class Allocator, class CellAssignor>
552{
553 Long nparticles = 0;
554
555 if (level < 0 || level >= int(m_particles.size())) { return nparticles; }
556
557 if (only_valid) {
559 ReduceData<unsigned long long> reduce_data(reduce_op);
560 using ReduceTuple = typename decltype(reduce_data)::Type;
561
562 for (const auto& kv : GetParticles(level)) {
563 const auto& ptile = kv.second;
564 auto const ptd = ptile.getConstParticleTileData();
565
566 reduce_op.eval(ptile.numParticles(), reduce_data,
567 [=] AMREX_GPU_DEVICE (int i) -> ReduceTuple
568 {
569 return (ptd.id(i).is_valid()) ? 1 : 0;
570 });
571 }
573 nparticles = static_cast<Long>(amrex::get<0>(reduce_data.value(reduce_op)));
575 else {
576 for (const auto& kv : GetParticles(level)) {
577 const auto& ptile = kv.second;
578 nparticles += ptile.numParticles();
579 }
580 }
581
582 if (!only_local) {
584 }
585
586 return nparticles;
587}
589template <typename ParticleType, int NArrayReal, int NArrayInt,
590 template<class> class Allocator, class CellAssignor>
591template <typename I, std::enable_if_t<std::is_integral_v<I> && (sizeof(I) >= sizeof(Long)), int> FOO>
592void
594{
595 AMREX_ASSERT(lev >= 0 && lev < int(m_particles.size()));
597 AMREX_ASSERT(BoxArray::SameRefs(mem.boxArray(), ParticleBoxArray(lev)) &&
598 mem.DistributionMap() == ParticleDistributionMap(lev));
599
600 [[maybe_unused]] Gpu::NoSyncRegion no_sync{};
601 for (ParConstIterType pti(*this, lev); pti.isValid(); ++pti)
602 {
603 int gid = pti.index();
604 mem[gid] += static_cast<I>(pti.capacity());
605 }
607
608//
609// This includes both valid and invalid particles since invalid particles still take up space.
610//
611
612template <typename ParticleType, int NArrayReal, int NArrayInt,
613 template<class> class Allocator, class CellAssignor>
614std::array<Long, 3>
617{
618 Long cnt = 0;
619
620 for (unsigned lev = 0; lev < m_particles.size(); lev++) {
621 const auto& pmap = m_particles[lev];
622 for (const auto& kv : pmap) {
623 const auto& ptile = kv.second;
624 cnt += ptile.numParticles();
625 }
626 }
628 Long mn = cnt, mx = mn;
629
630 const int IOProc = ParallelContext::IOProcessorNumberSub();
631 const Long sz = sizeof(ParticleType)+NumRealComps()*sizeof(ParticleReal)+NumIntComps()*sizeof(int);
632
633#ifdef AMREX_LAZY
634 Lazy::QueueReduction( [=] () mutable {
635#endif
639
640 amrex::Print() << "ParticleContainer spread across MPI nodes - bytes (num particles): [Min: "
641 << mn*sz
642 << " (" << mn << ")"
643 << ", Max: "
644 << mx*sz
645 << " (" << mx << ")"
646 << ", Total: "
647 << cnt*sz
648 << " (" << cnt << ")]\n";
649#ifdef AMREX_LAZY
650 });
651#endif
652
653 return {mn*sz, mx*sz, cnt*sz};
654}
656template <typename ParticleType, int NArrayReal, int NArrayInt,
657 template<class> class Allocator, class CellAssignor>
658std::array<Long, 3>
661{
662 Long cnt = 0;
663
664 for (unsigned lev = 0; lev < m_particles.size(); lev++) {
665 const auto& pmap = m_particles[lev];
666 for (const auto& kv : pmap) {
667 const auto& ptile = kv.second;
668 cnt += ptile.capacity();
669 }
670 }
671
672 Long mn = cnt, mx = mn;
673
675
676#ifdef AMREX_LAZY
677 Lazy::QueueReduction( [=] () mutable {
678#endif
682
683 amrex::Print() << "ParticleContainer spread across MPI nodes - bytes: [Min: "
684 << mn
685 << ", Max: "
686 << mx
687 << ", Total: "
688 << cnt
689 << "]\n";
690#ifdef AMREX_LAZY
691 });
692#endif
694 return {mn, mx, cnt};
695}
696
697template <typename ParticleType, int NArrayReal, int NArrayInt,
698 template<class> class Allocator, class CellAssignor>
699void
701{
702 for (unsigned lev = 0; lev < m_particles.size(); lev++) {
703 auto& pmap = m_particles[lev];
704 for (auto& kv : pmap) {
705 auto& ptile = kv.second;
706 ptile.shrink_to_fit();
707 }
708 }
709}
710
717template <typename ParticleType, int NArrayReal, int NArrayInt,
718 template<class> class Allocator, class CellAssignor>
719void
721{
722 BL_PROFILE("ParticleContainer::Increment");
724 AMREX_ASSERT(OK());
725 if (m_particles.empty()) { return; }
726 AMREX_ASSERT(lev >= 0 && lev < int(m_particles.size()));
727 AMREX_ASSERT(numParticlesOutOfRange(*this, 0) == 0);
728
729 const auto& geom = Geom(lev);
730 const auto plo = geom.ProbLoArray();
731 const auto dxi = geom.InvCellSizeArray();
732 const auto domain = geom.Domain();
733 amrex::ParticleToMesh(*this, mf, lev,
734 [=] AMREX_GPU_DEVICE (const typename ParticleTileType::ConstParticleTileDataType& ptd, int ip,
735 amrex::Array4<amrex::Real> const& count)
736 {
737 const auto p = ptd[ip];
738 CellAssignor assignor;
739 IntVect iv = assignor(p, plo, dxi, domain);
740 amrex::Gpu::Atomic::AddNoRet(&count(iv), 1.0_rt);
741 }, false);
742}
743
744template <typename ParticleType, int NArrayReal, int NArrayInt,
745 template<class> class Allocator, class CellAssignor>
746Long
748{
749 BL_PROFILE("ParticleContainer::IncrementWithTotal(lev)");
750 Increment(mf, lev);
751 return TotalNumberOfParticles(true, local);
752}
753
754template <typename ParticleType, int NArrayReal, int NArrayInt,
755 template<class> class Allocator, class CellAssignor>
756void
758{
759 BL_PROFILE("ParticleContainer::RemoveParticlesAtLevel()");
760 if (level >= int(this->m_particles.size())) { return; }
761
762 if (!this->m_particles[level].empty())
763 {
764 ParticleLevel().swap(this->m_particles[level]);
765 }
766}
767
768template <typename ParticleType, int NArrayReal, int NArrayInt,
769 template<class> class Allocator, class CellAssignor>
770void
772{
773 BL_PROFILE("ParticleContainer::RemoveParticlesNotAtFinestLevel()");
774 AMREX_ASSERT(this->finestLevel()+1 == int(this->m_particles.size()));
775
776 Long cnt = 0;
777
778 for (unsigned lev = 0; lev < m_particles.size() - 1; ++lev) {
779 auto& pmap = m_particles[lev];
780 if (!pmap.empty()) {
781 for (auto& kv : pmap) {
782 const auto& pbx = kv.second;
783 cnt += pbx.numParticles();
784 }
785 ParticleLevel().swap(pmap);
786 }
787 }
788
789 //
790 // Print how many particles removed on each processor if any were removed.
791 //
792 if (this->m_verbose > 1 && cnt > 0) {
793 amrex::AllPrint() << "Processor " << ParallelContext::MyProcSub() << " removed " << cnt
794 << " particles not in finest level\n";
795 }
796}
797
799{
800
804
806 const GpuArray<Real, AMREX_SPACEDIM> & dxi, const Box& domain)
807 : m_assign_buffer_grid(assign_buffer_grid), m_plo(plo), m_dxi(dxi), m_domain(domain)
808 {}
809
810 template <typename SrcData>
812 int operator() (const SrcData& src, int src_i) const noexcept
813 {
814 auto iv = getParticleCell(src, src_i, m_plo, m_dxi, m_domain);
815 return (m_assign_buffer_grid(iv).first != -1);
816 }
817};
818
820{
821 template <typename DstData, typename SrcData>
823 void operator() (DstData& dst, const SrcData& src,
824 int src_i, int dst_i) const noexcept
825 {
826 copyParticle(dst, src, src_i, dst_i);
827
829 dst.cpu(dst_i) = 0;
830 }
831};
832
833
834template <typename ParticleType, int NArrayReal, int NArrayInt,
835 template<class> class Allocator, class CellAssignor>
836void
837ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
838::CreateVirtualParticles (int level, AoS& virts) const
839{
840 ParticleTileType ptile;
841 CreateVirtualParticles(level, ptile);
842 ptile.GetArrayOfStructs().swap(virts);
843}
844
845template <typename ParticleType, int NArrayReal, int NArrayInt,
846 template<class> class Allocator, class CellAssignor>
847void
850{
851 BL_PROFILE("ParticleContainer::CreateVirtualParticles()");
852 AMREX_ASSERT(level > 0);
853 AMREX_ASSERT(virts.empty());
854
855 if (level >= static_cast<int>(m_particles.size())) {
856 return;
857 }
858
859 std::string const& aggregation_type = AggregationType();
860 int aggregation_buffer = AggregationBuffer();
861
862 if (aggregation_type == "None")
863 {
864 auto virts_offset = virts.numParticles();
865 for(ParConstIterType pti(*this, level); pti.isValid(); ++pti)
866 {
867 const auto& src_tile = ParticlesAt(level, pti);
868
869 auto np = src_tile.numParticles();
870 virts.resize(virts_offset+np);
871 transformParticles(virts, src_tile, 0, virts_offset, np, TransformerVirt());
872 virts_offset += np;
873 }
874 }
875 if (aggregation_type == "Cell")
876 {
877 //Components would be based on
878 int nComp = AMREX_SPACEDIM + NStructReal + NArrayReal;
879 // NArrayReal, NStructInt, NArrayInt behavior as before
880 int nGhost = 0;
881 MultiFab mf(ParticleBoxArray(level), ParticleDistributionMap(level), nComp, nGhost);
882
883 nComp = 1 + NStructInt + NArrayInt;
884 iMultiFab imf(ParticleBoxArray(level), ParticleDistributionMap(level), nComp, nGhost);
885
886 const auto& geom = Geom(level);
887 const auto plo = geom.ProbLoArray();
888 const auto dxi = geom.InvCellSizeArray();
889 const auto domain = geom.Domain();
890
891 BoxList bl_buffer;
892 bl_buffer.complementIn(Geom(level).Domain(), ParticleBoxArray(level));
893 BoxArray buffer(std::move(bl_buffer));
894 buffer.grow(aggregation_buffer);
895
897 locator.build(buffer, geom, do_tiling, tile_size);
898 AssignGrid<DenseBinIteratorFactory<Box>> assign_buffer_grid = locator.getGridAssignor();
899
900 amrex::ParticleToMesh(*this, mf, level,
901 [=] AMREX_GPU_DEVICE (const ParticleType& p,
902 amrex::Array4<amrex::Real> const& partData,
905 {
906 auto iv = getParticleCell(p, plo_loc, dxi_loc, domain);
907 if(assign_buffer_grid(iv).first == -1)
908 {
909 //Ordering may make this not unique
910 for (int i = 0; i < NArrayReal; ++i)
911 {
912 amrex::Gpu::Atomic::AddNoRet(&partData(iv,AMREX_SPACEDIM+NStructReal+i), partData(iv,AMREX_SPACEDIM)!=0.0 ? static_cast<Real>(0) : static_cast<Real>(p.rdata(NStructReal+i)));
913 }
914 //Add the rdata(0)-weighted sum of position
915 for (int i = 0; i < AMREX_SPACEDIM; ++i)
916 {
917 amrex::Gpu::Atomic::AddNoRet(&partData(iv,i), static_cast<Real>((p.rdata(0)*p.pos(i))));
918 }
919 //Add the rdata(0)-weighted sum of other rdata fields
920 for (int i = 1; i < NStructReal; ++i)
921 {
922 amrex::Gpu::Atomic::AddNoRet(&partData(iv,AMREX_SPACEDIM+i), static_cast<Real>((p.rdata(0)*p.rdata(i))));
923 }
924 //Add the rdata(0) sum
925 for (int i = 0; i < 1; ++i)
926 {
927 amrex::Gpu::Atomic::AddNoRet(&partData(iv,AMREX_SPACEDIM+i), static_cast<Real>(p.rdata(0)));
928 }
929 }
930
931 }); //skipping extra false argument, doing mf.setVal(0) at beginning
932
933 amrex::ParticleToMesh(*this, imf, level,
934 [=] AMREX_GPU_DEVICE (const ParticleType& p,
935 amrex::Array4<int> const& partData,
938 {
939
940 auto iv = getParticleCell(p, plo_loc, dxi_loc, domain);
941 if(assign_buffer_grid(iv).first == -1)
942 {
943 //if this cell has no particle id info, do a straight copy to store idata
944 if(partData(iv,0)==0)
945 {
946 //Add 1 to indicate at least 1 particle at cell iv
947 amrex::Gpu::Atomic::AddNoRet(&partData(iv,0), 1);
948 for (int i = 0; i < NStructInt; ++i)
949 {
950 amrex::Gpu::Atomic::AddNoRet(&partData(iv,1+i), p.idata(i));
951 }
952 for (int i = 0; i < NArrayInt; ++i)
953 {
954 amrex::Gpu::Atomic::AddNoRet(&partData(iv,1+NStructInt+i), p.idata(NStructInt+i));
955 }
956 }
957 }
958 });
959
960 //There may be a better way to ensure virts is the right length
961 virts.resize(imf.sum(0));
962
963 int last_offset = 0;
964 for (MFIter mfi(mf); mfi.isValid(); ++mfi)
965 {
966 const auto bx = mfi.tilebox();
967 const auto partData = mf.array(mfi);
968 const auto imf_arr = imf.array(mfi);
969
970 Gpu::DeviceVector<int> offsets(bx.numPts());
971 auto *offsets_ptr = offsets.dataPtr();
972 int next_offset = Scan::ExclusiveSum((int) bx.numPts(),(imf_arr.ptr(bx.smallEnd(),0)),(offsets.dataPtr()),Scan::retSum);
973 auto dst = virts.getParticleTileData();
974 ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
975 {
976 if(imf_arr(i,j,k,0)!=0)
977 {
978 const auto idx = last_offset + offsets_ptr[
979 imf_arr.get_offset(IntVectND<3>{i,j,k})
980 ];
981
982 dst.cpu(idx) = 0;
984
985 auto& p = dst[idx];
986 //Set rdata(0) first so we can normalize the weighted fields
987 //Note that this does not work for soa PC
988 p.rdata(0) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM));;
989 //Set pos with the normalized weighted field
990 for (int n = 0; n < AMREX_SPACEDIM; ++n)
991 {
992 p.pos(n) = static_cast<ParticleReal>(partData(i,j,k,n) / p.rdata(0));
993 }
994 //Set rdata(n>0) with the normalized weighted field for NStructReal
995 for (int n = 1; n < NStructReal; ++n)
996 {
997 p.rdata(n) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM+n) / p.rdata(0));
998 }
999 //Set rdata(n>0) with the normalized weighted field for NArrayReal
1000 for (int n = 0; n < NArrayReal; ++n)
1001 {
1002 dst.rdata(n)[idx] = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM+NStructReal+n));
1003 }
1004 //Set idata with the "first" particles idata field for NStructInt
1005 for (int n = 0; n < NStructInt; ++n)
1006 {
1007 p.idata(n) = imf_arr(i,j,k,1+n);
1008 }
1009 //Set idata with the "first" particles idata field for NArrayInt
1010 for (int n = 0; n < NArrayInt; ++n)
1011 {
1012 dst.idata(n)[idx] = imf_arr(i,j,k,1+NStructInt+n);
1013 }
1014 }
1015
1016 });
1017 last_offset+=next_offset;
1019 }
1020
1021 // last_offset should equal virts.numParticles()
1022 auto virts_offset = last_offset;
1023 for(ParConstIterType pti(*this, level); pti.isValid(); ++pti)
1024 {
1025 const auto& src_tile = ParticlesAt(level, pti);
1026
1027 auto np = src_tile.numParticles();
1028 virts.resize(virts_offset+np);
1029 virts_offset += filterAndTransformParticles(virts, src_tile, FilterVirt(assign_buffer_grid,plo,dxi,domain), TransformerVirt(),0,virts_offset);
1031 }
1032 virts.resize(virts_offset);
1034 }
1035}
1036
1038{
1039
1042
1048 : m_lev_min(level), m_lev_max(level+1), m_nGrow(nGrow), m_gid(gid), m_assign_grid(assign_grid)
1049 {}
1050
1051 template <typename SrcData>
1053 int operator() (const SrcData& src, int src_i) const noexcept
1054 {
1055 const auto tup_min = (m_assign_grid)(src[src_i], m_lev_min, m_lev_max, m_nGrow, DefaultAssignor{});
1056 const auto tup_max = (m_assign_grid)(src[src_i], m_lev_max, m_lev_max, m_nGrow, DefaultAssignor{});
1057 const auto p_boxes = amrex::get<0>(tup_min);
1058 const auto p_boxes_max = amrex::get<0>(tup_max);
1059 const auto p_levs_max = amrex::get<2>(tup_max);
1060 return p_boxes_max >=0 && p_boxes == m_gid && p_levs_max == m_lev_max;
1061 }
1062};
1063
1065{
1066
1067 template <typename DstData, typename SrcData>
1069 void operator() (DstData& dst, const SrcData& src,
1070 int src_i, int dst_i) const noexcept
1071 {
1072 copyParticle(dst, src, src_i, dst_i);
1073
1074 dst.id(dst_i) = LongParticleIds::GhostParticleID;
1075 dst.cpu(dst_i) = 0;
1076 }
1077};
1078
1079template <typename ParticleType, int NArrayReal, int NArrayInt,
1080 template<class> class Allocator, class CellAssignor>
1081void
1082ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
1083::CreateGhostParticles (int level, int nGrow, AoS& ghosts) const
1084{
1085 ParticleTileType ptile;
1086 CreateGhostParticles(level, nGrow, ptile);
1087 ptile.GetArrayOfStructs().swap(ghosts);
1088}
1089
1090template <typename ParticleType, int NArrayReal, int NArrayInt,
1091 template<class> class Allocator, class CellAssignor>
1092void
1094::CreateGhostParticles (int level, int nGrow, ParticleTileType& ghosts) const
1095{
1096 BL_PROFILE("ParticleContainer::CreateGhostParticles()");
1097 AMREX_ASSERT(ghosts.empty());
1098 AMREX_ASSERT(level < finestLevel());
1099
1100 if (level >= static_cast<int>(m_particles.size())) {
1101 return;
1102 }
1103
1104 if (! m_particle_locator.isValid(GetParGDB(), do_tiling, tile_size)) {
1105 m_particle_locator.build(GetParGDB(), do_tiling, tile_size);
1106 }
1107
1108 m_particle_locator.setGeometry(GetParGDB());
1109 AmrAssignGrid<DenseBinIteratorFactory<Box>> assign_grid = m_particle_locator.getGridAssignor();
1110 auto ghost_offset = ghosts.numParticles();
1111 for(ParConstIterType pti(*this, level); pti.isValid(); ++pti)
1112 {
1113 const auto& src_tile = ParticlesAt(level, pti);
1114 int gid = pti.index();
1115
1116 auto np = src_tile.numParticles();
1117 ghosts.resize(ghost_offset+np);
1118 ghost_offset += filterAndTransformParticles(ghosts, src_tile, AssignGridFilter(assign_grid,gid,level,nGrow), TransformerGhost(),0,ghost_offset);
1119 }
1120 ghosts.resize(ghost_offset);
1122}
1123
1124template <typename ParticleType, int NArrayReal, int NArrayInt,
1125 template<class> class Allocator, class CellAssignor>
1126void
1129{
1130 BL_PROFILE("ParticleContainer::clearParticles()");
1131
1132 for (int lev = 0; lev < static_cast<int>(m_particles.size()); ++lev)
1133 {
1134 for (auto& kv : m_particles[lev]) { kv.second.resize(0); }
1135 particle_detail::clearEmptyEntries(m_particles[lev]);
1136 }
1137}
1138
1139template <typename ParticleType, int NArrayReal, int NArrayInt,
1140 template<class> class Allocator, class CellAssignor>
1141template <class PCType, std::enable_if_t<IsParticleContainer<PCType>::value, int> foo>
1142void
1144copyParticles (const PCType& other, bool local)
1145{
1146 using PData = typename ParticleTileType::ConstParticleTileDataType;
1147 copyParticles(other, [] AMREX_GPU_HOST_DEVICE (const PData& /*data*/, int /*i*/) { return 1; }, local);
1148}
1149
1150template <typename ParticleType, int NArrayReal, int NArrayInt,
1151 template<class> class Allocator, class CellAssignor>
1152template <class PCType, std::enable_if_t<IsParticleContainer<PCType>::value, int> foo>
1153void
1155addParticles (const PCType& other, bool local)
1156{
1157 using PData = typename ParticleTileType::ConstParticleTileDataType;
1158 addParticles(other, [] AMREX_GPU_HOST_DEVICE (const PData& /*data*/, int /*i*/) { return 1; }, local);
1159}
1160
1161template <typename ParticleType, int NArrayReal, int NArrayInt,
1162 template<class> class Allocator, class CellAssignor>
1163template <class F, class PCType,
1164 std::enable_if_t<IsParticleContainer<PCType>::value, int> foo,
1165 std::enable_if_t<! std::is_integral_v<F>, int> bar>
1166void
1168copyParticles (const PCType& other, F&& f, bool local)
1169{
1170 BL_PROFILE("ParticleContainer::copyParticles");
1171 clearParticles();
1172 addParticles(other, std::forward<F>(f), local);
1173}
1174
1175template <typename ParticleType, int NArrayReal, int NArrayInt,
1176 template<class> class Allocator, class CellAssignor>
1177template <class F, class PCType,
1178 std::enable_if_t<IsParticleContainer<PCType>::value, int> foo,
1179 std::enable_if_t<! std::is_integral_v<F>, int> bar>
1180void
1182addParticles (const PCType& other, F const& f, bool local)
1183{
1184 BL_PROFILE("ParticleContainer::addParticles");
1185
1186 // touch all tiles in serial
1187 for (int lev = 0; lev < other.numLevels(); ++lev)
1188 {
1189 [[maybe_unused]] Gpu::NoSyncRegion no_sync{};
1190 const auto& plevel_other = other.GetParticles(lev);
1191 for(MFIter mfi = other.MakeMFIter(lev); mfi.isValid(); ++mfi)
1192 {
1193 auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
1194 if(!plevel_other.contains(index)) { continue; }
1195
1196 DefineAndReturnParticleTile(lev, mfi.index(), mfi.LocalTileIndex());
1197 }
1198 }
1199
1200#ifdef AMREX_USE_OMP
1201#pragma omp parallel if (Gpu::notInLaunchRegion())
1202#endif
1203 for (int lev = 0; lev < other.numLevels(); ++lev)
1204 {
1205 const auto& plevel_other = other.GetParticles(lev);
1206 for(MFIter mfi = other.MakeMFIter(lev); mfi.isValid(); ++mfi)
1207 {
1208 auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
1209 if(!plevel_other.contains(index)) { continue; }
1210
1211 // this has already had define() called above
1212 auto& ptile = ParticlesAt(lev, mfi.index(), mfi.LocalTileIndex());
1213 const auto& ptile_other = plevel_other.at(index);
1214 auto np = ptile_other.numParticles();
1215 if (np == 0) { continue; }
1216
1217 auto dst_index = ptile.numParticles();
1218 ptile.resize(dst_index + np);
1219
1220 auto count = amrex::filterParticles(ptile, ptile_other, f,
1221 static_cast<decltype(np)>(0), dst_index, np);
1222
1223 ptile.resize(dst_index + count);
1224 }
1225 }
1226
1227 if (! local) { Redistribute(); }
1228}
1229
1230//
1231// This redistributes valid particles and discards invalid ones.
1232//
1233template <typename ParticleType, int NArrayReal, int NArrayInt,
1234 template<class> class Allocator, class CellAssignor>
1235void
1237::Redistribute (int lev_min, int lev_max, int nGrow, int local, bool remove_negative)
1238{
1239 BL_PROFILE_SYNC_START_TIMED("SyncBeforeComms: Redist");
1240
1242 !is_rtsoa_pc || NumRuntimeRealComps() >= AMREX_SPACEDIM,
1243 "ParticleContainer with RTSoA requires at least AMREX_SPACEDIM "
1244 "runtime real components for positions"
1245 );
1246
1247 Redistribute_impl(lev_min, lev_max, nGrow, local, remove_negative);
1248
1251
1252template <typename ParticleType, int NArrayReal, int NArrayInt,
1253 template<class> class Allocator, class CellAssignor>
1254template <class index_type>
1255void
1257::ReorderParticles (int lev, const MFIter& mfi, const index_type* permutations)
1258{
1259 auto& ptile = ParticlesAt(lev, mfi);
1260 const size_t np = ptile.numParticles();
1261 const size_t np_total = np + ptile.numNeighborParticles();
1262
1263 if (memEfficientSort) {
1264 amrex::ReorderParticles(ptile, permutations);
1265 } else {
1266 ParticleTileType ptile_tmp;
1267 ptile_tmp.define(m_num_runtime_real, m_num_runtime_int,
1268 &m_soa_rdata_names, &m_soa_idata_names, arena());
1269 ptile_tmp.resize(np_total);
1270 // copy re-ordered particles
1271 gatherParticles(ptile_tmp, ptile, np, permutations);
1272 // copy neighbor particles
1273 amrex::copyParticles(ptile_tmp, ptile, np, np, np_total-np);
1274 ptile.swap(ptile_tmp);
1275 }
1276}
1277
1278template <typename ParticleType, int NArrayReal, int NArrayInt,
1279 template<class> class Allocator, class CellAssignor>
1280void
1285
1286template <typename ParticleType, int NArrayReal, int NArrayInt,
1287 template<class> class Allocator, class CellAssignor>
1288void
1291{
1292 BL_PROFILE("ParticleContainer::SortParticlesByBin()");
1293
1294 if (bin_size == IntVect::TheZeroVector()) { return; }
1295
1296 for (int lev = 0; lev < numLevels(); ++lev)
1297 {
1298 const Geometry& geom = Geom(lev);
1299 const auto dxi = geom.InvCellSizeArray();
1300 const auto plo = geom.ProbLoArray();
1301 const auto domain = geom.Domain();
1302
1303 for(MFIter mfi = MakeMFIter(lev); mfi.isValid(); ++mfi)
1304 {
1305 auto& ptile = ParticlesAt(lev, mfi);
1306 const size_t np = ptile.numParticles();
1307
1308 const Box& box = mfi.validbox();
1309
1310 int ntiles = numTilesInBox(box, true, bin_size);
1311
1312 m_bins.build(np, ptile.getParticleTileData(), ntiles,
1313 GetParticleBin{plo, dxi, domain, bin_size, box});
1314 ReorderParticles(lev, mfi, m_bins.permutationPtr());
1315 }
1316 }
1317}
1318
1319template <typename ParticleType, int NArrayReal, int NArrayInt,
1320 template<class> class Allocator, class CellAssignor>
1321void
1324{
1325 BL_PROFILE("ParticleContainer::SortParticlesForDeposition()");
1326
1327 for (int lev = 0; lev < numLevels(); ++lev)
1328 {
1329 const Geometry& geom = Geom(lev);
1330
1331 for(MFIter mfi = MakeMFIter(lev); mfi.isValid(); ++mfi)
1332 {
1333 const auto& ptile = ParticlesAt(lev, mfi);
1334 const size_t np = ptile.numParticles();
1335
1336 const Box& box = mfi.validbox();
1337
1338 using index_type = typename decltype(m_bins)::index_type;
1340 PermutationForDeposition<index_type>(perm, np, ptile, box, geom, idx_type);
1341 ReorderParticles(lev, mfi, perm.dataPtr());
1342 }
1343 }
1344}
1345
1346template <typename ParticleType, int NArrayReal, int NArrayInt,
1347 template<class> class Allocator, class CellAssignor>
1349int
1351::hostPartitionTile (ParticleTileType& src_tile,
1352 int lev, int gid, int tid,
1353 int lev_min, int lev_max, int nGrow, int local,
1354 bool remove_negative, int myproc,
1356 Gpu::DeviceVector<int>& levels,
1358 Gpu::DeviceVector<int>& src_indices,
1359 Gpu::DeviceVector<IntVect>& periodic_shift)
1360{
1361 ParticleLocData pld;
1362 auto ptd = src_tile.getParticleTileData();
1363 int num_move = 0;
1364
1365 Long last = src_tile.numParticles() - 1;
1366 Long pindex = 0;
1367 int who = -1;
1368 while (pindex <= last) {
1369 decltype(auto) p = ptd[pindex];
1371 // remove invalid if needed
1372 if (!ptd.id(pindex).is_valid()) {
1373 if (remove_negative) {
1374 copyParticle(ptd, ptd, last, pindex);
1375 correctCellVectors(last, pindex, gid, p);
1376 --last;
1377 } else {
1378 ++pindex;
1379 }
1380 continue;
1381 }
1382
1383 // Fast path: if on the finest level, try the last good location first
1384 // If not on finest level, we need to do the full locate because even if
1385 // the last assignment works, the particle might belong on a finer level.
1386 if (lev == lev_max && pld.m_tile == tid && pld.m_grid == gid && pld.m_lev == lev && who == myproc) {
1387 const auto iv = Index(p, lev);
1388 if (pld.m_tilebox.contains(iv)) {
1389 ++pindex;
1390 continue; // don't need correctCellVectors or particlePostLocate if it stays where it is
1391 }
1392 }
1393
1394 // full locate
1395 locateParticle(p, pld, lev_min, lev_max, nGrow, local ? gid : -1);
1396 particlePostLocate(p, pld, lev);
1397
1398 // particle may have been invalidated, so check if we need to remove again.
1399 if (!ptd.id(pindex).is_valid()) {
1400 copyParticle(ptd, ptd, last, pindex);
1401 correctCellVectors(last, pindex, gid, p);
1402 --last;
1403 continue;
1404 }
1405
1406 // flag particle for move if needed
1407 who = BufferMap().procID(pld.m_grid, pld.m_tile, pld.m_lev);
1408 if (pld.m_lev != lev || pld.m_grid != gid || pld.m_tile != tid || who != myproc) {
1409 // the particle is valid but needs to be sent somewhere else
1410 swapParticle(ptd, ptd, last, pindex);
1411 correctCellVectors(last, pindex, gid, p);
1412 boxes[num_move] = pld.m_grid;
1413 levels[num_move] = pld.m_lev;
1414 tiles[num_move] = pld.m_tile;
1415 src_indices[num_move] = static_cast<int>(last);
1416 ++num_move;
1417 --last;
1418 continue;
1419 }
1420
1421 ++pindex; // if here, particle stays
1422 }
1423
1424 boxes.resize(num_move);
1425 levels.resize(num_move);
1426 tiles.resize(num_move);
1427 src_indices.resize(num_move);
1428 periodic_shift.resize(num_move);
1429
1430 return static_cast<int>(pindex);
1431}
1432
1433//
1434// Shared implementation of Redistribute
1435//
1436template <typename ParticleType, int NArrayReal, int NArrayInt,
1437 template<class> class Allocator, class CellAssignor>
1438void
1439ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
1440::Redistribute_impl (int lev_min, int lev_max, int nGrow, int local, bool remove_negative)
1441{
1442 if (local) { AMREX_ASSERT(numParticlesOutOfRange(*this, lev_min, lev_max, local) == 0); }
1443
1444 BL_PROFILE("ParticleContainer::Redistribute_impl()");
1445 BL_PROFILE_VAR_NS("Redistribute_partition", blp_partition);
1446
1447 int theEffectiveFinestLevel = m_gdb->finestLevel();
1448 while (!m_gdb->LevelDefined(theEffectiveFinestLevel)) { theEffectiveFinestLevel--; }
1449
1450 if (int(m_particles.size()) < theEffectiveFinestLevel+1) {
1451 if (Verbose()) {
1452 amrex::Print() << "ParticleContainer::Redistribute() resizing containers from "
1453 << m_particles.size() << " to "
1454 << theEffectiveFinestLevel + 1 << '\n';
1455 }
1456 m_particles.resize(theEffectiveFinestLevel+1);
1457 m_dummy_mf.resize(theEffectiveFinestLevel+1);
1459
1460 for (int lev = 0; lev < theEffectiveFinestLevel+1; ++lev) { RedefineDummyMF(lev); }
1461
1462 int finest_lev_particles;
1463 if (lev_max == -1) {
1464 lev_max = theEffectiveFinestLevel;
1465 finest_lev_particles = m_particles.size() - 1;
1466 } else {
1467 finest_lev_particles = lev_max;
1468 }
1469 AMREX_ASSERT(lev_max <= finestLevel());
1470
1471 this->defineBufferMap();
1472
1473#ifndef AMREX_USE_GPU
1474 if (local > 0) { BuildRedistributeMask(0, local); }
1475#else
1476 if (! m_particle_locator.isValid(GetParGDB(), do_tiling, tile_size)) { m_particle_locator.build(GetParGDB(), do_tiling, tile_size); }
1477 m_particle_locator.setGeometry(GetParGDB());
1478#endif
1479
1480 BL_PROFILE_VAR_START(blp_partition);
1481 ParticleCopyOp op;
1482 int num_levels = finest_lev_particles + 1;
1483 op.setNumLevels(num_levels);
1484 Vector<std::map<std::pair<int, int>, int> > new_sizes(num_levels);
1485#ifndef AMREX_USE_GPU
1486 const int myproc = ParallelContext::MyProcSub();
1487#endif
1488#ifdef AMREX_USE_GPU
1489 auto assign_grid = m_particle_locator.getGridAssignor();
1490 const auto plo = Geom(0).ProbLoArray();
1491 const auto phi = Geom(0).ProbHiArray();
1492 const auto rlo = Geom(0).ProbLoArrayInParticleReal();
1493 const auto rhi = Geom(0).ProbHiArrayInParticleReal();
1494 const auto is_per = Geom(0).isPeriodicArray();
1495#endif
1496
1497#if defined(AMREX_USE_OMP) || defined(AMREX_USE_GPU)
1498 Vector<std::pair<int, int> > grid_tile_ids;
1499 Vector<ParticleTileType*> ptile_ptrs;
1500 Vector<int> plevs;
1501 Vector<int*> new_size_ptrs;
1502#ifndef AMREX_USE_GPU
1504 Vector<Gpu::DeviceVector<int>*> level_ptrs;
1506 Vector<Gpu::DeviceVector<int>*> src_index_ptrs;
1507 Vector<Gpu::DeviceVector<IntVect>*> periodic_shift_ptrs;
1508#endif
1509 std::size_t num_tiles = 0;
1510 for (int lev = lev_min; lev <= finest_lev_particles; ++lev) {
1511 for (auto const& kv : m_particles[lev]) {
1512 if (kv.second.numParticles() != 0) {
1513 ++num_tiles;
1514 }
1515 }
1516 }
1517 grid_tile_ids.reserve(num_tiles);
1518 ptile_ptrs.reserve(num_tiles);
1519 plevs.reserve(num_tiles);
1520 new_size_ptrs.reserve(num_tiles);
1521#ifndef AMREX_USE_GPU
1522 box_ptrs.reserve(num_tiles);
1523 level_ptrs.reserve(num_tiles);
1524 tile_ptrs.reserve(num_tiles);
1525 src_index_ptrs.reserve(num_tiles);
1526 periodic_shift_ptrs.reserve(num_tiles);
1527#endif
1528 for (int lev = lev_min; lev <= finest_lev_particles; lev++) {
1529 auto& pmap = m_particles[lev];
1530 for (auto& kv : pmap)
1531 {
1532 const auto np = kv.second.numParticles();
1533 if (np == 0) { continue; }
1534
1535 grid_tile_ids.push_back(kv.first);
1536 ptile_ptrs.push_back(&(kv.second));
1537 plevs.push_back(lev);
1538 auto index = std::make_pair(kv.first.first, kv.first.second);
1539 auto& new_size = new_sizes[lev][index];
1540 new_size = 0;
1541 new_size_ptrs.push_back(&new_size);
1542#ifndef AMREX_USE_GPU
1543 op.resize(kv.first.first, kv.first.second, lev, static_cast<int>(np));
1544 auto& boxes = op.m_boxes[lev][index];
1545 auto& levels = op.m_levels[lev][index];
1546 auto& tiles = op.m_tiles[lev][index];
1547 auto& src_indices = op.m_src_indices[lev][index];
1548 auto& periodic_shift = op.m_periodic_shift[lev][index];
1549 box_ptrs.push_back(&boxes);
1550 level_ptrs.push_back(&levels);
1551 tile_ptrs.push_back(&tiles);
1552 src_index_ptrs.push_back(&src_indices);
1553 periodic_shift_ptrs.push_back(&periodic_shift);
1554#endif
1555 }
1556 }
1557#endif
1558
1559#if defined(AMREX_USE_OMP) || defined(AMREX_USE_GPU)
1560#ifdef AMREX_USE_OMP
1561#pragma omp parallel for
1562#endif
1563 for (int pmap_it = 0; pmap_it < static_cast<int>(ptile_ptrs.size()); ++pmap_it)
1564 {
1565 int lev = plevs[pmap_it];
1566 int gid = grid_tile_ids[pmap_it].first;
1567 int tid = grid_tile_ids[pmap_it].second;
1568 auto& src_tile = *ptile_ptrs[pmap_it];
1569 const size_t np = src_tile.numParticles();
1570 if (np == 0) {continue;}
1571
1572#ifndef AMREX_USE_GPU
1573 auto& boxes = *box_ptrs[pmap_it];
1574 auto& levels = *level_ptrs[pmap_it];
1575 auto& tiles = *tile_ptrs[pmap_it];
1576 auto& src_indices = *src_index_ptrs[pmap_it];
1577 auto& periodic_shift = *periodic_shift_ptrs[pmap_it];
1578 *new_size_ptrs[pmap_it] = hostPartitionTile(src_tile,
1579 lev, gid, tid,
1580 lev_min, lev_max, nGrow, local,
1581 remove_negative, myproc,
1582 boxes, levels, tiles,
1583 src_indices, periodic_shift);
1584#else // GPU algorithm
1585 int num_stay = partitionParticlesByDest(src_tile, assign_grid,
1586 std::forward<CellAssignor>(CellAssignor{}),
1587 BufferMap(),
1588 plo, phi, rlo, rhi, is_per, lev, gid, tid,
1589 lev_min, lev_max, nGrow, remove_negative);
1590
1591 int num_move = np - num_stay;
1592 *new_size_ptrs[pmap_it] = num_stay;
1593 op.resize(gid, tid, lev, num_move);
1594
1595 auto index = std::make_pair(gid, tid);
1596 auto* p_boxes = op.m_boxes[lev][index].dataPtr();
1597 auto* p_levs = op.m_levels[lev][index].dataPtr();
1598 auto* p_tiles = op.m_tiles[lev][index].dataPtr();
1599 auto* p_src_indices = op.m_src_indices[lev][index].dataPtr();
1600 auto* p_periodic_shift = op.m_periodic_shift[lev][index].dataPtr();
1601 auto ptd = src_tile.getParticleTileData();
1602
1603 amrex::ParallelFor(num_move, [=] AMREX_GPU_DEVICE (int i)
1604 {
1605 const auto p = ptd[i + num_stay];
1606
1607 if (!p.id().is_valid())
1608 {
1609 p_boxes[i] = -1;
1610 p_tiles[i] = -1;
1611 p_levs[i] = -1;
1612 }
1613 else
1614 {
1615 const auto tup = assign_grid(p, lev_min, lev_max, nGrow,
1616 std::forward<CellAssignor>(CellAssignor{}));
1617 p_boxes[i] = amrex::get<0>(tup);
1618 p_tiles[i] = amrex::get<1>(tup);
1619 p_levs[i] = amrex::get<2>(tup);
1620 }
1621 p_periodic_shift[i] = IntVect(AMREX_D_DECL(0,0,0));
1622 p_src_indices[i] = i+num_stay;
1623 });
1624#endif
1625 }
1626#else
1627 for (int lev = lev_min; lev <= finest_lev_particles; ++lev) {
1628 auto& pmap = m_particles[lev];
1629 for (auto& kv : pmap)
1630 {
1631 auto& src_tile = kv.second;
1632 const auto np = src_tile.numParticles();
1633 if (np == 0) { continue; }
1634
1635 int gid = kv.first.first;
1636 int tid = kv.first.second;
1637 auto index = std::make_pair(gid, tid);
1638 auto& new_size = new_sizes[lev][index];
1639 new_size = 0;
1640
1641 op.resize(gid, tid, lev, static_cast<int>(np));
1642 auto& boxes = op.m_boxes[lev][index];
1643 auto& levels = op.m_levels[lev][index];
1644 auto& tiles = op.m_tiles[lev][index];
1645 auto& src_indices = op.m_src_indices[lev][index];
1646 auto& periodic_shift = op.m_periodic_shift[lev][index];
1647 new_size = hostPartitionTile(src_tile,
1648 lev, gid, tid,
1649 lev_min, lev_max, nGrow, local,
1650 remove_negative, myproc,
1651 boxes, levels, tiles,
1652 src_indices, periodic_shift);
1653 }
1654 }
1655#endif
1656 BL_PROFILE_VAR_STOP(blp_partition);
1657
1658 ParticleCopyPlan plan;
1659
1660 plan.build(*this, op, h_redistribute_int_comp,
1661 h_redistribute_real_comp, local);
1662
1663 // by default, this uses The_Arena();
1666
1667 if (use_comms_arena) {
1668 snd_buffer.setArena(The_Comms_Arena());
1669 rcv_buffer.setArena(The_Comms_Arena());
1670 }
1671
1672 packBuffer(*this, op, plan, snd_buffer);
1673
1674 // clear particles from container
1675 for (int lev = lev_min; lev <= lev_max; ++lev)
1676 {
1677 auto& plev = m_particles[lev];
1678 for (auto& kv : plev)
1679 {
1680 int gid = kv.first.first;
1681 int tid = kv.first.second;
1682 auto index = std::make_pair(gid, tid);
1683 auto& tile = plev[index];
1684 tile.resize(new_sizes[lev][index]);
1685 }
1686 }
1687
1688 for (int lev = lev_min; lev <= lev_max; lev++)
1689 {
1690 particle_detail::clearEmptyEntries(m_particles[lev]);
1691 }
1692
1693 if (int(m_particles.size()) > theEffectiveFinestLevel+1) {
1694 if (m_verbose > 0) {
1695 amrex::Print() << "ParticleContainer::Redistribute() resizing m_particles from "
1696 << m_particles.size() << " to " << theEffectiveFinestLevel+1 << '\n';
1697 }
1698 AMREX_ASSERT(int(m_particles.size()) >= 2);
1699
1700 m_particles.resize(theEffectiveFinestLevel + 1);
1701 m_dummy_mf.resize(theEffectiveFinestLevel + 1);
1702 }
1703
1705 {
1706 plan.buildMPIFinish(BufferMap());
1707 communicateParticlesStart(*this, plan, snd_buffer, rcv_buffer);
1708 this->ReserveForRedistribute(plan);
1709 unpackBuffer(*this, plan, snd_buffer, RedistributeUnpackPolicy());
1711 unpackRemotes(*this, plan, rcv_buffer, RedistributeUnpackPolicy());
1712 }
1713 else
1714 {
1716 Gpu::PinnedVector<char> pinned_snd_buffer;
1717 Gpu::PinnedVector<char> pinned_rcv_buffer;
1718
1719 if (snd_buffer.arena()->isPinned()) {
1720 plan.buildMPIFinish(BufferMap());
1722 communicateParticlesStart(*this, plan, snd_buffer, pinned_rcv_buffer);
1723 } else {
1724 pinned_snd_buffer.resize(snd_buffer.size());
1725 Gpu::dtoh_memcpy_async(pinned_snd_buffer.dataPtr(), snd_buffer.dataPtr(), snd_buffer.size());
1726 plan.buildMPIFinish(BufferMap());
1728 communicateParticlesStart(*this, plan, pinned_snd_buffer, pinned_rcv_buffer);
1729 }
1730
1731 this->ReserveForRedistribute(plan);
1732
1733 rcv_buffer.resize(pinned_rcv_buffer.size());
1734 unpackBuffer(*this, plan, snd_buffer, RedistributeUnpackPolicy());
1736 Gpu::htod_memcpy_async(rcv_buffer.dataPtr(), pinned_rcv_buffer.dataPtr(), pinned_rcv_buffer.size());
1737 unpackRemotes(*this, plan, rcv_buffer, RedistributeUnpackPolicy());
1738 }
1739
1741 AMREX_ASSERT(numParticlesOutOfRange(*this, lev_min, lev_max, nGrow) == 0);
1742}
1743
1744template <typename ParticleType, int NArrayReal, int NArrayInt,
1745 template<class> class Allocator, class CellAssignor>
1746void
1747ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>
1748::ReserveForRedistribute (ParticleCopyPlan const& plan)
1749{
1750 BL_PROFILE("ParticleContainer::ReserveForRedistribute()");
1751
1752 std::map<ParticleTileType*, int> addsizes;
1753
1754 for (int lev = 0; lev < this->BufferMap().numLevels(); ++lev) {
1755 for (MFIter mfi = this->MakeMFIter(lev); mfi.isValid(); ++mfi) {
1756 int gid = mfi.index();
1757 int tid = mfi.LocalTileIndex();
1758 auto& tile = this->DefineAndReturnParticleTile(lev, gid, tid);
1759 int num_copies = plan.m_box_counts_h[this->BufferMap().gridAndTileAndLevToBucket(gid, tid, lev)];
1760 if (num_copies > 0) {
1761 addsizes[&tile] += num_copies;
1762 }
1763 }
1764 }
1765
1766 if (plan.m_nrcvs > 0) {
1767 for (int i = 0, N = int(plan.m_rcv_box_counts.size()); i < N; ++i) {
1768 int copy_size = plan.m_rcv_box_counts[i];
1769 int lev = plan.m_rcv_box_levs[i];
1770 int gid = plan.m_rcv_box_ids[i];
1771 int tid = plan.m_rcv_box_tids[i];
1772 auto& tile = this->DefineAndReturnParticleTile(lev, gid, tid);
1773 addsizes[&tile] += copy_size;
1774 }
1775 }
1776
1777 ParticleTileType::reserve(addsizes);
1778}
1779
1780template <typename ParticleType, int NArrayReal, int NArrayInt,
1781 template<class> class Allocator, class CellAssignor>
1782bool
1784{
1785 BL_PROFILE("ParticleContainer::OK()");
1786
1787 if (lev_max == -1) {
1788 lev_max = finestLevel();
1789 }
1790
1791 return (m_dummy_mf.size() >= lev_max+1 && numParticlesOutOfRange(*this, lev_min, lev_max, nGrow) == 0);
1792}
1793
1794template <typename ParticleType, int NArrayReal, int NArrayInt,
1795 template<class> class Allocator, class CellAssignor>
1796void
1798::AddParticlesAtLevel (AoS& particles, int level, int nGrow)
1799{
1800 ParticleTileType ptile;
1801 ptile.GetArrayOfStructs().swap(particles);
1802 AddParticlesAtLevel(ptile, level, nGrow);
1803}
1804
1805template <typename ParticleType, int NArrayReal, int NArrayInt,
1806 template<class> class Allocator, class CellAssignor>
1807void
1809::AddParticlesAtLevel (ParticleTileType& particles, int level, int nGrow)
1810{
1811 BL_PROFILE("ParticleContainer::AddParticlesAtLevel()");
1812
1813 if (int(m_particles.size()) < level+1)
1814 {
1815 if (Verbose())
1816 {
1817 amrex::Print() << "ParticleContainer::AddParticlesAtLevel resizing m_particles from "
1818 << m_particles.size()
1819 << " to "
1820 << level+1 << '\n';
1821 }
1822 m_particles.resize(level+1);
1823 m_dummy_mf.resize(level+1);
1824 for (int lev = 0; lev < level+1; ++lev) {
1825 RedefineDummyMF(lev);
1826 }
1827 }
1828
1829 auto& ptile = DefineAndReturnParticleTile(level, 0, 0);
1830 int old_np = ptile.size();
1831 int num_to_add = particles.size();
1832 int new_np = old_np + num_to_add;
1833 ptile.resize(new_np);
1834 amrex::copyParticles(ptile, particles, 0, old_np, num_to_add);
1835 Redistribute(level, level, nGrow);
1836 particles.resize(0);
1837}
1838
1839// This is the single-level version for cell-centered density
1840template <typename ParticleType, int NArrayReal, int NArrayInt,
1841 template<class> class Allocator, class CellAssignor>
1842void
1844AssignCellDensitySingleLevel (int rho_index,
1845 MultiFab& mf_to_be_filled,
1846 int lev,
1847 int ncomp,
1848 int particle_lvl_offset) const
1849{
1850 BL_PROFILE("ParticleContainer::AssignCellDensitySingleLevel()");
1851
1852 if (rho_index != 0) { amrex::Abort("AssignCellDensitySingleLevel only works if rho_index = 0"); }
1853
1854 MultiFab* mf_pointer;
1855
1856 if (OnSameGrids(lev, mf_to_be_filled)) {
1857 // If we are already working with the internal mf defined on the
1858 // particle_box_array, then we just work with this.
1859 mf_pointer = &mf_to_be_filled;
1860 }
1861 else {
1862 // If mf_to_be_filled is not defined on the particle_box_array, then we need
1863 // to make a temporary here and copy into mf_to_be_filled at the end.
1864 mf_pointer = new MultiFab(ParticleBoxArray(lev),
1865 ParticleDistributionMap(lev),
1866 ncomp, mf_to_be_filled.nGrow());
1867 }
1868
1869 // We must have ghost cells for each FAB so that a particle in one grid can spread
1870 // its effect to an adjacent grid by first putting the value into ghost cells of its
1871 // own grid. The mf->SumBoundary call then adds the value from one grid's ghost cell
1872 // to another grid's valid region.
1873 if (mf_pointer->nGrow() < 1) {
1874 amrex::Error("Must have at least one ghost cell when in AssignCellDensitySingleLevel");
1875 }
1876
1877 const auto strttime = amrex::second();
1878
1879 const auto dxi = Geom(lev).InvCellSizeArray();
1880 const auto plo = Geom(lev).ProbLoArray();
1881 const auto pdxi = Geom(lev + particle_lvl_offset).InvCellSizeArray();
1882
1883 if (Geom(lev).isAnyPeriodic() && ! Geom(lev).isAllPeriodic())
1884 {
1885 amrex::Error("AssignCellDensitySingleLevel: problem must be periodic in no or all directions");
1886 }
1887
1888 mf_pointer->setVal(0);
1889
1891#ifdef AMREX_USE_OMP
1892#pragma omp parallel if (Gpu::notInLaunchRegion())
1893#endif
1894 {
1895 FArrayBox local_rho;
1896 for (ParConstIter pti(*this, lev); pti.isValid(); ++pti) {
1897 const Long np = pti.numParticles();
1898 auto ptd = pti.GetParticleTile().getConstParticleTileData();
1899 FArrayBox& fab = (*mf_pointer)[pti];
1900 auto rhoarr = fab.array();
1901#ifdef AMREX_USE_OMP
1902 Box tile_box;
1903 if (Gpu::notInLaunchRegion())
1904 {
1905 tile_box = pti.tilebox();
1906 tile_box.grow(mf_pointer->nGrow());
1907 local_rho.resize(tile_box,ncomp);
1908 local_rho.setVal<RunOn::Host>(0.0);
1909 rhoarr = local_rho.array();
1910 }
1911#endif
1912
1913 if (particle_lvl_offset == 0)
1914 {
1916 {
1917 auto p = ptd[i];
1918 amrex_deposit_cic(p, ncomp, rhoarr, plo, dxi);
1919 });
1920 }
1921 else
1922 {
1924 {
1925 auto p = ptd[i];
1926 amrex_deposit_particle_dx_cic(p, ncomp, rhoarr, plo, dxi, pdxi);
1927 });
1928 }
1929
1930#ifdef AMREX_USE_OMP
1931 if (Gpu::notInLaunchRegion())
1932 {
1933 fab.atomicAdd<RunOn::Host>(local_rho, tile_box, tile_box, 0, 0, ncomp);
1934 }
1935#endif
1936 }
1937 }
1938
1939 mf_pointer->SumBoundary(Geom(lev).periodicity());
1940
1941 // If ncomp > 1, first divide the momenta (component n)
1942 // by the mass (component 0) in order to get velocities.
1943 // Be careful not to divide by zero.
1944 for (int n = 1; n < ncomp; n++)
1945 {
1946 for (MFIter mfi(*mf_pointer); mfi.isValid(); ++mfi)
1947 {
1948 (*mf_pointer)[mfi].protected_divide<RunOn::Device>((*mf_pointer)[mfi],0,n,1);
1949 }
1950 }
1951
1952 // Only multiply the first component by (1/vol) because this converts mass
1953 // to density. If there are additional components (like velocity), we don't
1954 // want to divide those by volume.
1955 const Real* dx = Geom(lev).CellSize();
1956 const Real vol = AMREX_D_TERM(dx[0], *dx[1], *dx[2]);
1957
1958 mf_pointer->mult(Real(1.0)/vol, 0, 1, mf_pointer->nGrow());
1959
1960 // If mf_to_be_filled is not defined on the particle_box_array, then we need
1961 // to copy here from mf_pointer into mf_to_be_filled.
1962 if (mf_pointer != &mf_to_be_filled)
1963 {
1964 mf_to_be_filled.ParallelCopy(*mf_pointer,0,0,ncomp,0,0);
1965 delete mf_pointer;
1966 }
1967
1968 if (m_verbose > 1)
1969 {
1970 auto stoptime = amrex::second() - strttime;
1971
1972 ParallelReduce::Max(stoptime, ParallelContext::IOProcessorNumberSub(),
1973 ParallelContext::CommunicatorSub());
1974
1975 amrex::Print() << "ParticleContainer::AssignCellDensitySingleLevel) time: "
1976 << stoptime << '\n';
1977 }
1978}
1979
1980template <typename ParticleType, int NArrayReal, int NArrayInt,
1981 template<class> class Allocator, class CellAssignor>
1982void
1984ResizeRuntimeRealComp (int new_size, bool communicate)
1985{
1986 int old_size = m_num_runtime_real;
1987
1988 m_runtime_comps_defined = (new_size > 0);
1989 m_num_runtime_real = new_size;
1990 int cur_size = h_redistribute_real_comp.size();
1991 h_redistribute_real_comp.resize(cur_size-old_size+new_size, communicate);
1992 SetParticleSize();
1993
1994 for (int lev = 0; lev < numLevels(); ++lev) {
1995 for (ParIterType pti(*this,lev); pti.isValid(); ++pti) {
1996 auto& tile = DefineAndReturnParticleTile(lev, pti);
1997 auto np = tile.numParticles();
1998 if (np > 0 && new_size > old_size) {
1999 auto& soa = tile.GetStructOfArrays();
2000 soa.resize(np);
2001 }
2002 }
2003 }
2004}
2005
2006template <typename ParticleType, int NArrayReal, int NArrayInt,
2007 template<class> class Allocator, class CellAssignor>
2008void
2010ResizeRuntimeIntComp (int new_size, bool communicate)
2011{
2012 int old_size = m_num_runtime_int;
2013
2014 m_runtime_comps_defined = (new_size > 0);
2015 m_num_runtime_int = new_size;
2016 int cur_size = h_redistribute_int_comp.size();
2017 h_redistribute_int_comp.resize(cur_size-old_size+new_size, communicate);
2018 SetParticleSize();
2019
2020 for (int lev = 0; lev < numLevels(); ++lev) {
2021 for (ParIterType pti(*this,lev); pti.isValid(); ++pti) {
2022 auto& tile = DefineAndReturnParticleTile(lev, pti);
2023 auto np = tile.numParticles();
2024 if (np > 0 && new_size > old_size) {
2025 auto& soa = tile.GetStructOfArrays();
2026 soa.resize(np);
2027 }
2028 }
2029 }
2030}
2031
2032}
#define BL_PROFILE_VAR_START(vname)
Definition AMReX_BLProfiler.H:562
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#define BL_PROFILE_VAR_STOP(vname)
Definition AMReX_BLProfiler.H:563
#define BL_PROFILE_SYNC_STOP()
Definition AMReX_BLProfiler.H:645
#define BL_PROFILE_SYNC_START_TIMED(fname)
Definition AMReX_BLProfiler.H:644
#define BL_PROFILE_VAR_NS(fname, vname)
Definition AMReX_BLProfiler.H:561
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_HOST_DEVICE_FOR_1D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:105
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
amrex::ParmParse pp
Input file parser instance for the given namespace.
Definition AMReX_HypreIJIface.cpp:15
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Print on all processors of the default communicator.
Definition AMReX_Print.H:113
BaseFab< T > & atomicAdd(const BaseFab< T > &x) noexcept
Atomic FAB addition (a[i] <- a[i] + b[i]).
Definition AMReX_BaseFab.H:2482
Array4< T const > array() const noexcept
Definition AMReX_BaseFab.H:382
void setVal(T const &x, const Box &bx, int dcomp, int ncomp) noexcept
The setVal functions set sub-regions in the BaseFab to a constant value. This most general form speci...
Definition AMReX_BaseFab.H:1400
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:568
IndexType ixType() const noexcept
Return index type of this BoxArray.
Definition AMReX_BoxArray.H:858
BoxArray & grow(int n)
Grow each Box in the BoxArray by the specified amount.
Definition AMReX_BoxArray.cpp:706
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return intersections of Box and BoxArray.
Definition AMReX_BoxArray.cpp:1186
Box getCellCenteredBox(int index) const noexcept
Return cell-centered box at element index of this BoxArray.
Definition AMReX_BoxArray.H:748
static bool SameRefs(const BoxArray &lhs, const BoxArray &rhs)
whether two BoxArrays share the same data
Definition AMReX_BoxArray.H:841
A class for managing a List of Boxes that share a common IndexType. This class implements operations ...
Definition AMReX_BoxList.H:52
BoxList & complementIn(const Box &b, const BoxList &bl)
Definition AMReX_BoxList.cpp:307
__host__ __device__ BoxND & grow(int i) noexcept
Definition AMReX_Box.H:641
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:212
GpuArray< Real, 3 > InvCellSizeArray() const noexcept
Definition AMReX_CoordSys.H:87
A Fortran Array of REALs.
Definition AMReX_FArrayBox.H:231
void resize(const Box &b, int N=1, Arena *ar=nullptr)
For debugging purposes we hide BaseFab version and do some extra work.
Definition AMReX_FArrayBox.cpp:178
int size() const noexcept
Return the number of FABs in the FabArray.
Definition AMReX_FabArrayBase.H:110
int nGrow(int direction=0) const noexcept
Return the grow factor that defines the region of definition.
Definition AMReX_FabArrayBase.H:78
const DistributionMapping & DistributionMap() const noexcept
Return constant reference to associated DistributionMapping.
Definition AMReX_FabArrayBase.H:131
const BoxArray & boxArray() const noexcept
Return a constant reference to the BoxArray that defines the valid region associated with this FabArr...
Definition AMReX_FabArrayBase.H:95
void ParallelCopy(const FabArray< FAB > &src, const Periodicity &period=Periodicity::NonPeriodic(), CpOp op=FabArrayBase::COPY)
Definition AMReX_FabArray.H:854
Array4< typename FabArray< FAB >::value_type const > array(const MFIter &mfi) const noexcept
Definition AMReX_FabArray.H:568
void setVal(value_type val)
Set all components in the entire region of each FAB to val.
Definition AMReX_FabArray.H:2665
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:74
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:211
GpuArray< Real, 3 > ProbLoArray() const noexcept
Definition AMReX_Geometry.H:187
static void streamSynchronize() noexcept
Definition AMReX_GpuDevice.cpp:855
__host__ __device__ bool cellCentered() const noexcept
True if the IndexTypeND is CELL based in all directions.
Definition AMReX_IndexType.H:104
__host__ static __device__ constexpr IntVectND< dim > TheZeroVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:771
a one-thingy-per-box distributed object
Definition AMReX_LayoutData.H:13
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
int LocalTileIndex() const noexcept
The current local tile index in the current grid;.
Definition AMReX_MFIter.H:181
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:172
Box validbox() const noexcept
Return the valid Box in which the current tile resides.
Definition AMReX_MFIter.H:163
int index() const noexcept
The index into the underlying BoxArray of the current FAB.
Definition AMReX_MFIter.H:175
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
void mult(Real val, int comp, int num_comp, int nghost=0)
Scales the value of each cell in the specified subregion of the MultiFab by the scalar val (a[i] <- a...
Definition AMReX_MultiFab.cpp:1417
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
size_type size() const noexcept
Definition AMReX_PODVector.H:648
void resize(size_type a_new_size, GrowthStrategy strategy=GrowthStrategy::Poisson)
Definition AMReX_PODVector.H:728
T * dataPtr() noexcept
Definition AMReX_PODVector.H:670
Definition AMReX_ParIter.H:147
Definition AMReX_ParIter.H:118
int queryAdd(std::string_view name, T &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1045
int queryarr(std::string_view name, std::vector< int > &ref, int start_ix=FIRST, int num_val=ALL) const
Same as queryktharr() but searches for last occurrence of name.
Definition AMReX_ParmParse.cpp:2032
int query(std::string_view name, bool &ref, int ival=FIRST) const
Same as querykth() but searches for the last occurrence of name.
Definition AMReX_ParmParse.cpp:1946
virtual void reserveData()
Definition AMReX_ParticleContainerBase.cpp:41
virtual void resizeData()
Definition AMReX_ParticleContainerBase.cpp:46
A distributed container for Particles sorted onto the levels, grids, and tiles of a block-structured ...
Definition AMReX_ParticleContainer.H:149
void addParticles(const PCType &other, bool local=false)
Add particles from other to this ParticleContainer. local controls whether or not to call Redistribut...
Definition AMReX_ParticleContainerI.H:1155
IntVect Index(const P &p, int lev) const
Definition AMReX_ParticleContainerI.H:201
std::map< std::pair< int, int >, ParticleTileType > ParticleLevel
Definition AMReX_ParticleContainer.H:196
void SetSoACompileTimeNames(std::vector< std::string > const &rdata_name, std::vector< std::string > const &idata_name)
Definition AMReX_ParticleContainerI.H:109
typename ParticleTileType::AoS AoS
Definition AMReX_ParticleContainer.H:199
void SetParticleSize()
Definition AMReX_ParticleContainerI.H:16
void RemoveParticlesAtLevel(int level)
The Following methods are for managing Virtual and Ghost Particles.
Definition AMReX_ParticleContainerI.H:757
void clearParticles()
Clear all the particles in this container. This does not free memory.
Definition AMReX_ParticleContainerI.H:1128
void Increment(MultiFab &mf, int level)
Definition AMReX_ParticleContainerI.H:720
bool HasIntComp(std::string const &name)
Definition AMReX_ParticleContainerI.H:148
void ShrinkToFit()
Definition AMReX_ParticleContainerI.H:700
bool HasRealComp(std::string const &name)
Definition AMReX_ParticleContainerI.H:140
void resizeData() override
This resizes the vector of dummy MultiFabs used by the ParticleContainer for the current number of le...
Definition AMReX_ParticleContainerI.H:435
Long IncrementWithTotal(MultiFab &mf, int level, bool local=false)
Definition AMReX_ParticleContainerI.H:747
Long NumberOfParticlesAtLevel(int level, bool only_valid=true, bool only_local=false) const
Returns # of particles at specified the level.
Definition AMReX_ParticleContainerI.H:551
void SortParticlesByCell()
Sort the particles on each tile by cell, using Fortran ordering.
Definition AMReX_ParticleContainerI.H:1281
int GetRealCompIndex(std::string const &name)
Definition AMReX_ParticleContainerI.H:161
int GetIntCompIndex(std::string const &name)
Definition AMReX_ParticleContainerI.H:183
void RemoveParticlesNotAtFinestLevel()
Definition AMReX_ParticleContainerI.H:771
Vector< Long > NumberOfParticlesInGrid(int level, bool only_valid=true, bool only_local=false) const
Definition AMReX_ParticleContainerI.H:496
void copyParticles(const PCType &other, bool local=false)
Copy particles from other to this ParticleContainer. Will clear all the particles from this container...
Definition AMReX_ParticleContainerI.H:1144
ParticleLocData Reset(ParticleType &prt, bool update, bool verbose=true, ParticleLocData pld=ParticleLocData()) const
Updates a particle's location (Where), tries to periodic shift any particles that have left the domai...
Definition AMReX_ParticleContainerI.H:392
void CapacityOfParticlesInGrid(LayoutData< I > &mem, int lev) const
Return capacity of memory for particles at specific grid.
Definition AMReX_ParticleContainerI.H:593
std::conditional_t< is_rtsoa_pc, ParticleTileRT< typename ParticleType::RealType, typename ParticleType::IntType >, ParticleTile< ParticleType, NArrayReal, NArrayInt, Allocator > > ParticleTileType
Definition AMReX_ParticleContainer.H:191
Long TotalNumberOfParticles(bool only_valid=true, bool only_local=false) const
Returns # of particles at all levels.
Definition AMReX_ParticleContainerI.H:481
void reserveData() override
This reserves data in the vector of dummy MultiFabs used by the ParticleContainer for the maximum num...
Definition AMReX_ParticleContainerI.H:426
T_ParticleType ParticleType
Definition AMReX_ParticleContainer.H:151
Definition AMReX_ParticleLocator.H:123
void build(const BoxArray &ba, const Geometry &geom, bool a_do_tiling=false, const IntVect &a_tile_size=IntVect(1024000, 1024000, 1024000))
Definition AMReX_ParticleLocator.H:130
AssignGrid< BinIteratorFactory > getGridAssignor() const noexcept
Definition AMReX_ParticleLocator.H:206
This class provides the user with a few print options.
Definition AMReX_Print.H:35
Definition AMReX_Reduce.H:453
Definition AMReX_Reduce.H:612
std::enable_if_t< IsFabArray< MF >::value > eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition AMReX_Reduce.H:746
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
Long size() const noexcept
Definition AMReX_Vector.H:53
A Collection of IArrayBoxes.
Definition AMReX_iMultiFab.H:34
Long sum(int comp, int nghost=0, bool local=false) const
Returns the sum in component comp.
Definition AMReX_iMultiFab.cpp:454
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_particle_real ParticleReal
Floating Point Type for Particles.
Definition AMReX_REAL.H:90
amrex_long Long
Definition AMReX_INT.H:30
T ExclusiveSum(N n, T const *in, T *out, RetSum a_ret_sum=retSum)
Exclusive sum.
Definition AMReX_Scan.H:1291
void SumBoundary(const Periodicity &period=Periodicity::NonPeriodic(), bool deterministic=false)
Sum values in overlapped cells.
Definition AMReX_FabArray.H:3596
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition AMReX_Box.H:1280
Arena * The_Comms_Arena()
Definition AMReX_Arena.cpp:880
void Min(KeyValuePair< K, V > &vi, int root, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:287
void Max(KeyValuePair< K, V > &vi, int root, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:254
void Sum(T &v, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:221
void Sum(T &v, int root, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:352
__host__ __device__ AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
Definition AMReX_GpuAtomic.H:283
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:310
void dtoh_memcpy_async(void *p_h, const void *p_d, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:435
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:421
void QueueReduction(Func f)
Definition AMReX_Lazy.cpp:7
constexpr Long GhostParticleID
Definition AMReX_Particle.H:19
constexpr Long VirtualParticleID
Definition AMReX_Particle.H:20
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
int MyProcSub() noexcept
my sub-rank in current frame
Definition AMReX_ParallelContext.H:76
int IOProcessorNumberSub() noexcept
IO sub-rank in current frame.
Definition AMReX_ParallelContext.H:78
bool UseGpuAwareMpi()
Definition AMReX_ParallelDescriptor.H:113
void Bcast(void *, int, MPI_Datatype, int, MPI_Comm)
Definition AMReX_ParallelDescriptor.cpp:1295
void GatherLayoutDataToVector(const LayoutData< T > &sendbuf, Vector< T > &recvbuf, int root)
Gather LayoutData values to a vector on root.
Definition AMReX_ParallelDescriptor.H:1295
static constexpr RetSum retSum
Definition AMReX_Scan.H:32
Definition AMReX_Amr.cpp:49
int nComp(FabArrayBase const &fa)
Definition AMReX_FabArrayBase.cpp:2851
__host__ __device__ void swapParticle(const ParticleTileData< T_ParticleType, NAR, NAI > &dst, const ParticleTileData< T_ParticleType, NAR, NAI > &src, int src_i, int dst_i) noexcept
A general single particle swapping routine that can run on the GPU.
Definition AMReX_ParticleTransformation.H:120
__host__ __device__ int getTileIndex(const IntVect &iv, const Box &box, const bool a_do_tiling, const IntVect &a_tile_size, Box &tbx)
Definition AMReX_ParticleUtil.H:185
void communicateParticlesStart(const PC &pc, ParticleCopyPlan &plan, const SndBuffer &snd_buffer, RcvBuffer &rcv_buffer)
Definition AMReX_ParticleCommunication.H:908
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:193
__host__ __device__ void copyParticle(const ParticleTileData< T_ParticleType, NAR, NAI > &dst, const ConstParticleTileData< T_ParticleType, NAR, NAI > &src, int src_i, int dst_i) noexcept
A general single particle copying routine that can run on the GPU.
Definition AMReX_ParticleTransformation.H:32
void unpackRemotes(PC &pc, const ParticleCopyPlan &plan, Buffer &rcv_buffer, UnpackPolicy const &policy)
Definition AMReX_ParticleCommunication.H:1008
void copyParticles(DstTile &dst, const SrcTile &src) noexcept
Copy particles from src to dst. This version copies all the particles, writing them to the beginning ...
Definition AMReX_ParticleTransformation.H:222
int partitionParticlesByDest(PTile &ptile, const PLocator &ploc, CellAssignor const &assignor, const ParticleBufferMap &pmap, const GpuArray< Real, 3 > &plo, const GpuArray< Real, 3 > &phi, const GpuArray< ParticleReal, 3 > &rlo, const GpuArray< ParticleReal, 3 > &rhi, const GpuArray< int, 3 > &is_per, int lev, int gid, int tid, int lev_min, int lev_max, int nGrow, bool remove_negative)
Definition AMReX_ParticleUtil.H:648
Index filterAndTransformParticles(DstTile &dst, const SrcTile &src, Index *mask, F const &f, Index src_start, Index dst_start) noexcept
Conditionally copy particles from src to dst based on the value of mask. A transformation will also b...
Definition AMReX_ParticleTransformation.H:519
void ReorderParticles(PTile &ptile, const index_type *permutations)
Reorder particles on the tile ptile using a the permutations array.
Definition AMReX_ParticleUtil.H:947
__host__ __device__ bool enforcePeriodic(P &p, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &phi, amrex::GpuArray< amrex::ParticleReal, 3 > const &rlo, amrex::GpuArray< amrex::ParticleReal, 3 > const &rhi, amrex::GpuArray< int, 3 > const &is_per) noexcept
Definition AMReX_ParticleUtil.H:417
__host__ __device__ int numTilesInBox(const Box &box, const bool a_do_tiling, const IntVect &a_tile_size)
Definition AMReX_ParticleUtil.H:233
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:30
double second() noexcept
Definition AMReX_Utility.cpp:940
void communicateParticlesFinish(const ParticleCopyPlan &plan)
Definition AMReX_ParticleCommunication.cpp:443
Index filterParticles(DstTile &dst, const SrcTile &src, const Index *mask) noexcept
Conditionally copy particles from src to dst based on the value of mask.
Definition AMReX_ParticleTransformation.H:393
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
void ParticleToMesh(PC const &pc, const Vector< MultiFab * > &mf, int lev_min, int lev_max, F &&f, bool zero_out_input=true, bool vol_weight=true)
Deposit particles onto a hierarchy of MultiFabs.
Definition AMReX_AmrParticles.H:188
void Error(const std::string &msg)
Print out message to cerr and exit via amrex::Abort().
Definition AMReX.cpp:234
void gatherParticles(PTile &dst, const PTile &src, N np, const Index *inds)
Gather particles copies particles into contiguous order from an arbitrary order. Specifically,...
Definition AMReX_ParticleTransformation.H:739
int numParticlesOutOfRange(Iterator const &pti, int nGrow)
Returns the number of particles that are more than nGrow cells from the box correspond to the input i...
Definition AMReX_ParticleUtil.H:35
int Verbose() noexcept
Definition AMReX.cpp:179
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:240
const int[]
Definition AMReX_BLProfiler.cpp:1664
void transformParticles(DstTile &dst, const SrcTile &src, F &&f) noexcept
Apply the function f to all the particles in src, writing the result to dst. This version does all th...
Definition AMReX_ParticleTransformation.H:274
void unpackBuffer(PC &pc, const ParticleCopyPlan &plan, const Buffer &snd_buffer, UnpackPolicy const &policy)
Definition AMReX_ParticleCommunication.H:781
void packBuffer(const PC &pc, const ParticleCopyOp &op, const ParticleCopyPlan &plan, Buffer &snd_buffer)
Definition AMReX_ParticleCommunication.H:581
__host__ __device__ IntVect getParticleCell(P const &p, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &dxi) noexcept
Returns the cell index for a given particle using the provided lower bounds and cell sizes.
Definition AMReX_ParticleUtil.H:337
Definition AMReX_ParticleLocator.H:248
A multidimensional array accessor.
Definition AMReX_Array4.H:283
Definition AMReX_ParticleContainerI.H:1038
amrex::AmrAssignGrid< amrex::DenseBinIteratorFactory< amrex::Box > > m_assign_grid
Definition AMReX_ParticleContainerI.H:1041
int m_lev_max
Definition AMReX_ParticleContainerI.H:1040
AssignGridFilter(amrex::AmrAssignGrid< amrex::DenseBinIteratorFactory< amrex::Box > > assign_grid, int gid, int level, int nGrow)
This filters based on matching grids.
Definition AMReX_ParticleContainerI.H:1047
int m_nGrow
Definition AMReX_ParticleContainerI.H:1040
int m_lev_min
Definition AMReX_ParticleContainerI.H:1040
AMREX_GPU_HOST_DEVICE int operator()(const SrcData &src, int src_i) const noexcept
Definition AMReX_ParticleContainerI.H:1053
int m_gid
Definition AMReX_ParticleContainerI.H:1040
Definition AMReX_ParticleLocator.H:17
Definition AMReX_ParticleUtil.H:390
Definition AMReX_DenseBins.H:32
Definition AMReX_ParticleContainerI.H:799
Box m_domain
Definition AMReX_ParticleContainerI.H:803
GpuArray< Real, 3 > m_dxi
Definition AMReX_ParticleContainerI.H:802
FilterVirt(const amrex::AssignGrid< amrex::DenseBinIteratorFactory< amrex::Box > > &assign_buffer_grid, const GpuArray< Real, 3 > &plo, const GpuArray< Real, 3 > &dxi, const Box &domain)
Definition AMReX_ParticleContainerI.H:805
AMREX_GPU_HOST_DEVICE int operator()(const SrcData &src, int src_i) const noexcept
Definition AMReX_ParticleContainerI.H:812
amrex::AssignGrid< amrex::DenseBinIteratorFactory< amrex::Box > > m_assign_buffer_grid
Definition AMReX_ParticleContainerI.H:801
GpuArray< Real, 3 > m_plo
Definition AMReX_ParticleContainerI.H:802
Definition AMReX_ParticleUtil.H:304
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:43
Definition AMReX_GpuControl.H:184
Definition AMReX_ParticleCommunication.H:91
Vector< int > m_rcv_box_ids
Definition AMReX_ParticleCommunication.H:365
Vector< int > m_rcv_box_counts
Definition AMReX_ParticleCommunication.H:363
Vector< int > m_rcv_box_levs
Definition AMReX_ParticleCommunication.H:368
Vector< int > m_rcv_box_tids
Definition AMReX_ParticleCommunication.H:366
int m_nrcvs
Definition AMReX_ParticleCommunication.H:371
Gpu::HostVector< unsigned int > m_box_counts_h
Definition AMReX_ParticleCommunication.H:360
A struct used for storing a particle's position in the AMR hierarchy.
Definition AMReX_ParticleContainer.H:93
Box m_grown_gridbox
Definition AMReX_ParticleContainer.H:100
IntVect m_cell
Definition AMReX_ParticleContainer.H:97
int m_grid
Definition AMReX_ParticleContainer.H:95
int m_tile
Definition AMReX_ParticleContainer.H:96
int m_lev
Definition AMReX_ParticleContainer.H:94
Box m_tilebox
Definition AMReX_ParticleContainer.H:99
Box m_gridbox
Definition AMReX_ParticleContainer.H:98
The struct used to store particles.
Definition AMReX_Particle.H:405
__host__ __device__ RealVect pos() const &
Definition AMReX_Particle.H:456
Definition AMReX_ParticleContainerI.H:1065
AMREX_GPU_HOST_DEVICE void operator()(DstData &dst, const SrcData &src, int src_i, int dst_i) const noexcept
Definition AMReX_ParticleContainerI.H:1069
Definition AMReX_ParticleContainerI.H:820
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(DstData &dst, const SrcData &src, int src_i, int dst_i) const noexcept
Definition AMReX_ParticleContainerI.H:823