Skip to content
Closed
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
28 changes: 14 additions & 14 deletions Src/Extern/HDF5/AMReX_ParticleHDF5.H
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
WriteHDF5ParticleData(dir, name, write_real_comp, write_int_comp,
tmp_real_comp_names, tmp_int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p) -> int
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i) -> int
{
return p.id() > 0;
return ptd.id(i) > 0;
}, true);
}

Expand Down Expand Up @@ -102,9 +102,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
WriteHDF5ParticleData(dir, name, write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p) -> int
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i) -> int
{
return p.id() > 0;
return ptd.id(i) > 0;
});
}

Expand Down Expand Up @@ -138,9 +138,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
WriteHDF5ParticleData(dir, name, write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i)
{
return p.id() > 0;
return ptd.id(i) > 0;
});
}

Expand All @@ -166,9 +166,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i)
{
return p.id() > 0;
return ptd.id(i) > 0;
});
}

Expand Down Expand Up @@ -200,9 +200,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const ParticleType& p)
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i)
{
return p.id() > 0;
return ptd.id(i) > 0;
});
}

Expand Down Expand Up @@ -238,9 +238,9 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
WriteHDF5ParticleData(dir, name, write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i)
{
return p.id() > 0;
return ptd.id(i) > 0;
});
}

Expand All @@ -261,9 +261,9 @@ WritePlotFileHDF5 (const std::string& dir, const std::string& name,
write_real_comp, write_int_comp,
real_comp_names, int_comp_names,
compression,
[=] AMREX_GPU_HOST_DEVICE (const SuperParticleType& p)
[=] AMREX_GPU_HOST_DEVICE (const PTDType& ptd, int i)
{
return p.id() > 0;
return ptd.id(i) > 0;
});
}

Expand Down
7 changes: 7 additions & 0 deletions Src/Particle/AMReX_Particle.H
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ struct alignas(sizeof(double)) Particle

//! The floating point type used for the particles.
using RealType = ParticleReal;
using IntType = int;

static Long the_next_id;

Expand Down Expand Up @@ -366,6 +367,12 @@ struct alignas(sizeof(double)) Particle
#endif
}

[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
uint64_t& idcpu () & { return this->m_idcpu; }

[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
const uint64_t& idcpu () const & { return this->m_idcpu; }

[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
RealVect pos () const & {return RealVect(AMREX_D_DECL(this->m_pos[0], this->m_pos[1], this->m_pos[2]));}

Expand Down
1 change: 1 addition & 0 deletions Src/Particle/AMReX_ParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public:
//! A single level worth of particles is indexed (grid id, tile id)
//! for both SoA and AoS data.
using ParticleLevel = std::map<std::pair<int, int>, ParticleTileType>;
using PTDType = typename ParticleTileType::ParticleTileDataType;
using AoS = typename ParticleTileType::AoS;
using SoA = typename ParticleTileType::SoA;

Expand Down
77 changes: 41 additions & 36 deletions Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -954,42 +954,47 @@ ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssig
auto dst = virts.getParticleTileData();
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k)
{
if(imf_arr(i,j,k,0)!=0)
{
SuperParticleType p;
p.cpu() = 0;
p.id() = LongParticleIds::VirtualParticleID;

//Set rdata(0) first so we can normalize the weighted fields
p.rdata(0) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM));
//Set pos with the normalized weighted field
for (int n = 0; n < AMREX_SPACEDIM; ++n)
{
p.pos(n) = static_cast<ParticleReal>(partData(i,j,k,n) / p.rdata(0));
}
//Set rdata(n>0) with the normalized weighted field for NStructReal
for (int n = 1; n < NStructReal; ++n)
{
p.rdata(n) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM+n) / p.rdata(0));
}
//Set rdata(n>0) with the normalized weighted field for NArrayReal
for (int n = 0; n < NArrayReal; ++n)
{
p.rdata(NStructReal+n) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM+NStructReal+n));
}
//Set idata with the "first" particles idata field for NStructInt
for (int n = 0; n < NStructInt; ++n)
{
p.idata(n) = imf_arr(i,j,k,1+n);
}
//Set idata with the "first" particles idata field for NArrayInt
for (int n = 0; n < NArrayInt; ++n)
{
p.idata(NStructInt+n) = imf_arr(i,j,k,1+NStructInt+n);
}
//Set the new particle in dst tile
dst.setSuperParticle(p, last_offset+offsets_ptr[((i-imf_arr.begin.x)+(j-imf_arr.begin.y)*imf_arr.jstride+(k-imf_arr.begin.z)*imf_arr.kstride)]);
}
if(imf_arr(i,j,k,0)!=0)
{
const auto idx = last_offset + offsets_ptr[
((i-imf_arr.begin.x)
+(j-imf_arr.begin.y)*imf_arr.jstride
+(k-imf_arr.begin.z)*imf_arr.kstride)
];

dst.cpu() = 0;
dst.id(idx) = LongParticleIds::VirtualParticleID;

auto& p = dst[idx];
//Set rdata(0) first so we can normalize the weighted fields
//Note that this does not work for soa PC
p.rdata(0) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM));;
//Set pos with the normalized weighted field
for (int n = 0; n < AMREX_SPACEDIM; ++n)
{
p.pos(n) = static_cast<ParticleReal>(partData(i,j,k,n) / p.rdata(0));
}
//Set rdata(n>0) with the normalized weighted field for NStructReal
for (int n = 1; n < NStructReal; ++n)
{
p.rdata(n) = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM+n) / p.rdata(0));
}
//Set rdata(n>0) with the normalized weighted field for NArrayReal
for (int n = 0; n < NArrayReal; ++n)
{
dst.rdata(n)[idx] = static_cast<ParticleReal>(partData(i,j,k,AMREX_SPACEDIM+NStructReal+n));
}
//Set idata with the "first" particles idata field for NStructInt
for (int n = 0; n < NStructInt; ++n)
{
p.idata(n) = imf_arr(i,j,k,1+n);
}
//Set idata with the "first" particles idata field for NArrayInt
for (int n = 0; n < NArrayInt; ++n)
{
dst.idata(n)[idx] = imf_arr(i,j,k,1+NStructInt+n);
}
}

});
last_offset+=next_offset;
Expand Down
Loading
Loading