diff --git a/include/bout/region.hxx b/include/bout/region.hxx index 4649b680eb..bb1cf82bf1 100644 --- a/include/bout/region.hxx +++ b/include/bout/region.hxx @@ -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); } @@ -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); } };