MeshZones: Added findIndices
//- Find and return the zone indices for all matches
labelList findIndices(const wordRe&) const;
It may also be useful to provide versions taking a list of word or wordRe which
will be added as required.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -320,6 +320,39 @@ Foam::label Foam::MeshZones<ZoneType, MeshType>::findIndex
|
||||
}
|
||||
|
||||
|
||||
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::PackedBoolList Foam::MeshZones<ZoneType, MeshType>::findMatching
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -149,6 +149,9 @@ public:
|
||||
//- Find the zone index given the zone name
|
||||
label findIndex(const word& zoneName) const;
|
||||
|
||||
//- Find and return the zone indices for all matches
|
||||
labelList findIndices(const wordRe&) const;
|
||||
|
||||
//- Mark cells that match the zone specification
|
||||
PackedBoolList findMatching(const wordRe&) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user