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:
Henry Weller
2024-01-04 16:48:32 +00:00
parent d5869d7413
commit 17dd64112a
2 changed files with 38 additions and 2 deletions

View File

@ -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
(

View File

@ -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;