Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions Src/Extern/HDF5/AMReX_ParticleHDF5.H
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i) -> int
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
}, true);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i) -> int
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
});
}

Expand Down Expand Up @@ -140,7 +140,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i)
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
});
}

Expand Down Expand Up @@ -168,7 +168,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i)
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
});
}

Expand Down Expand Up @@ -202,7 +202,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i)
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
});
}

Expand Down Expand Up @@ -240,7 +240,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i)
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
});
}

Expand All @@ -263,7 +263,7 @@ WritePlotFileHDF5 (const std::string& dir, const std::string& name,
compression,
[=] AMREX_GPU_HOST_DEVICE (const ConstPTDType& ptd, int i)
{
return ptd.id(i) > 0;
return ptd.id(i).is_valid();
});
}

Expand Down Expand Up @@ -461,7 +461,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
const auto& aos = kv.second.GetArrayOfStructs();
for (int k = 0; k < aos.numParticles(); ++k) {
const ParticleType& p = aos[k];
if (p.id() > 0) {
if (p.id().is_valid()) {
//
// Only count (and checkpoint) valid particles.
//
Expand Down Expand Up @@ -1465,7 +1465,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
++iptr;
}

AMREX_ASSERT(p.id() > 0);
AMREX_ASSERT(p.id().is_valid());

AMREX_D_TERM(p.pos(0) = ParticleReal(rptr[0]);,
p.pos(1) = ParticleReal(rptr[1]);,
Expand Down
24 changes: 11 additions & 13 deletions Src/Extern/SENSEI/AMReX_ParticleDataAdaptorI.H
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::GetMeshMetadata(
for (long long i = 0; i < numReal; ++i)
{
const auto &part = ptd[i];
if (part.id() > 0)
if (part.id().is_valid())
{
#if (AMREX_SPACEDIM == 1)
bounds[0] = bounds[0] > part.pos(0) ? part.pos(0) : bounds[0];
Expand Down Expand Up @@ -690,8 +690,8 @@ svtkPolyData* ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::BuildPar

for (long long i = 0; i < numReal; ++i)
{
const auto& part = make_particle<ParticleType>{}(ptd, i);
if (part.id() > 0)
const auto& part = ptd[i];
if (part.id().is_valid())
{
// add a vertex type cell
vertex->InsertNextCell(1);
Expand Down Expand Up @@ -757,10 +757,9 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddParticlesIDArra
auto numReal = pti.numParticles();
for (long long i = 0; i < numReal; ++i)
{
const auto &part = make_particle<ParticleType>{}(ptd, i);
if (part.id() > 0)
if (ptd.id(i).is_valid())
{
partIds[i] = part.id();
partIds[i] = ptd.id(i);
}
}
partIds += numReal;
Expand Down Expand Up @@ -801,10 +800,9 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddParticlesCPUArr
auto numReal = pti.numParticles();
for (long long i = 0; i < numReal; ++i)
{
const auto &part = make_particle<ParticleType>{}(ptd, i);
if (part.id() > 0)
if (ptd.id(i).is_valid())
{
partCpu[i] = part.cpu();
partCpu[i] = ptd.cpu(i);
}
}
partCpu += numReal;
Expand Down Expand Up @@ -882,7 +880,7 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddParticlesSOARea
for (long long i = 0; i < numReal; ++i)
{
const auto &part = ptd[i];
if (part.id() > 0)
if (part.id().is_valid())
{
pData[i*nComps + j] = realData[i];
}
Expand Down Expand Up @@ -954,7 +952,7 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddParticlesSOAInt
for (long long i = 0; i < numReal; ++i)
{
const auto &part = ptd[i];
if (part.id() > 0)
if (part.id().is_valid())
{
pData[i] = intData[i];
}
Expand Down Expand Up @@ -1041,7 +1039,7 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddParticlesAOSRea
for (long long i = 0; i < numReal; ++i)
{
const auto &part = aos[i];
if (part.id() > 0)
if (part.id().is_valid())
{
pData[i*nComps + j] = part.rdata(indices[j]);
}
Expand Down Expand Up @@ -1114,7 +1112,7 @@ int ParticleDataAdaptor<ParticleType, NArrayReal, NArrayInt>::AddParticlesAOSInt
for (long long i = 0; i < numReal; ++i)
{
const auto &part = aos[i];
if (part.id() > 0)
if (part.id().is_valid())
{
pData[i] = part.idata(index);
}
Expand Down
62 changes: 31 additions & 31 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ Reset (ParticleType& p,
amrex::AllPrint()<< "Invalidating out-of-domain particle: " << p << '\n';
}

AMREX_ASSERT(p.id() > 0);
AMREX_ASSERT(p.id().is_valid());

p.id() = -p.id();
p.id().make_invalid();
}

return pld;
Expand Down Expand Up @@ -454,7 +454,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
if (!success && lev_min == 0)
{
// The particle has left the domain; invalidate it.
p.id() = -p.id();
p.id().make_invalid();
success = true;
}
}
Expand Down Expand Up @@ -516,7 +516,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
reduce_op.eval(np, reduce_data,
[=] AMREX_GPU_DEVICE (int i) -> ReduceTuple
{
return (ptd.id(i) > 0) ? 1 : 0;
return (ptd.id(i).is_valid()) ? 1 : 0;
});

int np_valid = amrex::get<0>(reduce_data.value(reduce_op));
Expand Down Expand Up @@ -566,7 +566,7 @@ Long ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, Cell
reduce_op.eval(ptile.numParticles(), reduce_data,
[=] AMREX_GPU_DEVICE (int i) -> ReduceTuple
{
return (ptd.id(i) > 0) ? 1 : 0;
return (ptd.id(i).is_valid()) ? 1 : 0;
});
}

Expand Down Expand Up @@ -715,7 +715,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
[=] AMREX_GPU_DEVICE (const typename ParticleTileType::ConstParticleTileDataType& ptd, int ip,
amrex::Array4<amrex::Real> const& count)
{
const auto p = make_particle<ConstParticleType>{}(ptd, ip);
const auto p = ptd[ip];
CellAssignor assignor;
IntVect iv = assignor(p, plo, dxi, domain);
amrex::Gpu::Atomic::AddNoRet(&count(iv), 1.0_rt);
Expand Down Expand Up @@ -792,7 +792,7 @@ struct FilterVirt
AMREX_GPU_HOST_DEVICE
int operator() (const SrcData& src, int src_i) const noexcept
{
auto iv = getParticleCell(src.m_aos[src_i], m_plo, m_dxi, m_domain);
auto iv = getParticleCell(src, src_i, m_plo, m_dxi, m_domain);
return (m_assign_buffer_grid(iv)!=-1);
}
};
Expand All @@ -806,8 +806,8 @@ struct TransformerVirt
{
copyParticle(dst, src, src_i, dst_i);

(dst.m_aos[dst_i]).id() = LongParticleIds::VirtualParticleID;
(dst.m_aos[dst_i]).cpu() = 0;
dst.id(dst_i) = LongParticleIds::VirtualParticleID;
dst.cpu(dst_i) = 0;
}
};

Expand Down Expand Up @@ -1035,8 +1035,8 @@ struct AssignGridFilter
AMREX_GPU_HOST_DEVICE
int operator() (const SrcData& src, int src_i) const noexcept
{
const auto tup_min = (m_assign_grid)(src.m_aos[src_i], m_lev_min, m_lev_max, m_nGrow, DefaultAssignor{});
const auto tup_max = (m_assign_grid)(src.m_aos[src_i], m_lev_max, m_lev_max, m_nGrow, DefaultAssignor{});
const auto tup_min = (m_assign_grid)(src[src_i], m_lev_min, m_lev_max, m_nGrow, DefaultAssignor{});
const auto tup_max = (m_assign_grid)(src[src_i], m_lev_max, m_lev_max, m_nGrow, DefaultAssignor{});
const auto p_boxes = amrex::get<0>(tup_min);
const auto p_boxes_max = amrex::get<0>(tup_max);
const auto p_levs_max = amrex::get<1>(tup_max);
Expand All @@ -1054,8 +1054,8 @@ struct TransformerGhost
{
copyParticle(dst, src, src_i, dst_i);

(dst.m_aos[dst_i]).id() = LongParticleIds::GhostParticleID;
(dst.m_aos[dst_i]).cpu() = 0;
dst.id(dst_i) = LongParticleIds::GhostParticleID;
dst.cpu(dst_i) = 0;
}
};

Expand Down Expand Up @@ -1497,9 +1497,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig

AMREX_FOR_1D ( num_move, i,
{
const auto p = make_particle<ParticleType>{}(ptd,i + num_stay);
const auto p = ptd[i + num_stay];

if (p.id() < 0)
if (!p.id().is_valid())
{
p_boxes[i] = -1;
p_levs[i] = -1;
Expand Down Expand Up @@ -1740,12 +1740,12 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
while (pindex <= last) {
ParticleType& p = aos[pindex];

if ((remove_negative == false) && (p.id() < 0)) {
if ((remove_negative == false) && (!p.id().is_valid())) {
++pindex;
continue;
}

if (p.id() < 0)
if (!p.id().is_valid())
{
aos[pindex] = aos[last];
for (int comp = 0; comp < NumRealComps(); comp++) {
Expand All @@ -1763,7 +1763,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig

particlePostLocate(p, pld, lev);

if (p.id() < 0)
if (!p.id().is_valid())
{
aos[pindex] = aos[last];
for (int comp = 0; comp < NumRealComps(); comp++) {
Expand Down Expand Up @@ -1793,7 +1793,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
arr.push_back(soa.GetIntData(comp)[pindex]);
}

p.id() = -p.id(); // Invalidate the particle
p.id().make_invalid(); // Invalidate the particle
}
}
else {
Expand Down Expand Up @@ -1821,10 +1821,10 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
}
}

p.id() = -p.id(); // Invalidate the particle
p.id().make_invalid(); // Invalidate the particle
}

if (p.id() < 0)
if (!p.id().is_valid())
{
aos[pindex] = aos[last];
for (int comp = 0; comp < NumRealComps(); comp++) {
Expand Down Expand Up @@ -1860,14 +1860,14 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
Long pindex = 0;
auto ptd = particle_tile->getParticleTileData();
while (pindex <= last) {
ParticleType p(ptd,pindex);
ParticleType p = ptd[pindex];

if ((remove_negative == false) && (p.id() < 0)) {
if ((remove_negative == false) && (!ptd.id(pindex).is_valid())) {
++pindex;
continue;
}

if (p.id() < 0){
if (!ptd.id(pindex).is_valid()){
soa.GetIdCPUData()[pindex] = soa.GetIdCPUData()[last];
for (int comp = 0; comp < NumRealComps(); comp++) {
soa.GetRealData(comp)[pindex] = soa.GetRealData(comp)[last];
Expand All @@ -1884,7 +1884,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig

particlePostLocate(p, pld, lev);

if (p.id() < 0) {
if (!ptd.id(pindex).is_valid()) {
soa.GetIdCPUData()[pindex] = soa.GetIdCPUData()[last];
for (int comp = 0; comp < NumRealComps(); comp++) {
soa.GetRealData(comp)[pindex] = soa.GetRealData(comp)[last];
Expand Down Expand Up @@ -1916,7 +1916,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
arr.push_back(soa.GetIntData(comp)[pindex]);
}

p.id() = -p.id(); // Invalidate the particle
ptd.id(pindex).make_invalid(); // Invalidate the particle
}
}
else {
Expand Down Expand Up @@ -1947,10 +1947,10 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
dst += sizeof(int);
}
}
p.id() = -p.id(); // Invalidate the particle
ptd.id(pindex).make_invalid(); // Invalidate the particle
}

if (p.id() < 0){
if (!ptd.id(pindex).is_valid()){
soa.GetIdCPUData()[pindex] = soa.GetIdCPUData()[last];
for (int comp = 0; comp < NumRealComps(); comp++) {
soa.GetRealData(comp)[pindex] = soa.GetRealData(comp)[last];
Expand Down Expand Up @@ -2504,7 +2504,7 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig

if (lev_max == -1) {
lev_max = finestLevel();
}
}

return (numParticlesOutOfRange(*this, lev_min, lev_max, nGrow) == 0);
}
Expand Down Expand Up @@ -2632,15 +2632,15 @@ AssignCellDensitySingleLevel (int rho_index,
{
AMREX_HOST_DEVICE_FOR_1D( np, i,
{
auto p = make_particle<ParticleType>{}(ptd,i);
auto p = ptd[i];
amrex_deposit_cic(p, ncomp, rhoarr, plo, dxi);
});
}
else
{
AMREX_HOST_DEVICE_FOR_1D( np, i,
{
auto p = make_particle<ParticleType>{}(ptd,i);
auto p = ptd[i];
amrex_deposit_particle_dx_cic(p, ncomp, rhoarr, plo, dxi, pdxi);
});
}
Expand Down
Loading
Loading