polyMesh, fvMesh: The moving and topoChanged flags are now maintained by fvMesh

avoiding problems with mesh generation, pre/post-processing applications
etc. triggering inappropriate changes to the moving and topoChanged states which
are only needed for updates in solvers corresponding to mesh changes.
This commit is contained in:
Henry Weller
2022-06-10 16:50:41 +01:00
parent 6ff2603fce
commit 867badc024
13 changed files with 47 additions and 63 deletions

View File

@ -191,10 +191,6 @@ int main(int argc, char *argv[])
} }
mesh.moving(false);
mesh.topoChanged(false);
label action = rndGen.sampleAB<label>(0, 6); label action = rndGen.sampleAB<label>(0, 6);

View File

@ -287,12 +287,12 @@ Foam::polyMesh::polyMesh(const IOobject& io)
*this *this
), ),
globalMeshDataPtr_(nullptr), globalMeshDataPtr_(nullptr),
moving_(false),
topoChanged_(false),
curMotionTimeIndex_(-1), curMotionTimeIndex_(-1),
oldPointsPtr_(nullptr), oldPointsPtr_(nullptr),
oldCellCentresPtr_(nullptr), oldCellCentresPtr_(nullptr),
storeOldCellCentres_(false) storeOldCellCentres_(false),
moving_(false),
topoChanged_(false)
{ {
if (!owner_.headerClassName().empty()) if (!owner_.headerClassName().empty())
{ {
@ -471,12 +471,12 @@ Foam::polyMesh::polyMesh
PtrList<cellZone>() PtrList<cellZone>()
), ),
globalMeshDataPtr_(nullptr), globalMeshDataPtr_(nullptr),
moving_(false),
topoChanged_(false),
curMotionTimeIndex_(-1), curMotionTimeIndex_(-1),
oldPointsPtr_(nullptr), oldPointsPtr_(nullptr),
oldCellCentresPtr_(nullptr), oldCellCentresPtr_(nullptr),
storeOldCellCentres_(false) storeOldCellCentres_(false),
moving_(false),
topoChanged_(false)
{ {
// Check if the faces and cells are valid // Check if the faces and cells are valid
forAll(faces_, facei) forAll(faces_, facei)
@ -625,12 +625,12 @@ Foam::polyMesh::polyMesh
0 0
), ),
globalMeshDataPtr_(nullptr), globalMeshDataPtr_(nullptr),
moving_(false),
topoChanged_(false),
curMotionTimeIndex_(-1), curMotionTimeIndex_(-1),
oldPointsPtr_(nullptr), oldPointsPtr_(nullptr),
oldCellCentresPtr_(nullptr), oldCellCentresPtr_(nullptr),
storeOldCellCentres_(false) storeOldCellCentres_(false),
moving_(false),
topoChanged_(false)
{ {
// Check if faces are valid // Check if faces are valid
forAll(faces_, facei) forAll(faces_, facei)
@ -1228,8 +1228,6 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
<< " index " << time().timeIndex() << endl; << " index " << time().timeIndex() << endl;
} }
moving(true);
// Pick up old points and cell centres // Pick up old points and cell centres
if (curMotionTimeIndex_ != time().timeIndex()) if (curMotionTimeIndex_ != time().timeIndex())
{ {

View File

@ -174,13 +174,7 @@ private:
mutable autoPtr<globalMeshData> globalMeshDataPtr_; mutable autoPtr<globalMeshData> globalMeshDataPtr_;
// Mesh motion related data // Mesh motion related dat
//- Is the mesh moving
bool moving_;
//- Is the mesh topology changing
bool topoChanged_;
//- Current time index for mesh motion //- Current time index for mesh motion
mutable label curMotionTimeIndex_; mutable label curMotionTimeIndex_;
@ -303,6 +297,20 @@ private:
labelHashSet* setPtr labelHashSet* setPtr
) const; ) const;
protected:
// Protected Member Data
//- Member data pending transfer to fvMesh
//- Is the mesh moving
bool moving_;
//- Is the mesh topology changing
bool topoChanged_;
public: public:
// Public Typedefs // Public Typedefs
@ -520,32 +528,16 @@ public:
return moving_; return moving_;
} }
//- Set the mesh to be moving
bool moving(const bool m)
{
bool m0 = moving_;
moving_ = m;
return m0;
}
//- Is mesh topology changing //- Is mesh topology changing
bool topoChanged() const bool topoChanged() const
{ {
return topoChanged_; return topoChanged_;
} }
//- Set the mesh topology to be changing
bool topoChanged(const bool c)
{
bool c0 = topoChanged_;
topoChanged_ = c;
return c0;
}
//- Is mesh changing (topology changing and/or moving) //- Is mesh changing (topology changing and/or moving)
bool changing() const bool changing() const
{ {
return moving()||topoChanged(); return moving() || topoChanged();
} }
//- Move points, returns volumes swept by faces in motion //- Move points, returns volumes swept by faces in motion

