Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reimplement SortParticlesByCell() in terms of SortParticlesByBin(), r… #1172

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 3 additions & 32 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -985,36 +985,7 @@ template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
void
ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>::SortParticlesByCell ()
{
BL_PROFILE("ParticleContainer::SortParticlesByCell()");

for (int lev = 0; lev < numLevels(); ++lev)
{
const Geometry& geom = Geom(lev);
const auto dxi = geom.InvCellSizeArray();
const auto plo = geom.ProbLoArray();
const auto domain = geom.Domain();

for(MFIter mfi = MakeMFIter(lev); mfi.isValid(); ++mfi)
{
auto& ptile = ParticlesAt(lev, mfi);
auto& aos = ptile.GetArrayOfStructs();
const size_t np = aos.numParticles();
auto pstruct_ptr = aos().dataPtr();

ParticleTileType ptile_tmp;
ptile_tmp.define(m_num_runtime_real, m_num_runtime_int);
ptile_tmp.resize(np);

m_bins.build(np, pstruct_ptr, mfi.tilebox(),
[=] AMREX_GPU_HOST_DEVICE (const ParticleType& p) noexcept -> IntVect
{
return getParticleCell(p, plo, dxi, domain);
});

gatherParticles(ptile_tmp, ptile, np, m_bins.permutationPtr());
ptile.swap(ptile_tmp);
}
}
SortParticlesByBin(IntVect(AMREX_D_DECL(1, 1, 1)));
}

template <int NStructReal, int NStructInt, int NArrayReal, int NArrayInt>
Expand Down Expand Up @@ -1043,13 +1014,13 @@ ParticleContainer<NStructReal, NStructInt, NArrayReal, NArrayInt>::SortParticles

const Box& box = mfi.tilebox();
IntVect lo = box.smallEnd();

m_bins.build(np, pstruct_ptr, mfi.tilebox(),
[=] AMREX_GPU_HOST_DEVICE (const ParticleType& p) noexcept -> IntVect
{
return (getParticleCell(p, plo, dxi, domain) - lo) / bin_size;
});

gatherParticles(ptile_tmp, ptile, np, m_bins.permutationPtr());
ptile.swap(ptile_tmp);
}
Expand Down