From 6068148c22f385e475b3f06694e4c45b0989db8c Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Fri, 18 Dec 2020 09:13:34 +0100
Subject: [PATCH] STYLE: adjust packing of members, header comments

---
 src/OpenFOAM/meshes/polyMesh/polyMesh.C              | 12 ++++++------
 src/OpenFOAM/meshes/polyMesh/polyMesh.H              |  9 +++++----
 src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C |  8 ++++----
 src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C        | 11 ++++++-----
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
index 96068ed5083..41799cf3214 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
@@ -308,10 +308,10 @@ Foam::polyMesh::polyMesh(const IOobject& io, const bool doInit)
     globalMeshDataPtr_(nullptr),
     moving_(false),
     topoChanging_(false),
+    storeOldCellCentres_(false),
     curMotionTimeIndex_(time().timeIndex()),
     oldPointsPtr_(nullptr),
-    oldCellCentresPtr_(nullptr),
-    storeOldCellCentres_(false)
+    oldCellCentresPtr_(nullptr)
 {
     if (!owner_.headerClassName().empty())
     {
@@ -514,10 +514,10 @@ Foam::polyMesh::polyMesh
     globalMeshDataPtr_(nullptr),
     moving_(false),
     topoChanging_(false),
+    storeOldCellCentres_(false),
     curMotionTimeIndex_(time().timeIndex()),
     oldPointsPtr_(nullptr),
-    oldCellCentresPtr_(nullptr),
-    storeOldCellCentres_(false)
+    oldCellCentresPtr_(nullptr)
 {
     // Note: changed that the constructors where values can be supplied
     //       (points, faces, owner/neighbour) use the readOpt. All others
@@ -672,10 +672,10 @@ Foam::polyMesh::polyMesh
     globalMeshDataPtr_(nullptr),
     moving_(false),
     topoChanging_(false),
+    storeOldCellCentres_(false),
     curMotionTimeIndex_(time().timeIndex()),
     oldPointsPtr_(nullptr),
-    oldCellCentresPtr_(nullptr),
-    storeOldCellCentres_(false)
+    oldCellCentresPtr_(nullptr)
 {
     // Note: probably needs io.readOpt() for points/faces/cells etc so
     //       we can run with READ_IF_PRESENT. See constructor above.
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
index 8205e0b1e8b..a75ccdf1ead 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
@@ -182,6 +182,9 @@ private:
             //- Is the mesh topology changing
             bool topoChanging_;
 
+            //- Store old cell centres?
+            mutable bool storeOldCellCentres_;
+
             //- Current time index for mesh motion
             mutable label curMotionTimeIndex_;
 
@@ -191,8 +194,6 @@ private:
             //- Old cell centres (for the last mesh motion)
             mutable autoPtr<pointField> oldCellCentresPtr_;
 
-            //- Whether or not to store the old cell centres
-            mutable bool storeOldCellCentres_;
 
 
     // Private Member Functions
@@ -434,10 +435,10 @@ public:
             //- Return face neighbour
             virtual const labelList& faceNeighbour() const;
 
-            //- Return old points for mesh motion
+            //- Return old points (mesh motion)
             virtual const pointField& oldPoints() const;
 
-            //- Return old points for mesh motion
+            //- Return old cellCentres (mesh motion)
             virtual const pointField& oldCellCentres() const;
 
             //- Return boundary mesh
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
index 570580794cf..a3022e2932b 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C
@@ -575,10 +575,10 @@ Foam::polyMesh::polyMesh
     globalMeshDataPtr_(nullptr),
     moving_(false),
     topoChanging_(false),
+    storeOldCellCentres_(false),
     curMotionTimeIndex_(time().timeIndex()),
     oldPointsPtr_(nullptr),
-    oldCellCentresPtr_(nullptr),
-    storeOldCellCentres_(false)
+    oldCellCentresPtr_(nullptr)
 {
     DebugInfo
         << "Constructing polyMesh from cell and boundary shapes." << endl;
@@ -857,10 +857,10 @@ Foam::polyMesh::polyMesh
     globalMeshDataPtr_(nullptr),
     moving_(false),
     topoChanging_(false),
+    storeOldCellCentres_(false),
     curMotionTimeIndex_(time().timeIndex()),
     oldPointsPtr_(nullptr),
-    oldCellCentresPtr_(nullptr),
-    storeOldCellCentres_(false)
+    oldCellCentresPtr_(nullptr)
 {
     DebugInfo
         << "Constructing polyMesh from cell and boundary shapes." << endl;
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C
index 0aeb340637c..2d89a7ef049 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMeshUpdate.C
@@ -70,12 +70,12 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
     if (oldPointsPtr_)
     {
         // Make a copy of the original points
-        pointField oldMotionPoints = *oldPointsPtr_;
+        pointField oldMotionPoints(*oldPointsPtr_);
 
         pointField& newMotionPoints = *oldPointsPtr_;
 
         // Resize the list to new size
-        newMotionPoints.setSize(points_.size());
+        newMotionPoints.resize(points_.size());
 
         // Map the list
         if (mpm.hasMotionPoints())
@@ -119,15 +119,16 @@ void Foam::polyMesh::updateMesh(const mapPolyMesh& mpm)
         }
     }
 
+    // Map the old motion cell-centres if present
     if (oldCellCentresPtr_)
     {
         // Make a copy of the original cell-centres
-        pointField oldMotionCellCentres = oldCellCentresPtr_();
+        pointField oldMotionCellCentres(*oldCellCentresPtr_);
 
-        pointField& newMotionCellCentres = oldCellCentresPtr_();
+        pointField& newMotionCellCentres = *oldCellCentresPtr_;
 
         // Resize the list to new size
-        newMotionCellCentres.setSize(cellCentres().size());
+        newMotionCellCentres.resize(cellCentres().size());
 
         // Map the list
         newMotionCellCentres.map(oldMotionCellCentres, mpm.cellMap());
-- 
GitLab