View File

@ -518,12 +518,12 @@ Foam::polyMesh::polyMesh
0 0
), ),
globalMeshDataPtr_(nullptr), globalMeshDataPtr_(nullptr),
moving_(false),
topoChanged_(false),
curMotionTimeIndex_(-1), curMotionTimeIndex_(-1),
oldPointsPtr_(nullptr), oldPointsPtr_(nullptr),
oldCellCentresPtr_(nullptr), oldCellCentresPtr_(nullptr),
storeOldCellCentres_(false) storeOldCellCentres_(false),
moving_(false),
topoChanged_(false)
{ {
if (debug) if (debug)
{ {
@ -807,12 +807,12 @@ Foam::polyMesh::polyMesh
0 0
), ),
globalMeshDataPtr_(nullptr), globalMeshDataPtr_(nullptr),
moving_(false),
topoChanged_(false),
curMotionTimeIndex_(-1), curMotionTimeIndex_(-1),
oldPointsPtr_(nullptr), oldPointsPtr_(nullptr),
oldCellCentresPtr_(nullptr), oldCellCentresPtr_(nullptr),
storeOldCellCentres_(false) storeOldCellCentres_(false),
moving_(false),
topoChanged_(false)
{ {
if (debug) if (debug)
{ {

View File

@ -1754,8 +1754,6 @@ Foam::autoPtr<Foam::polyDistributionMap> Foam::fvMeshDistribute::distribute
const labelList& distribution const labelList& distribution
) )
{ {
const bool topoChanged = mesh_.topoChanged();
// Some checks on distribution // Some checks on distribution
if (distribution.size() != mesh_.nCells()) if (distribution.size() != mesh_.nCells())
{ {
@ -3013,10 +3011,6 @@ Foam::autoPtr<Foam::polyDistributionMap> Foam::fvMeshDistribute::distribute
mesh_.setInstance(mesh_.time().timeName()); mesh_.setInstance(mesh_.time().timeName());
// Reset the topoChanged state of the mesh
// Distribution is not a topology change
mesh_.topoChanged(topoChanged);
// Print a bit // Print a bit
if (debug) if (debug)
{ {

View File

@ -3223,8 +3223,6 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::polyTopoChange::changeMesh
patchStarts, patchStarts,
syncParallel syncParallel
); );
mesh.topoChanged(true);
} }
else else
{ {
@ -3239,7 +3237,6 @@ Foam::autoPtr<Foam::polyTopoChangeMap> Foam::polyTopoChange::changeMesh
patchStarts, patchStarts,
syncParallel syncParallel
); );
mesh.topoChanged(true);
} }
// Clear out primitives // Clear out primitives

View File

@ -104,6 +104,7 @@ fvMeshTopoChangers = fvMesh/fvMeshTopoChangers
$(fvMeshTopoChangers)/fvMeshTopoChanger/fvMeshTopoChanger.C $(fvMeshTopoChangers)/fvMeshTopoChanger/fvMeshTopoChanger.C
$(fvMeshTopoChangers)/fvMeshTopoChanger/fvMeshTopoChangerNew.C $(fvMeshTopoChangers)/fvMeshTopoChanger/fvMeshTopoChangerNew.C
$(fvMeshTopoChangers)/none/fvMeshTopoChangersNone.C $(fvMeshTopoChangers)/none/fvMeshTopoChangersNone.C
$(fvMeshTopoChangers)/list/fvMeshTopoChangersList.C
fvMeshDistributors = fvMesh/fvMeshDistributors fvMeshDistributors = fvMesh/fvMeshDistributors

View File

@ -588,10 +588,10 @@ bool Foam::fvMesh::update()
deleteDemandDrivenData(V0Ptr_); deleteDemandDrivenData(V0Ptr_);
} }
// Set topoChanged false before any mesh change // Set topoChanged_ false before any mesh change
topoChanged(false); topoChanged_ = false;
bool updated = topoChanger_->update(); bool updated = topoChanger_->update();
topoChanged(updated); topoChanged_ = updated;
// Register V0 for distribution // Register V0 for distribution
if (V0Ptr_) if (V0Ptr_)
@ -1087,6 +1087,10 @@ Foam::tmp<Foam::scalarField> Foam::fvMesh::movePoints(const pointField& p)
meshObject::movePoints<fvMesh>(*this); meshObject::movePoints<fvMesh>(*this);
meshObject::movePoints<lduMesh>(*this); meshObject::movePoints<lduMesh>(*this);
// Set moving_ true
// Note: once set it remains true for the rest of the run
moving_ = true;
return tsweptVols; return tsweptVols;
} }

