From e28256477acd2beb5fcd4724481f28bcfb04a70b Mon Sep 17 00:00:00 2001 From: mattijs <mattijs@hunt.opencfd.co.uk> Date: Tue, 30 Jun 2009 22:16:01 +0100 Subject: [PATCH] checks on zones --- .../manipulation/checkMesh/checkTopology.C | 50 +++++++++++ .../manipulation/checkMesh/checkTopology.H | 3 + .../manipulation/checkMesh/printMeshStats.C | 8 +- .../meshes/polyMesh/zones/faceZone/faceZone.C | 82 +++++++++++++++++++ .../meshes/polyMesh/zones/faceZone/faceZone.H | 4 + 5 files changed, 143 insertions(+), 4 deletions(-) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index 14f57048365..9ce34cda1c7 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -7,6 +7,31 @@ #include "pointSet.H" #include "IOmanip.H" +bool Foam::checkSync(const wordList& names) +{ + List<wordList> allNames(Pstream::nProcs()); + allNames[Pstream::myProcNo()] = names; + Pstream::gatherList(allNames); + + bool hasError = false; + + for (label procI = 1; procI < allNames.size(); procI++) + { + if (allNames[procI] != allNames[0]) + { + hasError = true; + + Info<< " ***Inconsistent zones across processors, " + "processor 0 has zones:" << allNames[0] + << ", processor " << procI << " has zones:" + << allNames[procI] + << endl; + } + } + return hasError; +} + + Foam::label Foam::checkTopology ( const polyMesh& mesh, @@ -24,6 +49,31 @@ Foam::label Foam::checkTopology // Check if the boundary processor patches are correct mesh.boundaryMesh().checkParallelSync(true); + // Check names of zones are equal + if (checkSync(mesh.cellZones().names())) + { + noFailedChecks++; + } + if (checkSync(mesh.faceZones().names())) + { + noFailedChecks++; + } + if (checkSync(mesh.pointZones().names())) + { + noFailedChecks++; + } + + // Check contents of faceZones consistent + { + forAll(mesh.faceZones(), zoneI) + { + if (mesh.faceZones()[zoneI].checkParallelSync(true)) + { + noFailedChecks++; + } + } + } + { pointSet points(mesh, "unusedPoints", mesh.nPoints()/100); if (mesh.checkPoints(true, &points)) diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H index 787aa4318d2..4790765d16e 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.H @@ -1,8 +1,11 @@ #include "label.H" +#include "wordList.H" namespace Foam { class polyMesh; + bool checkSync(const wordList& names); + label checkTopology(const polyMesh&, const bool, const bool); } diff --git a/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C b/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C index 9a2c9396afb..269656594c5 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C +++ b/applications/utilities/mesh/manipulation/checkMesh/printMeshStats.C @@ -69,13 +69,13 @@ void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) << " cells: " << returnReduce(mesh.cells().size(), sumOp<label>()) << nl << " boundary patches: " - << returnReduce(mesh.boundaryMesh().size(), sumOp<label>()) << nl + << mesh.boundaryMesh().size() << nl << " point zones: " - << returnReduce(mesh.pointZones().size(), sumOp<label>()) << nl + << mesh.pointZones().size() << nl << " face zones: " - << returnReduce(mesh.faceZones().size(), sumOp<label>()) << nl + << mesh.faceZones().size() << nl << " cell zones: " - << returnReduce(mesh.cellZones().size(), sumOp<label>()) << nl + << mesh.cellZones().size() << nl << endl; diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C index 5b688c64000..d4cc0a28436 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C @@ -34,6 +34,7 @@ Description #include "primitiveMesh.H" #include "demandDrivenData.H" #include "mapPolyMesh.H" +#include "syncTools.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -530,6 +531,87 @@ bool Foam::faceZone::checkDefinition(const bool report) const } +bool Foam::faceZone::checkParallelSync(const bool report) const +{ + const polyMesh& mesh = zoneMesh().mesh(); + const polyBoundaryMesh& bm = mesh.boundaryMesh(); + + bool boundaryError = false; + + + // Check that zone faces are synced + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + { + boolList neiZoneFace(mesh.nFaces()-mesh.nInternalFaces(), false); + boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false); + forAll(*this, i) + { + label faceI = operator[](i); + + if (!mesh.isInternalFace(faceI)) + { + neiZoneFace[faceI-mesh.nInternalFaces()] = true; + neiZoneFlip[faceI-mesh.nInternalFaces()] = flipMap()[i]; + } + } + boolList myZoneFace(neiZoneFace); + syncTools::swapBoundaryFaceList(mesh, neiZoneFace, false); + boolList myZoneFlip(neiZoneFlip); + syncTools::swapBoundaryFaceList(mesh, neiZoneFlip, false); + + forAll(*this, i) + { + label faceI = operator[](i); + + label patchI = bm.whichPatch(faceI); + + if (patchI != -1 && bm[patchI].coupled()) + { + label bFaceI = faceI-mesh.nInternalFaces(); + + // Check face in zone on both sides + if (myZoneFace[bFaceI] != neiZoneFace[bFaceI]) + { + boundaryError = true; + + if (report) + { + Pout<< " ***Problem with faceZone " << index() + << " named " << name() + << ". Face " << faceI + << " on coupled patch " + << bm[patchI].name() + << " is not consistent with its coupled neighbour." + << endl; + } + } + + // Flip state should be opposite. + if (myZoneFlip[bFaceI] == neiZoneFlip[bFaceI]) + { + boundaryError = true; + + if (report) + { + Pout<< " ***Problem with faceZone " << index() + << " named " << name() + << ". Face " << faceI + << " on coupled patch " + << bm[patchI].name() + << " does not have consistent flipMap" + << " across coupled faces." + << endl; + } + } + } + } + } + + return returnReduce(boundaryError, orOp<bool>()); +} + + void Foam::faceZone::movePoints(const pointField& p) { if (patchPtr_) diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H index f96c1dc189f..16c7e82b09c 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.H @@ -302,6 +302,10 @@ public: //- Check zone definition. Return true if in error. bool checkDefinition(const bool report = false) const; + //- Check whether all procs have faces synchronised. Return + // true if in error. + bool checkParallelSync(const bool report = false) const; + //- Correct patch after moving points virtual void movePoints(const pointField&); -- GitLab