diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index af15b5edf5..162e895170 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -265,7 +265,7 @@ Foam::polyMesh::polyMesh(const IOobject& io) ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -447,7 +447,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -606,7 +606,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -673,8 +673,8 @@ void Foam::polyMesh::resetPrimitives const bool validBoundary ) { - // Clear addressing. Keep geometric props for mapping. - clearAddressing(); + // Clear addressing. Keep geometric props and updateable props for mapping. + clearAddressing(true); // Take over new primitive data. // Optimized to avoid overwriting data at all diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index 47fe014d60..5d95d9cfb8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -172,8 +172,8 @@ private: //- Is the mesh moving bool moving_; - //- Is the mesh changing (moving and/or topology changing) - bool changing_; + //- Is the mesh topology changing + bool topoChanging_; //- Current time index for mesh motion mutable label curMotionTimeIndex_; @@ -489,22 +489,27 @@ public: { bool m0 = moving_; moving_ = m; - changing_ = changing_ || moving_; return m0; } + //- Is mesh topology changing + bool topoChanging() const + { + return topoChanging_; + } + + //- Set the mesh topology to be changing + bool topoChanging(const bool c) + { + bool c0 = topoChanging_; + topoChanging_ = c; + return c0; + } + //- Is mesh changing (topology changing and/or moving) bool changing() const { - return changing_; - } - - //- Set the mesh to be changing - bool changing(const bool c) - { - bool c0 = changing_; - changing_ = c; - return c0; + return moving()||topoChanging(); } //- Move points, returns volumes swept by faces in motion @@ -580,7 +585,7 @@ public: void clearGeom(); //- Clear addressing - void clearAddressing(); + void clearAddressing(const bool isMeshUpdate = false); //- Clear all geometry and addressing unnecessary for CFD void clearOut(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C b/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C index 7a9558187d..96297ed3e1 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C @@ -60,6 +60,7 @@ void Foam::polyMesh::clearGeom() << endl; } + // Clear all geometric mesh objects meshObject::clear(*this); primitiveMesh::clearGeom(); @@ -93,16 +94,33 @@ void Foam::polyMesh::clearAdditionalGeom() } -void Foam::polyMesh::clearAddressing() +void Foam::polyMesh::clearAddressing(const bool isMeshUpdate) { if (debug) { Info<< "void polyMesh::clearAddressing() : " - << "clearing topology" + << "clearing topology isMeshUpdate:" << isMeshUpdate << endl; } - meshObject::clear(*this); + if (isMeshUpdate) + { + // Part of a mesh update. Keep meshObjects that have an updateMesh + // callback + meshObject::clearUpto + < + polyMesh, + TopologicalMeshObject, + UpdateableMeshObject + > + ( + *this + ); + } + else + { + meshObject::clear(*this); + } primitiveMesh::clearAddressing(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index 43d55876ca..ef5ee9956c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -553,7 +553,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -837,7 +837,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index 77fc1f26ca..bfc6b567f4 100644 --- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -32,6 +32,7 @@ License #include "syncTools.H" #include "pointFields.H" #include "sigFpe.H" +#include "cellSet.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1072,6 +1073,26 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) { protectedCell_.clear(); } + else + { + + cellSet protectedCells(*this, "protectedCells", nProtected); + forAll(protectedCell_, cellI) + { + if (protectedCell_[cellI]) + { + protectedCells.insert(cellI); + } + } + + Info<< "Detected " << returnReduce(nProtected, sumOp