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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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