From 1e95af4d571c46171fd8613641e29ff47a70505d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 9 Sep 2020 10:45:22 +0200 Subject: [PATCH] STYLE: use more generic terms allow/deny for selections --- .../dataConversion/foamToVTK/foamToVTK.C | 8 +++---- .../surfaceMeshExtract/surfaceMeshExtract.C | 8 +++---- .../surfaceSplitByPatch/surfaceSplitByPatch.C | 2 +- bin/tools/foamCreateModuleInclude | 4 ++-- .../primitives/strings/lists/stringListOps.H | 14 ++++++------- .../strings/lists/stringListOpsTemplates.C | 16 +++++++------- src/conversion/ccm/reader/ccmSolutionTable.H | 21 +++++++------------ src/fileFormats/ensight/mesh/ensightMesh.H | 4 ++-- src/functionObjects/field/ddt2/ddt2.C | 8 +++---- src/functionObjects/field/ddt2/ddt2.H | 2 +- src/surfMesh/MeshedSurface/MeshedSurface.H | 6 ++++-- .../surfaceFormats/surfaceFormatsCore.C | 8 +++---- .../surfaceFormats/surfaceFormatsCore.H | 8 +++---- src/surfMesh/triSurface/triSurface.H | 6 ++++-- 14 files changed, 57 insertions(+), 58 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 101736d53a..9749c968a9 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -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() ) ); diff --git a/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C b/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C index 2fff1bac66..38b364c949 100644 --- a/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C +++ b/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C @@ -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() ) ); diff --git a/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C b/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C index 3f2d9d79a6..65649dfd8a 100644 --- a/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C +++ b/applications/utilities/surface/surfaceSplitByPatch/surfaceSplitByPatch.C @@ -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 diff --git a/bin/tools/foamCreateModuleInclude b/bin/tools/foamCreateModuleInclude index 39054fb23e..1875a2f2c2 100755 --- a/bin/tools/foamCreateModuleInclude +++ b/bin/tools/foamCreateModuleInclude @@ -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 diff --git a/src/OpenFOAM/primitives/strings/lists/stringListOps.H b/src/OpenFOAM/primitives/strings/lists/stringListOps.H index 9e60bbdd19..e4c1d56d8f 100644 --- a/src/OpenFOAM/primitives/strings/lists/stringListOps.H +++ b/src/OpenFOAM/primitives/strings/lists/stringListOps.H @@ -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 labelList findMatching ( const StringListType& input, - const wordRes& whitelist, - const wordRes& blacklist = wordRes(), + const wordRes& allow, + const wordRes& deny = wordRes(), AccessOp aop = noOp() ); diff --git a/src/OpenFOAM/primitives/strings/lists/stringListOpsTemplates.C b/src/OpenFOAM/primitives/strings/lists/stringListOpsTemplates.C index 4de82c97e8..5e3f6ddf46 100644 --- a/src/OpenFOAM/primitives/strings/lists/stringListOpsTemplates.C +++ b/src/OpenFOAM/primitives/strings/lists/stringListOpsTemplates.C @@ -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 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) diff --git a/src/conversion/ccm/reader/ccmSolutionTable.H b/src/conversion/ccm/reader/ccmSolutionTable.H index 66fe7c38ab..f9343380c0 100644 --- a/src/conversion/ccm/reader/ccmSolutionTable.H +++ b/src/conversion/ccm/reader/ccmSolutionTable.H @@ -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 findNames ( - const wordRes& white, - const wordRes& black = wordRes() + const wordRes& allow, + const wordRes& deny = wordRes() ) const { List matched(SLList::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; } - }; diff --git a/src/fileFormats/ensight/mesh/ensightMesh.H b/src/fileFormats/ensight/mesh/ensightMesh.H index 1db242c65e..f85dddb5bf 100644 --- a/src/fileFormats/ensight/mesh/ensightMesh.H +++ b/src/fileFormats/ensight/mesh/ensightMesh.H @@ -303,10 +303,10 @@ public: //- Define patch selection matcher void patchSelection(List&& patterns); - //- Define patch selection blacklist + //- Define patch selection to exclude void patchExclude(const UList& patterns); - //- Define patch selection blacklist + //- Define patch selection to exclude void patchExclude(List&& patterns); //- Define faceZone selection matcher diff --git a/src/functionObjects/field/ddt2/ddt2.C b/src/functionObjects/field/ddt2/ddt2.C index f613f1197d..1e01c76118 100644 --- a/src/functionObjects/field/ddt2/ddt2.C +++ b/src/functionObjects/field/ddt2/ddt2.C @@ -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 ( @@ -159,7 +159,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict) return true; } - blacklist_.clear(); + denyField_.clear(); return false; } diff --git a/src/functionObjects/field/ddt2/ddt2.H b/src/functionObjects/field/ddt2/ddt2.H index 061f673222..7cb8a734e2 100644 --- a/src/functionObjects/field/ddt2/ddt2.H +++ b/src/functionObjects/field/ddt2/ddt2.H @@ -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_; diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.H b/src/surfMesh/MeshedSurface/MeshedSurface.H index 9e9e0e473f..5da16acea2 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.H +++ b/src/surfMesh/MeshedSurface/MeshedSurface.H @@ -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, diff --git a/src/surfMesh/surfaceFormats/surfaceFormatsCore.C b/src/surfMesh/surfaceFormats/surfaceFormatsCore.C index 83d2c15962..7b852cb3c1 100644 --- a/src/surfMesh/surfaceFormats/surfaceFormatsCore.C +++ b/src/surfMesh/surfaceFormats/surfaceFormatsCore.C @@ -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() ); } diff --git a/src/surfMesh/surfaceFormats/surfaceFormatsCore.H b/src/surfMesh/surfaceFormats/surfaceFormatsCore.H index 79d9afe12f..e023bb1480 100644 --- a/src/surfMesh/surfaceFormats/surfaceFormatsCore.H +++ b/src/surfMesh/surfaceFormats/surfaceFormatsCore.H @@ -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() ); diff --git a/src/surfMesh/triSurface/triSurface.H b/src/surfMesh/triSurface/triSurface.H index b920abc69a..695f6fbe68 100644 --- a/src/surfMesh/triSurface/triSurface.H +++ b/src/surfMesh/triSurface/triSurface.H @@ -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,