diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 96068ed5083ec1a5fb0d9976c12304d61a7a7ed2..41799cf3214ef8014725dc48d7d28bbe9dd6db76 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 8205e0b1e8bb700b2cf40ac3b4d2519cf898ebed..a75ccdf1eadf814d91180c4b3f24fe0dc2c9f9b5 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 570580794cf2a475f2ee49eef866d29351ebb0ad..a3022e2932b2de956f382122b74ba841b2aca621 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 0aeb340637c118ad4f03f98fe6658ad8f1dda310..2d89a7ef049ff4a139f4c1ef236f33b27a321bbd 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());