From e551bdf2db865efe07ba6b8c76644e2f7ddc35d0 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Mon, 9 Dec 2013 09:05:37 +0000
Subject: [PATCH] ENH: polyMeshFilter: enhanced checking (for merged points,
 map < -1)

---
 .../polyMeshFilter/polyMeshFilter.C            | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C b/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C
index 968ea6c4835..28398bdc92a 100644
--- a/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C
+++ b/src/dynamicMesh/polyMeshFilter/polyMeshFilter.C
@@ -267,7 +267,11 @@ Foam::label Foam::polyMeshFilter::filterFacesLoop(const label nOriginalBadFaces)
             newBadFaces = false;
             forAll(mesh_.points(), pI)
             {
-                if (isErrorPoint[origToCurrentPointMap[pI]])
+                if
+                (
+                    origToCurrentPointMap[pI] >= 0
+                 && isErrorPoint[origToCurrentPointMap[pI]]
+                )
                 {
                     if (!newErrorPoint[pI])
                     {
@@ -862,14 +866,22 @@ void Foam::polyMeshFilter::updateOldToNewPointMap
     {
         label oldPointI = origToCurrentPointMap[origPointI];
 
-        if (oldPointI < currToNew.size())
+        if (oldPointI != -1)
         {
             label newPointI = currToNew[oldPointI];
 
-            if (newPointI != -1)
+            if (newPointI >= 0)
             {
                 origToCurrentPointMap[origPointI] = newPointI;
             }
+            else if (newPointI == -1)
+            {
+                origToCurrentPointMap[origPointI] = -1;
+            }
+            else
+            {
+                origToCurrentPointMap[origPointI] = -newPointI-2;
+            }
         }
     }
 }
-- 
GitLab