mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: zone.C: added check for duplicate entry in zone
This commit is contained in:
@ -26,6 +26,7 @@ License
|
||||
#include "zone.H"
|
||||
#include "IOstream.H"
|
||||
#include "demandDrivenData.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -192,6 +193,9 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
// To check for duplicate entries
|
||||
labelHashSet elems(size());
|
||||
|
||||
forAll(addr, i)
|
||||
{
|
||||
if (addr[i] < 0 || addr[i] >= maxSize)
|
||||
@ -215,6 +219,18 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!elems.insert(addr[i]))
|
||||
{
|
||||
if (report)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"bool zone::checkDefinition("
|
||||
"const label maxSize, const bool report) const"
|
||||
) << "Zone " << name_
|
||||
<< " contains duplicate index label " << addr[i] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hasError;
|
||||
|
||||
Reference in New Issue
Block a user