STYLE: use more generic terms allow/deny for selections

This commit is contained in:
Mark Olesen
2020-09-09 10:45:22 +02:00
parent d4cd87830d
commit 1e95af4d57
14 changed files with 57 additions and 58 deletions

View File

@ -168,8 +168,8 @@ Note
labelList getSelectedPatches labelList getSelectedPatches
( (
const polyBoundaryMesh& patches, const polyBoundaryMesh& patches,
const wordRes& whitelist, const wordRes& allow,
const wordRes& blacklist const wordRes& deny
) )
{ {
// Name-based selection // Name-based selection
@ -178,8 +178,8 @@ labelList getSelectedPatches
stringListOps::findMatching stringListOps::findMatching
( (
patches, patches,
whitelist, allow,
blacklist, deny,
nameOp<polyPatch>() nameOp<polyPatch>()
) )
); );

View File

@ -63,8 +63,8 @@ using namespace Foam;
labelList getSelectedPatches labelList getSelectedPatches
( (
const polyBoundaryMesh& patches, const polyBoundaryMesh& patches,
const wordRes& whitelist, const wordRes& allow,
const wordRes& blacklist const wordRes& deny
) )
{ {
// Name-based selection // Name-based selection
@ -73,8 +73,8 @@ labelList getSelectedPatches
stringListOps::findMatching stringListOps::findMatching
( (
patches, patches,
whitelist, allow,
blacklist, deny,
nameOp<polyPatch>() nameOp<polyPatch>()
) )
); );

View File

@ -120,7 +120,7 @@ int main(int argc, char *argv[])
<< nl << endl; << nl << endl;
} }
// Identity if both whitelist and blacklist are empty // Identity if both include/exclude lists are empty
const labelList zoneIndices const labelList zoneIndices
( (
stringListOps::findMatching stringListOps::findMatching

View File

@ -339,8 +339,8 @@ unset WM_DIR
# Third-party cruft - only used for orig compilation # Third-party cruft - only used for orig compilation
# - as per spack installation # - as per spack installation
# Blacklist '[A-Z].*_ARCH_PATH' # Remove: '[A-Z].*_ARCH_PATH'
# Whitelist 'MPI_ARCH_PATH' # Keep: 'MPI_ARCH_PATH'
for envname in $(env | sed -n -e 's/^\(.*ARCH_PATH\)=.*$/\1/p') for envname in $(env | sed -n -e 's/^\(.*ARCH_PATH\)=.*$/\1/p')
do do

View File

@ -349,16 +349,16 @@ struct foundOp
//- Return ids for items with matching names. //- Return ids for items with matching names.
// Uses a combination of whitelist and blacklist. // Uses a combination of allow and deny lists
// //
// An empty whitelist accepts everything that is not blacklisted. // An empty 'allow' list accepts everything not in the 'deny' list.
// A regex match is trumped by a literal match. // A literal match has higher priority over a regex match.
// //
// Eg, // Eg,
// \verbatim // \verbatim
// input: ( abc apple wall wall1 wall2 ) // input: ( abc apple wall wall1 wall2 )
// whitelist: ( abc def "wall.*" ) // allow: ( abc def "wall.*" )
// blacklist: ( "[ab].*" wall ) // deny: ( "[ab].*" wall )
// //
// result: (abc wall1 wall2) // result: (abc wall1 wall2)
// \endverbatim // \endverbatim
@ -368,8 +368,8 @@ template<class StringListType, class AccessOp = noOp>
labelList findMatching labelList findMatching
( (
const StringListType& input, const StringListType& input,
const wordRes& whitelist, const wordRes& allow,
const wordRes& blacklist = wordRes(), const wordRes& deny = wordRes(),
AccessOp aop = noOp() AccessOp aop = noOp()
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd. Copyright (C) 2017-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -113,14 +113,14 @@ template<class StringListType, class AccessOp>
Foam::labelList Foam::stringListOps::findMatching Foam::labelList Foam::stringListOps::findMatching
( (
const StringListType& input, const StringListType& input,
const wordRes& whitelist, const wordRes& allow,
const wordRes& blacklist, const wordRes& deny,
AccessOp aop AccessOp aop
) )
{ {
const label len = input.size(); const label len = input.size();
if (whitelist.empty() && blacklist.empty()) if (allow.empty() && deny.empty())
{ {
return identity(len); return identity(len);
} }
@ -134,20 +134,20 @@ Foam::labelList Foam::stringListOps::findMatching
bool accept = false; bool accept = false;
if (whitelist.size()) if (allow.size())
{ {
const auto result = whitelist.matched(text); const auto result = allow.matched(text);
accept = accept =
( (
result == wordRe::LITERAL result == wordRe::LITERAL
? true ? true
: (result == wordRe::REGEX && !blacklist.match(text)) : (result == wordRe::REGEX && !deny.match(text))
); );
} }
else else
{ {
accept = !blacklist.match(text); accept = !deny.match(text);
} }
if (accept) if (accept)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,9 +65,8 @@ public:
// Constructors // Constructors
//- Null construct //- Default construct
namesList() namesList() = default;
{}
// Access // Access
@ -102,11 +101,11 @@ public:
} }
//- Return a list of names matching white-list and not in black-list //- Return a list of names in allow-list and not in deny-list
List<word> findNames List<word> findNames
( (
const wordRes& white, const wordRes& allow,
const wordRes& black = wordRes() const wordRes& deny = wordRes()
) const ) const
{ {
List<word> matched(SLList<T>::size()); List<word> matched(SLList<T>::size());
@ -116,16 +115,15 @@ public:
{ {
const word& name = iter().name(); const word& name = iter().name();
if (white.match(name) && !black.match(name)) if (allow.match(name) && !deny.match(name))
{ {
matched[matchi++] = name; matched[matchi++] = name;
} }
} }
matched.setSize(matchi); matched.resize(matchi);
return matched; return matched;
} }
}; };
@ -258,7 +256,6 @@ public:
return os; return os;
} }
}; };
@ -333,7 +330,6 @@ public:
return os; return os;
} }
}; };
@ -419,7 +415,6 @@ public:
return os; return os;
} }
}; };

