From 2c2e8247ef4e63597c03455e31b177d547ab1de5 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sun, 29 Nov 2015 21:40:37 +0000
Subject: [PATCH] mirrorFvMesh: Corrected parallel operation Patch provided by
 Bruno Santos Resolves bug-report
 http://www.openfoam.org/mantisbt/view.php?id=1494

---
 .../manipulation/mirrorMesh/mirrorFvMesh.C    | 23 ++++++++-----------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C
index 5df88a4f3bb..c52953e196f 100644
--- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C
+++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorFvMesh.C
@@ -243,8 +243,8 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
 
     // Mirror boundary faces patch by patch
 
-    wordList newPatchTypes(boundary().size());
-    wordList newPatchNames(boundary().size());
+
+    labelList newToOldPatch(boundary().size(), -1);
     labelList newPatchSizes(boundary().size(), -1);
     labelList newPatchStarts(boundary().size(), -1);
     label nNewPatches = 0;
@@ -303,8 +303,8 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
         // If patch exists, grab the name and type of the original patch
         if (nNewFaces > newPatchStarts[nNewPatches])
         {
-            newPatchTypes[nNewPatches] = boundaryMesh()[patchI].type();
-            newPatchNames[nNewPatches] = boundaryMesh()[patchI].name();
+            newToOldPatch[nNewPatches] = patchI;
+
             newPatchSizes[nNewPatches] =
                 nNewFaces - newPatchStarts[nNewPatches];
 
@@ -316,8 +316,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
     newFaces.setSize(nNewFaces);
     Info<< " New faces: " << nNewFaces << endl;
 
-    newPatchTypes.setSize(nNewPatches);
-    newPatchNames.setSize(nNewPatches);
+    newToOldPatch.setSize(nNewPatches);
     newPatchSizes.setSize(nNewPatches);
     newPatchStarts.setSize(nNewPatches);
 
@@ -377,18 +376,16 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
     fvMesh& pMesh = *mirrorMeshPtr_;
 
     // Add the boundary patches
-    List<polyPatch*> p(newPatchTypes.size());
+    List<polyPatch*> p(newPatchSizes.size());
 
     forAll(p, patchI)
     {
-        p[patchI] = polyPatch::New
+        p[patchI] = boundaryMesh()[newToOldPatch[patchI]].clone
         (
-            newPatchTypes[patchI],
-            newPatchNames[patchI],
-            newPatchSizes[patchI],
-            newPatchStarts[patchI],
+            pMesh.boundaryMesh(),
             patchI,
-            pMesh.boundaryMesh()
+            newPatchSizes[patchI],
+            newPatchStarts[patchI]
         ).ptr();
     }
 
-- 
GitLab