polyBoundaryMesh,MeshZones: Changed argument of findIndex from wordRe to word
as it makes no sense to search for a regular expression which may provide multiple results and then arbitrarily return the first of them.
This commit is contained in:
@ -684,37 +684,6 @@ Foam::labelList Foam::polyBoundaryMesh::findIndices
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyBoundaryMesh::findIndex(const wordRe& key) const
|
||||
{
|
||||
if (!key.empty())
|
||||
{
|
||||
if (key.isPattern())
|
||||
{
|
||||
labelList indices = this->findIndices(key);
|
||||
|
||||
// return first element
|
||||
if (!indices.empty())
|
||||
{
|
||||
return indices[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::polyBoundaryMesh::findPatchID(const word& patchName) const
|
||||
{
|
||||
const polyPatchList& patches = *this;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -170,7 +170,13 @@ public:
|
||||
) const;
|
||||
|
||||
//- Return patch index for the first match, return -1 if not found
|
||||
label findIndex(const wordRe&) const;
|
||||
label findIndex(const wordRe&) const = delete;
|
||||
|
||||
//- Find patch index given a name
|
||||
label findIndex(const word& patchName) const
|
||||
{
|
||||
return findPatchID(patchName);
|
||||
}
|
||||
|
||||
//- Find patch index given a name
|
||||
label findPatchID(const word& patchName) const;
|
||||
|
||||
@ -291,74 +291,6 @@ bool Foam::MeshZones<ZoneType, MeshType>::found
|
||||
}
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::label Foam::MeshZones<ZoneType, MeshType>::findIndex
|
||||
(
|
||||
const wordRe& key
|
||||
) const
|
||||
{
|
||||
if (!key.empty())
|
||||
{
|
||||
if (key.isPattern())
|
||||
{
|
||||
labelList indices = this->findIndices(key);
|
||||
|
||||
// return first element
|
||||
if (!indices.empty())
|
||||
{
|
||||
return indices[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::labelList Foam::MeshZones<ZoneType, MeshType>::findIndices
|
||||
(
|
||||
const wordRe& key
|
||||
) const
|
||||
{
|
||||
labelList indices;
|
||||
|
||||
if (!key.empty())
|
||||
{
|
||||
if (key.isPattern())
|
||||
{
|
||||
indices = findStrings(key, this->names());
|
||||
}
|
||||
else
|
||||
{
|
||||
indices.setSize(this->size());
|
||||
label nFound = 0;
|
||||
forAll(*this, i)
|
||||
{
|
||||
if (key == operator[](i).name())
|
||||
{
|
||||
indices[nFound++] = i;
|
||||
}
|
||||
}
|
||||
indices.setSize(nFound);
|
||||
}
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
|
||||
template<class ZoneType, class MeshType>
|
||||
Foam::label Foam::MeshZones<ZoneType, MeshType>::findZoneID
|
||||
(
|
||||
|
||||
@ -147,12 +147,16 @@ public:
|
||||
bool found(const word& zoneName) const;
|
||||
|
||||
//- Return zone index for the first match, return -1 if not found
|
||||
label findIndex(const wordRe&) const;
|
||||
//- Find the zone index given the zone name
|
||||
label findIndex(const wordRe&) const = delete;
|
||||
|
||||
//- Return zone indices for all matches
|
||||
labelList findIndices(const wordRe&) const;
|
||||
//- Find the zone index given the zone name
|
||||
label findIndex(const word& zoneName) const
|
||||
{
|
||||
return findZoneID(zoneName);
|
||||
}
|
||||
|
||||
//- Find zone index given a name
|
||||
//- Find the zone index given the zone name
|
||||
label findZoneID(const word& zoneName) const;
|
||||
|
||||
//- Mark cells that match the zone specification
|
||||
|
||||
Reference in New Issue
Block a user