View File

@ -303,10 +303,10 @@ public:
//- Define patch selection matcher //- Define patch selection matcher
void patchSelection(List<wordRe>&& patterns); void patchSelection(List<wordRe>&& patterns);
//- Define patch selection blacklist //- Define patch selection to exclude
void patchExclude(const UList<wordRe>& patterns); void patchExclude(const UList<wordRe>& patterns);
//- Define patch selection blacklist //- Define patch selection to exclude
void patchExclude(List<wordRe>&& patterns); void patchExclude(List<wordRe>&& patterns);
//- Define faceZone selection matcher //- Define faceZone selection matcher

View File

@ -76,7 +76,7 @@ bool Foam::functionObjects::ddt2::accept(const word& fieldName) const
{ {
// check input vs possible result names // check input vs possible result names
// to avoid circular calculations // to avoid circular calculations
return !blacklist_.match(fieldName); return !denyField_.match(fieldName);
} }
@ -108,7 +108,7 @@ Foam::functionObjects::ddt2::ddt2
fvMeshFunctionObject(name, runTime, dict), fvMeshFunctionObject(name, runTime, dict),
selectFields_(), selectFields_(),
resultName_(word::null), resultName_(word::null),
blacklist_(), denyField_(),
results_(), results_(),
mag_(dict.getOrDefault("mag", false)) mag_(dict.getOrDefault("mag", false))
{ {
@ -148,7 +148,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
|| checkFormatName(resultName_) || checkFormatName(resultName_)
) )
{ {
blacklist_.set denyField_.set
( (
string::quotemeta<regExp> string::quotemeta<regExp>
( (
@ -159,7 +159,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
return true; return true;
} }
blacklist_.clear(); denyField_.clear();
return false; return false;
} }

View File

@ -137,7 +137,7 @@ class ddt2
word resultName_; word resultName_;
//- Avoid processing the same field twice //- Avoid processing the same field twice
mutable regExp blacklist_; mutable regExp denyField_;
//- Hashed names of result fields //- Hashed names of result fields
wordHashSet results_; wordHashSet results_;

View File

@ -574,8 +574,10 @@ public:
//- Return a new surface subsetted on the selected zone names //- Return a new surface subsetted on the selected zone names
// //
// \param[in] includeNames the zone names to white-list // \param[in] includeNames surface zone names to include
// \param[in] excludeNames the zone names to black-list // \param[in] excludeNames surface zone names to exclude
//
// \see Foam::stringListOps::findMatching for details about matching
MeshedSurface subsetMesh MeshedSurface subsetMesh
( (
const wordRes& includeNames, const wordRes& includeNames,

View File

@ -59,16 +59,16 @@ Foam::string Foam::fileFormats::surfaceFormatsCore::getLineNoComment
Foam::labelList Foam::fileFormats::surfaceFormatsCore::getSelectedPatches Foam::labelList Foam::fileFormats::surfaceFormatsCore::getSelectedPatches
( (
const surfZoneList& patches, const surfZoneList& patches,
const wordRes& whitelist, const wordRes& allow,
const wordRes& blacklist const wordRes& deny
) )
{ {
return return
stringListOps::findMatching stringListOps::findMatching
( (
patches, patches,
whitelist, allow,
blacklist, deny,
nameOp<surfZone>() nameOp<surfZone>()
); );
} }

View File

@ -90,14 +90,14 @@ protected:
} }
//- Return ids for zone/patch that match by name. //- Return ids for zone/patch that match by name.
// Uses a combination of whitelist and blacklist. // Uses a combination of allow and deny lists.
// //
// See Foam::stringListOps::findMatching // \see Foam::stringListOps::findMatching for details about matching
static labelList getSelectedPatches static labelList getSelectedPatches
( (
const surfZoneList& patches, const surfZoneList& patches,
const wordRes& whitelist, const wordRes& allow,
const wordRes& blacklist = wordRes() const wordRes& deny = wordRes()
); );

View File

@ -548,8 +548,10 @@ public:
//- Return a new surface subsetted on the selected patch names //- Return a new surface subsetted on the selected patch names
// //
// \param[in] includeNames the patch names to white-list // \param[in] includeNames surface patch names to include
// \param[in] excludeNames the patch names to black-list // \param[in] excludeNames surface patch names to exclude
//
// \see Foam::stringListOps::findMatching for details about matching
triSurface subsetMesh triSurface subsetMesh
( (
const wordRes& includeNames, const wordRes& includeNames,