1#ifndef AMREX_PARTICLEUTIL_H_
2#define AMREX_PARTICLEUTIL_H_
3#include <AMReX_Config.H>
33template <class Iterator, std::enable_if_t<IsParticleIterator<Iterator>::value,
int> foo = 0>
51template <class Iterator, std::enable_if_t<IsParticleIterator<Iterator>::value,
int> foo = 0>
55 const auto& tile = pti.GetParticleTile();
56 const auto np = tile.numParticles();
57 const auto& ptd = tile.getConstParticleTileData();
58 const auto& geom = pti.Geom(pti.GetLevel());
60 const auto& domain = geom.Domain();
61 const auto& plo = geom.ProbLoArray();
62 const auto& dxi = geom.InvCellSizeArray();
64 Box box = pti.tilebox();
69 using ReduceTuple =
typename decltype(reduce_data)::Type;
71 reduce_op.
eval(np, reduce_data,
75 if (!p.id().is_valid()) {
return false; }
76 using AssignorType =
typename Iterator::CellAssignor;
77 AssignorType assignor;
78 IntVect iv = assignor(p, plo, dxi, domain);
81 int hv = amrex::get<0>(reduce_data.
value(reduce_op));
97template <class PC, std::enable_if_t<IsParticleContainer<PC>::value,
int> foo = 0>
116template <class PC, std::enable_if_t<IsParticleContainer<PC>::value,
int> foo = 0>
137template <class PC, std::enable_if_t<IsParticleContainer<PC>::value,
int> foo = 0>
161template <class PC, std::enable_if_t<IsParticleContainer<PC>::value,
int> foo = 0>
167 using ParIter =
typename PC::ParConstIterType;
169 for (
int lev = lev_min; lev <= lev_max; ++lev)
172#pragma omp parallel if (Gpu::notInLaunchRegion() && !system::regtest_reduction) reduction(+:num_wrong)
188 if (a_do_tiling ==
false) {
195 auto tiling_1d = [](
int i,
int lo,
int hi,
int tilesize,
196 int& ntile,
int& tileidx,
int& tlo,
int& thi) {
197 int ncells = hi-lo+1;
199 int ts_right = ncells/ntile;
200 int ts_left = ts_right+1;
201 int nleft = ncells - ntile*ts_right;
203 int nbndry = nleft*ts_left;
205 tileidx = ii / ts_left;
206 tlo = lo + tileidx * ts_left;
207 thi = tlo + ts_left - 1;
209 tileidx = nleft + (ii-nbndry) / ts_right;
210 tlo = lo + tileidx * ts_right + nleft;
211 thi = tlo + ts_right - 1;
216 IntVect ntiles, ivIndex, tilelo, tilehi;
222 AMREX_D_TERM(tiling_1d(iv0, sml[0], big[0], a_tile_size[0], ntiles[0], ivIndex[0], tilelo[0], tilehi[0]);,
223 tiling_1d(iv1, sml[1], big[1], a_tile_size[1], ntiles[1], ivIndex[1], tilelo[1], tilehi[1]);,
224 tiling_1d(iv2, sml[2], big[2], a_tile_size[2], ntiles[2], ivIndex[2], tilelo[2], tilehi[2]););
226 tbx =
Box(tilelo, tilehi);
228 return AMREX_D_TERM(ivIndex[0], + ntiles[0]*ivIndex[1], + ntiles[0]*ntiles[1]*ivIndex[2]);
235 if (a_do_tiling ==
false) {
241 auto tiling_1d = [](
int lo,
int hi,
int tilesize,
int& ntile) {
242 int ncells = hi-lo+1;
250 AMREX_D_TERM(tiling_1d(sml[0], big[0], a_tile_size[0], ntiles[0]);,
251 tiling_1d(sml[1], big[1], a_tile_size[1], ntiles[1]);,
252 tiling_1d(sml[2], big[2], a_tile_size[2], ntiles[2]););
254 return AMREX_D_TERM(ntiles[0], *=ntiles[1], *=ntiles[2]);
265 int* bin_type_array=
nullptr)
266 : m_off_bins_p(off_bins_p), m_dxi_p(dxi_p), m_plo_p(plo_p) ,
267 m_lo_p(lo_p) , m_hi_p(hi_p) , m_bin_type_array(bin_type_array) {}
269 template <
typename T>
274 int type = (m_bin_type_array) ? m_bin_type_array[i] : 0;
275 int offset = m_off_bins_p[type];
278 AMREX_ASSERT((p.pos(1)-m_plo_p[type][1])*m_dxi_p[type][1] - m_lo_p[type].
y >= 0.0);,
279 AMREX_ASSERT((p.pos(2)-m_plo_p[type][2])*m_dxi_p[type][2] - m_lo_p[type].
z >= 0.0));
281 auto iv =
IntVect(
AMREX_D_DECL(
static_cast<int>(amrex::Math::floor((p.pos(0)-m_plo_p[type][0])*m_dxi_p[type][0])) - m_lo_p[type].
x,
282 static_cast<int>(amrex::Math::floor((p.pos(1)-m_plo_p[type][1])*m_dxi_p[type][1])) - m_lo_p[type].
y,
283 static_cast<int>(amrex::Math::floor((p.pos(2)-m_plo_p[type][2])*m_dxi_p[type][2])) - m_lo_p[type].
z));
284 auto iv3 = iv.dim3();
285 int nx = m_hi_p[type].
x-m_lo_p[type].
x+1;
286 int ny = m_hi_p[type].
y-m_lo_p[type].
y+1;
287 int nz = m_hi_p[type].
z-m_lo_p[type].
z+1;
291 return static_cast<unsigned int>( (uix * ny + uiy) * nz + uiz +
offset );
295 const int* m_off_bins_p;
300 int* m_bin_type_array;
311 template <
typename ParticleType>
313 unsigned int operator() (
const ParticleType& p)
const noexcept
318 return static_cast<unsigned int>(tid);
342 AMREX_D_DECL(
int(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0])),
343 int(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1])),
344 int(amrex::Math::floor((p.pos(2)-plo[2])*dxi[2]))));
367 const Box& domain)
noexcept
370 iv += domain.smallEnd();
374template <
typename PTD>
379 const Box& domain)
noexcept
382 AMREX_D_DECL(
int(amrex::Math::floor((ptd.pos(0, i)-plo[0])*dxi[0])),
383 int(amrex::Math::floor((ptd.pos(1, i)-plo[1])*dxi[1])),
384 int(amrex::Math::floor((ptd.pos(2, i)-plo[2])*dxi[2]))));
385 iv += domain.smallEnd();
392 template <
typename P>
397 const Box& domain)
const noexcept
408 const Box& domain)
noexcept
410 if (!p.id().is_valid()) {
return -1; }
424 bool shifted =
false;
425 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim)
427 if (! is_per[idim]) {
continue; }
428 if (p.pos(idim) > rhi[idim]) {
429 while (p.pos(idim) > rhi[idim]) {
430 p.pos(idim) -=
static_cast<ParticleReal>(phi[idim] - plo[idim]);
433 if (p.pos(idim) < rlo[idim]) {
434 p.pos(idim) = rlo[idim];
438 else if (p.pos(idim) < rlo[idim]) {
439 while (p.pos(idim) < rlo[idim]) {
440 p.pos(idim) +=
static_cast<ParticleReal>(phi[idim] - plo[idim]);
443 if (p.pos(idim) > rhi[idim]) {
444 p.pos(idim) = rhi[idim];
448 AMREX_ASSERT( (p.pos(idim) >= rlo[idim] ) && ( p.pos(idim) <= rhi[idim] ));
466template <
typename PTile,
typename ParFunc>
470 const int np = ptile.numParticles();
471 if (np == 0) {
return 0; }
473 auto ptd = ptile.getParticleTileData();
475 const int num_left = Reduce::Sum<int>(np,
478 return int(is_left(ptd, i));
492 const int max_num_swaps = std::min(num_left, np - num_left);
493 if (max_num_swaps == 0) {
return num_left; }
497 int *
const p_index_left = index_left.
dataPtr();
498 int *
const p_index_right = index_right.
dataPtr();
514 Scan::PrefixSum<int>(np,
517 return int(!is_left(ptd, i));
521 if (!is_left(ptd, i)) {
523 if (dst < max_num_swaps) {
524 p_index_right[dst] = i;
527 int dst = num_left-1-(i-s);
528 if (dst < max_num_swaps) {
529 p_index_left[dst] = i;
556 int left_i = p_index_left[i];
557 int right_i = p_index_right[i];
558 if (right_i < left_i) {
583template <
typename PTile,
typename ParFunc>
587 const int np = ptile.numParticles();
588 if (np == 0) {
return; }
590 auto ptd = ptile.getParticleTileData();
592 const int max_num_swaps = std::min(num_left, np - num_left);
593 if (max_num_swaps == 0) {
return; }
597 int *
const p_index_left = index_left.
dataPtr();
598 int *
const p_index_right = index_right.
dataPtr();
600 Scan::PrefixSum<int>(np,
603 return int(!is_left(ptd, i));
607 if (!is_left(ptd, i)) {
609 if (dst < max_num_swaps) {
610 p_index_right[dst] = i;
613 int dst = num_left-1-(i-s);
614 if (dst < max_num_swaps) {
615 p_index_left[dst] = i;
624 int left_i = p_index_left[i];
625 int right_i = p_index_right[i];
626 if (right_i < left_i) {
635template <
typename PTile>
641 return ptd.id(i).is_valid();
643 ptile.resize(new_size);
646#if defined(AMREX_USE_GPU)
648template <
typename PTile,
typename PLocator,
typename CellAssignor>
657 int lev,
int gid,
int ,
658 int lev_min,
int lev_max,
int nGrow,
bool remove_negative)
664 uint8_t *
const p_particle_stays = particle_stays.
dataPtr();
665 auto ptd = ptile.getParticleTileData();
675 if (!ptd.id(i).is_valid())
682 auto p_prime = ptd.getSuperParticle(i);
683 enforcePeriodic(p_prime, plo, phi, rlo, rhi, is_per);
684 auto tup_prime = ploc(p_prime, lev_min, lev_max, nGrow, assignor);
685 assigned_grid = amrex::get<0>(tup_prime);
686 assigned_lev = amrex::get<1>(tup_prime);
687 if (assigned_grid >= 0)
689 AMREX_D_TERM(ptd.pos(0, i) = p_prime.pos(0);,
690 ptd.pos(1, i) = p_prime.pos(1);,
691 ptd.pos(2, i) = p_prime.pos(2););
693 else if (lev_min > 0)
696 p_prime.pos(1) = ptd.pos(1, i);,
697 p_prime.pos(2) = ptd.pos(2, i););
698 auto tup = ploc(p_prime, lev_min, lev_max, nGrow, assignor);
699 assigned_grid = amrex::get<0>(tup);
700 assigned_lev = amrex::get<1>(tup);
704 p_particle_stays[i] = uint8_t(
705 ((remove_negative ==
false) && (!ptd.id(i).is_valid())) ||
706 ((assigned_grid == gid) && (assigned_lev == lev) && (getPID(lev, gid) == pid)));
711 return p_particle_stays[i];
717template <
class PC1,
class PC2>
719 if (pc1.numLevels() != pc2.numLevels()) {
return false;}
720 if (pc1.do_tiling != pc2.do_tiling) {
return false;}
721 if (pc1.tile_size != pc2.tile_size) {
return false;}
722 for (
int lev = 0; lev < pc1.numLevels(); ++lev) {
723 if (pc1.ParticleBoxArray(lev) != pc2.ParticleBoxArray(lev)) {
return false;}
724 if (pc1.ParticleDistributionMap(lev) != pc2.ParticleDistributionMap(lev)) {
return false;}
731 using Iter =
typename PC::ParIterType;
732 for (
int lev = 0; lev < pc.numLevels(); ++lev) {
733 for (Iter pti(pc, lev); pti.isValid(); ++pti) {
734 pc.DefineAndReturnParticleTile(lev, pti);
739IntVect computeRefFac (
const ParGDBBase* a_gdb,
int src_lev,
int lev);
741Vector<int> computeNeighborProcs (
const ParGDBBase* a_gdb,
int ngrow);
744namespace particle_detail
747void clearEmptyEntries (C& c)
749 for (
auto c_it = c.begin(); c_it != c.end(); )
751 if (c_it->second.empty()) { c.erase(c_it++); }
758template <
class index_type,
typename F>
760 index_type nbins, F
const& f)
764#if defined(AMREX_USE_HIP)
767 static constexpr index_type gpu_block_size = 64;
768 static constexpr bool compressed_layout =
true;
772 static constexpr index_type gpu_block_size = 1024;
773 static constexpr bool compressed_layout =
false;
776 static constexpr index_type gpu_block_size_m1 = gpu_block_size - 1;
777 static constexpr index_type llist_guard = std::numeric_limits<index_type>::max();
780 nbins = (nbins + gpu_block_size_m1) / gpu_block_size * gpu_block_size;
787 index_type* pllist_start = llist_start.
dataPtr();
788 index_type* pllist_next = llist_next.
dataPtr();
789 index_type* pperm = perm.
dataPtr();
790 index_type* pglobal_idx = global_idx.
dataPtr();
795 pllist_next[i] = Gpu::Atomic::Exch(pllist_start + f(i), i);
798#if defined(AMREX_USE_CUDA) || defined(AMREX_USE_HIP)
799 amrex::launch<gpu_block_size>(nbins / gpu_block_size, Gpu::gpuStream(),
801 __shared__ index_type sdata[gpu_block_size];
802 __shared__ index_type global_idx_start;
803 __shared__ index_type idx_start;
805 index_type current_idx = 0;
807 if constexpr (compressed_layout) {
811 current_idx = pllist_start[threadIdx.x + gpu_block_size * blockIdx.x];
813 index_type num_particles_thread = 0;
814 while (current_idx != llist_guard) {
815 ++num_particles_thread;
816 current_idx = pllist_next[current_idx];
819 index_type num_particles_block =
820 Gpu::blockReduceSum<gpu_block_size>(num_particles_thread);
822 if (threadIdx.x == 0) {
823 global_idx_start = Gpu::Atomic::Add(pglobal_idx, num_particles_block);
827 current_idx = pllist_start[threadIdx.x + gpu_block_size * blockIdx.x];
830 sdata[threadIdx.x] = index_type(current_idx != llist_guard);
834 for (index_type i = 1; i<gpu_block_size; i*=2) {
836 if (threadIdx.x >= i) {
837 x = sdata[threadIdx.x - i];
840 if (threadIdx.x >= i) {
841 sdata[threadIdx.x] +=
x;
845 if (sdata[gpu_block_size_m1] == 0) {
848 if (threadIdx.x == gpu_block_size_m1) {
849 if constexpr (compressed_layout) {
850 idx_start = global_idx_start;
851 global_idx_start += sdata[gpu_block_size_m1];
853 idx_start = Gpu::Atomic::Add(pglobal_idx, sdata[gpu_block_size_m1]);
857 sdata[threadIdx.x] += idx_start;
858 if (current_idx != llist_guard) {
859 pperm[sdata[threadIdx.x] - 1] = current_idx;
860 current_idx = pllist_next[current_idx];
866 Abort(
"PermutationForDeposition only implemented for CUDA and HIP");
869 Gpu::Device::streamSynchronize();
872template <
class index_type,
class PTile>
879 const IntVect type_vect = idx_type - idx_type / 2 * 2;
892 const int ref_product =
AMREX_D_TERM(refine_vect[0], * refine_vect[1], * refine_vect[2]);
893 const IntVect ref_offset(
AMREX_D_DECL(1, refine_vect[0], refine_vect[0] * refine_vect[1]));
895 auto ptd = ptile.getConstParticleTileData();
896 PermutationForDeposition<index_type>(perm, nitems, bx.
numPts() * ref_product,
899 const auto p = ptd[idx];
901 IntVect iv = ((p.pos() - pos_offset) * dxi).round();
903 IntVect iv_coarse = iv / refine_vect;
904 IntVect iv_remainder = iv - iv_coarse * refine_vect;
908 return bx.
index(iv_coarse) + bx.
numPts() * (iv_remainder * ref_offset).sum();
914 int first_r_name = 0;
915 if constexpr (P::is_soa_particle) {
916 if (i < AMREX_SPACEDIM) {
917 constexpr int x_in_ascii = 120;
918 std::string
const name{char(x_in_ascii+i)};
921 first_r_name = AMREX_SPACEDIM;
923 std::string
const name{(
"real_comp" + std::to_string(i-first_r_name))};
929 std::string
const name{(
"int_comp" + std::to_string(i))};
943template <
class PTile,
class index_type,
944 std::enable_if_t<!PTile::ParticleType::is_rtsoa_particle, int> foo = 0>
948 const size_t np = ptile.numParticles();
949 const size_t np_total = np + ptile.numNeighborParticles();
951#if defined(AMREX_USE_CUDA) && defined(_WIN32)
952 if (!PTile::ParticleType::is_soa_particle)
954 if constexpr (!PTile::ParticleType::is_soa_particle)
957 static_assert(
sizeof(
typename PTile::ParticleType)%4 == 0 &&
sizeof(uint32_t) == 4);
958 using tmp_t = std::conditional_t<
sizeof(
typename PTile::ParticleType)%8 == 0,
960 constexpr std::size_t nchunks =
sizeof(
typename PTile::ParticleType) /
sizeof(tmp_t);
962 auto* ptmp = tmp.
data();
963 auto* paos = (tmp_t*)(ptile.getParticleTileData().m_aos);
964 for (std::size_t ichunk = 0; ichunk < nchunks; ++ichunk) {
968 ptmp[i] = paos[permutations[i]*nchunks+ichunk];
972 paos[i*nchunks+ichunk] = ptmp[i];
975 Gpu::streamSynchronize();
977 typename PTile::SoA::IdCPU tmp_idcpu;
978 if constexpr (PTile::has_polymorphic_allocator) {
979 tmp_idcpu.setArena(ptile.GetStructOfArrays().GetIdCPUData().arena());
981 tmp_idcpu.resize(np_total);
982 auto src = ptile.GetStructOfArrays().GetIdCPUData().data();
983 uint64_t* dst = tmp_idcpu.data();
986 dst[i] = i < np ? src[permutations[i]] : src[i];
989 Gpu::streamSynchronize();
991 ptile.GetStructOfArrays().GetIdCPUData().swap(tmp_idcpu);
995 typename PTile::RealVector tmp_real;
996 if (ptile.NumRealComps() > 0) {
997 if constexpr (PTile::has_polymorphic_allocator) {
998 tmp_real.setArena(ptile.GetStructOfArrays().GetRealData(0).arena());
1000 tmp_real.resize(np_total);
1002 for (
int comp = 0; comp < ptile.NumRealComps(); ++comp) {
1003 auto src = ptile.GetStructOfArrays().GetRealData(comp).data();
1007 dst[i] = i < np ? src[permutations[i]] : src[i];
1010 Gpu::streamSynchronize();
1012 ptile.GetStructOfArrays().GetRealData(comp).swap(tmp_real);
1016 typename PTile::IntVector tmp_int;
1017 if (ptile.NumIntComps() > 0) {
1018 if constexpr (PTile::has_polymorphic_allocator) {
1019 tmp_int.setArena(ptile.GetStructOfArrays().GetIntData(0).arena());
1021 tmp_int.resize(np_total);
1024 for (
int comp = 0; comp < ptile.NumIntComps(); ++comp) {
1025 auto src = ptile.GetStructOfArrays().GetIntData(comp).data();
1026 int* dst = tmp_int.data();
1029 dst[i] = i < np ? src[permutations[i]] : src[i];
1032 Gpu::streamSynchronize();
1034 ptile.GetStructOfArrays().GetIntData(comp).swap(tmp_int);
1047template <
class PTile,
class index_type,
1048 std::enable_if_t<PTile::ParticleType::is_rtsoa_particle, int> foo = 0>
1050ReorderParticles (PTile& ptile,
const index_type* permutations)
1052 const size_t np = ptile.numParticles();
1056 auto src = ptile.GetIdCPUData().data();
1057 uint64_t* dst = tmp_idcpu.data();
1060 dst[i] = src[permutations[i]];
1070 for (
int comp = 0; comp < ptile.NumRealComps(); ++comp) {
1071 auto src = ptile.GetRealData(comp).data();
1072 auto dst = tmp_real.data();
1075 dst[i] = src[permutations[i]];
1086 for (
int comp = 0; comp < ptile.NumIntComps(); ++comp) {
1087 auto src = ptile.GetIntData(comp).data();
1088 auto dst = tmp_int.data();
1091 dst[i] = src[permutations[i]];
1100 Gpu::streamSynchronize();
1103#ifdef AMREX_USE_HDF5_ASYNC
1104void async_vol_es_wait_particle();
1105void async_vol_es_wait_close_particle();
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
#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
Array4< int const > offset
Definition AMReX_HypreMLABecLap.cpp:1139
Array4< int const > mask
Definition AMReX_InterpFaceRegister.cpp:93
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
__host__ __device__ BoxND & grow(int i) noexcept
Definition AMReX_Box.H:641
__host__ __device__ const IntVectND< dim > & bigEnd() const &noexcept
Return the inclusive upper bound of the box.
Definition AMReX_Box.H:123
__host__ __device__ Long numPts() const noexcept
Return the number of points contained in the BoxND.
Definition AMReX_Box.H:356
__host__ __device__ BoxND & convert(IndexTypeND< dim > typ) noexcept
Convert the BoxND from the current type into the argument type. This may change the BoxND coordinates...
Definition AMReX_Box.H:974
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:212
__host__ __device__ Long index(const IntVectND< dim > &v) const noexcept
Return offset of point from smallend; i.e. index(smallend) -> 0, bigend would return numPts()-1....
Definition AMReX_Box.H:1055
__host__ __device__ const IntVectND< dim > & smallEnd() const &noexcept
Return the inclusive lower bound of the box.
Definition AMReX_Box.H:111
const Real * CellSize() const noexcept
Returns the cellsize for each coordinate direction.
Definition AMReX_CoordSys.H:71
const Real * InvCellSize() const noexcept
Returns the inverse cellsize for each coordinate direction.
Definition AMReX_CoordSys.H:82
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:74
void refine(IntVect const &rr)
Definition AMReX_Geometry.H:412
const Real * ProbHi() const noexcept
Returns the hi end of the problem domain in each dimension.
Definition AMReX_Geometry.H:181
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:211
const Real * ProbLo() const noexcept
Returns the lo end of the problem domain in each dimension.
Definition AMReX_Geometry.H:179
__host__ __device__ constexpr int min() const noexcept
minimum (no absolute values) value
Definition AMReX_IntVect.H:232
__host__ __device__ constexpr bool allGE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than or equal to argument for all components. NOTE: This is NOT a str...
Definition AMReX_IntVect.H:450
__host__ __device__ constexpr int max() const noexcept
maximum (no absolute values) value
Definition AMReX_IntVect.H:221
__host__ __device__ constexpr bool allLE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is less than or equal to argument for all components. NOTE: This is NOT a strict...
Definition AMReX_IntVect.H:400
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:169
Dynamically allocated vector for trivially copyable data.
Definition AMReX_PODVector.H:308
void resize(size_type a_new_size, GrowthStrategy strategy=GrowthStrategy::Poisson)
Definition AMReX_PODVector.H:728
void free_async() noexcept
Definition AMReX_PODVector.H:853
T * dataPtr() noexcept
Definition AMReX_PODVector.H:670
T * data() noexcept
Definition AMReX_PODVector.H:666
Definition AMReX_ParIter.H:118
Definition AMReX_ParticleBufferMap.H:53
GetPID getPIDFunctor() const noexcept
Definition AMReX_ParticleBufferMap.H:156
Definition AMReX_Reduce.H:453
Type value()
Definition AMReX_Reduce.H:488
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
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
void Sum(T &v, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:221
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
static constexpr struct amrex::Scan::Type::Exclusive exclusive
static constexpr RetSum noRetSum
Definition AMReX_Scan.H:33
Definition AMReX_Amr.cpp:49
__host__ __device__ void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:139
__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
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
void EnsureThreadSafeTiles(PC &pc)
Definition AMReX_ParticleUtil.H:730
std::string getDefaultCompNameInt(const int i)
Definition AMReX_ParticleUtil.H:928
void ReorderParticles(PTile &ptile, const index_type *permutations)
Reorder particles on the tile ptile using a the permutations array.
Definition AMReX_ParticleUtil.H:946
__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
void removeInvalidParticles(PTile &ptile)
Definition AMReX_ParticleUtil.H:637
__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
std::string getDefaultCompNameReal(const int i)
Definition AMReX_ParticleUtil.H:913
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:24
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:33
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:44
__host__ __device__ int getParticleGrid(P const &p, amrex::Array4< int > const &mask, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &dxi, const Box &domain) noexcept
Definition AMReX_ParticleUtil.H:405
void PermutationForDeposition(Gpu::DeviceVector< index_type > &perm, index_type nitems, index_type nbins, F const &f)
Definition AMReX_ParticleUtil.H:759
bool SameIteratorsOK(const PC1 &pc1, const PC2 &pc2)
Definition AMReX_ParticleUtil.H:718
int partitionParticles(PTile &ptile, ParFunc const &is_left)
Reorders the ParticleTile into two partitions left [0, num_left-1] and right [num_left,...
Definition AMReX_ParticleUtil.H:468
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 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, int lev_min, int lev_max, int nGrow, bool remove_negative)
Definition AMReX_ParticleUtil.H:650
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
__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
A multidimensional array accessor.
Definition AMReX_Array4.H:283
Definition AMReX_ParticleUtil.H:259
BinMapper(const int *off_bins_p, const GpuArray< Real, 3 > *dxi_p, const GpuArray< Real, 3 > *plo_p, const Dim3 *lo_p, const Dim3 *hi_p, int *bin_type_array=nullptr)
Definition AMReX_ParticleUtil.H:260
__host__ __device__ unsigned int operator()(const T &ptd, int i) const
Definition AMReX_ParticleUtil.H:271
Definition AMReX_ParticleUtil.H:390
__host__ __device__ IntVect operator()(P const &p, amrex::GpuArray< amrex::Real, 3 > const &plo, amrex::GpuArray< amrex::Real, 3 > const &dxi, const Box &domain) const noexcept
Definition AMReX_ParticleUtil.H:394
Definition AMReX_Dim3.H:12
int x
Definition AMReX_Dim3.H:12
int z
Definition AMReX_Dim3.H:12
int y
Definition AMReX_Dim3.H:12
Definition AMReX_ParticleUtil.H:304
GpuArray< Real, 3 > plo
Definition AMReX_ParticleUtil.H:305
IntVect bin_size
Definition AMReX_ParticleUtil.H:308
__host__ __device__ unsigned int operator()(const ParticleType &p) const noexcept
Definition AMReX_ParticleUtil.H:313
GpuArray< Real, 3 > dxi
Definition AMReX_ParticleUtil.H:306
Box domain
Definition AMReX_ParticleUtil.H:307
Box box
Definition AMReX_ParticleUtil.H:309
Fixed-size array that can be used on GPU.
Definition AMReX_Array.H:43
Definition AMReX_GpuMemory.H:56
T * dataPtr()
Definition AMReX_GpuMemory.H:90