Commit 1e95af4d authored by Mark Olesen's avatar Mark Olesen

STYLE: use more generic terms allow/deny for selections

parent d4cd8783
......@@ -168,8 +168,8 @@ Note
labelList getSelectedPatches
(
const polyBoundaryMesh& patches,
const wordRes& whitelist,
const wordRes& blacklist
const wordRes& allow,
const wordRes& deny
)
{
// Name-based selection
......@@ -178,8 +178,8 @@ labelList getSelectedPatches
stringListOps::findMatching
(
patches,
whitelist,
blacklist,
allow,
deny,
nameOp<polyPatch>()
)
);
......
......@@ -63,8 +63,8 @@ using namespace Foam;
labelList getSelectedPatches
(
const polyBoundaryMesh& patches,
const wordRes& whitelist,
const wordRes& blacklist
const wordRes& allow,
const wordRes& deny
)
{
// Name-based selection
......@@ -73,8 +73,8 @@ labelList getSelectedPatches
stringListOps::findMatching
(
patches,
whitelist,
blacklist,
allow,
deny,
nameOp<polyPatch>()
)
);
......
......@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
<< nl << endl;
}
// Identity if both whitelist and blacklist are empty
// Identity if both include/exclude lists are empty
const labelList zoneIndices
(
stringListOps::findMatching
......
......@@ -339,8 +339,8 @@ unset WM_DIR
# Third-party cruft - only used for orig compilation
# - as per spack installation
# Blacklist '[A-Z].*_ARCH_PATH'
# Whitelist 'MPI_ARCH_PATH'
# Remove: '[A-Z].*_ARCH_PATH'
# Keep: 'MPI_ARCH_PATH'
for envname in $(env | sed -n -e 's/^\(.*ARCH_PATH\)=.*$/\1/p')
do
......
......@@ -349,16 +349,16 @@ struct foundOp
//- 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.
// A regex match is trumped by a literal match.
// An empty 'allow' list accepts everything not in the 'deny' list.
// A literal match has higher priority over a regex match.
//
// Eg,
// \verbatim
// input: ( abc apple wall wall1 wall2 )
// whitelist: ( abc def "wall.*" )
// blacklist: ( "[ab].*" wall )
// allow: ( abc def "wall.*" )
// deny: ( "[ab].*" wall )
//
// result: (abc wall1 wall2)
// \endverbatim
......@@ -368,8 +368,8 @@ template<class StringListType, class AccessOp = noOp>
labelList findMatching
(
const StringListType& input,
const wordRes& whitelist,
const wordRes& blacklist = wordRes(),
const wordRes& allow,
const wordRes& deny = wordRes(),
AccessOp aop = noOp()
);
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -113,14 +113,14 @@ template<class StringListType, class AccessOp>
Foam::labelList Foam::stringListOps::findMatching
(
const StringListType& input,
const wordRes& whitelist,
const wordRes& blacklist,
const wordRes& allow,
const wordRes& deny,
AccessOp aop
)
{
const label len = input.size();
if (whitelist.empty() && blacklist.empty())
if (allow.empty() && deny.empty())
{
return identity(len);
}
......@@ -134,20 +134,20 @@ Foam::labelList Foam::stringListOps::findMatching
bool accept = false;
if (whitelist.size())
if (allow.size())
{
const auto result = whitelist.matched(text);
const auto result = allow.matched(text);
accept =
(
result == wordRe::LITERAL
? true
: (result == wordRe::REGEX && !blacklist.match(text))
: (result == wordRe::REGEX && !deny.match(text))
);
}
else
{
accept = !blacklist.match(text);
accept = !deny.match(text);
}
if (accept)
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -65,9 +65,8 @@ public:
// Constructors
//- Null construct
namesList()
{}
//- Default construct
namesList() = default;
// 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
(
const wordRes& white,
const wordRes& black = wordRes()
const wordRes& allow,
const wordRes& deny = wordRes()
) const
{
List<word> matched(SLList<T>::size());
......@@ -116,16 +115,15 @@ public:
{
const word& name = iter().name();
if (white.match(name) && !black.match(name))
if (allow.match(name) && !deny.match(name))
{
matched[matchi++] = name;
}
}
matched.setSize(matchi);
matched.resize(matchi);
return matched;
}
};
......@@ -258,7 +256,6 @@ public:
return os;
}
};
......@@ -333,7 +330,6 @@ public:
return os;
}
};
......@@ -419,7 +415,6 @@ public:
return os;
}
};
......
......@@ -303,10 +303,10 @@ public:
//- Define patch selection matcher
void patchSelection(List<wordRe>&& patterns);
//- Define patch selection blacklist
//- Define patch selection to exclude
void patchExclude(const UList<wordRe>& patterns);
//- Define patch selection blacklist
//- Define patch selection to exclude
void patchExclude(List<wordRe>&& patterns);
//- Define faceZone selection matcher
......
......@@ -76,7 +76,7 @@ bool Foam::functionObjects::ddt2::accept(const word& fieldName) const
{
// check input vs possible result names
// to avoid circular calculations
return !blacklist_.match(fieldName);
return !denyField_.match(fieldName);
}
......@@ -108,7 +108,7 @@ Foam::functionObjects::ddt2::ddt2
fvMeshFunctionObject(name, runTime, dict),
selectFields_(),
resultName_(word::null),
blacklist_(),
denyField_(),
results_(),
mag_(dict.getOrDefault("mag", false))
{
......@@ -148,7 +148,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
|| checkFormatName(resultName_)
)
{
blacklist_.set
denyField_.set
(
string::quotemeta<regExp>
(
......@@ -159,7 +159,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
return true;
}
blacklist_.clear();
denyField_.clear();
return false;
}
......
......@@ -137,7 +137,7 @@ class ddt2
word resultName_;
//- Avoid processing the same field twice
mutable regExp blacklist_;
mutable regExp denyField_;
//- Hashed names of result fields
wordHashSet results_;
......
......@@ -574,8 +574,10 @@ public:
//- Return a new surface subsetted on the selected zone names
//
// \param[in] includeNames the zone names to white-list
// \param[in] excludeNames the zone names to black-list
// \param[in] includeNames surface zone names to include
// \param[in] excludeNames surface zone names to exclude
//
// \see Foam::stringListOps::findMatching for details about matching
MeshedSurface subsetMesh
(
const wordRes& includeNames,
......
......@@ -59,16 +59,16 @@ Foam::string Foam::fileFormats::surfaceFormatsCore::getLineNoComment
Foam::labelList Foam::fileFormats::surfaceFormatsCore::getSelectedPatches
(
const surfZoneList& patches,
const wordRes& whitelist,
const wordRes& blacklist
const wordRes& allow,
const wordRes& deny
)
{
return
stringListOps::findMatching
(
patches,
whitelist,
blacklist,
allow,
deny,
nameOp<surfZone>()
);
}
......
......@@ -90,14 +90,14 @@ protected:
}
//- 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
(
const surfZoneList& patches,
const wordRes& whitelist,
const wordRes& blacklist = wordRes()
const wordRes& allow,
const wordRes& deny = wordRes()
);
......
......@@ -548,8 +548,10 @@ public:
//- Return a new surface subsetted on the selected patch names
//
// \param[in] includeNames the patch names to white-list
// \param[in] excludeNames the patch names to black-list
// \param[in] includeNames surface patch names to include
// \param[in] excludeNames surface patch names to exclude
//
// \see Foam::stringListOps::findMatching for details about matching
triSurface subsetMesh
(
const wordRes& includeNames,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment