| 330 | } |
| 331 | |
| 332 | void ParticleContainerBase::BuildRedistributeMask (int lev, int nghost) const |
| 333 | { |
| 334 | BL_PROFILE("ParticleContainer::BuildRedistributeMask"); |
| 335 | AMREX_ASSERT(lev == 0); |
| 336 | |
| 337 | if (redistribute_mask_ptr == nullptr || |
| 338 | redistribute_mask_nghost < nghost || |
| 339 | ! BoxArray::SameRefs(redistribute_mask_ptr->boxArray(), this->ParticleBoxArray(lev)) || |
| 340 | ! DistributionMapping::SameRefs(redistribute_mask_ptr->DistributionMap(), this->ParticleDistributionMap(lev))) |
| 341 | { |
| 342 | const Geometry& geom = this->Geom(lev); |
| 343 | const BoxArray& ba = this->ParticleBoxArray(lev); |
| 344 | const DistributionMapping& dmap = this->ParticleDistributionMap(lev); |
| 345 | |
| 346 | redistribute_mask_nghost = nghost; |
| 347 | redistribute_mask_ptr = std::make_unique<iMultiFab>(ba, dmap, 2, nghost); |
| 348 | redistribute_mask_ptr->setVal(-1, nghost); |
| 349 | |
| 350 | const auto tile_size_do = amrex::ParticleContainerBase::do_tiling ? amrex::ParticleContainerBase::tile_size : IntVect::TheZeroVector(); |
| 351 | |
| 352 | #ifdef AMREX_USE_OMP |
| 353 | #pragma omp parallel |
| 354 | #endif |
| 355 | for (MFIter mfi(*redistribute_mask_ptr, tile_size_do); mfi.isValid(); ++mfi) |
| 356 | { |
| 357 | const Box& box = mfi.tilebox(); |
| 358 | const int grid_id = mfi.index(); |
| 359 | const int tile_id = mfi.LocalTileIndex(); |
| 360 | (*redistribute_mask_ptr)[mfi].template setVal<RunOn::Host>(grid_id, box, 0, 1); |
| 361 | (*redistribute_mask_ptr)[mfi].template setVal<RunOn::Host>(tile_id, box, 1, 1); |
| 362 | } |
| 363 | |
| 364 | redistribute_mask_ptr->FillBoundary(geom.periodicity()); |
| 365 | |
| 366 | neighbor_procs.clear(); |
| 367 | for (MFIter mfi(*redistribute_mask_ptr, tile_size_do); mfi.isValid(); ++mfi) |
| 368 | { |
| 369 | const Box& box = mfi.growntilebox(); |
| 370 | for (IntVect iv = box.smallEnd(); iv <= box.bigEnd(); box.next(iv)) |
| 371 | { |
| 372 | const int grid = (*redistribute_mask_ptr)[mfi](iv, 0); |
| 373 | if (grid >= 0) |
| 374 | { |
| 375 | const int global_rank = this->ParticleDistributionMap(lev)[grid]; |
| 376 | const int rank = ParallelContext::global_to_local_rank(global_rank); |
| 377 | if (rank != ParallelContext::MyProcSub()) { |
| 378 | neighbor_procs.push_back(rank); |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | RemoveDuplicates(neighbor_procs); |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | } |
nothing calls this directly
no test coverage detected