2 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
3 bool NeighborParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>::use_mask =
false;
5 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
6 bool NeighborParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>::enable_inverse =
false;
8 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
9 NeighborParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>
10 ::NeighborParticleContainer (
ParGDBBase* gdb,
int ncells)
12 m_num_neighbor_cells(ncells)
17 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
23 :
ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt> (geom, dmap, ba),
24 m_num_neighbor_cells(nneighbor)
26 initializeCommComps();
29 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
36 :
ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt> (geom, dmap, ba, rr),
37 m_num_neighbor_cells(nneighbor)
39 initializeCommComps();
42 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
46 for (
int ii = 0; ii < AMREX_SPACEDIM + NStructReal + this->NumRealComps(); ++ii) {
47 ghost_real_comp.push_back(1);
49 for (
int ii = 0; ii < 2 + NStructInt + this->NumIntComps(); ++ii) {
50 ghost_int_comp.push_back(1);
55 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
59 ghost_real_comp[i] = value;
63 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
67 ghost_int_comp[i] = value;
71 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
76 for (
int ii = 0; ii < AMREX_SPACEDIM + NStructReal + this->NumRealComps(); ++ii) {
77 if (ghost_real_comp[ii]) {
78 comm_size +=
sizeof(
typename ParticleType::RealType);
81 for (
int ii = 0; ii < 2 + NStructInt + this->NumIntComps(); ++ii) {
82 if (ghost_int_comp[ii]) {
83 comm_size +=
sizeof(
int);
86 if ( enableInverse() ) { comm_size += 4*
sizeof(
int); }
87 cdata_size = comm_size;
90 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
96 this->SetParticleBoxArray(lev, ba);
97 this->SetParticleDistributionMap(lev, dmap);
101 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
106 this->SetParticleBoxArray(lev, ba);
107 this->SetParticleDistributionMap(lev, dmap);
108 this->Redistribute();
111 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
116 for (
int lev = 0; lev < this->numLevels(); ++lev)
118 this->SetParticleBoxArray(lev, ba[lev]);
119 this->SetParticleDistributionMap(lev, dmap[lev]);
121 this->Redistribute();
124 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
129 BL_PROFILE(
"NeighborParticleContainer::areMasksValid");
131 resizeContainers(this->numLevels());
133 for (
int lev = 0; lev < this->numLevels(); ++lev)
135 BoxArray ba = this->ParticleBoxArray(lev);
138 if (mask_ptr[lev] ==
nullptr ||
148 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
153 BL_PROFILE(
"NeighborParticleContainer::BuildMasks");
155 if (this->numLevels() == 1) { use_mask =
true; }
156 else { use_mask =
false; }
158 resizeContainers(this->numLevels());
160 for (
int lev = 0; lev < this->numLevels(); ++lev)
162 BoxArray ba = this->ParticleBoxArray(lev);
165 const Geometry& geom = this->Geom(lev);
167 mask_ptr[lev] = std::make_unique<iMultiFab>(ba, dmap,
int(num_mask_comps), m_num_neighbor_cells);
168 mask_ptr[lev]->setVal(-1, m_num_neighbor_cells);
175 const Box& box = mfi.tilebox();
176 const int grid_id = mfi.
index();
177 const int tile_id = mfi.LocalTileIndex();
178 (*mask_ptr[lev])[mfi].
template setVal<RunOn::Host>(grid_id, box, MaskComps::grid, 1);
179 (*mask_ptr[lev])[mfi].
template setVal<RunOn::Host>(tile_id, box, MaskComps::tile, 1);
180 (*mask_ptr[lev])[mfi].
template setVal<RunOn::Host>(lev , box, MaskComps::level, 1);
187 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
192 BL_PROFILE(
"NeighborParticleContainer::GetNeighborCommTags");
194 local_neighbors.clear();
195 neighbor_procs.clear();
203 const Box& box = mfi.growntilebox();
205 const int grid = (*mask_ptr[lev])[mfi](iv, MaskComps::grid);
207 const int tile = (*mask_ptr[lev])[mfi](iv, MaskComps::tile);
208 const int level = (*mask_ptr[lev])[mfi](iv, MaskComps::level);
209 const int global_proc = this->ParticleDistributionMap(level)[grid];
212 local_neighbors.push_back(comm_tag);
214 neighbor_procs.push_back(proc);
222 for (
int lev = 0; lev < this->numLevels(); ++lev)
226 const Box& box = mfi.validbox();
228 GetCommTagsBox(comm_tags, lev, box);
229 for (
auto const& tag : comm_tags) {
230 local_neighbors.push_back(tag);
232 neighbor_procs.push_back(tag.proc_id);
243 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
250 for (
int l = src_lev; l < lev; ++l) {
251 ref_fac *= this->GetParGDB()->refRatio(l);
253 }
else if (src_lev > lev) {
254 for (
int l = src_lev; l > lev; --l) {
255 ref_fac *= this->GetParGDB()->refRatio(l-1);
262 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
267 std::vector< std::pair<int, Box> > isects;
270 for (
int lev = 0; lev < this->numLevels(); ++lev) {
282 const Periodicity& periodicity = this->Geom(lev).periodicity();
283 const std::vector<IntVect>& pshifts = periodicity.
shiftIntVect();
284 const BoxArray& ba = this->ParticleBoxArray(lev);
286 for (
auto const& pshift : pshifts)
288 const Box& pbox = box + pshift;
289 bool first_only =
false;
291 for (
const auto& isec : isects) {
292 const int grid = isec.first;
293 const int global_proc = this->ParticleDistributionMap(lev)[grid];
297 if (ba[grid].contains(iv))
300 this->do_tiling, this->tile_size, tbx);
309 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
314 BL_PROFILE(
"NeighborParticleContainer::cacheNeighborInfo");
318 resizeContainers(this->numLevels());
327 std::map<NeighborCommTag, Vector<NeighborIndexMap> > remote_map;
331 std::map<NeighborCommTag, Vector<Vector<NeighborIndexMap> > > tmp_remote_map;
333 local_map.resize(this->numLevels());
334 tmp_local_map.resize(this->numLevels());
338 for (
int lev = 0; lev < this->numLevels(); ++lev) {
340 for (
int i = 0; i < static_cast<int>(local_neighbors.size()); ++i) {
342 tmp_remote_map[comm_tag].resize(num_threads);
343 remote_map[comm_tag];
345 tmp_local_map[lev][index].resize(num_threads);
346 local_map[lev][index];
347 buffer_tag_cache[lev][index].resize(num_threads);
351 for (
int lev = 0; lev < this->numLevels(); ++lev) {
362 const int& grid = pti.index();
363 const int& tile = pti.LocalTileIndex();
368 auto& cache = buffer_tag_cache[lev][src_index][thread_num];
370 auto& particles = pti.GetArrayOfStructs();
371 for (
int i = 0; i < pti.numParticles(); ++i) {
374 getNeighborTags(tags, p, m_num_neighbor_cells, src_tag, pti);
377 for (
int j = 0; j < static_cast<int>(tags.
size()); ++j) {
380 if (tag.
grid < 0) {
continue; }
383 const int cache_index = cache.size();
384 cache.push_back(tag);
386 const int global_who = this->ParticleDistributionMap(tag.
level)[tag.
grid];
389 lev, src_index.first, src_index.second,
390 cache_index, thread_num);
392 auto& tmp = tmp_local_map[tag.
level][dst_index];
394 buffer.push_back(nim);
398 buffer.push_back(nim);
407 for (
int lev = 0; lev < this->numLevels(); ++lev) {
412 for (
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi) {
413 const int grid = mfi.index();
414 const int tile = mfi.LocalTileIndex();
416 for (
int i = 0; i < num_threads; ++i) {
417 local_map[lev][index].insert(local_map[lev][index].
end(),
418 tmp_local_map[lev][index][i].
begin(),
419 tmp_local_map[lev][index][i].
end());
420 tmp_local_map[lev][index][i].erase(tmp_local_map[lev][index][i].
begin(),
421 tmp_local_map[lev][index][i].
end());
427 typename std::map<NeighborCommTag, Vector<Vector<NeighborIndexMap> > >::iterator it;
430 #pragma omp single nowait
432 for (it=tmp_remote_map.begin(); it != tmp_remote_map.end(); it++) {
434 #pragma omp task firstprivate(it)
439 for (
int i = 0; i < num_threads; ++i) {
440 remote_map[tag].insert(remote_map[tag].
end(), tmp[i].
begin(), tmp[i].
end());
441 tmp[i].erase(tmp[i].
begin(), tmp[i].
end());
446 for (
int lev = 0; lev < this->numLevels(); ++lev) {
448 for (
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi) {
449 const int grid = mfi.index();
450 const int tile = mfi.LocalTileIndex();
453 const int num_ghosts = map.
size();
454 neighbors[lev][dst_index].define(this->NumRuntimeRealComps(),
455 this->NumRuntimeIntComps());
456 neighbors[lev][dst_index].resize(num_ghosts);
457 local_neighbor_sizes[lev][dst_index] = neighbors[lev][dst_index].size();
461 for (
int lev = 0; lev < this->numLevels(); ++lev) {
462 for (
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi) {
463 const int grid = mfi.index();
464 const int tile = mfi.LocalTileIndex();
467 const int num_ghosts = map.
size();
469 #pragma omp parallel for
471 for (
int i = 0; i < num_ghosts; ++i) {
483 std::map<int, int> tile_counts;
484 for (
const auto& kv: remote_map) {
485 tile_counts[kv.first.proc_id] += 1;
488 for (
const auto& kv: remote_map) {
489 if (kv.first.proc_id ==
MyProc) {
continue; }
491 buffer.resize(
sizeof(
int));
492 std::memcpy(buffer.data(), &tile_counts[kv.first.proc_id],
sizeof(
int));
495 for (
auto& kv : remote_map) {
496 if (kv.first.proc_id ==
MyProc) {
continue; }
497 int np = kv.second.size();
498 int data_size = np * cdata_size;
500 size_t old_size = buffer.
size();
501 size_t new_size = buffer.
size() + 4*
sizeof(
int) + data_size;
502 buffer.resize(new_size);
503 char* dst = &buffer[old_size];
504 std::memcpy(dst, &(kv.first.level_id),
sizeof(
int)); dst +=
sizeof(
int);
505 std::memcpy(dst, &(kv.first.grid_id ),
sizeof(
int)); dst +=
sizeof(
int);
506 std::memcpy(dst, &(kv.first.tile_id ),
sizeof(
int)); dst +=
sizeof(
int);
508 size_t buffer_offset = old_size + 4*
sizeof(
int);
510 #pragma omp parallel for
512 for (
int i = 0; i < np; ++i) {
516 tags[nim.
src_index].dst_index = buffer_offset + i*cdata_size;
520 if ( enableInverse() )
522 for (
int lev = 0; lev < this->numLevels(); ++lev)
524 for (
const auto& kv : neighbors[lev])
526 inverse_tags[lev][kv.first].resize(kv.second.size());
532 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
541 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
548 shrink_box.
grow(-nGrow);
556 const IntVect& iv = this->Index(p, lev);
557 if (shrink_box.
contains(iv)) {
return; }
559 const Periodicity& periodicity = this->Geom(lev).periodicity();
560 const Box& domain = this->Geom(lev).Domain();
566 for (
int ii = -nGrow[0]; ii < nGrow[0] + 1; ii += nGrow[0]) {,
567 for (
int jj = -nGrow[1]; jj < nGrow[1] + 1; jj += nGrow[1]) {,
568 for (
int kk = -nGrow[2]; kk < nGrow[2] + 1; kk += nGrow[2]) {)
569 if (
AMREX_D_TERM((ii == 0), && (jj == 0), && (kk == 0))) {
continue; }
574 tag.
grid =
mask(neighbor_cell, MaskComps::grid);
575 tag.
tile =
mask(neighbor_cell, MaskComps::tile);
576 tag.
level =
mask(neighbor_cell, MaskComps::level);
578 for (
int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
579 if (! periodicity.
isPeriodic(dir)) {
continue; }
580 if (neighbor_cell[dir] < lo[dir]) {
582 }
else if (neighbor_cell[dir] > hi[dir]) {
588 if (tag != src_tag) { tags.push_back(tag); }
600 std::vector< std::pair<int, Box> > isects;
602 for (
int lev = 0; lev < this->numLevels(); ++lev)
605 const Periodicity& periodicity = this->Geom(lev).periodicity();
606 const std::vector<IntVect>& pshifts = periodicity.
shiftIntVect();
607 const BoxArray& ba = this->ParticleBoxArray(lev);
608 const IntVect& iv = this->Index(p, lev);
609 for (
auto const& pshift : pshifts)
612 bool first_only =
false;
614 for (
const auto& isec : isects)
616 const Box& grid_box = ba[isec.first];
618 if ( !grid_box.
contains(cell) ) {
continue; }
620 this->do_tiling, this->tile_size, tbx);
622 nbor.periodic_shift = -pshift;
623 if (src_tag != nbor) { tags.push_back(nbor); }
634 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
643 m_has_neighbors =
true;
646 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
650 int int_start_comp,
int int_num_comp) {
655 sumNeighborsCPU(real_start_comp, real_num_comp, int_start_comp, int_num_comp);
659 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
668 updateNeighborsGPU(boundary_neighbors_only);
671 updateNeighborsCPU(
true);
673 m_has_neighbors =
true;
676 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
686 m_has_neighbors =
false;
689 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
690 template <
class CheckPair>
697 BL_PROFILE(
"NeighborParticleContainer::buildNeighborList");
699 resizeContainers(this->numLevels());
701 for (
int lev = 0; lev < this->numLevels(); ++lev)
703 m_neighbor_list[lev].clear();
706 PairIndex index(pti.index(), pti.LocalTileIndex());
707 m_neighbor_list[lev][index];
710 #ifndef AMREX_USE_GPU
711 neighbor_list[lev].clear();
713 PairIndex index(pti.index(), pti.LocalTileIndex());
714 neighbor_list[lev][index];
718 auto& plev = this->GetParticles(lev);
719 const auto& geom = this->Geom(lev);
722 #pragma omp parallel if (Gpu::notInLaunchRegion())
726 int gid = pti.index();
727 int tid = pti.LocalTileIndex();
728 auto index = std::make_pair(gid, tid);
730 auto& ptile = plev[index];
732 if (ptile.numParticles() == 0) {
continue; }
734 Box bx = pti.tilebox();
748 dxi_v.
push_back(geom.InvCellSizeArray());
751 m_neighbor_list[lev][index].build(ptile,
753 off_bins_v, dxi_v, plo_v, lo_v, hi_v, ng);
755 #ifndef AMREX_USE_GPU
756 const auto& counts = m_neighbor_list[lev][index].GetCounts();
757 const auto& list = m_neighbor_list[lev][index].GetList();
760 for (
int i = 0; i < ptile.numParticles(); ++i)
762 auto cnt = counts[i];
763 neighbor_list[lev][index].push_back(cnt);
764 for (
size_t j = 0; j < cnt; ++j)
766 neighbor_list[lev][index].push_back(list[li++]+1);
774 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
775 template <
class CheckPair,
class OtherPCType>
782 BL_PROFILE(
"NeighborParticleContainer::buildNeighborList");
791 resizeContainers(this->numLevels());
792 neighbor_lists.resize(this->numLevels());
794 for (
int lev = 0; lev < this->numLevels(); ++lev)
796 neighbor_lists[lev].clear();
799 PairIndex index(pti.index(), pti.LocalTileIndex());
800 neighbor_lists[lev][index];
803 auto& plev = this->GetParticles(lev);
804 const auto& geom = this->Geom(lev);
807 #pragma omp parallel if (Gpu::notInLaunchRegion())
811 int gid = pti.index();
812 int tid = pti.LocalTileIndex();
813 auto index = std::make_pair(gid, tid);
815 const auto& ptile = plev[index];
816 auto& other_ptile = other.ParticlesAt(lev, pti);
817 if (ptile.numParticles() == 0) {
continue; }
819 Box bx = pti.tilebox();
833 dxi_v.
push_back(geom.InvCellSizeArray());
836 neighbor_lists[lev][index].build(ptile, other_ptile,
838 off_bins_v, dxi_v, plo_v, lo_v, hi_v, ng);
843 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
844 template <
class CheckPair>
848 int num_bin_types,
bool )
852 if (num_bin_types == 1) {
AMREX_ASSERT(ref_ratio[0] == 1); }
854 BL_PROFILE(
"NeighborParticleContainer::buildNeighborList");
856 resizeContainers(this->numLevels());
858 for (
int lev = 0; lev < this->numLevels(); ++lev)
860 m_neighbor_list[lev].clear();
863 PairIndex index(pti.index(), pti.LocalTileIndex());
864 m_neighbor_list[lev][index];
867 #ifndef AMREX_USE_GPU
868 neighbor_list[lev].clear();
870 PairIndex index(pti.index(), pti.LocalTileIndex());
871 neighbor_list[lev][index];
875 auto& plev = this->GetParticles(lev);
876 const auto& geom = this->Geom(lev);
879 #pragma omp parallel if (Gpu::notInLaunchRegion())
883 int gid = pti.index();
884 int tid = pti.LocalTileIndex();
885 auto index = std::make_pair(gid, tid);
886 auto& ptile = plev[index];
888 if (ptile.numParticles() == 0) {
continue; }
890 Box bx = pti.tilebox();
893 auto& soa = pti.GetStructOfArrays();
894 auto TypeVec = soa.GetIntData(type_ind);
895 int* bin_type_array = TypeVec.data();
904 for (
int type(0); type<num_bin_types; ++type) {
906 Box dom = geom.Domain();
907 const Real* plo = geom.ProbLo();
908 const Real* phi = geom.ProbHi();
909 auto lcoord = geom.Coord();
915 lbx.
refine( ref_ratio[type] );
916 ldom.
refine( ref_ratio[type] );
922 Geometry lgeom(ldom,lrb,lcoord,lper);
925 int NGhost = ref_ratio[type]*m_num_neighbor_cells;
953 m_neighbor_list[lev][index].build(ptile,
955 off_bins_v, dxi_v, plo_v, lo_v, hi_v,
956 ng, num_bin_types, bin_type_array);
958 #ifndef AMREX_USE_GPU
961 const auto& counts = m_neighbor_list[lev][index].GetCounts();
962 const auto& list = m_neighbor_list[lev][index].GetList();
965 for (
int i = 0; i < ptile.numParticles(); ++i) {
966 auto cnt = counts[i];
967 neighbor_list[lev][index].push_back(cnt);
968 for (
size_t j = 0; j < cnt; ++j) {
969 neighbor_list[lev][index].push_back(list[li++]+1);
979 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
980 template <
class CheckPair>
985 BL_PROFILE(
"NeighborParticleContainer::selectActualNeighbors");
986 const auto& geom_fine = this->Geom(0);
987 const auto& ba_fine = this->ParticleBoxArray(0);
988 if (ba_fine.size() == 1 && !geom_fine.isAnyPeriodic()) {
992 for (
int lev = 0; lev < this->numLevels(); ++lev)
995 if (!m_boundary_particle_ids.empty()) {
996 for (
auto& keyval: m_boundary_particle_ids[lev]) {
997 keyval.second.clear();
1002 PairIndex index(pti.index(), pti.LocalTileIndex());
1005 m_boundary_particle_ids[lev][index];
1006 m_boundary_particle_ids[lev][index].resize(pti.numNeighborParticles());
1007 auto* p_boundary_particle_ids = m_boundary_particle_ids[lev][index].dataPtr();
1009 const auto& aos = pti.GetArrayOfStructs();
1010 const auto* pstruct = aos().dataPtr();
1011 const auto ptile_data = this->ParticlesAt(lev, pti).getConstParticleTileData();
1013 Box box = pti.validbox();
1014 Box grownBox = pti.tilebox();
1016 const auto lo =
lbound(grownBox);
1017 const auto hi =
ubound(grownBox);
1019 const auto& geom = this->Geom(lev);
1020 const auto domain = geom.Domain();
1021 const auto dxi = geom.InvCellSizeArray();
1022 const auto plo = geom.ProbLoArray();
1024 const size_t np_real = pti.numRealParticles();
1025 const size_t np_total = aos().size();
1028 bins.
build(np_total, pstruct, grownBox,
1031 AMREX_D_TERM(
int i =
static_cast<int>(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0]) - lo.x);,
1032 int j =
static_cast<int>(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1]) - lo.y);,
1033 int k =
static_cast<int>(amrex::Math::floor((p.pos(2)-plo[2])*dxi[2]) - lo.z));
1043 unsigned int* p_np_boundary = np_boundary.
data();
1048 static_cast<int>(amrex::Math::floor((pstruct[i].pos(0)-plo[0])*dxi[0])) - lo.x,
1049 static_cast<int>(amrex::Math::floor((pstruct[i].pos(1)-plo[1])*dxi[1])) - lo.y,
1050 static_cast<int>(amrex::Math::floor((pstruct[i].pos(2)-plo[2])*dxi[2])) - lo.z));
1051 auto iv3 = iv.
dim3();
1057 int nx = hi.x-lo.x+1;
1058 int ny = hi.y-lo.y+1;
1059 int nz = hi.z-lo.z+1;
1061 bool isActualNeighbor =
false;
1065 if (isActualNeighbor) {
break; }
1066 int nbr_cell_id = (ii * ny + jj) * nz + kk;
1067 for (
auto p = poffset[nbr_cell_id]; p < poffset[nbr_cell_id+1]; ++p) {
1068 if (pperm[p] ==
int(i)) {
continue; }
1073 p_boundary_particle_ids[loc] = i;
1074 isActualNeighbor =
true;
1084 unsigned int* p_np_boundary_h = np_boundary.copyToHost();
1085 m_boundary_particle_ids[lev][index].resize(*p_np_boundary_h);
1090 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
1095 BL_PROFILE(
"NeighborParticleContainer::printNeighborList");
1097 for (
int lev = 0; lev < this->numLevels(); ++lev)
1099 for(
MFIter mfi = this->MakeMFIter(lev); mfi.
isValid(); ++mfi)
1101 int gid = mfi.index();
1102 int tid = mfi.LocalTileIndex();
1103 auto index = std::make_pair(gid, tid);
1104 m_neighbor_list[lev][index].print();
1109 template <
int NStructReal,
int NStructInt,
int NArrayReal,
int NArrayInt>
1114 this->reserveData();
1116 if (
static_cast<int>(neighbors.size()) <= num_levels )
1118 neighbors.resize(num_levels);
1119 m_neighbor_list.resize(num_levels);
1120 neighbor_list.resize(num_levels);
1121 mask_ptr.resize(num_levels);
1122 buffer_tag_cache.resize(num_levels);
1123 local_neighbor_sizes.resize(num_levels);
1124 if ( enableInverse() ) { inverse_tags.resize(num_levels); }
1127 AMREX_ASSERT((neighbors.size() == m_neighbor_list.size()) &&
1128 (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_GpuLaunch.nolint.H:41
#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
#define AMREX_D_DECL(a, b, c)
Definition: AMReX_SPACE.H:104
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
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:819
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 & 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 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 BoxND & grow(int i) noexcept
Definition: AMReX_Box.H:627
AMREX_GPU_HOST_DEVICE IndexTypeND< dim > ixType() const noexcept
Returns the indexing type.
Definition: AMReX_Box.H:127
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 > & bigEnd() const &noexcept
Get the bigend.
Definition: AMReX_Box.H:116
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 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
GpuArray< Real, AMREX_SPACEDIM > InvCellSizeArray() const noexcept
Definition: AMReX_CoordSys.H:87
index_type * offsetsPtr() noexcept
returns the pointer to the offsets array
Definition: AMReX_DenseBins.H:510
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
index_type * permutationPtr() noexcept
returns the pointer to the permutation array
Definition: AMReX_DenseBins.H:507
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:164
Rectangular problem domain geometry.
Definition: AMReX_Geometry.H:73
GpuArray< Real, AMREX_SPACEDIM > ProbLoArray() const noexcept
Definition: AMReX_Geometry.H:186
Periodicity periodicity() const noexcept
Definition: AMReX_Geometry.H:355
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 AMREX_FORCE_INLINE int max() const noexcept
maximum (no absolute values) value
Definition: AMReX_IntVect.H:214
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE 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:672
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
void GetNeighborCommTags()
Definition: AMReX_NeighborParticlesI.H:190
std::pair< int, int > PairIndex
Definition: AMReX_NeighborParticles.H:196
void selectActualNeighbors(CheckPair const &check_pair, int num_cells=1)
bool areMasksValid()
Definition: AMReX_NeighborParticlesI.H:127
void clearNeighbors()
Definition: AMReX_NeighborParticlesI.H:679
void fillNeighbors()
Definition: AMReX_NeighborParticlesI.H:637
void cacheNeighborInfo()
Definition: AMReX_NeighborParticlesI.H:312
void resizeContainers(int num_levels)
Definition: AMReX_NeighborParticlesI.H:1112
void setIntCommComp(int i, bool value)
Definition: AMReX_NeighborParticlesI.H:66
void updateNeighbors(bool boundary_neighbors_only=false)
Definition: AMReX_NeighborParticlesI.H:662
void buildNeighborList(CheckPair const &check_pair, bool sort=false)
void sumNeighbors(int real_start_comp, int real_num_comp, int int_start_comp, int int_num_comp)
Definition: AMReX_NeighborParticlesI.H:649
void getNeighborTags(Vector< NeighborCopyTag > &tags, const ParticleType &p, int nGrow, const NeighborCopyTag &src_tag, const MyParIter &pti)
Definition: AMReX_NeighborParticlesI.H:535
void setRealCommComp(int i, bool value)
Definition: AMReX_NeighborParticlesI.H:58
void initializeCommComps()
Definition: AMReX_NeighborParticlesI.H:45
void calcCommSize()
Definition: AMReX_NeighborParticlesI.H:74
void printNeighborList()
Definition: AMReX_NeighborParticlesI.H:1093
typename ParticleContainerType::ParticleType ParticleType
Definition: AMReX_NeighborParticles.H:38
void GetCommTagsBox(Vector< NeighborCommTag > &tags, int lev, const Box &in_box)
Definition: AMReX_NeighborParticlesI.H:265
void Regrid(const DistributionMapping &dmap, const BoxArray &ba)
Definition: AMReX_NeighborParticlesI.H:93
NeighborParticleContainer(ParGDBBase *gdb, int ncells)
Definition: AMReX_NeighborParticlesI.H:10
IntVect computeRefFac(int src_lev, int lev)
Definition: AMReX_NeighborParticlesI.H:246
void BuildMasks()
Definition: AMReX_NeighborParticlesI.H:151
Definition: AMReX_PODVector.H:246
T * data() noexcept
Definition: AMReX_PODVector.H:593
iterator begin() noexcept
Definition: AMReX_PODVector.H:601
iterator end() noexcept
Definition: AMReX_PODVector.H:605
void push_back(const T &a_value)
Definition: AMReX_PODVector.H:556
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:145
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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void * memcpy(void *dest, const void *src, std::size_t count)
Definition: AMReX_GpuUtility.H:214
void htod_memcpy_async(void *p_d, const void *p_h, const std::size_t sz) noexcept
Definition: AMReX_GpuDevice.H:251
int MyProc()
Definition: AMReX_MPMD.cpp:117
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
constexpr int iz
Definition: AMReX_Interp_3D_C.H:37
constexpr int iy
Definition: AMReX_Interp_2D_C.H:33
constexpr int ix
Definition: AMReX_Interp_2D_C.H:32
DistributionMapping const & DistributionMap(FabArrayBase const &fa)
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
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 constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
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 constexpr AMREX_FORCE_INLINE 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
BoxArray const & boxArray(FabArrayBase const &fa)
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 void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
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
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:225
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:190
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
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