ENH: reduce reliance on stringListOps functions

- findStrings, findMatchingStrings now mostly covered by matching
  intrinsics in wordRe and wordRes.

  Add static wordRes match() and matching() variants

COMP: remove stringListOps include from objectRegistry.H

- was already noted for removal (NOV-2018)
This commit is contained in:
Mark Olesen
2024-04-12 21:03:27 +02:00
parent 92c329a8a9
commit 16dd92b38e
36 changed files with 239 additions and 124 deletions

View File

@ -55,7 +55,7 @@ do
bitSet haveMeshOnProc; bitSet haveMeshOnProc;
std::unique_ptr<faMeshSubset> subsetter; std::unique_ptr<faMeshSubset> subsetter;
IOobjectList objects(0); IOobjectList objects;
refPtr<fileOperation> newHandler(fileOperation::NewUncollated()); refPtr<fileOperation> newHandler(fileOperation::NewUncollated());

View File

@ -26,7 +26,7 @@ forAll(meshes, regioni)
{ {
const auto& mesh = meshes[regioni]; const auto& mesh = meshes[regioni];
IOobjectList objects(0); IOobjectList objects;
if (doConvertFields && !timeDirs.empty()) if (doConvertFields && !timeDirs.empty())
{ {

View File

@ -141,7 +141,7 @@ Note
#include "pointSet.H" #include "pointSet.H"
#include "HashOps.H" #include "HashOps.H"
#include "regionProperties.H" #include "regionProperties.H"
#include "stringListOps.H" #include "stringListOps.H" // For stringListOps::findMatching()
#include "Cloud.H" #include "Cloud.H"
#include "readFields.H" #include "readFields.H"
@ -780,7 +780,7 @@ int main(int argc, char *argv[])
} }
} }
IOobjectList objects(0); IOobjectList objects;
if (doConvertFields) if (doConvertFields)
{ {

View File

@ -80,7 +80,6 @@ Usage
#include "IOobjectList.H" #include "IOobjectList.H"
#include "IOPtrList.H" #include "IOPtrList.H"
#include "volFields.H" #include "volFields.H"
#include "stringListOps.H"
#include "timeSelector.H" #include "timeSelector.H"
using namespace Foam; using namespace Foam;
@ -189,7 +188,7 @@ labelList findMatches
const HashTable<wordList>& shortcuts, const HashTable<wordList>& shortcuts,
const wordList& shortcutNames, const wordList& shortcutNames,
const wordList& thisKeys, const wordList& thisKeys,
const keyType& key const wordRe& key
) )
{ {
labelList matches; labelList matches;
@ -197,20 +196,20 @@ labelList findMatches
if (key.isPattern()) if (key.isPattern())
{ {
// Wildcard match // Wildcard match
matches = findStrings(key, thisKeys); matches = wordRes::matching(key, thisKeys);
} }
else if (shortcuts.size()) else if (shortcuts.size())
{ {
// See if patchGroups expand to valid thisKeys // See if patchGroups expand to valid thisKeys
labelList indices = findStrings(key, shortcutNames); labelList indices = wordRes::matching(key, shortcutNames);
for (const label idx : indices) for (const label idx : indices)
{ {
const word& name = shortcutNames[idx]; const word& name = shortcutNames[idx];
const wordList& keys = shortcuts[name]; const wordList& keys = shortcuts[name];
forAll(keys, j) for (const word& k : keys)
{ {
const label index = thisKeys.find(keys[j]); const label index = thisKeys.find(k);
if (index != -1) if (index != -1)
{ {
matches.append(index); matches.append(index);

View File

@ -51,6 +51,7 @@ Description
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "ListListOps.H" #include "ListListOps.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "indirectPrimitivePatch.H" #include "indirectPrimitivePatch.H"
#include "globalMeshData.H" #include "globalMeshData.H"
#include "globalIndex.H" #include "globalIndex.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -294,7 +294,7 @@ bool Foam::searchableSurfaceModifiers::cut::modify
// Find the surfaces to cut with // Find the surfaces to cut with
for (const wordRe& cutterName : cutterNames_) for (const wordRe& cutterName : cutterNames_)
{ {
labelList geomIDs = findStrings(cutterName, geometry_.names()); labelList geomIDs = wordRes::matching(cutterName, geometry_.names());
for (const label geomI : geomIDs) for (const label geomI : geomIDs)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd. Copyright (C) 2015-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -130,9 +130,14 @@ int main(int argc, char *argv[])
for (const entry& e : regionsDict) for (const entry& e : regionsDict)
{ {
const keyType& regionName = e.keyword(); const wordRe regionName(e.keyword());
const dictionary& regionDict = e.dict(); const dictionary& regionDict = e.dict();
labelList regionIDs
(
wordRes::matching(regionName, surf.regions())
);
autoPtr<searchableSurfaceModifier> modifier autoPtr<searchableSurfaceModifier> modifier
( (
searchableSurfaceModifier::New searchableSurfaceModifier::New
@ -143,9 +148,6 @@ int main(int argc, char *argv[])
) )
); );
labelList regionIDs =
findStrings(regionName, surf.regions());
if (modifier().modify(regionIDs, surf)) if (modifier().modify(regionIDs, surf))
{ {
changed = true; changed = true;

View File

@ -56,7 +56,7 @@ Usage
#include "argList.H" #include "argList.H"
#include "MeshedSurfaces.H" #include "MeshedSurfaces.H"
#include "stringListOps.H" #include "stringListOps.H" // For stringListOps::findMatching()
#include "geometricSurfacePatch.H" #include "geometricSurfacePatch.H"
using namespace Foam; using namespace Foam;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +28,7 @@ License
#include "removeEntry.H" #include "removeEntry.H"
#include "dictionary.H" #include "dictionary.H"
#include "stringListOps.H" #include "wordRes.H"
#include "addToMemberFunctionSelectionTable.H" #include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -75,7 +75,7 @@ bool Foam::functionEntries::removeEntry::execute
{ {
// Remove by pattern // Remove by pattern
const wordList dictKeys = parentDict.toc(); const wordList dictKeys = parentDict.toc();
const labelList indices = findStrings(key, dictKeys); const labelList indices = wordRes::matching(key, dictKeys);
for (const auto idx : indices) for (const auto idx : indices)
{ {

View File

@ -822,7 +822,7 @@ bool Foam::functionObjectList::execute
{ {
for (functionObject& funcObj : functions()) for (functionObject& funcObj : functions())
{ {
if (stringOps::match(functionNames, funcObj.name())) if (wordRes::match(functionNames, funcObj.name()))
{ {
// Probably do not need try/catch... // Probably do not need try/catch...

View File

@ -46,11 +46,6 @@ SourceFiles
#include "wordRes.H" #include "wordRes.H"
#include "Pair.H" #include "Pair.H"
// Historically included by objectRegistryTemplates (until NOV-2018),
// but not used by objectRegistry directly.
// Leave here for now to avoid a missing include in other bits of code.
#include "stringListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam

View File

@ -42,8 +42,8 @@ static wordHashSet getAcceptableFunctionKeys
const bool report = false const bool report = false
) )
{ {
wordHashSet acceptKeys(0); wordHashSet acceptKeys;
wordHashSet rejectKeys(0); wordHashSet rejectKeys;
if (!dictPtr) if (!dictPtr)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2023 OpenCFD Ltd. Copyright (C) 2015-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1476,7 +1476,7 @@ void Foam::argList::parse
{ {
labelList matched labelList matched
( (
findMatchingStrings(hostRoot.first(), hostMachine) wordRes::matching(hostRoot.first(), hostMachine)
); );
for (const label matchi : matched) for (const label matchi : matched)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -70,10 +70,10 @@ namespace stringOps
//- Count the number of occurrences of the specified character //- Count the number of occurrences of the specified character
std::string::size_type count(const std::string& s, const char c); std::string::size_type count(const std::string& s, const char c);
//- Return true if text matches one of the regular expressions. //- True if text matches one of the selector expressions
inline bool match(const UList<wordRe>& patterns, const std::string& text) inline bool match(const UList<wordRe>& selectors, const std::string& text)
{ {
return wordRes::matcher(patterns)(text); return wordRes::match(selectors, text);
} }
//- Quote any meta-characters in given string //- Quote any meta-characters in given string

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2023 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,24 +67,13 @@ class wordRes
( (
const UList<wordRe>& selectors, const UList<wordRe>& selectors,
const std::string& text, const std::string& text,
const bool literal=false const bool literal = false
);
//- Smart match across entire list, returning the best match type.
// Stops on the first literal match, or continues to examine
// if a regex match occurs.
// \return wordRe::LITERAL, wordRe::REGEX on match and
// wordRe::UNKNOWN otherwise.
inline static wordRe::compOption found_matched
(
const UList<wordRe>& selectors,
const std::string& text
); );
public: public:
// Static Data / Methods // Static Methods
//- Return a null wordRes (reference to a nullObject). //- Return a null wordRes (reference to a nullObject).
//- Behaves like a empty wordRes. //- Behaves like a empty wordRes.
@ -93,10 +82,6 @@ public:
return NullObjectRef<wordRes>(); return NullObjectRef<wordRes>();
} }
//- Return a wordRes with duplicate entries filtered out.
// No distinction made between literals and regular expressions.
static wordRes uniq(const UList<wordRe>& input);
// Constructors // Constructors
@ -108,6 +93,60 @@ public:
~wordRes() = default; ~wordRes() = default;
// Static Functions
//- Return a wordRes with duplicate entries filtered out.
// No distinction made between literals and regular expressions.
static wordRes uniq(const UList<wordRe>& input);
//- Test for a match
inline static bool match
(
const UList<wordRe>& selectors,
const std::string& text,
bool literal = false
);
//- Smart match across entire list, returning the best match type.
// Stops on the first literal match, or continues to examine
// if a regex match occurs.
// \return wordRe::LITERAL, wordRe::REGEX on match and
// wordRe::UNKNOWN otherwise.
inline static wordRe::compOption matched
(
const UList<wordRe>& selectors,
const std::string& text
);
//- Determine the list indices for all matches.
//
// \return indices of the matches in the input list
template<class StringType>
inline static labelList matching
(
//! A single literal or pattern matcher
const wordRe& select,
//! List of string inputs to match against
const UList<StringType>& input,
//! Invert the matching logic
const bool invert = false
);
//- Determine the list indices for all matches.
//
// \return indices of the matches in the input list
template<class StringType>
inline static labelList matching
(
//! The list of matchers
const UList<wordRe>& selectors,
//! List of string inputs to match against
const UList<StringType>& input,
//! Invert the matching logic
const bool invert = false
);
// Member Functions // Member Functions
//- Filter out duplicate entries (inplace). //- Filter out duplicate entries (inplace).
@ -128,16 +167,16 @@ public:
// UNKNOWN otherwise. // UNKNOWN otherwise.
inline wordRe::compOption matched(const std::string& text) const; inline wordRe::compOption matched(const std::string& text) const;
//- Return list indices for all matches. //- Determine the list indices for all matches.
// //
// \param input A list of string inputs to match against
// \param invert invert the matching logic
// \return indices of the matches in the input list // \return indices of the matches in the input list
template<class StringType> template<class StringType>
inline labelList matching inline labelList matching
( (
//! List of string inputs to match against
const UList<StringType>& input, const UList<StringType>& input,
const bool invert=false //! Invert the matching logic
const bool invert = false
) const; ) const;
@ -152,18 +191,19 @@ public:
//- Functor wrapper of a list of wordRe for matching //- Functor wrapper of a list of wordRe for matching
struct matcher struct matcher
{ {
//- Construct with 'allow' matcher //- Construct with \em select matcher(s)
inline matcher(const UList<wordRe>& allow); inline explicit matcher(const UList<wordRe>& selectors) noexcept;
//- Nothing defined //- No selectors defined
inline bool empty() const noexcept; inline bool empty() const noexcept;
//- True if text matches ANY of the entries. //- True if text matches ANY of the selectors.
//- Always false if entries are empty.
// Allows use as a predicate. // Allows use as a predicate.
inline bool operator()(const std::string& text) const; inline bool operator()(const std::string& text) const;
private: private:
const UList<wordRe>& allow_; const UList<wordRe>& select_;
}; };
@ -188,7 +228,7 @@ public:
( (
const UList<wordRe>& allow, const UList<wordRe>& allow,
const UList<wordRe>& deny const UList<wordRe>& deny
); ) noexcept;
//- Nothing defined //- Nothing defined
inline bool empty() const noexcept; inline bool empty() const noexcept;

View File

@ -48,7 +48,27 @@ inline Foam::label Foam::wordRes::first_match
} }
inline Foam::wordRe::compOption Foam::wordRes::found_matched // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
inline bool Foam::wordRes::match
(
const UList<wordRe>& selectors,
const std::string& text,
bool literal
)
{
for (const wordRe& select : selectors)
{
if (select.match(text, literal))
{
return true;
}
}
return false;
}
inline Foam::wordRe::compOption Foam::wordRes::matched
( (
const UList<wordRe>& selectors, const UList<wordRe>& selectors,
const std::string& text const std::string& text
@ -80,36 +100,27 @@ inline Foam::wordRe::compOption Foam::wordRes::found_matched
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::wordRes::match(const std::string& text, bool literal) const
{
return (first_match(*this, text, literal) >= 0);
}
inline Foam::wordRe::compOption
Foam::wordRes::matched(const std::string& text) const
{
return found_matched(*this, text);
}
template<class StringType> template<class StringType>
inline Foam::labelList Foam::wordRes::matching inline Foam::labelList Foam::wordRes::matching
( (
const wordRe& select,
const UList<StringType>& input, const UList<StringType>& input,
const bool invert const bool invert
) const )
{ {
if (select.empty() && !invert)
{
return labelList();
}
const label len = input.size(); const label len = input.size();
labelList indices(len); labelList indices(len);
label count = 0; label count = 0;
for (label i=0; i < len; ++i) for (label i = 0; i < len; ++i)
{ {
if (match(input[i]) ? !invert : invert) if (select.match(input[i]) ? !invert : invert)
{ {
indices[count] = i; indices[count] = i;
++count; ++count;
@ -121,11 +132,69 @@ inline Foam::labelList Foam::wordRes::matching
} }
template<class StringType>
inline Foam::labelList Foam::wordRes::matching
(
const UList<wordRe>& selectors,
const UList<StringType>& input,
const bool invert
)
{
if (selectors.empty() && !invert)
{
return labelList();
}
const label len = input.size();
labelList indices(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
if (wordRes::match(selectors, input[i]) ? !invert : invert)
{
indices[count] = i;
++count;
}
}
indices.resize(count);
return indices;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::wordRes::match(const std::string& text, bool literal) const
{
return wordRes::match(*this, text, literal);
}
inline Foam::wordRe::compOption
Foam::wordRes::matched(const std::string& text) const
{
return wordRes::matched(*this, text);
}
template<class StringType>
inline Foam::labelList Foam::wordRes::matching
(
const UList<StringType>& input,
const bool invert
) const
{
return wordRes::matching(*this, input, invert);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::wordRes::operator()(const std::string& text) const inline bool Foam::wordRes::operator()(const std::string& text) const
{ {
return (wordRes::first_match(*this, text) >= 0); return wordRes::match(*this, text);
} }
@ -133,10 +202,10 @@ inline bool Foam::wordRes::operator()(const std::string& text) const
inline Foam::wordRes::matcher::matcher inline Foam::wordRes::matcher::matcher
( (
const UList<wordRe>& allow const UList<wordRe>& selectors
) ) noexcept
: :
allow_(allow) select_(selectors)
{} {}
@ -144,7 +213,7 @@ inline Foam::wordRes::filter::filter
( (
const UList<wordRe>& allow, const UList<wordRe>& allow,
const UList<wordRe>& deny const UList<wordRe>& deny
) ) noexcept
: :
allow_(allow), allow_(allow),
deny_(deny) deny_(deny)
@ -153,7 +222,7 @@ inline Foam::wordRes::filter::filter
inline bool Foam::wordRes::matcher::empty() const noexcept inline bool Foam::wordRes::matcher::empty() const noexcept
{ {
return allow_.empty(); return select_.empty();
} }
inline bool Foam::wordRes::filter::empty() const noexcept inline bool Foam::wordRes::filter::empty() const noexcept
@ -164,7 +233,7 @@ inline bool Foam::wordRes::filter::empty() const noexcept
inline bool Foam::wordRes::matcher::operator()(const std::string& text) const inline bool Foam::wordRes::matcher::operator()(const std::string& text) const
{ {
return (wordRes::first_match(allow_, text) >= 0); return wordRes::match(select_, text);
} }
@ -173,17 +242,17 @@ inline bool Foam::wordRes::filter::operator()(const std::string& text) const
if (allow_.empty()) if (allow_.empty())
{ {
// No allow specified, so accept everything that is NOT blocked // No allow specified, so accept everything that is NOT blocked
return (deny_.empty() || (wordRes::first_match(deny_, text) < 0)); return (deny_.empty() || !wordRes::match(deny_, text));
} }
else if (deny_.empty()) else if (deny_.empty())
{ {
// Nothing blocked, apply accept filter // Nothing blocked, apply accept filter
return (wordRes::first_match(allow_, text) >= 0); return wordRes::match(allow_, text);
} }
else else
{ {
// Both accept and deny filters, need to search more carefully // Both accept and deny filters, need to search more carefully
const auto result = wordRes::found_matched(allow_, text); const auto result = wordRes::matched(allow_, text);
return return
( (
@ -192,7 +261,7 @@ inline bool Foam::wordRes::filter::operator()(const std::string& text) const
: :
( (
result == wordRe::REGEX result == wordRe::REGEX
&& (wordRes::first_match(deny_, text) < 0) && !wordRes::match(deny_, text)
) )
); );
} }

View File

@ -31,6 +31,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "processorPolyPatch.H" #include "processorPolyPatch.H"
#include "stringListOps.H" // For stringListOps::findMatching()
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -136,7 +136,7 @@ bool Foam::functionObjects::fieldSelection::resetFieldFilters
bool Foam::functionObjects::fieldSelection::read(const dictionary& dict) bool Foam::functionObjects::fieldSelection::read(const dictionary& dict)
{ {
HashSet<wordRe> fields(0); HashSet<wordRe> fields;
dict.readEntry("fields", fields); dict.readEntry("fields", fields);
return resetFieldFilters(fields); return resetFieldFilters(fields);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,7 +27,6 @@ License
#include "ddt2.H" #include "ddt2.H"
#include "stringOps.H" #include "stringOps.H"
#include "stringListOps.H"
#include "volFields.H" #include "volFields.H"
#include "dictionary.H" #include "dictionary.H"
#include "wordRes.H" #include "wordRes.H"
@ -173,7 +172,11 @@ bool Foam::functionObjects::ddt2::execute()
{ {
results_.clear(); results_.clear();
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names())); wordHashSet candidates
(
mesh_.names(selectFields_)
);
DynamicList<word> missing(selectFields_.size()); DynamicList<word> missing(selectFields_.size());
DynamicList<word> ignored(selectFields_.size()); DynamicList<word> ignored(selectFields_.size());

View File

@ -581,7 +581,10 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
const wordRe regionGroupName(dEntry.keyword()); const wordRe regionGroupName(dEntry.keyword());
const dictionary& regionDict = dEntry.dict(); const dictionary& regionDict = dEntry.dict();
labelList regionIDs = findStrings(regionGroupName, allRegionNames); labelList regionIDs
(
wordRes::matching(regionGroupName, allRegionNames)
);
const wordList regionNames(allRegionNames, regionIDs); const wordList regionNames(allRegionNames, regionIDs);

View File

@ -146,7 +146,7 @@ bool Foam::functionObjects::wallHeatFlux::read(const dictionary& dict)
dict.readIfPresent("qr", qrName_); dict.readIfPresent("qr", qrName_);
wordRes patchNames; wordRes patchNames;
labelHashSet patchSet(0); labelHashSet patchSet;
if (dict.readIfPresent("patches", patchNames) && !patchNames.empty()) if (dict.readIfPresent("patches", patchNames) && !patchNames.empty())
{ {
patchSet = pbm.patchSet(patchNames); patchSet = pbm.patchSet(patchNames);

View File

@ -131,7 +131,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
wordRes patchNames; wordRes patchNames;
labelHashSet patchSet(0); labelHashSet patchSet;
if (dict.readIfPresent("patches", patchNames) && !patchNames.empty()) if (dict.readIfPresent("patches", patchNames) && !patchNames.empty())
{ {
patchSet = pbm.patchSet(patchNames); patchSet = pbm.patchSet(patchNames);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,7 +26,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "zeroGradient.H" #include "zeroGradient.H"
#include "stringListOps.H"
#include "volFields.H" #include "volFields.H"
#include "dictionary.H" #include "dictionary.H"
#include "wordRes.H" #include "wordRes.H"
@ -135,7 +134,11 @@ bool Foam::functionObjects::zeroGradient::execute()
{ {
results_.clear(); results_.clear();
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names())); wordHashSet candidates
(
mesh_.names(selectFields_)
);
DynamicList<word> missing(selectFields_.size()); DynamicList<word> missing(selectFields_.size());
DynamicList<word> ignored(selectFields_.size()); DynamicList<word> ignored(selectFields_.size());

View File

@ -244,7 +244,7 @@ bool Foam::functionObjects::ensightWrite::write()
// Output fields MUST be specified to avoid accidentally // Output fields MUST be specified to avoid accidentally
// writing everything. Can still use ".*" for everything // writing everything. Can still use ".*" for everything
wordHashSet candidateNames(0); wordHashSet candidateNames;
if (!selectFields_.empty()) if (!selectFields_.empty())
{ {

View File

@ -29,7 +29,7 @@ License
#include "dictionary.H" #include "dictionary.H"
#include "Time.H" #include "Time.H"
#include "areaFields.H" #include "areaFields.H"
#include "stringListOps.H" #include "stringListOps.H" // For stringListOps::foundOp()
#include "foamVtkInternalWriter.H" #include "foamVtkInternalWriter.H"
#include "foamVtkPatchWriter.H" #include "foamVtkPatchWriter.H"
#include "foamVtkSeriesWriter.H" #include "foamVtkSeriesWriter.H"
@ -304,7 +304,7 @@ bool Foam::functionObjects::vtkWrite::write()
// Output fields MUST be specified to avoid accidentally // Output fields MUST be specified to avoid accidentally
// writing everything. Can still use ".*" for everything // writing everything. Can still use ".*" for everything
wordHashSet candidateNames(0); wordHashSet candidateNames;
if (!selectFields_.empty()) if (!selectFields_.empty())
{ {

View File

@ -27,6 +27,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ParticleErosion.H" #include "ParticleErosion.H"
#include "wordRes.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
@ -110,15 +111,15 @@ Foam::ParticleErosion<CloudType>::ParticleErosion
); );
labelHashSet uniqIds; labelHashSet uniqIds;
for (const wordRe& re : patchNames) for (const wordRe& select : patchNames)
{ {
labelList ids = findMatchingStrings(re, allPatchNames); labelList ids = wordRes::matching(select, allPatchNames);
if (ids.empty()) if (ids.empty())
{ {
WarningInFunction WarningInFunction
<< "Cannot find any patch names matching " << re << "Cannot find any patch names matching "
<< endl; << select << nl;
} }
uniqIds.insert(ids); uniqIds.insert(ids);

View File

@ -27,7 +27,6 @@ License
#include "ParticleHistogram.H" #include "ParticleHistogram.H"
#include "Pstream.H" #include "Pstream.H"
#include "stringListOps.H"
#include "ListOps.H" #include "ListOps.H"
#include "ListListOps.H" #include "ListListOps.H"

View File

@ -28,7 +28,6 @@ License
#include "ParticlePostProcessing.H" #include "ParticlePostProcessing.H"
#include "Pstream.H" #include "Pstream.H"
#include "stringListOps.H"
#include "ListOps.H" #include "ListOps.H"
#include "ListListOps.H" #include "ListListOps.H"

View File

@ -28,7 +28,6 @@ License
#include "PatchCollisionDensity.H" #include "PatchCollisionDensity.H"
#include "Pstream.H" #include "Pstream.H"
#include "stringListOps.H"
#include "ListOps.H" #include "ListOps.H"
#include "ListListOps.H" #include "ListListOps.H"

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -106,7 +106,7 @@ Foam::label Foam::triSurfaceLoader::select(const word& name)
if (available_.found(name)) if (available_.found(name))
{ {
selected_.resize(1); selected_.resize(1);
selected_.first() = name; selected_.front() = name;
} }
else else
{ {
@ -121,14 +121,14 @@ Foam::label Foam::triSurfaceLoader::select(const wordRe& mat)
{ {
if (mat.isPattern()) if (mat.isPattern())
{ {
labelList foundIds = findStrings(mat, available_); labelList foundIds = wordRes::matching(mat, available_);
Foam::sort(foundIds); Foam::sort(foundIds);
selected_ = wordList(available_, foundIds); selected_ = wordList(available_, foundIds);
} }
else if (available_.found(static_cast<const word&>(mat))) else if (available_.found(static_cast<const word&>(mat)))
{ {
selected_.resize(1); selected_.resize(1);
selected_.first() = mat; selected_.front() = mat;
} }
else else
{ {
@ -162,7 +162,7 @@ Foam::label Foam::triSurfaceLoader::select(const UList<wordRe>& matcher)
{ {
if (mat.isPattern()) if (mat.isPattern())
{ {
labelList indices = findStrings(mat, available_); labelList indices = wordRes::matching(mat, available_);
Foam::sort(indices); Foam::sort(indices);
for (const label idx : indices) for (const label idx : indices)

View File

@ -35,7 +35,6 @@ License
#include "surfaceInterpolate.H" #include "surfaceInterpolate.H"
#include "fvcDiv.H" #include "fvcDiv.H"
#include "fvcGrad.H" #include "fvcGrad.H"
#include "stringListOps.H"
#include "cyclicPolyPatch.H" #include "cyclicPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -174,7 +174,7 @@ Foam::IOobjectList Foam::sampledSets::preCheckFields(unsigned request)
wordList allFields; // Just needed for warnings wordList allFields; // Just needed for warnings
HashTable<wordHashSet> selected; HashTable<wordHashSet> selected;
IOobjectList objects(0); IOobjectList objects;
if (loadFromFiles_) if (loadFromFiles_)
{ {

View File

@ -34,6 +34,7 @@ License
#include "treeDataFace.H" #include "treeDataFace.H"
#include "meshTools.H" #include "meshTools.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "stringListOps.H" // For stringListOps::findMatching()
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -75,7 +75,7 @@ Foam::IOobjectList Foam::sampledSurfaces::preCheckFields()
wordList allFields; // Just needed for warnings wordList allFields; // Just needed for warnings
HashTable<wordHashSet> selected; HashTable<wordHashSet> selected;
IOobjectList objects(0); IOobjectList objects;
if (loadFromFiles_) if (loadFromFiles_)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,7 +30,7 @@ License
#include "Time.H" #include "Time.H"
#include "ListOps.H" #include "ListOps.H"
#include "surfMesh.H" #include "surfMesh.H"
#include "stringListOps.H" #include "stringListOps.H" // For stringListOps::findMatching()
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "surfZoneList.H" #include "surfZoneList.H"
#include "MeshedSurface.H" #include "MeshedSurface.H"
#include "ListOps.H" #include "ListOps.H"
#include "stringListOps.H" // For stringListOps::findMatching()
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //