polyMesh: Changed the mesh writing following motion and topology change

The mesh will now be written only for the write time following mesh-motion or
topology change (refinement/unrefinement, mesh-to-mesh mapping, load-balancing
etc.) and not for all subsequent time-steps as it did previously.  This reduces
storage and reconstruction effort of changing mesh cases.
This commit is contained in:
Henry Weller
2022-05-19 18:20:48 +01:00
parent 8f8fa29e3e
commit b439fc1599
6 changed files with 80 additions and 155 deletions

View File

@ -1260,16 +1260,7 @@ Foam::tmp<Foam::scalarField> Foam::polyMesh::movePoints
}
}
points_.writeOpt() = IOobject::AUTO_WRITE;
points_.instance() = time().timeName();
points_.eventNo() = getEvent();
if (tetBasePtIsPtr_.valid())
{
tetBasePtIsPtr_().writeOpt() = IOobject::AUTO_WRITE;
tetBasePtIsPtr_().instance() = time().timeName();
tetBasePtIsPtr_().eventNo() = getEvent();
}
setPointsInstance(time().timeName());
tmp<scalarField> sweptVols = primitiveMesh::movePoints
(

View File

@ -213,6 +213,12 @@ private:
//- Read and return the tetBasePtIs
autoPtr<labelIOList> readTetBasePtIs() const;
//- Set the write option of the points
void setPointsWrite(const IOobject::writeOption wo);
//- Set the write option of the topology
void setTopologyWrite(const IOobject::writeOption wo);
// Helper functions for constructor from cell shapes
@ -757,6 +763,18 @@ public:
) const;
// Write
//- Write the underlying polyMesh
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool write = true
) const;
// Member Operators
//- Disallow default bitwise assignment

View File

