MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / BuildRedistributeMask

Method BuildRedistributeMask

Src/Particle/AMReX_ParticleContainerBase.cpp:332–385  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330}
331
332void 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}

Callers

nothing calls this directly

Calls 15

global_to_local_rankFunction · 0.85
MyProcSubFunction · 0.85
RemoveDuplicatesFunction · 0.85
DistributionMapMethod · 0.80
GeomMethod · 0.80
tileboxMethod · 0.80
LocalTileIndexMethod · 0.80
periodicityMethod · 0.80
growntileboxMethod · 0.80
boxArrayMethod · 0.45
setValMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected