From eb33b7957e9a5c171d38f7feafc65d79d7389019 Mon Sep 17 00:00:00 2001
From: Sergio Ferraris <s.ferraris@opencfd.co.uk>
Date: Fri, 28 Aug 2020 08:46:36 -0700
Subject: [PATCH] BUG: Correction to tgtPointFace srcPointFace member functions

---
 .../AMIInterpolation/AMIInterpolation.C          | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
index 7e3f5cd883b..b41934ae019 100644
--- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
+++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
@@ -1073,7 +1073,7 @@ const
 
         if (ray.hit())
         {
-            // tgtPoint = ray.rawPoint();
+            tgtPoint = ray.rawPoint();
             return srcFacei;
         }
         else if (ray.distance() < nearest.distance())
@@ -1085,7 +1085,7 @@ const
 
     if (nearest.hit() || nearest.eligibleMiss())
     {
-        // tgtPoint = nearest.rawPoint();
+        tgtPoint = nearest.rawPoint();
         return nearestFacei;
     }
 
@@ -1118,21 +1118,23 @@ const
 
         pointHit ray = f.ray(srcPoint, n, tgtPoints);
 
-        if (ray.hit() || ray.eligibleMiss())
+        if (ray.hit())
         {
-            // srcPoint = ray.rawPoint();
+            srcPoint = ray.rawPoint();
             return tgtFacei;
         }
-        else if (ray.distance() < nearest.distance())
+        const pointHit near = f.nearestPoint(srcPoint, tgtPoints);
+
+        if (near.distance() < nearest.distance())
         {
-            nearest = ray;
+            nearest = near;
             nearestFacei = tgtFacei;
         }
     }
 
     if (nearest.hit() || nearest.eligibleMiss())
     {
-        // srcPoint = nearest.rawPoint();
+        srcPoint = nearest.rawPoint();
         return nearestFacei;
     }
 
-- 
GitLab