From 6e512196281766e24db2a31ea8394daf08d62e59 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Thu, 22 Jul 2021 08:09:07 +0000
Subject: [PATCH] [distance] Precompute distance p->a

---
 dumux/geometry/distance.hh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/dumux/geometry/distance.hh b/dumux/geometry/distance.hh
index ddccf50a14..2b4db9b18b 100644
--- a/dumux/geometry/distance.hh
+++ b/dumux/geometry/distance.hh
@@ -84,10 +84,11 @@ inline typename Point::value_type
 distancePointSegment(const Point& p, const Point& a, const Point& b)
 {
     const auto ab = b - a;
-    auto t = (p - a)*ab;
+    const auto ap = p - a;
+    const auto t = ap*ab;
 
     if (t <= 0.0)
-        return (a - p).two_norm();
+        return ap.two_norm();
 
     const auto lengthSq = ab.two_norm2();
     if (t >= lengthSq)
-- 
GitLab