From 76be61052f4681addacd8ea75c9905f1d76509f3 Mon Sep 17 00:00:00 2001 From: "Dennis.Glaeser" <dennis.glaeser@iws.uni-stuttgart.de> Date: Sat, 18 Apr 2020 15:58:48 +0200 Subject: [PATCH] [geoisection][1d1d] use std::clamp instead of min/max --- dumux/common/geometry/geometryintersection.hh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dumux/common/geometry/geometryintersection.hh b/dumux/common/geometry/geometryintersection.hh index 8ae5add778..306bead65f 100644 --- a/dumux/common/geometry/geometryintersection.hh +++ b/dumux/common/geometry/geometryintersection.hh @@ -373,17 +373,17 @@ public: auto t2 = ab*(q - a); using std::swap; - if (t2 > t1) + if (t1 > t2) swap(t1, t2); - using std::min; - t1 = min(abNorm2, max(0.0, t1)); - t2 = max(0.0, min(abNorm2, t2)); + using std::clamp; + t1 = clamp(t1, 0.0, abNorm2); + t2 = clamp(t2, 0.0, abNorm2); if (abs(t2-t1) < eps2) return false; - intersection = Intersection({geo1.global(t2/abNorm2), geo1.global(t1/abNorm2)}); + intersection = Intersection({geo1.global(t1/abNorm2), geo1.global(t2/abNorm2)}); return true; } }; @@ -1379,9 +1379,9 @@ public: if (tp > tq) swap(tp, tq); - using std::min; using std::max; - tp = min(abNorm2, max(0.0, tp)); - tq = max(0.0, min(abNorm2, tq)); + using std::clamp; + tp = clamp(tp, 0.0, abNorm2); + tq = clamp(tq, 0.0, abNorm2); if (abs(tp-tq) < eps2) return false; -- GitLab