Skip to content
Snippets Groups Projects
Commit 6c279829 authored by mattijs's avatar mattijs
Browse files

ENH: pointZone,cellZone,ZoneMesh : add parallel checking facility.

parent 09892917
Branches
Tags
No related merge requests found
...@@ -27,6 +27,7 @@ License ...@@ -27,6 +27,7 @@ License
#include "entry.H" #include "entry.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "stringListOps.H" #include "stringListOps.H"
#include "Pstream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
...@@ -372,6 +373,84 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::checkDefinition ...@@ -372,6 +373,84 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::checkDefinition
} }
template<class ZoneType, class MeshType>
bool Foam::ZoneMesh<ZoneType, MeshType>::checkParallelSync
(
const bool report
) const
{
if (!Pstream::parRun())
{
return false;
}
const PtrList<ZoneType>& zones = *this;
bool hasError = false;
// Collect all names
List<wordList> allNames(Pstream::nProcs());
allNames[Pstream::myProcNo()] = this->names();
Pstream::gatherList(allNames);
Pstream::scatterList(allNames);
List<wordList> allTypes(Pstream::nProcs());
allTypes[Pstream::myProcNo()] = this->types();
Pstream::gatherList(allTypes);
Pstream::scatterList(allTypes);
// Have every processor check but only master print error.
for (label procI = 1; procI < allNames.size(); procI++)
{
if
(
(allNames[procI] != allNames[0])
|| (allTypes[procI] != allTypes[0])
)
{
hasError = true;
if (debug || (report && Pstream::master()))
{
Info<< " ***Inconsistent zones across processors, "
"processor 0 has zone names:" << allNames[0]
<< " zone types:" << allTypes[0]
<< " processor " << procI << " has zone names:"
<< allNames[procI]
<< " zone types:" << allTypes[procI]
<< endl;
}
}
}
// Check contents
if (!hasError)
{
forAll(zones, zoneI)
{
if (zones[zoneI].checkParallelSync(false))
{
hasError = true;
if (debug || (report && Pstream::master()))
{
Info<< " ***Zone " << zones[zoneI].name()
<< " of type " << zones[zoneI].type()
<< " is not correctly synchronised"
<< " across coupled boundaries."
<< " (coupled faces are either not both "
<< " present in set or have same flipmap)" << endl;
}
}
}
}
return hasError;
}
// Correct zone mesh after moving points // Correct zone mesh after moving points
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& p) void Foam::ZoneMesh<ZoneType, MeshType>::movePoints(const pointField& p)
......
...@@ -149,6 +149,10 @@ public: ...@@ -149,6 +149,10 @@ public:
//- Check zone definition. Return true if in error. //- Check zone definition. Return true if in error.
bool checkDefinition(const bool report = false) const; bool checkDefinition(const bool report = false) const;
//- Check whether all procs have all zones and in same order. Return
// true if in error.
bool checkParallelSync(const bool report = false) const;
//- Correct zone mesh after moving points //- Correct zone mesh after moving points
void movePoints(const pointField&); void movePoints(const pointField&);
......
...@@ -209,6 +209,13 @@ public: ...@@ -209,6 +209,13 @@ public:
//- Check zone definition. Return true if in error. //- Check zone definition. Return true if in error.
virtual bool checkDefinition(const bool report = false) const; virtual bool checkDefinition(const bool report = false) const;
//- Check whether zone is synchronised across coupled boundaries. Return
// true if in error.
virtual bool checkParallelSync(const bool report = false) const
{
return false;
}
//- Write dictionary //- Write dictionary
virtual void writeDict(Ostream&) const; virtual void writeDict(Ostream&) const;
......
...@@ -29,6 +29,7 @@ License ...@@ -29,6 +29,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "syncTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...@@ -134,6 +135,49 @@ bool Foam::pointZone::checkDefinition(const bool report) const ...@@ -134,6 +135,49 @@ bool Foam::pointZone::checkDefinition(const bool report) const
} }
bool Foam::pointZone::checkParallelSync(const bool report) const
{
const polyMesh& mesh = zoneMesh().mesh();
labelList maxZone(mesh.nPoints(), -1);
labelList minZone(mesh.nPoints(), labelMax);
forAll(*this, i)
{
label pointI = operator[](i);
maxZone[pointI] = index();
minZone[pointI] = index();
}
syncTools::syncPointList(mesh, maxZone, maxEqOp<label>(), -1);
syncTools::syncPointList(mesh, minZone, minEqOp<label>(), labelMax);
bool error = false;
forAll(maxZone, pointI)
{
// Check point in zone on both sides
if (maxZone[pointI] != minZone[pointI])
{
if (report && !error)
{
Info<< " ***Problem with pointZone " << index()
<< " named " << name()
<< ". Point " << pointI
<< " at " << mesh.points()[pointI]
<< " is in zone "
<< (minZone[pointI] == labelMax ? -1 : minZone[pointI])
<< " on some processors and in zone "
<< maxZone[pointI]
<< " on some other processors."
<< endl;
}
error = true;
}
}
return error;
}
void Foam::pointZone::writeDict(Ostream& os) const void Foam::pointZone::writeDict(Ostream& os) const
{ {
os << nl << name_ << nl << token::BEGIN_BLOCK << nl os << nl << name_ << nl << token::BEGIN_BLOCK << nl
......
...@@ -208,6 +208,10 @@ public: ...@@ -208,6 +208,10 @@ public:
//- Check zone definition. Return true if in error. //- Check zone definition. Return true if in error.
virtual bool checkDefinition(const bool report = false) const; virtual bool checkDefinition(const bool report = false) const;
//- Check whether zone is synchronised across coupled boundaries. Return
// true if in error.
virtual bool checkParallelSync(const bool report = false) const;
//- Correct patch after moving points //- Correct patch after moving points
virtual void movePoints(const pointField&) virtual void movePoints(const pointField&)
{} {}
......
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