From bac943e6fc3621c17c3f766d7df45a392e535b82 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 7 Mar 2018 11:21:48 +0100 Subject: [PATCH] ENH: new bitSet class and improved PackedList class (closes #751) - The bitSet class replaces the old PackedBoolList class. The redesign provides better block-wise access and reduced method calls. This helps both in cases where the bitSet may be relatively sparse, and in cases where advantage of contiguous operations can be made. This makes it easier to work with a bitSet as top-level object. In addition to the previously available count() method to determine if a bitSet is being used, now have simpler queries: - all() - true if all bits in the addressable range are empty - any() - true if any bits are set at all. - none() - true if no bits are set. These are faster than count() and allow early termination. The new test() method tests the value of a single bit position and returns a bool without any ambiguity caused by the return type (like the get() method), nor the const/non-const access (like operator[] has). The name corresponds to what std::bitset uses. The new find_first(), find_last(), find_next() methods provide a faster means of searching for bits that are set. This can be especially useful when using a bitSet to control an conditional: OLD (with macro): forAll(selected, celli) { if (selected[celli]) { sumVol += mesh_.cellVolumes()[celli]; } } NEW (with const_iterator): for (const label celli : selected) { sumVol += mesh_.cellVolumes()[celli]; } or manually for ( label celli = selected.find_first(); celli != -1; celli = selected.find_next() ) { sumVol += mesh_.cellVolumes()[celli]; } - When marking up contiguous parts of a bitset, an interval can be represented more efficiently as a labelRange of start/size. For example, OLD: if (isA(pp)) { forAll(pp, i) { ignoreFaces.set(i); } } NEW: if (isA(pp)) { ignoreFaces.set(pp.range()); } --- .../combustion/PDRFoam/PDRFoamAutoRefine.C | 2 +- .../overPimpleDyMFoam/interpolatedFaces.H | 8 +- applications/test/List/Test-List.C | 10 +- applications/test/ListOps/Test-ListOps.C | 2 +- .../test/PackedList/Test-PackedList.C | 4 +- .../test/PackedList1/Test-PackedList1.C | 246 ++++-- .../test/PackedList2/Test-PackedList2.C | 4 +- applications/test/PackedList3/Make/files | 3 - applications/test/PackedList4/Make/files | 3 - .../test/PackedList4/Test-PackedList4.C | 168 ---- .../test/PatchTools/Test-PatchTools.C | 2 +- applications/test/bitSet1/Make/files | 3 + .../{PackedList3 => bitSet1}/Make/options | 0 .../Test-bitSet1.C} | 62 +- applications/test/bitSet2/Make/files | 3 + .../{PackedList4 => bitSet2}/Make/options | 0 applications/test/bitSet2/Test-bitSet2.C | 311 ++++++++ applications/test/bitops/Test-bitops.C | 10 + applications/test/limits/Make/files | 3 + applications/test/limits/Make/options | 2 + .../test/machine-sizes/Test-machine-sizes.cpp | 58 +- .../Test-surfaceMeshConvert.C | 5 - applications/test/syncTools/Test-syncTools.C | 18 +- .../utilities/mesh/advanced/PDRMesh/PDRMesh.C | 10 +- .../mesh/advanced/modifyMesh/cellSplitter.C | 15 +- .../mesh/advanced/modifyMesh/modifyMesh.C | 2 +- .../refineWallLayer/refineWallLayer.C | 50 +- .../fluent3DMeshToFoam/fluent3DMeshToFoam.L | 6 +- .../fluentMeshToFoam/fluentMeshToFoam.L | 8 +- .../extrude/extrudeMesh/extrudeMesh.C | 2 +- .../extrudeToRegionMesh/extrudeToRegionMesh.C | 4 +- .../extrude2DMesh/extrude2DMeshApp.C | 2 +- .../controlMeshRefinement.C | 4 +- .../conformalVoronoiMesh.C | 2 +- .../conformalVoronoiMesh.H | 10 +- .../conformalVoronoiMeshCalcDualMesh.C | 16 +- .../conformalVoronoiMeshConformToSurface.C | 4 +- .../conformalVoronoiMeshIO.C | 8 +- .../generation/foamyMesh/foamyQuadMesh/CV2D.C | 2 +- .../generation/foamyMesh/foamyQuadMesh/CV2D.H | 2 +- .../mesh/manipulation/checkMesh/checkTools.C | 2 +- .../manipulation/checkMesh/checkTopology.C | 2 +- .../createBaffles/createBaffles.C | 25 +- .../mergeOrSplitBaffles/mergeOrSplitBaffles.C | 2 +- .../orientFaceZone/orientFaceZone.C | 2 +- .../manipulation/polyDualMesh/meshDualiser.C | 6 +- .../manipulation/polyDualMesh/meshDualiser.H | 6 +- .../polyDualMesh/polyDualMeshApp.C | 6 +- .../mesh/manipulation/refineMesh/refineMesh.C | 2 +- .../mesh/manipulation/subsetMesh/subsetMesh.C | 2 +- .../decomposePar/domainDecompositionMesh.C | 42 +- .../surface/surfaceHookUp/surfaceHookUp.C | 6 +- .../surface/surfaceInflate/surfaceInflate.C | 34 +- .../surfaceLambdaMuSmooth.C | 6 +- etc/controlDict | 1 + src/OpenFOAM/Make/files | 5 +- src/OpenFOAM/containers/Bits/BitOps/BitOps.H | 192 +++++ .../containers/Bits/PackedList/PackedList.C | 120 +++ .../{Lists => Bits}/PackedList/PackedList.H | 406 +++++----- .../PackedList/PackedListCore.C | 10 +- .../Bits/PackedList/PackedListCore.H | 67 ++ .../containers/Bits/PackedList/PackedListI.H | 753 ++++++++++++++++++ .../containers/Bits/PackedList/PackedListIO.C | 314 ++++++++ .../containers/Bits/bitSet/PackedBoolList.H | 36 + src/OpenFOAM/containers/Bits/bitSet/bitSet.C | 569 +++++++++++++ src/OpenFOAM/containers/Bits/bitSet/bitSet.H | 547 +++++++++++++ src/OpenFOAM/containers/Bits/bitSet/bitSetI.H | 672 ++++++++++++++++ .../containers/Bits/bitSet/bitSetIO.C | 135 ++++ .../containers/Bits/bitSet/bitSetTemplates.C | 59 ++ .../containers/HashTables/HashOps/HashOps.C | 51 +- .../containers/HashTables/HashOps/HashOps.H | 52 +- .../containers/Lists/ListOps/ListOps.C | 15 +- .../containers/Lists/ListOps/ListOps.H | 18 +- .../Lists/ListOps/ListOpsTemplates.C | 26 +- .../Lists/PackedList/PackedBoolList.C | 217 ----- .../Lists/PackedList/PackedBoolList.H | 216 ----- .../Lists/PackedList/PackedBoolListI.H | 152 ---- .../containers/Lists/PackedList/PackedList.C | 536 ------------- .../containers/Lists/PackedList/PackedListI.H | 730 ----------------- .../meshes/bandCompression/bandCompression.C | 6 +- .../meshes/meshShapes/cell/oppositeCellFace.C | 8 +- .../facePointPatch/facePointPatch.C | 1 - .../polyMesh/globalMeshData/globalMeshData.C | 8 +- .../polyMesh/globalMeshData/globalMeshData.H | 9 +- .../polyMesh/polyMeshCheck/polyMeshCheck.C | 8 +- .../meshes/polyMesh/syncTools/syncTools.C | 28 +- .../meshes/polyMesh/syncTools/syncTools.H | 12 +- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C | 4 +- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H | 4 +- .../primitiveMesh/PatchTools/PatchTools.H | 5 +- .../PatchTools/PatchToolsMatch.C | 2 +- .../PatchTools/PatchToolsSearch.C | 9 +- .../meshes/primitiveMesh/primitiveMesh.H | 5 +- .../primitiveMeshCheck/primitiveMeshCheck.C | 4 +- .../primitiveMeshCheck/primitiveMeshTools.C | 2 +- .../primitiveMeshCheck/primitiveMeshTools.H | 4 +- src/conversion/ccm/reader/ccmReaderMesh.C | 22 +- src/conversion/ensight/mesh/ensightMesh.C | 2 +- src/conversion/polyDualMesh/polyDualMesh.C | 21 +- .../dynamicRefineFvMesh/dynamicRefineFvMesh.C | 26 +- .../dynamicRefineFvMesh/dynamicRefineFvMesh.H | 22 +- .../createShellMesh/createShellMesh.C | 14 +- .../createShellMesh/createShellMesh.H | 8 +- .../extrudePatchMesh/extrudePatchMesh.C | 2 +- .../badQualityToCell/badQualityToCell.H | 2 +- .../badQualityToFace/badQualityToFace.H | 2 +- .../motionSmoother/motionSmootherAlgo.C | 10 +- .../motionSmoother/motionSmootherAlgo.H | 12 +- .../displacementLayeredMotionMotionSolver.C | 12 +- .../displacementLayeredMotionMotionSolver.H | 10 +- .../polyMeshFilter/polyMeshFilter.C | 18 +- .../polyMeshFilter/polyMeshFilter.H | 8 +- .../polyTopoChange/addPatchCellLayer.C | 2 +- .../polyTopoChange/edgeCollapser.C | 44 +- .../polyTopoChange/edgeCollapser.H | 31 +- .../polyTopoChange/hexRef8/hexRef8.C | 22 +- .../polyTopoChange/hexRef8/hexRef8.H | 4 +- .../polyTopoChange/polyTopoChange.C | 8 +- .../polyTopoChange/polyTopoChange.H | 8 +- .../polyTopoChange/tetDecomposer.H | 2 +- src/fileFormats/ensight/part/ensightFaces.C | 2 +- src/fileFormats/ensight/part/ensightFaces.H | 4 +- src/fileFormats/starcd/STARCDCore.C | 2 +- ...InletVelocityFvPatchVectorFieldTemplates.C | 2 +- .../isoAdvection/isoAdvection/isoAdvection.C | 20 +- .../isoAdvection/isoAdvection/isoAdvection.H | 7 +- .../wallBoundedParticle.H | 4 +- .../wallBoundedStreamLine.C | 4 +- .../wallBoundedStreamLine.H | 2 +- .../wallBoundedStreamLineParticle.H | 2 +- src/lagrangian/basic/Cloud/Cloud.H | 4 +- .../basic/InteractionLists/InteractionLists.C | 6 +- .../InflationInjection/InflationInjection.C | 2 +- .../InjectedParticleDistributionInjection.C | 2 +- .../InjectedParticleInjection.C | 4 +- .../ManualInjection/ManualInjection.C | 4 +- .../displacementMotionSolverMeshMover.C | 4 +- .../fieldSmoother/fieldSmoother.C | 16 +- .../fieldSmoother/fieldSmoother.H | 18 +- .../fieldSmoother/fieldSmootherTemplates.C | 4 +- .../medialAxisMeshMover.C | 24 +- .../medialAxisMeshMover.H | 6 +- .../meshRefinement/meshRefinement.C | 22 +- .../meshRefinement/meshRefinement.H | 24 +- .../meshRefinement/meshRefinementBaffles.C | 22 +- .../meshRefinementProblemCells.C | 4 +- .../meshRefinement/meshRefinementRefine.C | 12 +- .../meshRefinement/meshRefinementTemplates.C | 4 +- .../snappyHexMeshDriver/snappyLayerDriver.C | 10 +- .../snappyHexMeshDriver/snappyLayerDriver.H | 22 +- .../snappyLayerDriverTemplates.C | 2 +- .../snappyHexMeshDriver/snappySnapDriver.C | 20 +- .../snappyHexMeshDriver/snappySnapDriver.H | 10 +- .../snappySnapDriverFeature.C | 26 +- .../trackedParticle/trackedParticle.H | 4 +- src/meshTools/AABBTree/AABBTree.C | 4 +- .../algorithms/MeshWave/FaceCellWave.H | 6 +- .../PatchEdgeFaceWave/PatchEdgeFaceWave.C | 2 +- .../PatchEdgeFaceWave/PatchEdgeFaceWave.H | 8 +- .../algorithms/PointEdgeWave/PointEdgeWave.H | 7 +- src/meshTools/edgeMesh/edgeMesh.C | 4 +- .../edgeMeshFormats/nas/NASedgeFormat.C | 32 +- .../edgeMeshFormats/starcd/STARCDedgeFormat.C | 33 +- .../extendedEdgeMesh/extendedEdgeMesh.C | 4 +- .../extendedEdgeMeshTemplates.C | 4 +- .../extendedFeatureEdgeMeshTemplates.C | 4 +- src/meshTools/indexedOctree/treeDataFace.H | 4 +- .../mappedPolyPatch/mappedPatchBase.C | 2 +- src/meshTools/regionSplit/regionSplit.C | 6 +- .../targetVolumeToCell/targetVolumeToCell.C | 20 +- .../targetVolumeToCell/targetVolumeToCell.H | 8 +- .../faceSources/regionToFace/regionToFace.H | 2 +- src/meshTools/sets/topoSets/faceZoneSet.C | 2 +- .../surfaceIntersection/surfaceIntersection.C | 4 +- .../cellVolumeWeightCellCellStencil.C | 6 +- .../inverseDistanceCellCellStencil.C | 10 +- .../inverseDistanceCellCellStencil.H | 2 +- .../distributedTriSurfaceMesh.C | 2 +- .../sampledPlane/sampledPlane.C | 2 +- .../plane/surfMeshPlaneSampler.C | 6 +- src/sampling/surface/isoSurface/isoSurface.C | 12 +- src/sampling/surface/isoSurface/isoSurface.H | 6 +- .../surface/isoSurface/isoSurfaceCell.C | 12 +- .../surface/isoSurface/isoSurfaceCell.H | 10 +- .../surface/isoSurface/isoSurfaceTemplates.C | 4 +- src/surfMesh/triSurface/triSurface.C | 26 +- src/surfMesh/triSurface/triSurfaceIO.C | 4 +- src/surfMesh/triSurface/triSurfaceStitch.C | 4 +- .../rawTopoChangerFvMesh.C | 2 +- .../rawTopoChangerFvMesh.H | 6 +- .../rawTopoChangerFvMeshTemplates.C | 4 +- 191 files changed, 4995 insertions(+), 3151 deletions(-) delete mode 100644 applications/test/PackedList3/Make/files delete mode 100644 applications/test/PackedList4/Make/files delete mode 100644 applications/test/PackedList4/Test-PackedList4.C create mode 100644 applications/test/bitSet1/Make/files rename applications/test/{PackedList3 => bitSet1}/Make/options (100%) rename applications/test/{PackedList3/Test-PackedList3.C => bitSet1/Test-bitSet1.C} (61%) create mode 100644 applications/test/bitSet2/Make/files rename applications/test/{PackedList4 => bitSet2}/Make/options (100%) create mode 100644 applications/test/bitSet2/Test-bitSet2.C create mode 100644 applications/test/limits/Make/files create mode 100644 applications/test/limits/Make/options create mode 100644 src/OpenFOAM/containers/Bits/BitOps/BitOps.H create mode 100644 src/OpenFOAM/containers/Bits/PackedList/PackedList.C rename src/OpenFOAM/containers/{Lists => Bits}/PackedList/PackedList.H (51%) rename src/OpenFOAM/containers/{Lists => Bits}/PackedList/PackedListCore.C (89%) create mode 100644 src/OpenFOAM/containers/Bits/PackedList/PackedListCore.H create mode 100644 src/OpenFOAM/containers/Bits/PackedList/PackedListI.H create mode 100644 src/OpenFOAM/containers/Bits/PackedList/PackedListIO.C create mode 100644 src/OpenFOAM/containers/Bits/bitSet/PackedBoolList.H create mode 100644 src/OpenFOAM/containers/Bits/bitSet/bitSet.C create mode 100644 src/OpenFOAM/containers/Bits/bitSet/bitSet.H create mode 100644 src/OpenFOAM/containers/Bits/bitSet/bitSetI.H create mode 100644 src/OpenFOAM/containers/Bits/bitSet/bitSetIO.C create mode 100644 src/OpenFOAM/containers/Bits/bitSet/bitSetTemplates.C delete mode 100644 src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C delete mode 100644 src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H delete mode 100644 src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H delete mode 100644 src/OpenFOAM/containers/Lists/PackedList/PackedList.C delete mode 100644 src/OpenFOAM/containers/Lists/PackedList/PackedListI.H diff --git a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C index 4005d2d26f..6f41ca13c7 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) fvc::makeAbsolute(phi, rho, U); // Test : disable refinement for some cells - PackedBoolList& protectedCell = + bitSet& protectedCell = refCast(mesh).protectedCell(); if (protectedCell.empty()) diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H index c9dd9cd8fe..b86e23c3c8 100644 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H @@ -2,8 +2,8 @@ interpolationCellPoint UInterpolator(HbyA); // Determine faces on outside of interpolated cells -PackedBoolList isOwnerInterpolatedFace(mesh.nInternalFaces()); -PackedBoolList isNeiInterpolatedFace(mesh.nInternalFaces()); +bitSet isOwnerInterpolatedFace(mesh.nInternalFaces()); +bitSet isNeiInterpolatedFace(mesh.nInternalFaces()); // Determine donor cells labelListList donorCell(mesh.nInternalFaces()); @@ -175,11 +175,11 @@ surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf()); forAll(isNeiInterpolatedFace, faceI) { label cellId = -1; - if (isNeiInterpolatedFace[faceI]) + if (isNeiInterpolatedFace.test(faceI)) { cellId = mesh.faceNeighbour()[faceI]; } - else if (isOwnerInterpolatedFace[faceI]) + else if (isOwnerInterpolatedFace.test(faceI)) { cellId = mesh.faceOwner()[faceI]; } diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 9af25cbe5a..979ce9ac5d 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -474,7 +474,7 @@ int main(int argc, char *argv[]) } { - PackedBoolList select = HashSetOps::bitset(locations); + bitSet select = HashSetOps::bitset(locations); auto output = ListOps::createWithValue