Skip to content

Commit 36bdb85

Browse files
authored
Merge pull request #120 from lanl/jmm/fix-out-of-bounds
Jmm/fix out of bounds
2 parents 0fe18f1 + 9508fe2 commit 36bdb85

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

spiner/piecewise_grid_1d.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ class PiecewiseGrid1D {
5656
grids_[i] = grids[i];
5757
pointTotals_[i] = point_tot;
5858
point_tot += grids[i].nPoints();
59-
const Real diff = std::abs(grids_[i].min() - grids_[i - 1].max());
60-
const Real avg =
61-
0.5 * (std::abs(grids_[i].min()) + std::abs(grids_[i - 1].max()));
62-
if ((i > 0) && ratio_(diff, avg) >= EPS_()) {
63-
PORTABLE_ALWAYS_THROW_OR_ABORT(
64-
"Grids must be ordered and intersect at exactly one point.");
59+
if (i > 0) {
60+
const Real diff = std::abs(grids_[i].min() - grids_[i - 1].max());
61+
const Real avg =
62+
0.5 * (std::abs(grids_[i].min()) + std::abs(grids_[i - 1].max()));
63+
if (ratio_(diff, avg) >= EPS_()) {
64+
PORTABLE_ALWAYS_THROW_OR_ABORT(
65+
"Grids must be ordered and intersect at exactly one point.");
66+
}
6567
}
6668
}
6769
}

0 commit comments

Comments
 (0)