Skip to content

Commit

Permalink
Add ParticleIDWrapper::negative()
Browse files Browse the repository at this point in the history
A cheaper way to check if a particle is valid.
  • Loading branch information
ax3l committed Jan 31, 2024
1 parent a831351 commit 5ef1a66
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Src/Particle/AMReX_Particle.H
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,20 @@ struct ParticleIDWrapper
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void negate () noexcept
{
// he leftmost bit is our id sign - we will XOR it with 1
// the leftmost bit is our id sign - we will XOR it with 1 to flip it
m_idata ^= static_cast<uint64_t>(1) << 63;
}

/** Check the sign of the id.
*
* Returns false if the id is positive, otherwise true (invalid particle).
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
bool negative () noexcept
{
// the leftmost bit is our id sign
return m_idata >> 63;
}
};

struct ParticleCPUWrapper
Expand Down

0 comments on commit 5ef1a66

Please sign in to comment.