4template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
7template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
10template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
11NeighborParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>
14 m_num_neighbor_cells(ncells)
19template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
25 :
ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt> (geom, dmap, ba),
26 m_num_neighbor_cells(nneighbor)
31template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
38 :
ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt> (geom, dmap, ba, rr),
39 m_num_neighbor_cells(nneighbor)
44template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
48 for (
int ii = 0; ii < AMREX_SPACEDIM + NStructReal + this->NumRealComps(); ++ii) {
49 ghost_real_comp.push_back(1);
51 for (
int ii = 0; ii < 2 + NStructInt + this->NumIntComps(); ++ii) {
52 ghost_int_comp.push_back(1);
57template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
61 ghost_real_comp[i] = value;
65template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
69 ghost_int_comp[i] = value;
73template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
78 for (
int ii = 0; ii < AMREX_SPACEDIM + NStructReal + this->NumRealComps(); ++ii) {
79 if (ghost_real_comp[ii]) {
80 comm_size +=
sizeof(
typename ParticleType::RealType);
83 for (
int ii = 0; ii < 2 + NStructInt + this->NumIntComps(); ++ii) {
84 if (ghost_int_comp[ii]) {
85 comm_size +=
sizeof(
int);
88 if ( enableInverse() ) { comm_size += 4*
sizeof(
int); }
89 cdata_size = comm_size;
92template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
98 this->SetParticleBoxArray(lev, ba);
99 this->SetParticleDistributionMap(lev, dmap);
100 this->Redistribute();
103template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
108 this->SetParticleBoxArray(lev, ba);
109 this->SetParticleDistributionMap(lev, dmap);
110 this->Redistribute();
113template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
118 for (
int lev = 0; lev < this->numLevels(); ++lev)
120 this->SetParticleBoxArray(lev, ba[lev]);
121 this->SetParticleDistributionMap(lev, dmap[lev]);
123 this->Redistribute();
126template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
131 BL_PROFILE(
"NeighborParticleContainer::areMasksValid");
133 resizeContainers(this->numLevels());
135 for (
int lev = 0; lev < this->numLevels(); ++lev)
137 BoxArray ba = this->ParticleBoxArray(lev);
140 if (mask_ptr[lev] ==
nullptr ||
150template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
155 BL_PROFILE(
"NeighborParticleContainer::BuildMasks");
157 if (this->numLevels() == 1) { use_mask =
true; }
158 else { use_mask =
false; }
160 resizeContainers(this->numLevels());
162 for (
int lev = 0; lev < this->numLevels(); ++lev)
164 BoxArray ba = this->ParticleBoxArray(lev);
167 const Geometry& geom = this->Geom(lev);
169 mask_ptr[lev] = std::make_unique<iMultiFab>(ba, dmap,
int(num_mask_comps), m_num_neighbor_cells);
170 mask_ptr[lev]->setVal(-1, m_num_neighbor_cells);
177 const Box& box = mfi.tilebox();
178 const int grid_id = mfi.
index();
179 const int tile_id = mfi.LocalTileIndex();
180 (*mask_ptr[lev])[mfi].
template setVal<RunOn::Host>(grid_id, box, MaskComps::grid, 1);
181 (*mask_ptr[lev])[mfi].
template setVal<RunOn::Host>(tile_id, box, MaskComps::tile, 1);
182 (*mask_ptr[lev])[mfi].
template setVal<RunOn::Host>(lev , box, MaskComps::level, 1);
189template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
194 BL_PROFILE(
"NeighborParticleContainer::GetNeighborCommTags");
196 local_neighbors.clear();
197 neighbor_procs.clear();
205 const Box& box = mfi.growntilebox();
207 const int grid = (*mask_ptr[lev])[mfi](iv, MaskComps::grid);
209 const int tile = (*mask_ptr[lev])[mfi](iv, MaskComps::tile);
210 const int level = (*mask_ptr[lev])[mfi](iv, MaskComps::level);
211 const int global_proc = this->ParticleDistributionMap(level)[grid];
214 local_neighbors.push_back(comm_tag);
216 neighbor_procs.push_back(proc);
224 for (
int lev = 0; lev < this->numLevels(); ++lev)
228 const Box& box = mfi.validbox();
230 GetCommTagsBox(comm_tags, lev, box);
231 for (
auto const& tag : comm_tags) {
232 local_neighbors.push_back(tag);
234 neighbor_procs.push_back(tag.proc_id);
245template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
252 for (
int l = src_lev; l < lev; ++l) {
253 ref_fac *= this->GetParGDB()->refRatio(l);
255 }
else if (src_lev > lev) {
256 for (
int l = src_lev; l > lev; --l) {
257 ref_fac *= this->GetParGDB()->refRatio(l-1);
264template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
269 std::vector< std::pair<int, Box> > isects;
272 for (
int lev = 0; lev < this->numLevels(); ++lev) {
284 const Periodicity& periodicity = this->Geom(lev).periodicity();
285 const std::vector<IntVect>& pshifts = periodicity.
shiftIntVect();
286 const BoxArray& ba = this->ParticleBoxArray(lev);
288 for (
auto const& pshift : pshifts)
290 const Box& pbox = box + pshift;
291 bool first_only =
false;
293 for (
const auto& isec : isects) {
294 const int grid = isec.first;
295 const int global_proc = this->ParticleDistributionMap(lev)[grid];
299 if (ba[grid].contains(iv))
302 this->do_tiling, this->tile_size, tbx);
311template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
316 BL_PROFILE(
"NeighborParticleContainer::cacheNeighborInfo");
320 resizeContainers(this->numLevels());
329 std::map<NeighborCommTag, Vector<NeighborIndexMap> > remote_map;
333 std::map<NeighborCommTag, Vector<Vector<NeighborIndexMap> > > tmp_remote_map;
335 local_map.resize(this->numLevels());
336 tmp_local_map.resize(this->numLevels());
340 for (
int lev = 0; lev < this->numLevels(); ++lev) {
342 for (
int i = 0; i < static_cast<int>(local_neighbors.size()); ++i) {
344 tmp_remote_map[comm_tag].resize(num_threads);
345 remote_map[comm_tag];
347 tmp_local_map[lev][index].resize(num_threads);
348 local_map[lev][index];
349 buffer_tag_cache[lev][index].resize(num_threads);
353 for (
int lev = 0; lev < this->numLevels(); ++lev) {
364 const int& grid = pti.index();
365 const int& tile = pti.LocalTileIndex();
370 auto& cache = buffer_tag_cache[lev][src_index][thread_num];
372 auto& particles = pti.GetArrayOfStructs();
373 for (
int i = 0; i < pti.numParticles(); ++i) {
376 getNeighborTags(tags, p, m_num_neighbor_cells, src_tag, pti);
379 for (
int j = 0; j < static_cast<int>(tags.
size()); ++j) {
382 if (tag.
grid < 0) {
continue; }
385 const int cache_index = cache.size();
386 cache.push_back(tag);
388 const int global_who = this->ParticleDistributionMap(tag.
level)[tag.
grid];
391 lev, src_index.first, src_index.second,
392 cache_index, thread_num);
394 auto& tmp = tmp_local_map[tag.
level][dst_index];
396 buffer.push_back(nim);
400 buffer.push_back(nim);
409 for (
int lev = 0; lev < this->numLevels(); ++lev) {
414 for (
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi) {
415 const int grid = mfi.index();
416 const int tile = mfi.LocalTileIndex();
418 for (
int i = 0; i < num_threads; ++i) {
419 local_map[lev][index].insert(local_map[lev][index].
end(),
420 tmp_local_map[lev][index][i].
begin(),
421 tmp_local_map[lev][index][i].
end());
422 tmp_local_map[lev][index][i].erase(tmp_local_map[lev][index][i].
begin(),
423 tmp_local_map[lev][index][i].
end());
429 typename std::map<NeighborCommTag, Vector<Vector<NeighborIndexMap> > >::iterator it;
432#pragma omp single nowait
434 for (it=tmp_remote_map.begin(); it != tmp_remote_map.end(); it++) {
436#pragma omp task firstprivate(it)
441 for (
int i = 0; i < num_threads; ++i) {
442 remote_map[tag].insert(remote_map[tag].
end(), tmp[i].begin(), tmp[i].end());
443 tmp[i].erase(tmp[i].
begin(), tmp[i].end());
448 for (
int lev = 0; lev < this->numLevels(); ++lev) {
450 for (
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi) {
451 const int grid = mfi.index();
452 const int tile = mfi.LocalTileIndex();
455 const int num_ghosts = map.
size();
456 neighbors[lev][dst_index].define(this->NumRuntimeRealComps(),
457 this->NumRuntimeIntComps());
458 neighbors[lev][dst_index].resize(num_ghosts);
459 local_neighbor_sizes[lev][dst_index] = neighbors[lev][dst_index].size();
463 for (
int lev = 0; lev < this->numLevels(); ++lev) {
464 for (
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi) {
465 const int grid = mfi.index();
466 const int tile = mfi.LocalTileIndex();
469 const int num_ghosts = map.
size();
471#pragma omp parallel for
473 for (
int i = 0; i < num_ghosts; ++i) {
485 std::map<int, int> tile_counts;
486 for (
const auto& kv: remote_map) {
487 tile_counts[kv.first.proc_id] += 1;
490 for (
const auto& kv: remote_map) {
491 if (kv.first.proc_id == MyProc) {
continue; }
493 buffer.resize(
sizeof(
int));
494 std::memcpy(buffer.data(), &tile_counts[kv.first.proc_id],
sizeof(
int));
497 for (
auto& kv : remote_map) {
498 if (kv.first.proc_id == MyProc) {
continue; }
499 int np = kv.second.size();
500 int data_size = np * cdata_size;
502 size_t old_size = buffer.
size();
503 size_t new_size = buffer.
size() + 4*
sizeof(
int) + data_size;
504 buffer.resize(new_size);
505 char* dst = &buffer[old_size];
506 std::memcpy(dst, &(kv.first.level_id),
sizeof(
int)); dst +=
sizeof(
int);
507 std::memcpy(dst, &(kv.first.grid_id ),
sizeof(
int)); dst +=
sizeof(
int);
508 std::memcpy(dst, &(kv.first.tile_id ),
sizeof(
int)); dst +=
sizeof(
int);
509 std::memcpy(dst, &data_size,
sizeof(
int)); dst +=
sizeof(
int);
510 size_t buffer_offset = old_size + 4*
sizeof(
int);
512#pragma omp parallel for
514 for (
int i = 0; i < np; ++i) {
518 tags[nim.
src_index].dst_index = buffer_offset + i*cdata_size;
522 if ( enableInverse() )
524 for (
int lev = 0; lev < this->numLevels(); ++lev)
526 for (
const auto& kv : neighbors[lev])
528 inverse_tags[lev][kv.first].resize(kv.second.size());
534template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
543template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
550 shrink_box.
grow(-nGrow);
558 const IntVect& iv = this->Index(p, lev);
559 if (shrink_box.
contains(iv)) {
return; }
561 const Periodicity& periodicity = this->Geom(lev).periodicity();
562 const Box& domain = this->Geom(lev).Domain();
568 for (
int ii = -nGrow[0]; ii < nGrow[0] + 1; ii += nGrow[0]) {,
569 for (
int jj = -nGrow[1]; jj < nGrow[1] + 1; jj += nGrow[1]) {,
570 for (
int kk = -nGrow[2]; kk < nGrow[2] + 1; kk += nGrow[2]) {)
571 if (
AMREX_D_TERM((ii == 0), && (jj == 0), && (kk == 0))) {
continue; }
576 tag.
grid =
mask(neighbor_cell, MaskComps::grid);
577 tag.
tile =
mask(neighbor_cell, MaskComps::tile);
578 tag.
level =
mask(neighbor_cell, MaskComps::level);
580 for (
int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
581 if (! periodicity.
isPeriodic(dir)) {
continue; }
582 if (neighbor_cell[dir] < lo[dir]) {
584 }
else if (neighbor_cell[dir] > hi[dir]) {
590 if (tag != src_tag) { tags.push_back(tag); }
602 std::vector< std::pair<int, Box> > isects;
604 for (
int lev = 0; lev < this->numLevels(); ++lev)
607 const Periodicity& periodicity = this->Geom(lev).periodicity();
608 const std::vector<IntVect>& pshifts = periodicity.
shiftIntVect();
609 const BoxArray& ba = this->ParticleBoxArray(lev);
610 const IntVect& iv = this->Index(p, lev);
611 for (
auto const& pshift : pshifts)
614 bool first_only =
false;
616 for (
const auto& isec : isects)
618 const Box& grid_box = ba[isec.first];
620 if ( !grid_box.
contains(cell) ) {
continue; }
622 this->do_tiling, this->tile_size, tbx);
624 nbor.periodic_shift = -pshift;
625 if (src_tag != nbor) { tags.push_back(nbor); }
636template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
645 m_has_neighbors =
true;
648template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
652 int int_start_comp,
int int_num_comp) {
657 sumNeighborsCPU(real_start_comp, real_num_comp, int_start_comp, int_num_comp);
661template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
670 updateNeighborsGPU(boundary_neighbors_only);
673 updateNeighborsCPU(
true);
675 m_has_neighbors =
true;
678template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
688 m_has_neighbors =
false;
691template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
692template <
class CheckPair>
699 BL_PROFILE(
"NeighborParticleContainer::buildNeighborList");
701 resizeContainers(this->numLevels());
703 for (
int lev = 0; lev < this->numLevels(); ++lev)
705 m_neighbor_list[lev].clear();
708 PairIndex index(pti.index(), pti.LocalTileIndex());
709 m_neighbor_list[lev][index];
713 neighbor_list[lev].clear();
715 PairIndex index(pti.index(), pti.LocalTileIndex());
716 neighbor_list[lev][index];
720 auto& plev = this->GetParticles(lev);
721 const auto& geom = this->Geom(lev);
724#pragma omp parallel if (Gpu::notInLaunchRegion())
728 int gid = pti.index();
729 int tid = pti.LocalTileIndex();
730 auto index = std::make_pair(gid, tid);
732 auto& ptile = plev[index];
734 if (ptile.numParticles() == 0) {
continue; }
736 Box bx = pti.tilebox();
750 dxi_v.
push_back(geom.InvCellSizeArray());
753 m_neighbor_list[lev][index].build(ptile,
755 off_bins_v, dxi_v, plo_v, lo_v, hi_v, ng);
758 const auto& counts = m_neighbor_list[lev][index].GetCounts();
759 const auto& list = m_neighbor_list[lev][index].GetList();
762 for (
int i = 0; i < ptile.numParticles(); ++i)
764 auto cnt = counts[i];
765 neighbor_list[lev][index].push_back(cnt);
766 for (
size_t j = 0; j < cnt; ++j)
768 neighbor_list[lev][index].push_back(list[li++]+1);
776template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
777template <
class CheckPair,
class OtherPCType>
784 BL_PROFILE(
"NeighborParticleContainer::buildNeighborList");
793 resizeContainers(this->numLevels());
794 neighbor_lists.resize(this->numLevels());
796 for (
int lev = 0; lev < this->numLevels(); ++lev)
798 neighbor_lists[lev].clear();
801 PairIndex index(pti.index(), pti.LocalTileIndex());
802 neighbor_lists[lev][index];
805 auto& plev = this->GetParticles(lev);
806 const auto& geom = this->Geom(lev);
809#pragma omp parallel if (Gpu::notInLaunchRegion())
813 int gid = pti.index();
814 int tid = pti.LocalTileIndex();
815 auto index = std::make_pair(gid, tid);
817 const auto& ptile = plev[index];
818 auto& other_ptile = other.ParticlesAt(lev, pti);
819 if (ptile.numParticles() == 0) {
continue; }
821 Box bx = pti.tilebox();
835 dxi_v.
push_back(geom.InvCellSizeArray());
838 neighbor_lists[lev][index].build(ptile, other_ptile,
840 off_bins_v, dxi_v, plo_v, lo_v, hi_v, ng);
845template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
846template <
class CheckPair>
850 int num_bin_types,
bool )
854 if (num_bin_types == 1) {
AMREX_ASSERT(ref_ratio[0] == 1); }
856 BL_PROFILE(
"NeighborParticleContainer::buildNeighborList");
858 resizeContainers(this->numLevels());
860 for (
int lev = 0; lev < this->numLevels(); ++lev)
862 m_neighbor_list[lev].clear();
865 PairIndex index(pti.index(), pti.LocalTileIndex());
866 m_neighbor_list[lev][index];
870 neighbor_list[lev].clear();
872 PairIndex index(pti.index(), pti.LocalTileIndex());
873 neighbor_list[lev][index];
877 auto& plev = this->GetParticles(lev);
878 const auto& geom = this->Geom(lev);
881#pragma omp parallel if (Gpu::notInLaunchRegion())
885 int gid = pti.index();
886 int tid = pti.LocalTileIndex();
887 auto index = std::make_pair(gid, tid);
888 auto& ptile = plev[index];
890 if (ptile.numParticles() == 0) {
continue; }
892 Box bx = pti.tilebox();
895 auto& soa = pti.GetStructOfArrays();
896 auto TypeVec = soa.GetIntData(type_ind);
897 int* bin_type_array = TypeVec.data();
906 for (
int type(0); type<num_bin_types; ++type) {
908 Box dom = geom.Domain();
909 const Real* plo = geom.ProbLo();
910 const Real* phi = geom.ProbHi();
911 auto lcoord = geom.Coord();
917 lbx.
refine( ref_ratio[type] );
918 ldom.
refine( ref_ratio[type] );
924 Geometry lgeom(ldom,lrb,lcoord,lper);
927 int NGhost = ref_ratio[type]*m_num_neighbor_cells;
945 std::memcpy( dxi_v.
data() + type, dxInv.data(),
sizeof(dxInv) );
946 std::memcpy( plo_v.
data() + type, ploa.data() ,
sizeof(ploa) );
947 std::memcpy( lo_v.
data() + type, &lo ,
sizeof(lo) );
948 std::memcpy( hi_v.
data() + type, &hi ,
sizeof(hi) );
949 std::memcpy( nbins_v.
data() + type, &nbins ,
sizeof(nbins) );
955 m_neighbor_list[lev][index].build(ptile,
957 off_bins_v, dxi_v, plo_v, lo_v, hi_v,
958 ng, num_bin_types, bin_type_array);
963 const auto& counts = m_neighbor_list[lev][index].GetCounts();
964 const auto& list = m_neighbor_list[lev][index].GetList();
967 for (
int i = 0; i < ptile.numParticles(); ++i) {
968 auto cnt = counts[i];
969 neighbor_list[lev][index].push_back(cnt);
970 for (
size_t j = 0; j < cnt; ++j) {
971 neighbor_list[lev][index].push_back(list[li++]+1);
981template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
982template <
class CheckPair>
987 BL_PROFILE(
"NeighborParticleContainer::selectActualNeighbors");
988 const auto& geom_fine = this->Geom(0);
989 const auto& ba_fine = this->ParticleBoxArray(0);
990 if (ba_fine.size() == 1 && !geom_fine.isAnyPeriodic()) {
994 for (
int lev = 0; lev < this->numLevels(); ++lev)
997 if (!m_boundary_particle_ids.empty()) {
998 for (
auto& keyval: m_boundary_particle_ids[lev]) {
999 keyval.second.clear();
1004 PairIndex index(pti.index(), pti.LocalTileIndex());
1007 m_boundary_particle_ids[lev][index];
1008 m_boundary_particle_ids[lev][index].resize(pti.numNeighborParticles());
1009 auto* p_boundary_particle_ids = m_boundary_particle_ids[lev][index].dataPtr();
1011 const auto& aos = pti.GetArrayOfStructs();
1012 const auto* pstruct = aos().dataPtr();
1013 const auto ptile_data = this->ParticlesAt(lev, pti).getConstParticleTileData();
1015 Box box = pti.validbox();
1016 Box grownBox = pti.tilebox();
1018 const auto lo =
lbound(grownBox);
1019 const auto hi =
ubound(grownBox);
1021 const auto& geom = this->Geom(lev);
1022 const auto domain = geom.Domain();
1023 const auto dxi = geom.InvCellSizeArray();
1024 const auto plo = geom.ProbLoArray();
1026 const size_t np_real = pti.numRealParticles();
1027 const size_t np_total = aos().size();
1030 bins.
build(np_total, pstruct, grownBox,
1033 AMREX_D_TERM(
int i =
static_cast<int>(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0]) - lo.x);,
1034 int j =
static_cast<int>(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1]) - lo.y);,
1035 int k =
static_cast<int>(amrex::Math::floor((p.pos(2)-plo[2])*dxi[2]) - lo.z));
1045 unsigned int* p_np_boundary = np_boundary.
data();
1050 static_cast<int>(amrex::Math::floor((pstruct[i].pos(0)-plo[0])*dxi[0])) - lo.x,
1051 static_cast<int>(amrex::Math::floor((pstruct[i].pos(1)-plo[1])*dxi[1])) - lo.y,
1052 static_cast<int>(amrex::Math::floor((pstruct[i].pos(2)-plo[2])*dxi[2])) - lo.z));
1053 auto iv3 = iv.
dim3();
1059 int nx = hi.x-lo.x+1;
1060 int ny = hi.y-lo.y+1;
1061 int nz = hi.z-lo.z+1;
1063 bool isActualNeighbor =
false;
1067 if (isActualNeighbor) {
break; }
1068 int nbr_cell_id = (ii * ny + jj) * nz + kk;
1069 for (
auto p = poffset[nbr_cell_id]; p < poffset[nbr_cell_id+1]; ++p) {
1070 if (pperm[p] ==
int(i)) {
continue; }
1075 p_boundary_particle_ids[loc] = i;
1076 isActualNeighbor =
true;
1086 unsigned int* p_np_boundary_h = np_boundary.copyToHost();
1087 m_boundary_particle_ids[lev][index].resize(*p_np_boundary_h);
1092template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
1097 BL_PROFILE(
"NeighborParticleContainer::printNeighborList");
1099 for (
int lev = 0; lev < this->numLevels(); ++lev)
1101 for(
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi)
1103 int gid = mfi.index();
1104 int tid = mfi.LocalTileIndex();
1105 auto index = std::make_pair(gid, tid);
1106 m_neighbor_list[lev][index].print();
1111template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
1116 this->reserveData();
1118 if (
static_cast<int>(neighbors.size()) <= num_levels )
1120 neighbors.resize(num_levels);
1121 m_neighbor_list.resize(num_levels);
1122 neighbor_list.resize(num_levels);
1123 mask_ptr.resize(num_levels);
1124 buffer_tag_cache.resize(num_levels);
1125 local_neighbor_sizes.resize(num_levels);
1126 if ( enableInverse() ) { inverse_tags.resize(num_levels); }
1129 AMREX_ASSERT((neighbors.size() == m_neighbor_list.size()) &&
1130 (neighbors.size() == mask_ptr.size() ) );
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:551
#define BL_PROFILE_VAR_STOP(vname)
Definition AMReX_BLProfiler.H:563
#define BL_PROFILE_VAR(fname, vname)
Definition AMReX_BLProfiler.H:560
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FOR_1D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:97
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
Array4< int const > mask
Definition AMReX_InterpFaceRegister.cpp:93
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:129
A FortranArrayBox(FAB)-like object.
Definition AMReX_BaseFab.H:183
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:550
std::vector< std::pair< int, Box > > intersections(const Box &bx) const
Return intersections of Box and BoxArray.
static bool SameRefs(const BoxArray &lhs, const BoxArray &rhs)
whether two BoxArrays share the same data
Definition AMReX_BoxArray.H:820
AMREX_GPU_HOST_DEVICE BoxND & coarsen(int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition AMReX_Box.H:708
AMREX_GPU_HOST_DEVICE IndexTypeND< dim > ixType() const noexcept
Returns the indexing type.
Definition AMReX_Box.H:127
AMREX_GPU_HOST_DEVICE void next(IntVectND< dim > &) const noexcept
Step through the rectangle. It is a runtime error to give a point not inside rectangle....
Definition AMReX_Box.H:1059
AMREX_GPU_HOST_DEVICE Long index(const IntVectND< dim > &v) const noexcept
Returns offset of point from smallend; i.e. index(smallend) -> 0, bigend would return numPts()-1....
Definition AMReX_Box.H:993
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & smallEnd() const &noexcept
Get the smallend of the BoxND.
Definition AMReX_Box.H:105
AMREX_GPU_HOST_DEVICE BoxND & grow(int i) noexcept
Definition AMReX_Box.H:627
AMREX_GPU_HOST_DEVICE BoxND & refine(int ref_ratio) noexcept
Refine BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo*ratio...
Definition AMReX_Box.H:684
AMREX_GPU_HOST_DEVICE Long numPts() const noexcept
Returns the number of points contained in the BoxND.
Definition AMReX_Box.H:346
AMREX_GPU_HOST_DEVICE bool contains(const IntVectND< dim > &p) const noexcept
Returns true if argument is contained within BoxND.
Definition AMReX_Box.H:204
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & bigEnd() const &noexcept
Get the bigend.
Definition AMReX_Box.H:116
GpuArray< Real, AMREX_SPACEDIM > InvCellSizeArray() const noexcept
Definition AMReX_CoordSys.H:87
A container for storing items in a set of bins.
Definition AMReX_DenseBins.H:77
index_type * offsetsPtr() noexcept
returns the pointer to the offsets array
Definition AMReX_DenseBins.H:512
index_type * permutationPtr() noexcept
returns the pointer to the permutation array
Definition AMReX_DenseBins.H:509
void build(N nitems, const_pointer_input_type v, const Box &bx, F &&f)
Populate the bins with a set of items.
Definition AMReX_DenseBins.H:130
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:41
static bool SameRefs(const DistributionMapping &lhs, const DistributionMapping &rhs)
Definition AMReX_DistributionMapping.H:187
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:73
Periodicity periodicity() const noexcept
Definition AMReX_Geometry.H:355
GpuArray< Real, AMREX_SPACEDIM > ProbLoArray() const noexcept
Definition AMReX_Geometry.H:186
Definition AMReX_GpuBuffer.H:17
T const * data() const noexcept
Definition AMReX_GpuBuffer.H:65
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 dim3() const noexcept
Definition AMReX_IntVect.H:163
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE 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:670
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int max() const noexcept
maximum (no absolute values) value
Definition AMReX_IntVect.H:212
Definition AMReX_MFIter.H:57
Box tilebox() const noexcept
Return the tile Box at the current index.
Definition AMReX_MFIter.cpp:385
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:141
Definition AMReX_NeighborList.H:247
Definition AMReX_NeighborParticles.H:35
std::pair< int, int > PairIndex
Definition AMReX_NeighborParticles.H:196
void selectActualNeighbors(CheckPair const &check_pair, int num_cells=1)
Definition AMReX_NeighborParticlesI.H:985
void getNeighborTags(Vector< NeighborCopyTag > &tags, const ParticleType &p, int nGrow, const NeighborCopyTag &src_tag, const MyParIter &pti)
Definition AMReX_NeighborParticlesI.H:537
void printNeighborList()
Definition AMReX_NeighborParticlesI.H:1095
static bool enable_inverse
Definition AMReX_NeighborParticles.H:428
void initializeCommComps()
Definition AMReX_NeighborParticlesI.H:47
void resizeContainers(int num_levels)
Definition AMReX_NeighborParticlesI.H:1114
static bool use_mask
Definition AMReX_NeighborParticles.H:426
void buildNeighborList(CheckPair const &check_pair, bool sort=false)
Definition AMReX_NeighborParticlesI.H:695
typename ParticleContainerType::ParticleType ParticleType
Definition AMReX_NeighborParticles.H:38
Definition AMReX_PODVector.H:262
iterator begin() noexcept
Definition AMReX_PODVector.H:617
iterator end() noexcept
Definition AMReX_PODVector.H:621
T * data() noexcept
Definition AMReX_PODVector.H:609
void push_back(const T &a_value)
Definition AMReX_PODVector.H:572
Definition AMReX_ParGDB.H:13
Definition AMReX_ParIter.H:113
A distributed container for Particles sorted onto the levels, grids, and tiles of a block-structured ...
Definition AMReX_ParticleContainer.H:146
This provides length of period for periodic domains. 0 means it is not periodic in that direction....
Definition AMReX_Periodicity.H:17
std::vector< IntVect > shiftIntVect(IntVect const &nghost=IntVect(0)) const
Definition AMReX_Periodicity.cpp:8
bool isAnyPeriodic() const noexcept
Definition AMReX_Periodicity.H:22
bool isPeriodic(int dir) const noexcept
Definition AMReX_Periodicity.H:26
A Box with real dimensions. A RealBox is OK iff volume >= 0.
Definition AMReX_RealBox.H:21
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:27
Long size() const noexcept
Definition AMReX_Vector.H:50
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T Add(T *sum, T value) noexcept
Definition AMReX_GpuAtomic.H:198
OutIter exclusive_scan(InIter begin, InIter end, OutIter result)
Definition AMReX_Scan.H:1377
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition AMReX_GpuDevice.H:251
constexpr int get_thread_num()
Definition AMReX_OpenMP.H:37
constexpr int get_max_threads()
Definition AMReX_OpenMP.H:36
int MyProcSub() noexcept
my sub-rank in current frame
Definition AMReX_ParallelContext.H:76
int global_to_local_rank(int rank) noexcept
Definition AMReX_ParallelContext.H:98
AMREX_GPU_HOST_DEVICE auto call_check_pair(F const &check_pair, const SrcData &src_tile, const DstData &dst_tile, N1 i, N2 j) noexcept -> decltype(check_pair(src_tile.m_aos[i], dst_tile.m_aos[j]))
Definition AMReX_NeighborList.H:19
Definition AMReX_Amr.cpp:49
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
BoxND< AMREX_SPACEDIM > Box
Definition AMReX_BaseFwd.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVect getParticleCell(P const &p, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi) noexcept
Returns the cell index for a given particle using the provided lower bounds and cell sizes.
Definition AMReX_ParticleUtil.H:374
void EnsureThreadSafeTiles(PC &pc)
Definition AMReX_ParticleUtil.H:705
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 end(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:1890
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 ubound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:315
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 lbound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:308
IntVectND< AMREX_SPACEDIM > IntVect
Definition AMReX_BaseFwd.H:30
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Grow BoxND in all directions by given amount.
Definition AMReX_Box.H:1211
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition AMReX.H:127
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Dim3 begin(BoxND< dim > const &box) noexcept
Definition AMReX_Box.H:1881
bool SameIteratorsOK(const PC1 &pc1, const PC2 &pc2)
Definition AMReX_ParticleUtil.H:693
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:35
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:34
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:230
const int[]
Definition AMReX_BLProfiler.cpp:1664
IntVect computeRefFac(const ParGDBBase *a_gdb, int src_lev, int lev)
Definition AMReX_ParticleUtil.cpp:6
void RemoveDuplicates(Vector< T > &vec)
Definition AMReX_Vector.H:208
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > shift(const BoxND< dim > &b, int dir, int nzones) noexcept
Return a BoxND with indices shifted by nzones in dir direction.
Definition AMReX_Box.H:1372
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int getTileIndex(const IntVect &iv, const Box &box, const bool a_do_tiling, const IntVect &a_tile_size, Box &tbx)
Definition AMReX_ParticleUtil.H:222
BoxArray const & boxArray(FabArrayBase const &fa)
std::array< T, N > Array
Definition AMReX_Array.H:24
Definition AMReX_Dim3.H:12
Definition AMReX_NeighborParticles.H:152
int tile_id
Definition AMReX_NeighborParticles.H:161
int grid_id
Definition AMReX_NeighborParticles.H:160
Definition AMReX_NeighborParticles.H:82
int src_index
Definition AMReX_NeighborParticles.H:86
int tile
Definition AMReX_NeighborParticles.H:85
int grid
Definition AMReX_NeighborParticles.H:84
int level
Definition AMReX_NeighborParticles.H:83
IntVect periodic_shift
Definition AMReX_NeighborParticles.H:88
Definition AMReX_NeighborParticles.H:51
int thread_num
Definition AMReX_NeighborParticles.H:60
int src_level
Definition AMReX_NeighborParticles.H:56
int src_index
Definition AMReX_NeighborParticles.H:59
int src_grid
Definition AMReX_NeighborParticles.H:57
int dst_level
Definition AMReX_NeighborParticles.H:52
int src_tile
Definition AMReX_NeighborParticles.H:58