Skip to content

Commit

Permalink
Ensure that particles are always < rhi after applying periodic bcs. (#…
Browse files Browse the repository at this point in the history
…3263)

We either need to iterate or just fix it this way, which is symmetric
with the way rlo is handled. This relies on `rhi` being the largest
point that is *inside* the domain, which is consistent with the ASSERT
below.

The proposed changes:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
atmyers committed Apr 20, 2023
1 parent b0a0379 commit 9718b9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Src/Particle/AMReX_ParticleUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,8 @@ bool enforcePeriodic (P& p,
p.pos(idim) += static_cast<ParticleReal>(phi[idim] - plo[idim]);
}
// clamp to avoid precision issues;
if (p.pos(idim) >= rhi[idim]) {
p.pos(idim) = std::nextafter(p.pos(idim), rlo[idim]);
if (p.pos(idim) > rhi[idim]) {
p.pos(idim) = rhi[idim];
}
shifted = true;
}
Expand Down

0 comments on commit 9718b9c

Please sign in to comment.