Skip to content

Commit

Permalink
Use amrex::getParticleCell More (#5557)
Browse files Browse the repository at this point in the history
One leftover occurance in `ParticleReductionFunctor`.

Follow-up to #5118
  • Loading branch information
ax3l authored Jan 14, 2025
1 parent c666e75 commit 57703f8
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ ParticleReductionFunctor::operator() (amrex::MultiFab& mf_dst, const int dcomp,
get_particle_position(p, xw, yw, zw);

// Get position in AMReX convention to calculate corresponding index.
// Ideally this will be replaced with the AMReX NGP interpolator
// Always do x direction. No RZ case because it's not implemented, and code
// will have aborted
const auto [ii, jj, kk] = amrex::getParticleCell(p, plo, dxi).dim3();

// Fix dimensions since parser assumes u = gamma * v / c
Expand Down Expand Up @@ -97,20 +100,8 @@ ParticleReductionFunctor::operator() (amrex::MultiFab& mf_dst, const int dcomp,
// Ideally this will be replaced with the AMReX NGP interpolator
// Always do x direction. No RZ case because it's not implemented, and code
// will have aborted
int ii = 0, jj = 0, kk = 0;
const amrex::ParticleReal x = p.pos(0);
const amrex::Real lx = (x - plo[0]) * dxi[0];
ii = static_cast<int>(amrex::Math::floor(lx));
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_3D)
const amrex::ParticleReal y = p.pos(1);
const amrex::Real ly = (y - plo[1]) * dxi[1];
jj = static_cast<int>(amrex::Math::floor(ly));
#endif
#if defined(WARPX_DIM_3D)
const amrex::ParticleReal z = p.pos(2);
const amrex::Real lz = (z - plo[2]) * dxi[2];
kk = static_cast<int>(amrex::Math::floor(lz));
#endif
const auto [ii, jj, kk] = amrex::getParticleCell(p, plo, dxi).dim3();

// Fix dimensions since parser assumes u = gamma * v / c
const amrex::ParticleReal ux = p.rdata(PIdx::ux) / PhysConst::c;
const amrex::ParticleReal uy = p.rdata(PIdx::uy) / PhysConst::c;
Expand Down

0 comments on commit 57703f8

Please sign in to comment.