@ -29,60 +29,69 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::polyMesh::setInstance(const fileName& inst)
void Foam::polyMesh::setPointsWrite(const Foam::IOobject::writeOption wo)
{
if (debug)
{
InfoInFunction << "Resetting file instance to " << inst << endl;
}
points_.writeOpt() = IOobject::AUTO_WRITE;
points_.instance() = inst;
faces_.writeOpt() = IOobject::AUTO_WRITE;
faces_.instance() = inst;
owner_.writeOpt() = IOobject::AUTO_WRITE;
owner_.instance() = inst;
neighbour_.writeOpt() = IOobject::AUTO_WRITE;
neighbour_.instance() = inst;
boundary_.writeOpt() = IOobject::AUTO_WRITE;
boundary_.instance() = inst;
pointZones_.writeOpt() = IOobject::AUTO_WRITE;
pointZones_.instance() = inst;
faceZones_.writeOpt() = IOobject::AUTO_WRITE;
faceZones_.instance() = inst;
cellZones_.writeOpt() = IOobject::AUTO_WRITE;
cellZones_.instance() = inst;
points_.writeOpt() = wo;
if (tetBasePtIsPtr_.valid())
{
tetBasePtIsPtr_->writeOpt() = IOobject::AUTO_WRITE;
tetBasePtIsPtr_->instance() = inst;
tetBasePtIsPtr_->writeOpt() = wo;
}
}
void Foam::polyMesh::setTopologyWrite(const Foam::IOobject::writeOption wo)
{
setPointsWrite(wo);
faces_.writeOpt() = wo;
owner_.writeOpt() = wo;
neighbour_.writeOpt() = wo;
boundary_.writeOpt() = wo;
pointZones_.writeOpt() = wo;
faceZones_.writeOpt() = wo;
cellZones_.writeOpt() = wo;
}
void Foam::polyMesh::setPointsInstance(const fileName& inst)
{
if (debug)
{
InfoInFunction << "Resetting file instance to " << inst << endl;
InfoInFunction << "Resetting points instance to " << inst << endl;
}
points_.writeOpt() = IOobject::AUTO_WRITE;
points_.instance() = inst;
points_.eventNo() = getEvent();
if (tetBasePtIsPtr_.valid())
{
tetBasePtIsPtr_->writeOpt() = IOobject::AUTO_WRITE;
tetBasePtIsPtr_->instance() = inst;
tetBasePtIsPtr_().eventNo() = getEvent();
}
setPointsWrite(IOobject::AUTO_WRITE);
}
void Foam::polyMesh::setInstance(const fileName& inst)
{
if (debug)
{
InfoInFunction << "Resetting topology instance to " << inst << endl;
}
setPointsInstance(inst);
faces_.instance() = inst;
owner_.instance() = inst;
neighbour_.instance() = inst;
boundary_.instance() = inst;
pointZones_.instance() = inst;
faceZones_.instance() = inst;
cellZones_.instance() = inst;
setTopologyWrite(IOobject::AUTO_WRITE);
}
@ -96,7 +105,6 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
// Find the points and faces instance
fileName pointsInst(time().findInstance(meshDir(), "points"));
fileName facesInst(time().findInstance(meshDir(), "faces"));
// fileName boundaryInst(time().findInstance(meshDir(), "boundary"));
if (debug)
{
@ -493,4 +501,20 @@ Foam::polyMesh::readUpdateState Foam::polyMesh::readUpdate()
}
bool Foam::polyMesh::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp,
const bool write
) const
{
const bool written = objectRegistry::writeObject(fmt, ver, cmp, write);
const_cast<polyMesh&>(*this).setTopologyWrite(IOobject::NO_WRITE);
return written;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -180,9 +180,9 @@ public:
{
return extrudedPatch_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -1137,102 +1137,6 @@ Foam::domainDecomposition::procFaceAddressingBf() const
}
void Foam::domainDecomposition::writeCompletePoints() const
{
if (procMeshes_[0].pointsInstance() != procMeshes_[0].facesInstance())
{
pointField completeFacesInstancePoints(completeMesh().nPoints());
for (label proci = 0; proci < nProcs(); proci++)
{
const fvMesh& procMesh = procMeshes_[proci];
pointIOField procFacesInstancePoints
(
IOobject
(
"points",
procMesh.facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
completeFacesInstancePoints.rmap
(
procFacesInstancePoints,
procPointAddressing_[proci]
);
}
pointIOField
(
IOobject
(
"points",
procMeshes_[0].facesInstance(),
polyMesh::meshSubDir,
completeMesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
move(completeFacesInstancePoints)
).write();
}
}
void Foam::domainDecomposition::writeProcPoints() const
{
if (completeMesh().pointsInstance() != completeMesh().facesInstance())
{
pointIOField completeFacesInstancePoints
(
IOobject
(
"points",
completeMesh().facesInstance(),
polyMesh::meshSubDir,
completeMesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
for (label proci = 0; proci < nProcs(); proci++)
{
const fvMesh& procMesh = procMeshes_[proci];
pointField procFacesInstancePoints
(
completeFacesInstancePoints,
procPointAddressing_[proci]
);
pointIOField
(
IOobject
(
"points",
completeMesh().facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
move(procFacesInstancePoints)
).write();
}
}
}
void Foam::domainDecomposition::writeAddressing() const
{
for (label proci = 0; proci < nProcs(); proci++)
@ -1534,9 +1438,6 @@ void Foam::domainDecomposition::writeComplete(const bool doSets) const
refinementDatas
).write();
// Write points if pointsInstance differing from facesInstance
writeCompletePoints();
// Write decomposition addressing
writeAddressing();
}
@ -1668,9 +1569,6 @@ void Foam::domainDecomposition::writeProcs(const bool doSets) const
).write();
}
// Write points if pointsInstance differing from facesInstance
writeProcPoints();
// Write decomposition addressing
writeAddressing();
}

View File

@ -256,12 +256,6 @@ public:
const PtrList<surfaceLabelField::Boundary>&
procFaceAddressingBf() const;
//- Write additional points, if necessary
void writeCompletePoints() const;
//- Writ additional points, if necessary
void writeProcPoints() const;
//- Write the decomposition addressing
void writeAddressing() const;