From 1f6f708da8f2597342b1c0fbc173230e76f4cc4c Mon Sep 17 00:00:00 2001 From: Pascal Beckstein Date: Tue, 6 Sep 2016 17:59:55 +0200 Subject: [PATCH] Bugfixes and improvements for parallel decomposition/reconstruction of regions --- .../decomposePar/decomposePar.C | 17 +++++-- .../decomposePar/faMeshDecomposition.C | 27 +++++++----- .../decomposeSets/processorMeshes.C | 44 +++++++++++++++++-- .../reconstructPar/processorMeshes.C | 44 +++++++++++++++++-- src/finiteArea/faMesh/faMesh.C | 4 +- src/finiteVolume/fvMesh/fvMesh.C | 4 +- 6 files changed, 116 insertions(+), 24 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 81bfd65ca..06ba968ae 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -284,6 +284,7 @@ int main(int argc, char *argv[]) ( "cellDist", runTime.timeName(), + mesh.dbDir(), mesh, IOobject::NO_READ, IOobject::NO_WRITE @@ -914,7 +915,7 @@ int main(int argc, char *argv[]) "faBoundary", mesh.time().findInstance ( - mesh.dbDir()/polyMesh::meshSubDir, + mesh.meshDir(), "boundary" ), faMesh::meshSubDir, @@ -989,12 +990,20 @@ int main(int argc, char *argv[]) faMesh procMesh(procFvMesh); + word faceLabelsInstance = + procMesh.time().findInstance + ( + procMesh.meshDir(), + "faceLabels" + ); + + labelIOList faceProcAddressing ( IOobject ( "faceProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::MUST_READ, @@ -1007,7 +1016,7 @@ int main(int argc, char *argv[]) IOobject ( "boundaryProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::MUST_READ, @@ -1031,7 +1040,7 @@ int main(int argc, char *argv[]) IOobject ( "edgeProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::MUST_READ, diff --git a/applications/utilities/parallelProcessing/decomposePar/faMeshDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/faMeshDecomposition.C index effd4cd06..a81f01324 100644 --- a/applications/utilities/parallelProcessing/decomposePar/faMeshDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/faMeshDecomposition.C @@ -78,7 +78,7 @@ void faMeshDecomposition::distributeFaces() IOobject ( "faceProcAddressing", - "constant", + procMesh.facesInstance(), procMesh.meshSubDir, procMesh, IOobject::MUST_READ, @@ -94,7 +94,7 @@ void faMeshDecomposition::distributeFaces() IOobject ( "owner", - "constant", + procMesh.facesInstance(), procMesh.meshSubDir, procMesh, IOobject::MUST_READ, @@ -127,7 +127,7 @@ void faMeshDecomposition::distributeFaces() IOobject ( "faceProcAddressing", - "constant", + procMesh.facesInstance(), procMesh.meshSubDir, procMesh, IOobject::MUST_READ, @@ -263,7 +263,7 @@ void faMeshDecomposition::decomposeMesh(const bool filterEmptyPatches) IOobject ( "pointProcAddressing", - "constant", + procFvMesh.facesInstance(), procFvMesh.meshSubDir, procFvMesh, IOobject::MUST_READ, @@ -279,7 +279,7 @@ void faMeshDecomposition::decomposeMesh(const bool filterEmptyPatches) IOobject ( "faceProcAddressing", - "constant", + procFvMesh.facesInstance(), procFvMesh.meshSubDir, procFvMesh, IOobject::MUST_READ, @@ -1202,7 +1202,7 @@ bool faMeshDecomposition::writeDecomposition() IOobject ( "boundaryProcAddressing", - "constant", + procFvMesh.facesInstance(), procFvMesh.meshSubDir, procFvMesh, IOobject::MUST_READ, @@ -1340,13 +1340,20 @@ bool faMeshDecomposition::writeDecomposition() maxProcPatches = max(maxProcPatches, nProcPatches); maxProcEdges = max(maxProcEdges, nProcEdges); + word faceLabelsInstance = + procMesh.time().findInstance + ( + procMesh.meshDir(), + "faceLabels" + ); + // create and write the addressing information labelIOList pointProcAddressing ( IOobject ( "pointProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::NO_READ, @@ -1361,7 +1368,7 @@ bool faMeshDecomposition::writeDecomposition() IOobject ( "edgeProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::NO_READ, @@ -1376,7 +1383,7 @@ bool faMeshDecomposition::writeDecomposition() IOobject ( "faceProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::NO_READ, @@ -1391,7 +1398,7 @@ bool faMeshDecomposition::writeDecomposition() IOobject ( "boundaryProcAddressing", - "constant", + faceLabelsInstance, procMesh.meshSubDir, procFvMesh, IOobject::NO_READ, diff --git a/applications/utilities/parallelProcessing/decomposeSets/processorMeshes.C b/applications/utilities/parallelProcessing/decomposeSets/processorMeshes.C index 6b31f4022..aac22b67b 100644 --- a/applications/utilities/parallelProcessing/decomposeSets/processorMeshes.C +++ b/applications/utilities/parallelProcessing/decomposeSets/processorMeshes.C @@ -157,6 +157,16 @@ Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate() // Check if any new meshes need to be read. polyMesh::readUpdateState procStat = meshes_[procI].readUpdate(); + // Force changed mesh if the processor mesh holds points. This is + // essential for changed region meshes and if the current time is + // equal to the initial time during construction. + // Pascal Beckstein, 14/Jul/2016 + fileName timePath = meshes_[procI].time().timePath(); + if (isFile(timePath/meshes_[procI].meshDir()/"points")) + { + procStat = polyMesh::POINTS_MOVED; + } + // Combine into overall mesh change status if (stat == polyMesh::UNCHANGED) { @@ -196,8 +206,36 @@ Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate() void Foam::processorMeshes::reconstructPoints(fvMesh& mesh) { + // We may not use + // mesh.movePoints(newPoints); + // mesh.write(); + // here, as this will fail for mesh regions containing + // directMappedPolyPatches or + // directMappedWallPolyPatches + // and probably other region-coupled patches. E.g. for both above + // mentioned directMapped patch types we have calls to + // directMappedPatchBase::map() + // in the corresponding initMovePoints(const pointField& p) member + // function. This however involves parallel communication and it would + // require all other connected regions to be already reconstructed and + // registered during reconstruction of the current region! + // Pascal Beckstein, 14/Jul/2016 + // Create the new points - vectorField newPoints(mesh.nPoints()); + pointIOField newPoints + ( + IOobject + ( + "points", + mesh.time().timeName(), + mesh.meshSubDir, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh.allPoints() + ); forAll (meshes_, procI) { @@ -225,8 +263,8 @@ void Foam::processorMeshes::reconstructPoints(fvMesh& mesh) } } - mesh.movePoints(newPoints); - mesh.write(); + newPoints.write(); + mesh.readUpdate(); } diff --git a/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C b/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C index 6b31f4022..aac22b67b 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C +++ b/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C @@ -157,6 +157,16 @@ Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate() // Check if any new meshes need to be read. polyMesh::readUpdateState procStat = meshes_[procI].readUpdate(); + // Force changed mesh if the processor mesh holds points. This is + // essential for changed region meshes and if the current time is + // equal to the initial time during construction. + // Pascal Beckstein, 14/Jul/2016 + fileName timePath = meshes_[procI].time().timePath(); + if (isFile(timePath/meshes_[procI].meshDir()/"points")) + { + procStat = polyMesh::POINTS_MOVED; + } + // Combine into overall mesh change status if (stat == polyMesh::UNCHANGED) { @@ -196,8 +206,36 @@ Foam::polyMesh::readUpdateState Foam::processorMeshes::readUpdate() void Foam::processorMeshes::reconstructPoints(fvMesh& mesh) { + // We may not use + // mesh.movePoints(newPoints); + // mesh.write(); + // here, as this will fail for mesh regions containing + // directMappedPolyPatches or + // directMappedWallPolyPatches + // and probably other region-coupled patches. E.g. for both above + // mentioned directMapped patch types we have calls to + // directMappedPatchBase::map() + // in the corresponding initMovePoints(const pointField& p) member + // function. This however involves parallel communication and it would + // require all other connected regions to be already reconstructed and + // registered during reconstruction of the current region! + // Pascal Beckstein, 14/Jul/2016 + // Create the new points - vectorField newPoints(mesh.nPoints()); + pointIOField newPoints + ( + IOobject + ( + "points", + mesh.time().timeName(), + mesh.meshSubDir, + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh.allPoints() + ); forAll (meshes_, procI) { @@ -225,8 +263,8 @@ void Foam::processorMeshes::reconstructPoints(fvMesh& mesh) } } - mesh.movePoints(newPoints); - mesh.write(); + newPoints.write(); + mesh.readUpdate(); } diff --git a/src/finiteArea/faMesh/faMesh.C b/src/finiteArea/faMesh/faMesh.C index 164bdcee5..a8af7d989 100644 --- a/src/finiteArea/faMesh/faMesh.C +++ b/src/finiteArea/faMesh/faMesh.C @@ -261,7 +261,7 @@ Foam::faMesh::faMesh(const polyMesh& pMesh) // Calculate the geometry for the patches (transformation tensors etc.) boundary_.calcGeometry(); - if (isFile(pMesh.time().timePath()/"S0")) + if (isFile(pMesh.time().timePath()/pMesh.dbDir()/"S0")) { S0Ptr_ = new DimensionedField ( @@ -808,7 +808,7 @@ Foam::faMesh::faMesh // Calculate the geometry for the patches (transformation tensors etc.) boundary_.calcGeometry(); - if (isFile(mesh().time().timePath()/"S0")) + if (isFile(mesh().time().timePath()/mesh().dbDir()/"S0")) { S0Ptr_ = new DimensionedField ( diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 928b3b83b..2c2eab0be 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -123,7 +123,7 @@ Foam::fvMesh::fvMesh(const IOobject& io) // Check the existance of the cell volumes and read if present // and set the storage of V00 - if (isFile(time().timePath()/"V0")) + if (isFile(time().timePath()/polyMesh::dbDir()/"V0")) { if (debug) { @@ -148,7 +148,7 @@ Foam::fvMesh::fvMesh(const IOobject& io) // Check the existance of the mesh fluxes, read if present and set the // mesh to be moving - if (isFile(time().timePath()/"meshPhi")) + if (isFile(time().timePath()/polyMesh::dbDir()/"meshPhi")) { if (debug) {