Commit e2825647 authored by mattijs's avatar mattijs
Browse files

checks on zones

parent e6416c26
......@@ -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))
......
#include "label.H"
#include "wordList.H"
namespace Foam
{
class polyMesh;
bool checkSync(const wordList& names);
label checkTopology(const polyMesh&, const bool, const bool);
}
......@@ -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;
......
......@@ -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_)
......
......@@ -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&);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment