From bf0b3d88727568f16133d8defdd8e3860fa9a983 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 4 May 2022 00:33:53 +0200 Subject: [PATCH] ENH: relocate sortedOrder from ListOps.H to List.H - commonly used, only depends on routines defined in UList (don't need the rest of ListOps for it). ENH: implement boolList::operator() const - allows use as a predicate functor, as per bitSet and labelHashSet GIT: combine SubList, UList into List directory (intertwined concepts) STYLE: default initialize DynamicList instead of with size 0 --- applications/test/boolList/Test-boolList.C | 24 +++++- applications/test/boolList/bitSetOrBoolList.H | 13 +++- applications/test/boolList/disabledBoolList.H | 7 +- applications/test/cplusplus1/Test-cpluplus1.C | 2 +- .../conformalVoronoiMeshCalcDualMesh.C | 14 ++-- src/OSspecific/MSwindows/signals/sigFpe.C | 2 +- src/OSspecific/POSIX/signals/sigFpe.C | 2 +- .../IndirectLists/SortList/SortListI.H | 2 +- src/OpenFOAM/containers/Lists/List/List.C | 48 ++++++++++++ src/OpenFOAM/containers/Lists/List/List.H | 19 ++++- .../Lists/{SubList => List}/SubList.H | 6 +- .../Lists/{SubList => List}/SubListI.H | 2 + .../containers/Lists/{UList => List}/UList.C | 74 ++++++++++--------- .../containers/Lists/{UList => List}/UList.H | 47 ++++++++---- .../containers/Lists/{UList => List}/UListI.H | 6 +- .../Lists/{UList => List}/UListIO.C | 0 .../Lists/{UList => List}/stdVectorIO.C | 0 .../containers/Lists/ListOps/ListOps.H | 21 +----- .../Lists/ListOps/ListOpsTemplates.C | 44 +---------- .../Lists/SortableList/SortableList.C | 2 +- .../meshes/bandCompression/bandCompression.C | 1 - .../polyTopoChange/hexRef8/hexRef8Data.C | 2 +- .../hexRef8/refinementHistory.C | 4 +- src/fileFormats/ensight/file/ensightFile.C | 2 +- src/fileFormats/vtk/format/foamVtkFormatter.H | 2 +- src/meshTools/polyTopoChange/polyTopoChange.C | 1 - 26 files changed, 200 insertions(+), 147 deletions(-) rename src/OpenFOAM/containers/Lists/{SubList => List}/SubList.H (98%) rename src/OpenFOAM/containers/Lists/{SubList => List}/SubListI.H (99%) rename src/OpenFOAM/containers/Lists/{UList => List}/UList.C (92%) rename src/OpenFOAM/containers/Lists/{UList => List}/UList.H (93%) rename src/OpenFOAM/containers/Lists/{UList => List}/UListI.H (98%) rename src/OpenFOAM/containers/Lists/{UList => List}/UListIO.C (100%) rename src/OpenFOAM/containers/Lists/{UList => List}/stdVectorIO.C (100%) diff --git a/applications/test/boolList/Test-boolList.C b/applications/test/boolList/Test-boolList.C index dd4f79a38f..f3eac1bd62 100644 --- a/applications/test/boolList/Test-boolList.C +++ b/applications/test/boolList/Test-boolList.C @@ -157,18 +157,34 @@ int main(int argc, char *argv[]) { boolList list2(5, true); list2.unset(2); + list2.unset(3); Info<< "Test wrapper idea" << nl; bitSetOrBoolList wrapper(list2); - if (wrapper.test(1)) + // Use predicate, or test() method + + if (list2(1)) { - Info<< "1 is on" << nl; + Info<< "1 is on (original)" << nl; } - if (!wrapper.test(2)) + if (!list2(2)) { - Info<< "2 is off" << nl; + Info<< "2 is off (original)" << nl; + } + if (!list2(100)) + { + Info<< "100 is off (original)" << nl; + } + + if (wrapper(1)) + { + Info<< "1 is on (wrapped)" << nl; + } + if (!wrapper(2)) + { + Info<< "2 is off (wrapped)" << nl; } } diff --git a/applications/test/boolList/bitSetOrBoolList.H b/applications/test/boolList/bitSetOrBoolList.H index 56e3b9d1f5..98ee9fbac3 100644 --- a/applications/test/boolList/bitSetOrBoolList.H +++ b/applications/test/boolList/bitSetOrBoolList.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,8 +32,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef bitSetOrBoolList_H -#define bitSetOrBoolList_H +#ifndef Foam_bitSetOrBoolList_H +#define Foam_bitSetOrBoolList_H #include "bitSet.H" #include "boolList.H" @@ -88,6 +88,13 @@ public: { return bits_.test(i) || bools_.test(i); } + + //- Test predicate + bool operator()(const label i) const + { + // Can also use test(i) etc... + return bits_(i) || bools_(i); + } }; diff --git a/applications/test/boolList/disabledBoolList.H b/applications/test/boolList/disabledBoolList.H index 7adc481e35..28b3bd69ac 100644 --- a/applications/test/boolList/disabledBoolList.H +++ b/applications/test/boolList/disabledBoolList.H @@ -41,8 +41,8 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef disabledBoolList_H -#define disabledBoolList_H +#ifndef Foam_disabledBoolList_H +#define Foam_disabledBoolList_H /*---------------------------------------------------------------------------*\ Class disabledBoolList Declaration @@ -60,6 +60,9 @@ struct disabledBoolList bool test(int) const { return true; } void set(bool) {} + + // Perhaps not? + /// bool operator()(const label i) const { return true; } }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/cplusplus1/Test-cpluplus1.C b/applications/test/cplusplus1/Test-cpluplus1.C index 37a4853ec0..8b86ee33c8 100644 --- a/applications/test/cplusplus1/Test-cpluplus1.C +++ b/applications/test/cplusplus1/Test-cpluplus1.C @@ -31,7 +31,7 @@ Description #include "string.H" #include "macros.H" #include "IOstreams.H" -#include "UList.H" +#include "List.H" #include "HashSet.H" #include diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index ad2ce6d098..72e91c3100 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -163,9 +163,8 @@ void Foam::conformalVoronoiMesh::calcTetMesh label nPatches = patchNames.size(); - List> patchFaces(nPatches, DynamicList(0)); - - List> patchOwners(nPatches, DynamicList