Skip to content

Commit

Permalink
Add ParticleIDWrapper::negate()
Browse files Browse the repository at this point in the history
A cheaper way to swap signs on particle ids.
  • Loading branch information
ax3l committed Jan 31, 2024
1 parent 33dea1f commit a831351
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Src/Particle/AMReX_Particle.H
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ struct ParticleIDWrapper
r = (sign) ? lval : -lval;
return r;
}

/** Swap the sign of the id.
*
* Positive ids become negative and negative ids become positive.
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void negate () noexcept
{
// he leftmost bit is our id sign - we will XOR it with 1
m_idata ^= static_cast<uint64_t>(1) << 63;
}
};

struct ParticleCPUWrapper
Expand Down

0 comments on commit a831351

Please sign in to comment.