From ba6a726ec196b75a27f065ad7f5ba26cc7c63eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gr=C3=BCninger?= <foss@grueninger.de> Date: Fri, 22 Oct 2021 23:57:54 +0200 Subject: [PATCH] [splinecommon_] Harmonize and simplify detection of reversed points --- dumux/common/splinecommon_.hh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dumux/common/splinecommon_.hh b/dumux/common/splinecommon_.hh index 39db7ddba0..8bebaae5d3 100644 --- a/dumux/common/splinecommon_.hh +++ b/dumux/common/splinecommon_.hh @@ -310,9 +310,11 @@ protected: // copy sample points, make sure that the first x value is // smaller than the last one + bool reverse = (srcX[0] > srcX[numSamples - 1]); + for (int i = 0; i < numSamples; ++i) { int idx = i; - if (srcX[0] > srcX[numSamples - 1]) + if (reverse) idx = numSamples - i - 1; destX[i] = srcX[idx]; destY[i] = srcY[idx]; @@ -337,9 +339,7 @@ protected: // find out whether the x values are in reverse order ListIterator it = srcBegin; ++it; - bool reverse = false; - if ((*srcBegin)[0] > (*it)[0]) - reverse = true; + bool reverse = ((*srcBegin)[0] > (*it)[0]); --it; // loop over all sampling points @@ -374,9 +374,7 @@ protected: // find out whether the x values are in reverse order ListIterator it = srcBegin; ++it; - bool reverse = false; - if (std::get<0>(*srcBegin) > std::get<0>(*it)) - reverse = true; + bool reverse = (std::get<0>(*srcBegin) > std::get<0>(*it)); --it; // loop over all sampling points -- GitLab