From a2bc1fd3a6b63f31265b076652bcf5bb72194103 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 21 Dec 2020 17:25:56 +0000 Subject: [PATCH] BUG: extrudeMesh: revert previous fix. see #1964 The polyMesh construct-from-components will now ignore the readOpt for the supplied primitives as before. This again re-allows READ_IF_PRESENT for fv* in combination with supplied primitives. --- .../extrude/extrudeMesh/extrudeMesh.C | 2 +- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 16 +--- src/OpenFOAM/meshes/polyMesh/polyMesh.H | 2 +- src/dynamicMesh/fvMeshTools/fvMeshTools.C | 84 +++++++++++++++++-- 4 files changed, 85 insertions(+), 19 deletions(-) diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index f46706141b..8f9c0b9d7b 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -704,7 +704,7 @@ int main(int argc, char *argv[]) regionName, runTimeExtruded.constant(), runTimeExtruded, - IOobject::NO_READ, // Do not read primitives, do read fv* + IOobject::READ_IF_PRESENT, // Read fv* if present IOobject::AUTO_WRITE, false ), diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 41799cf321..4d8dd6260c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -404,7 +404,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - io.readOpt(), + IOobject::NO_READ, //io.readOpt(), io.writeOpt() ), std::move(points) @@ -417,7 +417,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - io.readOpt(), + IOobject::NO_READ, //io.readOpt(), io.writeOpt() ), std::move(faces) @@ -430,7 +430,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - io.readOpt(), + IOobject::NO_READ, //io.readOpt(), io.writeOpt() ), std::move(owner) @@ -443,7 +443,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - io.readOpt(), + IOobject::NO_READ, //io.readOpt(), io.writeOpt() ), std::move(neighbour) @@ -519,11 +519,6 @@ Foam::polyMesh::polyMesh oldPointsPtr_(nullptr), oldCellCentresPtr_(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 forAll(faces_, facei) { @@ -677,9 +672,6 @@ Foam::polyMesh::polyMesh oldPointsPtr_(nullptr), oldCellCentresPtr_(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 forAll(faces_, facei) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index a75ccdf1ea..cda2419cbd 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -331,7 +331,7 @@ public: // Boundary is added using addPatches() member function polyMesh(const IOobject& io, const zero, const bool syncPar=true); - //- Construct from IOobject or from components. + //- Construct from IOobject and components. // Boundary is added using addPatches() member function polyMesh ( diff --git a/src/dynamicMesh/fvMeshTools/fvMeshTools.C b/src/dynamicMesh/fvMeshTools/fvMeshTools.C index 0b4c828cf1..f79eb95693 100644 --- a/src/dynamicMesh/fvMeshTools/fvMeshTools.C +++ b/src/dynamicMesh/fvMeshTools/fvMeshTools.C @@ -442,6 +442,7 @@ Foam::autoPtr Foam::fvMeshTools::newMesh fileName facesInstance; + fileName pointsInstance; // Patch types // ~~~~~~~~~~~ @@ -457,7 +458,12 @@ Foam::autoPtr Foam::fvMeshTools::newMesh "faces", IOobject::MUST_READ ); - + pointsInstance = io.time().findInstance + ( + meshSubDir, + "points", + IOobject::MUST_READ + ); patchEntries = polyBoundaryMeshEntries ( IOobject @@ -491,8 +497,9 @@ Foam::autoPtr Foam::fvMeshTools::newMesh fromMaster >> patchEntries; } - Pstream::scatter(facesInstance); + Pstream::scatter(pointsInstance); + // Dummy meshes // ~~~~~~~~~~~~ @@ -522,8 +529,7 @@ Foam::autoPtr Foam::fvMeshTools::newMesh // Read mesh // ~~~~~~~~~ - // Now all processors read a mesh or use supplied points,faces etc - // if there is none. + // Now all processors use supplied points,faces etc // Note: fvSolution, fvSchemes are also using the supplied IOobject so // on slave will be NO_READ, on master READ_IF_PRESENT. This will // conflict with e.g. timeStampMaster reading so switch off. @@ -535,7 +541,75 @@ Foam::autoPtr Foam::fvMeshTools::newMesh regIOobject::fileModificationChecking; regIOobject::fileModificationChecking = regIOobject::timeStamp; - auto meshPtr = autoPtr::New(meshIO, Zero); + + //- Points + pointIOField points + ( + IOobject + ( + "points", + pointsInstance, //meshIO.instance(), + meshSubDir, + meshIO.db(), + (haveMesh ? IOobject::MUST_READ : IOobject::NO_READ), + IOobject::NO_WRITE, + false + ) + ); + + //- Faces + faceCompactIOList faces + ( + IOobject + ( + "faces", + meshIO.instance(), + meshSubDir, + meshIO.db(), + (haveMesh ? IOobject::MUST_READ : IOobject::NO_READ), + IOobject::NO_WRITE, + false + ) + ); + + //- Face owner + labelIOList owner + ( + IOobject + ( + "owner", + meshIO.instance(), + meshSubDir, + meshIO.db(), + (haveMesh ? IOobject::MUST_READ : IOobject::NO_READ), + IOobject::NO_WRITE, + false + ) + ); + + //- Face neighbour + labelIOList neighbour + ( + IOobject + ( + "neighbour", + meshIO.instance(), + meshSubDir, + meshIO.db(), + (haveMesh ? IOobject::MUST_READ : IOobject::NO_READ), + IOobject::NO_WRITE, + false + ) + ); + + auto meshPtr = autoPtr::New + ( + meshIO, + std::move(points), + std::move(faces), + std::move(owner), + std::move(neighbour) + ); fvMesh& mesh = *meshPtr; regIOobject::fileModificationChecking = oldCheckType;