BUG: redistributePar: failing reconstruct. See #1953.

In reconstruct mode redistributePar will have
- master read undecomposed mesh
- slaves construct dummy mesh (0 faces/points etc.)
  but correct patches and zones
so all processors have two valid meshes. This was
all handled inside fvMeshTools::newMesh and this
was behaving differently.
This commit is contained in:
mattijs 2020-12-16 17:24:53 +00:00
parent 723edc1c61
commit dbaed65d75
3 changed files with 43 additions and 14 deletions

View File

@ -2754,6 +2754,10 @@ int main(int argc, char *argv[])
Info<< "Time = " << runTime.timeName() << endl << endl; Info<< "Time = " << runTime.timeName() << endl << endl;
// Read undecomposed mesh on master and 'empty' mesh
// (zero faces, point, cells but valid patches and zones) on slaves.
// This is a bit of tricky code and hidden inside fvMeshTools for
// now.
Info<< "Reading undecomposed mesh (on master)" << endl; Info<< "Reading undecomposed mesh (on master)" << endl;
autoPtr<fvMesh> baseMeshPtr = fvMeshTools::newMesh autoPtr<fvMesh> baseMeshPtr = fvMeshTools::newMesh
( (

View File

@ -402,7 +402,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), io.readOpt(),
io.writeOpt() io.writeOpt()
), ),
std::move(points) std::move(points)
@ -415,7 +415,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), io.readOpt(),
io.writeOpt() io.writeOpt()
), ),
std::move(faces) std::move(faces)
@ -428,7 +428,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), io.readOpt(),
io.writeOpt() io.writeOpt()
), ),
std::move(owner) std::move(owner)
@ -441,7 +441,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), io.readOpt(),
io.writeOpt() io.writeOpt()
), ),
std::move(neighbour) std::move(neighbour)
@ -455,7 +455,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), IOobject::NO_READ, // ignore since no alternative can be supplied
io.writeOpt() io.writeOpt()
), ),
*this, *this,
@ -475,7 +475,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), IOobject::NO_READ, // ignore since no alternative can be supplied
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
*this, *this,
@ -489,7 +489,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), IOobject::NO_READ,// ignore since no alternative can be supplied
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
*this, *this,
@ -503,7 +503,7 @@ Foam::polyMesh::polyMesh
instance(), instance(),
meshSubDir, meshSubDir,
*this, *this,
IOobject::NO_READ, //io.readOpt(), IOobject::NO_READ, // ignore since no alternative can be supplied
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
*this, *this,
@ -515,6 +515,11 @@ Foam::polyMesh::polyMesh
curMotionTimeIndex_(time().timeIndex()), curMotionTimeIndex_(time().timeIndex()),
oldPointsPtr_(nullptr) oldPointsPtr_(nullptr)
{ {
// Note: changed that the constructors where values can be supplied
// (points, faces, owner/neighbour) use the readOpt. All others
// (boundary, *zones) ignore readOpt. To be reviewed as with
// constructor below
// Check if the faces and cells are valid // Check if the faces and cells are valid
forAll(faces_, facei) forAll(faces_, facei)
{ {
@ -666,6 +671,9 @@ Foam::polyMesh::polyMesh
curMotionTimeIndex_(time().timeIndex()), curMotionTimeIndex_(time().timeIndex()),
oldPointsPtr_(nullptr) oldPointsPtr_(nullptr)
{ {
// Note: probably needs io.readOpt() for points/faces/cells etc so
// we can run with READ_IF_PRESENT. See constructor above.
// Check if faces are valid // Check if faces are valid
forAll(faces_, facei) forAll(faces_, facei)
{ {

View File

@ -450,6 +450,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
PtrList<entry> patchEntries; PtrList<entry> patchEntries;
if (Pstream::master()) if (Pstream::master())
{ {
const bool oldParRun = Pstream::parRun(false);
facesInstance = io.time().findInstance facesInstance = io.time().findInstance
( (
meshSubDir, meshSubDir,
@ -470,6 +471,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
false false
) )
); );
Pstream::parRun(oldParRun);
// Send patches // Send patches
for (const int slave : Pstream::subProcs()) for (const int slave : Pstream::subProcs())
@ -520,11 +522,14 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
// Read mesh // Read mesh
// ~~~~~~~~~ // ~~~~~~~~~
// Now all processors read a mesh and use supplied points,faces etc // Now all processors read a mesh or use supplied points,faces etc
// if there is none. // if there is none.
// Note: fvSolution, fvSchemes are also using the supplied Ioobject so // Note: fvSolution, fvSchemes are also using the supplied IOobject so
// on slave will be NO_READ, on master READ_IF_PRESENT. This will // on slave will be NO_READ, on master READ_IF_PRESENT. This will
// conflict with e.g. timeStampMaster reading so switch off. // conflict with e.g. timeStampMaster reading so switch off.
// Note: v2006 used the READ_IF_PRESENT flag in the meshIO.readOpt(). v2012
// (correctly) does no longer so below code explicitly addFvPatches
// using the separately read boundary file.
const regIOobject::fileCheckTypes oldCheckType = const regIOobject::fileCheckTypes oldCheckType =
regIOobject::fileModificationChecking; regIOobject::fileModificationChecking;
@ -551,8 +556,12 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
DynamicList<polyPatch*> newPatches; DynamicList<polyPatch*> newPatches;
if (haveMesh) //Pstream::master()) if (mesh.boundary().size() == patchEntries.size())
{ {
// Assumably we have correctly read the boundary and can clone.
// Note: for
// v2012 onwards this is probably never the case and this whole
// section can be removed.
forAll(mesh.boundary(), patchI) forAll(mesh.boundary(), patchI)
{ {
newPatches.append newPatches.append
@ -563,6 +572,10 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
} }
else else
{ {
// Use patchEntries (read on master & scattered to slaves). This
// is probably always happening since boundary file is not read with
// READ_IF_PRESENT on recent versions.
forAll(patchEntries, patchI) forAll(patchEntries, patchI)
{ {
const entry& e = patchEntries[patchI]; const entry& e = patchEntries[patchI];
@ -577,8 +590,12 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
else else
{ {
dictionary patchDict(e.dict()); dictionary patchDict(e.dict());
if (mesh.nInternalFaces() == 0)
{
patchDict.set("nFaces", 0); patchDict.set("nFaces", 0);
patchDict.set("startFace", 0); patchDict.set("startFace", 0);
}
newPatches.append newPatches.append
( (
@ -655,7 +672,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::fvMeshTools::newMesh
); );
} }
if (pz.size() && fz.size() && cz.size()) if (pz.size() || fz.size() || cz.size())
{ {
mesh.addZones(pz, fz, cz); mesh.addZones(pz, fz, cz);
} }