View File

@ -83,6 +83,12 @@ class GeometricBoundaryField;
template<class Type> template<class Type>
class UCompactListList; class UCompactListList;
namespace fvMeshTopoChangers
{
class list;
}
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class fvMesh Declaration Class fvMesh Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -94,8 +100,6 @@ class fvMesh
public surfaceInterpolation, public surfaceInterpolation,
public data public data
{ {
private:
// Private Data // Private Data
//- Boundary mesh //- Boundary mesh
@ -261,6 +265,7 @@ public:
typedef fvMesh Mesh; typedef fvMesh Mesh;
typedef fvBoundaryMesh BoundaryMesh; typedef fvBoundaryMesh BoundaryMesh;
friend fvMeshTopoChangers::list;
// Declare name of the class and its debug switch // Declare name of the class and its debug switch
ClassName("fvMesh"); ClassName("fvMesh");

View File

@ -80,7 +80,7 @@ bool Foam::fvMeshTopoChangers::list::update()
forAllIter(PtrDictionary<fvMeshTopoChanger>, list_, iter) forAllIter(PtrDictionary<fvMeshTopoChanger>, list_, iter)
{ {
updated = iter().update() || updated; updated = iter().update() || updated;
mesh().topoChanged(updated); mesh().topoChanged_ = updated;
} }
return updated; return updated;

View File

@ -1,5 +1,4 @@
refiner/fvMeshTopoChangersRefiner.C refiner/fvMeshTopoChangersRefiner.C
movingCone/fvMeshTopoChangersMovingCone.C movingCone/fvMeshTopoChangersMovingCone.C
list/fvMeshTopoChangersList.C
LIB = $(FOAM_LIBBIN)/libfvMeshTopoChangers LIB = $(FOAM_LIBBIN)/libfvMeshTopoChangers

View File

@ -69,7 +69,6 @@ void Foam::domainDecomposition::decomposePoints()
procPointAddressing_[proci] procPointAddressing_[proci]
) )
); );
procMesh.moving(false);
} }
} }
} }
@ -96,7 +95,6 @@ void Foam::domainDecomposition::reconstructPoints()
} }
completeMesh_->movePoints(completePoints); completeMesh_->movePoints(completePoints);
completeMesh_->moving(false);
} }
} }