ENH: boundaryMesh - allow not found state in findPatchID

This commit is contained in:
Andrew Heather 2017-09-22 13:58:47 +01:00
parent 85877cb0f4
commit 99b67ba8db
2 changed files with 24 additions and 2 deletions

View File

@ -656,7 +656,11 @@ Foam::label Foam::polyBoundaryMesh::findIndex(const keyType& key) const
}
Foam::label Foam::polyBoundaryMesh::findPatchID(const word& patchName) const
Foam::label Foam::polyBoundaryMesh::findPatchID
(
const word& patchName,
bool allowNotFound
) const
{
const polyPatchList& patches = *this;
@ -668,6 +672,20 @@ Foam::label Foam::polyBoundaryMesh::findPatchID(const word& patchName) const
}
}
if (!allowNotFound)
{
string regionStr("");
if (mesh_.name() != polyMesh::defaultRegion)
{
regionStr = "in region '" + mesh_.name() + "' ";
}
FatalErrorInFunction
<< "Patch '" << patchName << "' not found. "
<< "Available patch names " << regionStr << "include: " << names()
<< exit(FatalError);
}
// Patch not found
if (debug)
{

View File

@ -171,7 +171,11 @@ public:
label findIndex(const keyType&) const;
//- Find patch index given a name
label findPatchID(const word& patchName) const;
label findPatchID
(
const word& patchName,
const bool allowNotFound = true
) const;
//- Find patch indices for a given polyPatch type
template<class Type>