From 51fd6327a64eae7904a8b4a2b02bb0109ae1490d Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Wed, 2 Dec 2009 17:04:31 +0100 Subject: [PATCH] use PackedBoolList typedef instead of PackedList<1> Note: PackedList constructor initializes to zero, faster not to do it ourselves. ie, PackedList foo(nPoints); vs. PackedList foo(nPoints, 0); saves an extra nPoints operations with shifts/masks etc. If speed is important, change this type of code PackedList isMaster(nPoints, 1u); for (loop) { if (condition) { isMaster.set(i, 0u); // unset bit } } return isMaster; into this: PackedList notMaster(nPoints); for (loop) { if (!condition) { notMaster.set(i, 1u); } } notMaster.flip(); return notMaster; or this: PackedList isMaster(nPoints); isMaster.flip(); for (loop) { if (condition) { isMaster.set(i, 0u); } } return isMaster; --- .../meshes/polyMesh/syncTools/syncTools.C | 8 ++++---- .../autoHexMeshDriver/autoLayerDriverShrink.C | 5 +---- .../autoHexMeshDriver/autoSnapDriver.C | 9 ++------- .../meshRefinement/meshRefinement.C | 2 +- .../distributedTriSurfaceMesh.C | 19 +++++++++++-------- .../rawTopoChangerFvMesh.C | 4 ++-- .../rawTopoChangerFvMesh.H | 6 +++--- .../rawTopoChangerFvMeshTemplates.C | 4 ++-- 8 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C index f1ffe42d747..817bee73bf6 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C @@ -75,8 +75,8 @@ void Foam::syncTools::checkTransform // Determines for every point whether it is coupled and if so sets only one. Foam::PackedBoolList Foam::syncTools::getMasterPoints(const polyMesh& mesh) { - PackedBoolList isMasterPoint(mesh.nPoints(), 0); - PackedBoolList donePoint(mesh.nPoints(), 0); + PackedBoolList isMasterPoint(mesh.nPoints()); + PackedBoolList donePoint(mesh.nPoints()); // Do multiple shared points. Min. proc is master @@ -194,8 +194,8 @@ Foam::PackedBoolList Foam::syncTools::getMasterPoints(const polyMesh& mesh) // Determines for every edge whether it is coupled and if so sets only one. Foam::PackedBoolList Foam::syncTools::getMasterEdges(const polyMesh& mesh) { - PackedBoolList isMasterEdge(mesh.nEdges(), 0); - PackedBoolList doneEdge(mesh.nEdges(), 0); + PackedBoolList isMasterEdge(mesh.nEdges()); + PackedBoolList doneEdge(mesh.nEdges()); // Do multiple shared edges. Min. proc is master diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index bc2dcabf58e..671cc334657 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -35,9 +35,6 @@ Description #include "pointData.H" #include "PointEdgeWave.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Calculate inverse sum of edge weights (currently always 1.0) @@ -240,7 +237,7 @@ void Foam::autoLayerDriver::smoothNormals const edgeList& edges = mesh.edges(); // Points that do not change. - PackedBoolList isFixedPoint(mesh.nPoints(), 0); + PackedBoolList isFixedPoint(mesh.nPoints()); // Internal points that are fixed forAll(fixedPoints, i) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index 41475a321af..c74e8718827 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -47,12 +47,7 @@ Description // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ - -defineTypeNameAndDebug(autoSnapDriver, 0); - -} // End namespace Foam +defineTypeNameAndDebug(Foam::autoSnapDriver, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -1308,7 +1303,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoSnapDriver::repatchToSurface // Faces that do not move - PackedBoolList isZonedFace(mesh.nFaces(), 0); + PackedBoolList isZonedFace(mesh.nFaces()); { // 1. All faces on zoned surfaces const wordList& faceZoneNames = surfaces.faceZoneNames(); diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index bda334cc511..12df8cbec0b 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -1274,7 +1274,7 @@ Foam::labelList Foam::meshRefinement::intersectedPoints() const const faceList& faces = mesh_.faces(); // Mark all points on faces that will become baffles - PackedBoolList isBoundaryPoint(mesh_.nPoints(), 0u); + PackedBoolList isBoundaryPoint(mesh_.nPoints()); label nBoundaryPoints = 0; forAll(surfaceIndex_, faceI) diff --git a/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C b/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C index c7ef4d5d946..60ad087b70a 100644 --- a/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C +++ b/src/meshTools/searchableSurface/distributedTriSurfaceMesh.C @@ -36,15 +36,19 @@ License #include "IFstream.H" #include "decompositionMethod.H" #include "vectorList.H" +#include "PackedBoolList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - -defineTypeNameAndDebug(distributedTriSurfaceMesh, 0); -addToRunTimeSelectionTable(searchableSurface, distributedTriSurfaceMesh, dict); - + defineTypeNameAndDebug(distributedTriSurfaceMesh, 0); + addToRunTimeSelectionTable + ( + searchableSurface, + distributedTriSurfaceMesh, + dict + ); } @@ -873,7 +877,7 @@ Foam::distributedTriSurfaceMesh::independentlyDistributedBbs bbs[procI].setSize(1); //bbs[procI][0] = boundBox::invertedBox; bbs[procI][0].min() = point( VGREAT, VGREAT, VGREAT); - bbs[procI][0].max() = point(-VGREAT, -VGREAT, -VGREAT); + bbs[procI][0].max() = point(-VGREAT, -VGREAT, -VGREAT); } forAll (s, triI) @@ -917,8 +921,7 @@ void Foam::distributedTriSurfaceMesh::calcBounds // Unfortunately nPoints constructs meshPoints() so do compact version // ourselves - PackedList<1> pointIsUsed(points().size()); - pointIsUsed = 0U; + PackedBoolList pointIsUsed(points().size()); nPoints = 0; bb.min() = point(VGREAT, VGREAT, VGREAT); @@ -933,7 +936,7 @@ void Foam::distributedTriSurfaceMesh::calcBounds forAll(f, fp) { label pointI = f[fp]; - if (pointIsUsed.set(pointI, 1)) + if (pointIsUsed.set(pointI, 1u)) { bb.min() = ::Foam::min(bb.min(), points()[pointI]); bb.max() = ::Foam::max(bb.max(), points()[pointI]); diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C index ccfb392b2e4..7903aaeeca7 100644 --- a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C @@ -82,8 +82,8 @@ bool Foam::rawTopoChangerFvMesh::update() // - internal faces inflated out of nothing // - patch faces created out of previously internal faces - // Is face mapped in any way - PackedList<1> mappedFace(nFaces()); + // Is face mapped in any way? + PackedBoolList mappedFace(nFaces()); const label nOldInternal = topoChangeMap().oldPatchStarts()[0]; diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H index 612829c3c8c..33a83dcc464 100644 --- a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H @@ -40,7 +40,7 @@ SourceFiles #define rawTopoChangerFvMesh_H #include "topoChangerFvMesh.H" -#include "PackedList.H" +#include "PackedBoolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -64,12 +64,12 @@ class rawTopoChangerFvMesh static void setUnmappedValues ( GeometricField<Type, PatchField, GeoMesh>& fld, - const PackedList<1>& mappedFace, + const PackedBoolList& mappedFace, const GeometricField<Type, PatchField, GeoMesh>& baseFld ); template<class Type, template<class> class PatchField, class GeoMesh> - void zeroUnmappedValues(const PackedList<1>&) const; + void zeroUnmappedValues(const PackedBoolList&) const; //- Disallow default bitwise copy construct rawTopoChangerFvMesh(const rawTopoChangerFvMesh&); diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C index 0be03061863..42410be6d31 100644 --- a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMeshTemplates.C @@ -33,7 +33,7 @@ template<class Type, template<class> class PatchField, class GeoMesh> void Foam::rawTopoChangerFvMesh::setUnmappedValues ( GeometricField<Type, PatchField, GeoMesh>& fld, - const PackedList<1>& mappedFace, + const PackedBoolList& mappedFace, const GeometricField<Type, PatchField, GeoMesh>& baseFld ) { @@ -65,7 +65,7 @@ void Foam::rawTopoChangerFvMesh::setUnmappedValues template<class Type, template<class> class PatchField, class GeoMesh> void Foam::rawTopoChangerFvMesh::zeroUnmappedValues ( - const PackedList<1>& mappedFace + const PackedBoolList& mappedFace ) const { typedef GeometricField<Type, PatchField, GeoMesh> FieldType; -- GitLab