fvMesh: Added independent readUpdateState enumeration

This lets calling code determine the difference between a polyMesh
topology change and a re-stitch. This prevents unnecessary
post-processing output in a few cases when using NCC; most notably the
generation of cellProc fields by reconstructPar.
This commit is contained in:
Will Bainbridge
2023-11-08 14:26:21 +00:00
parent b6d1d308d6
commit 03ec16135a
14 changed files with 63 additions and 38 deletions

View File

@ -75,7 +75,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.userTimeName() << nl << endl;
// Update the mesh if changed
if (mesh.readUpdate() == polyMesh::TOPO_PATCH_CHANGE)
if (mesh.readUpdate() == fvMesh::TOPO_PATCH_CHANGE)
{
Info<< "Detected changed patches. Recreating patch group table."
<< endl;

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-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -393,7 +393,7 @@ int main(int argc, char *argv[])
Info<< "Translating time = " << runTime.name() << nl;
polyMesh::readUpdateState meshState = mesh.readUpdate();
fvMesh::readUpdateState meshState = mesh.readUpdate();
if (timeIndex != 0 && meshSubsetter.hasSubMesh())
{
Info<< "Converting cellZone " << cellZoneName
@ -406,7 +406,7 @@ int main(int argc, char *argv[])
}
if (meshState != polyMesh::UNCHANGED)
if (meshState != fvMesh::UNCHANGED)
{
eMesh.correct();
}

View File

@ -321,7 +321,7 @@ int main(int argc, char *argv[])
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell
// decomposition.
polyMesh::readUpdateState meshState = vMesh.readUpdate();
fvMesh::readUpdateState meshState = vMesh.readUpdate();
const fvMesh& mesh = vMesh.mesh();
@ -576,7 +576,7 @@ int main(int argc, char *argv[])
INTEGER4 strandID = 1;
if (meshState != polyMesh::UNCHANGED)
if (meshState != fvMesh::UNCHANGED)
{
if (doWriteInternal)
{

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-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,11 +54,11 @@ Foam::vtkMesh::vtkMesh
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
Foam::fvMesh::readUpdateState Foam::vtkMesh::readUpdate()
{
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
fvMesh::readUpdateState meshState = baseMesh_.readUpdate();
if (meshState != polyMesh::UNCHANGED)
if (meshState != fvMesh::UNCHANGED)
{
// Note: since fvMeshSubset has no movePoints() functionality
// reconstruct the subset even if only movement.

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-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -114,7 +114,7 @@ public:
// Edit
//- Read mesh
polyMesh::readUpdateState readUpdate();
fvMesh::readUpdateState readUpdate();
//- Map volume field (does in fact do very little interpolation;

View File

@ -495,15 +495,11 @@ int main(int argc, char *argv[])
// Check for new polyMesh/ and update mesh, fvMeshSubset and cell
// decomposition.
polyMesh::readUpdateState meshState = vMesh.readUpdate();
fvMesh::readUpdateState meshState = vMesh.readUpdate();
const fvMesh& mesh = vMesh.mesh();
if
(
meshState == polyMesh::TOPO_CHANGE
|| meshState == polyMesh::TOPO_PATCH_CHANGE
)
if (meshState >= fvMesh::TOPO_CHANGE)
{
Info<< " Read new mesh" << nl << endl;
}

View File

@ -55,11 +55,11 @@ Foam::vtkMesh::vtkMesh
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate()
Foam::fvMesh::readUpdateState Foam::vtkMesh::readUpdate()
{
polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
fvMesh::readUpdateState meshState = baseMesh_.readUpdate();
if (meshState != polyMesh::UNCHANGED)
if (meshState != fvMesh::UNCHANGED)
{
// Note: since fvMeshSubset has no movePoints() functionality,
// reconstruct the subset even if only movement.

View File

@ -148,7 +148,7 @@ public:
// Edit
//- Read mesh
polyMesh::readUpdateState readUpdate();
fvMesh::readUpdateState readUpdate();
//- Map volume field (does in fact do very little interpolation;

View File

@ -300,7 +300,7 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.userTimeName() << endl;
if (mesh.readUpdate() != polyMesh::UNCHANGED)
if (mesh.readUpdate() != fvMesh::UNCHANGED)
{
// Update functionObjectList if mesh changes
functionsPtr = functionObjectList::New

View File

@ -86,8 +86,7 @@ public:
//- Enumeration defining the state of the mesh after a read update.
// Used for post-processing applications, where the mesh
// needs to update based on the files written in time
// directories
// needs to update based on the files written in time directories.
enum readUpdateState
{
UNCHANGED,

View File

@ -733,7 +733,7 @@ void Foam::fvMesh::swap(fvMesh& otherMesh)
}
Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate
Foam::fvMesh::readUpdateState Foam::fvMesh::readUpdate
(
const stitchType stitch
)
@ -805,19 +805,24 @@ Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate
stitcher_->connect(false, stitch == stitchType::geometric, true);
}
// If the mesh has been re-stitched with different geometry, then the
// finite-volume topology has changed
if
(
stitcher_.valid()
&& stitcher_->stitches()
&& state == polyMesh::POINTS_MOVED
)
// Return the corresponding fvMesh read update state
switch(state)
{
state = polyMesh::TOPO_CHANGE;
case polyMesh::UNCHANGED:
return UNCHANGED;
case polyMesh::POINTS_MOVED:
return
stitcher_.valid()
&& stitcher_->stitches()
&& stitch != stitchType::none
&& state != polyMesh::UNCHANGED
? STITCHED
: POINTS_MOVED;
case polyMesh::TOPO_CHANGE:
return TOPO_CHANGE;
case polyMesh::TOPO_PATCH_CHANGE:
return TOPO_PATCH_CHANGE;
}
return state;
}

View File

@ -104,6 +104,18 @@ public:
// Public data types
//- Enumeration defining the state of the mesh after a read update.
// Used for post-processing applications, where the mesh
// needs to update based on the files written in time directories.
enum readUpdateState
{
UNCHANGED,
POINTS_MOVED,
STITCHED,
TOPO_CHANGE,
TOPO_PATCH_CHANGE
};
//- Extent to which to stitch on read and readUpdate. By default, a
// full geometric stitch is performed. A non-geometric stitch can be
// done as an optimisation in situations when finite volume geometry

View File

@ -72,7 +72,7 @@ public:
//- Enumeration defining the state of the mesh after a read update.
// Used for post-processing applications, where the mesh
// needs to update based on the files written in time directories
// needs to update based on the files written in time directories.
enum readUpdateState
{
UNCHANGED,

View File

@ -13,4 +13,17 @@ runApplication decomposePar -cellProc
runParallel $(getApplication)
runApplication reconstructPar -cellProc
# Link cellProc files at unchanged times back to cellProc files at previous
# changed times. This allows them to be visualised continuously.
tPrev=0
foamListTimes | while read -r t
do
if [ -f "$t"/cellProc ]
then
tPrev="$t"
else
ln -s ../"$tPrev"/cellProc "$t"/cellProc
fi
done
#------------------------------------------------------------------------------