From a803f9ea2c5564c3c4594e8e8ee4fe9ffb509e46 Mon Sep 17 00:00:00 2001
From: graham <g.macpherson@opencfd.co.uk>
Date: Thu, 21 Apr 2011 18:02:40 +0100
Subject: [PATCH] ENH: Patches for mesh quality eval are now proc patches.

Forcing empty patches to write in parallel.
---
 .../conformalVoronoiMeshCalcDualMesh.C        | 49 +++++++++++++------
 .../conformalVoronoiMeshIO.C                  |  7 +--
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
index 6d1286a1b6a..ee0ea7c5fda 100644
--- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
+++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
@@ -1421,7 +1421,6 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
     timeCheck("Start of checkPolyMeshQuality");
 
     Info<< nl << "Creating polyMesh to assess quality" << endl;
-    Info<< nl << "THIS NEEDS TO USE PARALLEL EVALUATION OF QUALITY" << endl;
 
     createFacesOwnerNeighbourAndPatches
     (
@@ -1458,21 +1457,38 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
 
     List<polyPatch*> patches(patchStarts.size());
 
-    forAll (patches, p)
+    forAll(patches, p)
     {
-        patches[p] = new polyPatch
-        (
-            patchNames[p],
-            patchSizes[p],
-            patchStarts[p],
-            p,
-            pMesh.boundaryMesh()
-        );
+        if (patchTypes[p] == processorPolyPatch::typeName)
+        {
+            patches[p] = new processorPolyPatch
+            (
+                patchNames[p],
+                patchSizes[p],
+                patchStarts[p],
+                p,
+                pMesh.boundaryMesh(),
+                Pstream::myProcNo(),
+                procNeighbours[p]
+            );
+        }
+        else
+        {
+            patches[p] = polyPatch::New
+            (
+                patchTypes[p],
+                patchNames[p],
+                patchSizes[p],
+                patchStarts[p],
+                p,
+                pMesh.boundaryMesh()
+            ).ptr();
+        }
     }
 
     pMesh.addPatches(patches);
 
-    // mesh.overrideCellCentres(cellCentres);
+    // pMesh.overrideCellCentres(cellCentres);
 
     timeCheck("polyMesh created, checking quality");
 
@@ -2018,7 +2034,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
         procNeighbours,
         patchFaces,
         patchOwners,
-        false
+        includeEmptyPatches
     );
 }
 
@@ -2161,9 +2177,6 @@ void Foam::conformalVoronoiMesh::sortProcPatches
         return;
     }
 
-    Info<< "PROC PATCH SORT IS WRONG, OWNER PATCH CELL INDEX IS NOT UNIQUE"
-        << endl;
-
     forAll(patchSortingIndices, patchI)
     {
         faceList& faces = patchFaces[patchI];
@@ -2290,6 +2303,12 @@ void Foam::conformalVoronoiMesh::addPatches
     bool includeEmptyPatches
 ) const
 {
+    // Always write out all patches in parallel
+    if (Pstream::parRun())
+    {
+        includeEmptyPatches = true;
+    }
+
     label nTotalPatches = patchNames.size();
 
     label nValidPatches = 0;
diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C
index bc2d0f0043f..174c07d9b08 100644
--- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C
+++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C
@@ -360,11 +360,7 @@ void Foam::conformalVoronoiMesh::writeMesh
         }
     }
 
-    Info<< "addPatches(patches, false); FALSE REQUIRED TO AVOID MEMORY CRASH"
-        << endl;
-
-    // mesh.addPatches(patches);
-    mesh.addPatches(patches, false);
+    mesh.addPatches(patches);
 
     if (!mesh.write())
     {
@@ -394,7 +390,6 @@ void Foam::conformalVoronoiMesh::writeMesh
 
     // cellCs.write();
 
-
     Info<< "DISABLED WRITING OF CELL SIZE AND PROTRUSION SET" << endl;
 
     // writeCellSizes(mesh);
-- 
GitLab