Skip to content

Commit

Permalink
enforce_bc: handle multiple displacements
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Dec 5, 2024
1 parent e7c5c1f commit e4ce92a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/madness/mra/mraimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3217,20 +3217,23 @@ template <typename T, std::size_t NDIM>


static inline bool enforce_bc(bool is_periodic, Level n, Translation& l) {
Translation two2n = 1ul << n;
if (l < 0) {
if (is_periodic)
l += two2n; // Periodic BC
else
return false; // Zero BC
}
else if (l >= two2n) {
if (is_periodic)
l -= two2n; // Periodic BC
else
return false; // Zero BC
}
return true;
const Translation two2n = 1ul << n;
if (l < 0) {
if (is_periodic) {
do {
l += two2n; // Periodic BC
} while (l < 0);
} else
return false; // Zero BC
} else if (l >= two2n) {
if (is_periodic) {
do {
l -= two2n; // Periodic BC
} while (l >= two2n);
} else
return false; // Zero BC
}
return true;
}

static inline bool enforce_in_volume(Level n, Translation& l) {
Expand Down

0 comments on commit e4ce92a

Please sign in to comment.