From 645ef863304f237fbe179a2945e9147f0fdc256f Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Fri, 9 Dec 2011 12:00:57 +0000
Subject: [PATCH] ENH: autoLayerDriver: parallel point normals

---
 .../autoHexMeshDriver/autoLayerDriver.C       | 70 ++++++++-----------
 1 file changed, 29 insertions(+), 41 deletions(-)

diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C
index f442f72827f..67d4fec174e 100644
--- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C
+++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C
@@ -47,6 +47,7 @@ Description
 #include "IOmanip.H"
 #include "globalIndex.H"
 #include "DynamicField.H"
+#include "PatchTools.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
@@ -369,7 +370,16 @@ void Foam::autoLayerDriver::handleFeatureAngle
         autoPtr<OFstream> str;
         if (debug)
         {
-            str.reset(new OFstream(mesh.time().path()/"featureEdges.obj"));
+            str.reset
+            (
+                new OFstream
+                (
+                    mesh.time().path()
+                  / "featureEdges_"
+                  + meshRefiner_.timeName()
+                  + ".obj"
+                )
+            );
             Info<< "Writing feature edges to " << str().name() << endl;
         }
 
@@ -1220,49 +1230,19 @@ void Foam::autoLayerDriver::getPatchDisplacement
     const vectorField& faceNormals = pp.faceNormals();
     const labelListList& pointFaces = pp.pointFaces();
     const pointField& localPoints = pp.localPoints();
-    const labelList& meshPoints = pp.meshPoints();
 
     // Determine pointNormal
     // ~~~~~~~~~~~~~~~~~~~~~
 
-    pointField pointNormals(pp.nPoints(), vector::zero);
-    {
-        labelList nPointFaces(pp.nPoints(), 0);
-
-        forAll(faceNormals, faceI)
-        {
-            const face& f = pp.localFaces()[faceI];
-
-            forAll(f, fp)
-            {
-                pointNormals[f[fp]] += faceNormals[faceI];
-                nPointFaces[f[fp]] ++;
-            }
-        }
-
-        syncTools::syncPointList
-        (
-            mesh,
-            meshPoints,
-            pointNormals,
-            plusEqOp<vector>(),
-            vector::zero        // null value
-        );
-
-        syncTools::syncPointList
+    pointField pointNormals
+    (
+        PatchTools::pointNormals
         (
             mesh,
-            meshPoints,
-            nPointFaces,
-            plusEqOp<label>(),
-            label(0)            // null value
-        );
-
-        forAll(pointNormals, i)
-        {
-            pointNormals[i] /= nPointFaces[i];
-        }
-    }
+            pp,
+            pp.addressing()
+        )
+    );
 
 
     // Determine local length scale on patch
@@ -2266,7 +2246,11 @@ void Foam::autoLayerDriver::addLayers
     {
         const_cast<Time&>(mesh.time())++;
         Info<< "Writing baffled mesh to " << meshRefiner_.timeName() << endl;
-        mesh.write();
+        meshRefiner_.write
+        (
+            debug,
+            mesh.time().path()/meshRefiner_.timeName()
+        );
     }
 
 
@@ -2732,7 +2716,7 @@ void Foam::autoLayerDriver::addLayers
         {
             dumpDisplacement
             (
-                mesh.time().path()/"layer",
+                mesh.time().path()/"layer_" + meshRefiner_.timeName(),
                 pp(),
                 patchDisp,
                 extrudeStatus
@@ -2744,7 +2728,11 @@ void Foam::autoLayerDriver::addLayers
             // See comment in autoSnapDriver why we should not remove meshPhi
             // using mesh.clearPout().
 
-            mesh.write();
+            meshRefiner_.write
+            (
+                debug,
+                mesh.time().path()/meshRefiner_.timeName()
+            );
         }
 
 
-- 
GitLab