Skip to content

Commit

Permalink
another Redistribute optimization.
Browse files Browse the repository at this point in the history
atmyers committed Nov 7, 2017
1 parent ec98101 commit cb6b1ab
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
@@ -128,41 +128,37 @@ ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>::Where (const

std::vector< std::pair<int, Box> > isects;

for (int lev = lev_max; lev >= lev_min; lev--)
{
const IntVect& iv = Index(p, lev);
const BoxArray& ba = ParticleBoxArray(lev);
BL_ASSERT(ba.ixType().cellCentered());

if (lev == pld.m_lev) {
// The fact that we are here means this particle does not belong to any finer grids.
if (0 <= pld.m_grid && pld.m_grid < ba.size())
{
if (pld.m_grown_gridbox.contains(iv))
{
pld.m_cell = iv;
if (!pld.m_tilebox.contains(iv)) {
pld.m_tile = getTileIndex(iv, pld.m_gridbox, pld.m_tilebox);
}
return true;
}
}
}

ba.intersections(Box(iv, iv), isects, true, nGrow);

if (!isects.empty())
{
const Box& bx = ba.getCellCenteredBox(isects[0].first);
for (int lev = lev_max; lev >= lev_min; lev--) {
const IntVect& iv = Index(p, lev);
if (lev == pld.m_lev) {
// The fact that we are here means this particle does not belong to any finer grids.
if (pld.m_grid >= 0) {
if (pld.m_grown_gridbox.contains(iv)) {
pld.m_cell = iv;
if (!pld.m_tilebox.contains(iv)) {
pld.m_tile = getTileIndex(iv, pld.m_gridbox, pld.m_tilebox);
}
return true;
}
}
}

const BoxArray& ba = ParticleBoxArray(lev);
BL_ASSERT(ba.ixType().cellCentered());
ba.intersections(Box(iv, iv), isects, true, nGrow);

if (!isects.empty()) {
const Box& bx = ba.getCellCenteredBox(isects[0].first);
pld.m_lev = lev;
pld.m_grid = isects[0].first;
pld.m_tile = getTileIndex(iv, bx, pld.m_tilebox);
pld.m_cell = iv;
pld.m_gridbox = bx;
pld.m_grown_gridbox = amrex::grow(bx, nGrow);
return true;
}
}
}
}

return false;
}

0 comments on commit cb6b1ab

Please sign in to comment.