Skip to content

Commit

Permalink
Merge pull request #2888 from boutproject/add-zpm-method
Browse files Browse the repository at this point in the history
Add .zpm for sign-independent coding
  • Loading branch information
ZedThree authored Oct 23, 2024
2 parents 9bb1c00 + 910936a commit e8b82e9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/bout/region.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ struct SpecificInd {
ASSERT3(dz >= 0);
return {(ind) % nz < dz ? ind + nz - dz : ind - dz, ny, nz};
}
/// Automatically select zm or zp depending on sign
inline SpecificInd zpm(int dz) const { return dz > 0 ? zp(dz) : zm(-dz); }

// and for 2 cells
inline SpecificInd xpp() const { return xp(2); }
Expand All @@ -319,8 +321,7 @@ struct SpecificInd {

/// Generic offset of \p index in multiple directions simultaneously
inline SpecificInd offset(int dx, int dy, int dz) const {
auto temp = (dz > 0) ? zp(dz) : zm(-dz);
return temp.yp(dy).xp(dx);
return zpm(dz).yp(dy).xp(dx);
}
};

Expand Down

0 comments on commit e8b82e9

Please sign in to comment.