From 6f6fdd635dd2a9baa35d22aee810ca67e010c1c1 Mon Sep 17 00:00:00 2001
From: laurence <laurence>
Date: Thu, 26 Sep 2013 15:25:57 +0100
Subject: [PATCH] BUG: foamyHexMesh: Correct feature point pair indexing

---
 .../conformalVoronoiMeshCalcDualMesh.C        |  1 -
 .../conformalVoronoiMeshFeaturePoints.C       | 22 ++++---------------
 .../featurePointConformer.C                   | 22 +++++++++++++++++++
 .../featurePointConformer.H                   |  3 +++
 4 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
index e220556fa59..abe115fef98 100644
--- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
+++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
@@ -2218,7 +2218,6 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
                     if
                     (
                         vA->boundaryPoint() && vB->boundaryPoint()
-                     && !isProcBoundaryEdge(eit)
                      && !ptPairs_.isPointPair(vA, vB)
                      && !ftPtConformer_.featurePointPairs().isPointPair(vA, vB)
                     )
diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C
index f0c4c7d7466..f142470106b 100644
--- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C
+++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C
@@ -1160,23 +1160,6 @@ void Foam::conformalVoronoiMesh::insertFeaturePoints(bool distribute)
     Info<< nl
         << "Inserting feature points" << endl;
 
-
-//    Map<label> oldToNewIndices = insertPoints(featureVertices_, distribute);
-
-//    featurePtPairs_.reIndex(oldToNewIndices);
-
-//    forAll(featureVertices_, vI)
-//    {
-//        Map<label>::const_iterator iter =
-//            oldToNewIndices.find(featureVertices_[vI].index());
-
-//        if (iter != oldToNewIndices.end())
-//        {
-//            featureVertices_[vI].index() = iter();
-//        }
-//    }
-
-
     const label preFeaturePointSize(number_of_vertices());
 
     if (Pstream::parRun() && distribute)
@@ -1187,7 +1170,10 @@ void Foam::conformalVoronoiMesh::insertFeaturePoints(bool distribute)
     const List<Vb>& ftPtVertices = ftPtConformer_.featurePointVertices();
 
     // Insert the created points directly as already distributed.
-    this->DelaunayMesh<Delaunay>::insertPoints(ftPtVertices, true);
+    Map<label> oldToNewIndices =
+        this->DelaunayMesh<Delaunay>::insertPoints(ftPtVertices, true);
+
+    ftPtConformer_.reIndexPointPairs(oldToNewIndices);
 
     label nFeatureVertices = number_of_vertices() - preFeaturePointSize;
     reduce(nFeatureVertices, sumOp<label>());
diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C
index 6501d72758c..fa42d63e173 100644
--- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C
+++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C
@@ -609,4 +609,26 @@ void Foam::featurePointConformer::distribute
 }
 
 
+void Foam::featurePointConformer::reIndexPointPairs
+(
+    const Map<label>& oldToNewIndices
+)
+{
+    forAll(featurePointVertices_, vI)
+    {
+        const label currentIndex = featurePointVertices_[vI].index();
+
+        Map<label>::const_iterator newIndexIter =
+            oldToNewIndices.find(currentIndex);
+
+        if (newIndexIter != oldToNewIndices.end())
+        {
+            featurePointVertices_[vI].index() = newIndexIter();
+        }
+    }
+
+    ftPtPairs_.reIndex(oldToNewIndices);
+}
+
+
 // ************************************************************************* //
diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.H
index ddda0959e8b..e3c415b7fab 100644
--- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.H
+++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.H
@@ -176,6 +176,9 @@ public:
             //- Distribute the feature point vertices according to the
             //  supplied background mesh
             void distribute(const backgroundMeshDecomposition& decomposition);
+
+            //- Reindex the feature point pairs using the map.
+            void reIndexPointPairs(const Map<label>& oldToNewIndices);
 };
 
 
-- 
GitLab