Merge branch 'feature-bitset' into 'develop'

ENH: new bitSet class and improved PackedList class (closes #751)

See merge request Development/OpenFOAM-plus!200
This commit is contained in:
Andrew Heather
2018-04-25 11:39:59 +01:00
191 changed files with 4995 additions and 3151 deletions

View File

@ -81,7 +81,7 @@ void modifyOrAddFace
const label zoneID,
const bool zoneFlip,
PackedBoolList& modifiedFace
bitSet& modifiedFace
)
{
if (modifiedFace.set(facei))
@ -338,7 +338,7 @@ void subsetTopoSets
Info<< "Subsetting " << set.type() << " " << set.name() << endl;
// Map the data
PackedBoolList isSet(set.maxSize(mesh));
bitSet isSet(set.maxSize(mesh));
forAllConstIter(labelHashSet, set, iter)
{
isSet.set(iter.key());
@ -374,7 +374,7 @@ void createCoupledBaffles
fvMesh& mesh,
const labelList& coupledWantedPatch,
polyTopoChange& meshMod,
PackedBoolList& modifiedFace
bitSet& modifiedFace
)
{
const faceZoneMesh& faceZones = mesh.faceZones();
@ -442,7 +442,7 @@ void createCyclicCoupledBaffles
const labelList& cyclicMasterPatch,
const labelList& cyclicSlavePatch,
polyTopoChange& meshMod,
PackedBoolList& modifiedFace
bitSet& modifiedFace
)
{
const faceZoneMesh& faceZones = mesh.faceZones();
@ -1119,7 +1119,7 @@ int main(int argc, char *argv[])
// Whether first use of face (modify) or consecutive (add)
PackedBoolList modifiedFace(mesh.nFaces());
bitSet modifiedFace(mesh.nFaces());
// Create coupled wall-side baffles
createCoupledBaffles

View File

@ -366,7 +366,7 @@ void Foam::cellSplitter::setRefinement
// Mark off affected face.
boolList faceUpToDate(mesh_.nFaces(), true);
bitSet faceUpToDate(mesh_.nFaces(), true);
forAllConstIter(Map<point>, cellToMidPoint, iter)
{
@ -374,18 +374,15 @@ void Foam::cellSplitter::setRefinement
const cell& cFaces = mesh_.cells()[celli];
forAll(cFaces, i)
{
label facei = cFaces[i];
faceUpToDate[facei] = false;
}
faceUpToDate.unsetMany(cFaces);
}
forAll(faceUpToDate, facei)
{
if (!faceUpToDate[facei])
if (!faceUpToDate.test(facei))
{
faceUpToDate.set(facei);
const face& f = mesh_.faces()[facei];
if (mesh_.isInternalFace(facei))
@ -454,8 +451,6 @@ void Foam::cellSplitter::setRefinement
)
);
}
faceUpToDate[facei] = true;
}
}
}

View File

@ -579,7 +579,7 @@ int main(int argc, char *argv[])
pointField newPoints(points);
PackedBoolList collapseEdge(mesh.nEdges());
bitSet collapseEdge(mesh.nEdges());
Map<point> collapsePointToLocation(mesh.nPoints());
// Get new positions and construct collapse network

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -97,10 +97,10 @@ int main(int argc, char *argv[])
label nPatchFaces = 0;
label nPatchEdges = 0;
forAllConstIter(labelHashSet, patchSet, iter)
for (const label patchi : patchSet)
{
nPatchFaces += mesh.boundaryMesh()[iter.key()].size();
nPatchEdges += mesh.boundaryMesh()[iter.key()].nEdges();
nPatchFaces += mesh.boundaryMesh()[patchi].size();
nPatchEdges += mesh.boundaryMesh()[patchi].nEdges();
}
// Construct from estimate for the number of cells to refine
@ -111,15 +111,13 @@ int main(int argc, char *argv[])
DynamicList<scalar> allCutEdgeWeights(nPatchEdges);
// Find cells to refine
forAllConstIter(labelHashSet, patchSet, iter)
for (const label patchi : patchSet)
{
const polyPatch& pp = mesh.boundaryMesh()[iter.key()];
const polyPatch& pp = mesh.boundaryMesh()[patchi];
const labelList& meshPoints = pp.meshPoints();
forAll(meshPoints, pointi)
for (const label meshPointi : meshPoints)
{
label meshPointi = meshPoints[pointi];
const labelList& pCells = mesh.pointCells()[meshPointi];
cutCells.insertMany(pCells);
@ -139,49 +137,43 @@ int main(int argc, char *argv[])
<< cells.instance()/cells.local()/cells.name()
<< nl << endl;
forAllConstIter(cellSet, cells, iter)
for (const label celli : cells)
{
cutCells.erase(iter.key());
cutCells.erase(celli);
}
Info<< "Removed from cells to cut all the ones not in set "
<< setName << nl << endl;
}
// Mark all mesh points on patch
boolList vertOnPatch(mesh.nPoints(), false);
bitSet vertOnPatch(mesh.nPoints());
forAllConstIter(labelHashSet, patchSet, iter)
for (const label patchi : patchSet)
{
const polyPatch& pp = mesh.boundaryMesh()[iter.key()];
const polyPatch& pp = mesh.boundaryMesh()[patchi];
const labelList& meshPoints = pp.meshPoints();
forAll(meshPoints, pointi)
{
vertOnPatch[meshPoints[pointi]] = true;
}
vertOnPatch.setMany(meshPoints);
}
forAllConstIter(labelHashSet, patchSet, iter)
for (const label patchi : patchSet)
{
const polyPatch& pp = mesh.boundaryMesh()[iter.key()];
const polyPatch& pp = mesh.boundaryMesh()[patchi];
const labelList& meshPoints = pp.meshPoints();
forAll(meshPoints, pointi)
for (const label meshPointi : meshPoints)
{
label meshPointi = meshPoints[pointi];
const labelList& pEdges = mesh.pointEdges()[meshPointi];
forAll(pEdges, pEdgeI)
for (const label edgei : pEdges)
{
const label edgeI = pEdges[pEdgeI];
const edge& e = mesh.edges()[edgeI];
const edge& e = mesh.edges()[edgei];
label otherPointi = e.otherVertex(meshPointi);
if (!vertOnPatch[otherPointi])
if (!vertOnPatch.test(otherPointi))
{
allCutEdges.append(edgeI);
allCutEdges.append(edgei);
if (e.start() == meshPointi)
{
@ -214,7 +206,7 @@ int main(int argc, char *argv[])
(
mesh,
cutCells.toc(), // cells candidate for cutting
labelList(0), // cut vertices
labelList(), // cut vertices
allCutEdges, // cut edges
cutEdgeWeights // weight on cut edges
);

View File

@ -869,7 +869,7 @@ int main(int argc, char *argv[])
// Pre-filtering: flip "owner" boundary or wrong oriented internal
// faces and move to neighbour
boolList fm(faces.size(), false);
bitSet fm(faces.size(), false);
forAll(faces, facei)
{
if
@ -878,7 +878,7 @@ int main(int argc, char *argv[])
|| (neighbour[facei] != -1 && owner[facei] > neighbour[facei])
)
{
fm[facei] = true;
fm.set(facei);
if (!cubitFile)
{
faces[facei].flip();
@ -1279,7 +1279,7 @@ int main(int argc, char *argv[])
false, // flipFaceFlux
-1, // patchID
faceZonei, // zoneID
fm[facei] // zoneFlip
fm.test(facei) // zoneFlip
);
}

View File

@ -1620,14 +1620,14 @@ int main(int argc, char *argv[])
labelList cls(end() - start() + 1);
// Mark zone cells, used for finding faces
boolList zoneCell(pShapeMesh.nCells(), false);
bitSet zoneCell(pShapeMesh.nCells(), false);
// shift cell indizes by 1
label nr=0;
for (label celli = (start() - 1); celli < end(); celli++)
{
cls[nr]=celli;
zoneCell[celli] = true;
zoneCell.set(celli);
nr++;
}
@ -1646,7 +1646,7 @@ int main(int argc, char *argv[])
label own = pShapeMesh.faceOwner()[facei];
if (nei != -1)
{
if (zoneCell[nei] && zoneCell[own])
if (zoneCell.test(nei) && zoneCell.test(own))
{
zoneFaces.append(facei);
}
@ -1669,7 +1669,7 @@ int main(int argc, char *argv[])
const labelList& faceCells = bPatches[pI].faceCells();
forAll(faceCells, fcI)
{
if (zoneCell[faceCells[fcI] ])
if (zoneCell.test(faceCells[fcI]))
{
boundaryZones[pI].append(name);
break;

View File

@ -890,7 +890,7 @@ int main(int argc, char *argv[])
const edgeList& edges = mesh.edges();
const pointField& points = mesh.points();
PackedBoolList collapseEdge(mesh.nEdges());
bitSet collapseEdge(mesh.nEdges());
Map<point> collapsePointToLocation(mesh.nPoints());
forAll(edges, edgeI)

View File

@ -1268,7 +1268,7 @@ void extrudeGeometricProperties
// Determine edge normals on original patch
labelList patchEdges;
labelList coupledEdges;
PackedBoolList sameEdgeOrientation;
bitSet sameEdgeOrientation;
PatchTools::matchEdges
(
extrudePatch,
@ -2160,7 +2160,7 @@ int main(int argc, char *argv[])
labelListList extrudeEdgePatches(extrudePatch.nEdges());
// Is edge a non-manifold edge
PackedBoolList nonManifoldEdge(extrudePatch.nEdges());
bitSet nonManifoldEdge(extrudePatch.nEdges());
// Note: logic has to be same as in countExtrudePatches.
forAll(edgeFaces, edgeI)

View File

@ -256,7 +256,7 @@ int main(int argc, char *argv[])
const boundBox& bb = mesh().bounds();
const scalar mergeDim = 1e-4 * bb.minDim();
PackedBoolList collapseEdge(mesh().nEdges());
bitSet collapseEdge(mesh().nEdges());
Map<point> collapsePointToLocation(mesh().nPoints());
forAll(edges, edgeI)

View File

@ -321,7 +321,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation
sizes.clear();
alignments.clear();
PackedBoolList keepVertex(vertices.size(), true);
bitSet keepVertex(vertices.size(), true);
forAll(vertices, vI)
{
@ -496,7 +496,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation
}
}
PackedBoolList keepVertex(vertices.size(), true);
bitSet keepVertex(vertices.size(), true);
forAll(vertices, vI)
{

View File

@ -1081,7 +1081,7 @@ void Foam::conformalVoronoiMesh::move()
Zero
);
PackedBoolList pointToBeRetained(number_of_vertices(), true);
bitSet pointToBeRetained(number_of_vertices(), true);
DynamicList<Point> pointsToInsert(number_of_vertices());

View File

@ -47,7 +47,7 @@ SourceFiles
#include "cellShapeControl.H"
#include "cvControls.H"
#include "DynamicList.H"
#include "PackedBoolList.H"
#include "bitSet.H"
#include "Time.H"
#include "polyMesh.H"
#include "plane.H"
@ -606,7 +606,7 @@ private:
pointField& cellCentres,
labelList& cellToDelaunayVertex,
labelListList& patchToDelaunayVertex,
PackedBoolList& boundaryFacesToRemove
bitSet& boundaryFacesToRemove
);
void calcNeighbourCellCentres
@ -760,7 +760,7 @@ private:
wordList& patchNames,
PtrList<dictionary>& patchDicts,
labelListList& patchPointPairSlaves,
PackedBoolList& boundaryFacesToRemove,
bitSet& boundaryFacesToRemove,
bool includeEmptyPatches = false
) const;
@ -791,7 +791,7 @@ private:
faceList& faces,
labelList& owner,
PtrList<dictionary>& patchDicts,
PackedBoolList& boundaryFacesToRemove,
bitSet& boundaryFacesToRemove,
const List<DynamicList<face>>& patchFaces,
const List<DynamicList<label>>& patchOwners,
const List<DynamicList<bool>>& indirectPatchFace
@ -997,7 +997,7 @@ public:
const wordList& patchNames,
const PtrList<dictionary>& patchDicts,
const pointField& cellCentres,
PackedBoolList& boundaryFacesToRemove
bitSet& boundaryFacesToRemove
) const;
//- Calculate and write a field of the target cell size,

View File

@ -47,7 +47,7 @@ void Foam::conformalVoronoiMesh::calcDualMesh
pointField& cellCentres,
labelList& cellToDelaunayVertex,
labelListList& patchToDelaunayVertex,
PackedBoolList& boundaryFacesToRemove
bitSet& boundaryFacesToRemove
)
{
timeCheck("Start calcDualMesh");
@ -277,7 +277,7 @@ void Foam::conformalVoronoiMesh::calcTetMesh
sortFaces(faces, owner, neighbour);
// PackedBoolList boundaryFacesToRemove;
// bitSet boundaryFacesToRemove;
// List<DynamicList<bool>> indirectPatchFace;
//
// addPatches
@ -703,7 +703,7 @@ Foam::conformalVoronoiMesh::createPolyMeshFromPoints
PtrList<dictionary> patchDicts;
pointField cellCentres;
labelListList patchToDelaunayVertex;
PackedBoolList boundaryFacesToRemove;
bitSet boundaryFacesToRemove;
timeCheck("Start of checkPolyMeshQuality");
@ -1103,7 +1103,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality
}
PackedBoolList ptToBeLimited(pts.size(), false);
bitSet ptToBeLimited(pts.size(), false);
forAllConstIter(labelHashSet, wrongFaces, iter)
{
@ -1704,7 +1704,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
wordList& patchNames,
PtrList<dictionary>& patchDicts,
labelListList& patchPointPairSlaves,
PackedBoolList& boundaryFacesToRemove,
bitSet& boundaryFacesToRemove,
bool includeEmptyPatches
) const
{
@ -2486,7 +2486,7 @@ void Foam::conformalVoronoiMesh::addPatches
faceList& faces,
labelList& owner,
PtrList<dictionary>& patchDicts,
PackedBoolList& boundaryFacesToRemove,
bitSet& boundaryFacesToRemove,
const List<DynamicList<face>>& patchFaces,
const List<DynamicList<label>>& patchOwners,
const List<DynamicList<bool>>& indirectPatchFace
@ -2531,7 +2531,7 @@ void Foam::conformalVoronoiMesh::removeUnusedPoints
{
Info<< nl << "Removing unused points" << endl;
PackedBoolList ptUsed(pts.size(), false);
bitSet ptUsed(pts.size(), false);
// Scan all faces to find all of the points that are used
@ -2585,7 +2585,7 @@ Foam::labelList Foam::conformalVoronoiMesh::removeUnusedCells
{
Info<< nl << "Removing unused cells" << endl;
PackedBoolList cellUsed(vertexCount(), false);
bitSet cellUsed(vertexCount(), false);
// Scan all faces to find all of the cells that are used

View File

@ -2271,7 +2271,7 @@ void Foam::conformalVoronoiMesh::reinsertSurfaceConformation()
ptPairs_.reIndex(oldToNewIndices);
PackedBoolList selectedElems(surfaceConformationVertices_.size(), true);
bitSet selectedElems(surfaceConformationVertices_.size(), true);
forAll(surfaceConformationVertices_, vI)
{
@ -2295,7 +2295,7 @@ void Foam::conformalVoronoiMesh::reinsertSurfaceConformation()
}
}
inplaceSubset<PackedBoolList, List<Vb>>
inplaceSubset<bitSet, List<Vb>>
(
selectedElems,
surfaceConformationVertices_

View File

@ -115,7 +115,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
wordList patchNames;
PtrList<dictionary> patchDicts;
pointField cellCentres;
PackedBoolList boundaryFacesToRemove;
bitSet boundaryFacesToRemove;
calcDualMesh
(
@ -377,7 +377,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
//
// Info<< nl << "Writing tetDualMesh to " << instance << endl;
//
// PackedBoolList boundaryFacesToRemove;
// bitSet boundaryFacesToRemove;
// writeMesh
// (
// "tetDualMesh",
@ -773,7 +773,7 @@ void Foam::conformalVoronoiMesh::writeMesh
const wordList& patchNames,
const PtrList<dictionary>& patchDicts,
const pointField& cellCentres,
PackedBoolList& boundaryFacesToRemove
bitSet& boundaryFacesToRemove
) const
{
if (foamyHexMeshControls().objOutput())
@ -949,7 +949,7 @@ void Foam::conformalVoronoiMesh::writeMesh
orEqOp<unsigned int>()
);
labelList addr(boundaryFacesToRemove.used());
labelList addr(boundaryFacesToRemove.toc());
faceSet indirectPatchFaces
(

View File

@ -496,7 +496,7 @@ void Foam::CV2D::newPoints()
scalar u = 1.0;
scalar l = 0.7;
PackedBoolList pointToBeRetained(startOfSurfacePointPairs_, true);
bitSet pointToBeRetained(startOfSurfacePointPairs_, true);
std::list<Point> pointsToInsert;

View File

@ -122,7 +122,7 @@ SourceFiles
#include "point2DFieldFwd.H"
#include "dictionary.H"
#include "Switch.H"
#include "PackedBoolList.H"
#include "bitSet.H"
#include "EdgeMap.H"
#include "cv2DControls.H"
#include "tolerances.H"

View File

@ -306,7 +306,7 @@ void Foam::mergeAndWrite
// Determine faces on outside of cellSet
PackedBoolList isInSet(mesh.nCells());
bitSet isInSet(mesh.nCells());
forAllConstIter(cellSet, set, iter)
{
isInSet.set(iter.key());

View File

@ -660,7 +660,7 @@ Foam::label Foam::checkTopology
const cellList& cells = mesh.cells();
const faceList& faces = mesh.faces();
PackedBoolList isZonePoint(mesh.nPoints());
bitSet isZonePoint(mesh.nPoints());
for (const cellZone& cZone : cellZones)
{

View File

@ -192,7 +192,7 @@ void modifyOrAddFace
const label zoneID,
const bool zoneFlip,
PackedBoolList& modifiedFace
bitSet& modifiedFace
)
{
if (modifiedFace.set(facei))
@ -247,7 +247,7 @@ void createFaces
const labelList& newMasterPatches,
const labelList& newSlavePatches,
polyTopoChange& meshMod,
PackedBoolList& modifiedFace,
bitSet& modifiedFace,
label& nModified
)
{
@ -538,15 +538,13 @@ int main(int argc, char *argv[])
if (mesh.faceZones().findZoneID(name) == -1)
{
mesh.faceZones().clearAddressing();
label sz = mesh.faceZones().size();
const label zoneID = mesh.faceZones().size();
labelList addr(0);
boolList flip(0);
mesh.faceZones().setSize(sz+1);
mesh.faceZones().setSize(zoneID+1);
mesh.faceZones().set
(
sz,
new faceZone(name, addr, flip, sz, mesh.faceZones())
zoneID,
new faceZone(name, labelList(), false, zoneID, mesh.faceZones())
);
}
}
@ -604,7 +602,14 @@ int main(int argc, char *argv[])
mesh.faceZones().set
(
zoneID,
new faceZone(name, addr, flip, zoneID, mesh.faceZones())
new faceZone
(
name,
std::move(addr),
std::move(flip),
zoneID,
mesh.faceZones()
)
);
}
@ -751,7 +756,7 @@ int main(int argc, char *argv[])
// side come first and faces from the other side next.
// Whether first use of face (modify) or consecutive (add)
PackedBoolList modifiedFace(mesh.nFaces());
bitSet modifiedFace(mesh.nFaces());
label nModified = 0;
forAll(selectors, selectorI)

View File

@ -483,7 +483,7 @@ int main(int argc, char *argv[])
}
candidates.setCapacity(sz);
PackedBoolList isCandidate(mesh.nPoints());
bitSet isCandidate(mesh.nPoints());
forAll(splitPatchIDs, i)
{
const labelList& mp = patches[splitPatchIDs[i]].meshPoints();

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
const PackedBoolList isMasterFace(syncTools::getMasterFaces(mesh));
const bitSet isMasterFace(syncTools::getMasterFaces(mesh));
// Data on all edges and faces

View File

@ -146,7 +146,7 @@ Foam::label Foam::meshDualiser::findDualCell
void Foam::meshDualiser::generateDualBoundaryEdges
(
const PackedBoolList& isBoundaryEdge,
const bitSet& isBoundaryEdge,
const label pointi,
polyTopoChange& meshMod
)
@ -374,7 +374,7 @@ Foam::label Foam::meshDualiser::addBoundaryFace
void Foam::meshDualiser::createFacesAroundEdge
(
const bool splitFace,
const PackedBoolList& isBoundaryEdge,
const bitSet& isBoundaryEdge,
const label edgeI,
const label startFacei,
polyTopoChange& meshMod,
@ -886,7 +886,7 @@ void Foam::meshDualiser::setRefinement
// Mark boundary edges and points.
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedBoolList isBoundaryEdge(mesh_.nEdges());
bitSet isBoundaryEdge(mesh_.nEdges());
for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); facei++)
{
const labelList& fEdges = mesh_.faceEdges()[facei];

View File

@ -48,7 +48,7 @@ SourceFiles
#define meshDualiser_H
#include "DynamicList.H"
#include "PackedBoolList.H"
#include "bitSet.H"
#include "boolList.H"
#include "typeInfo.H"
@ -100,7 +100,7 @@ class meshDualiser
// emanating from (boundary & feature) point
void generateDualBoundaryEdges
(
const PackedBoolList& isBoundaryEdge,
const bitSet& isBoundaryEdge,
const label pointi,
polyTopoChange& meshMod
);
@ -143,7 +143,7 @@ class meshDualiser
void createFacesAroundEdge
(
const bool splitFace,
const PackedBoolList& isBoundaryEdge,
const bitSet& isBoundaryEdge,
const label edgeI,
const label startFacei,
polyTopoChange& meshMod,

View File

@ -67,7 +67,7 @@ Note
#include "unitConversion.H"
#include "polyTopoChange.H"
#include "mapPolyMesh.H"
#include "PackedBoolList.H"
#include "bitSet.H"
#include "meshTools.H"
#include "OFstream.H"
#include "meshDualiser.H"
@ -87,7 +87,7 @@ using namespace Foam;
void simpleMarkFeatures
(
const polyMesh& mesh,
const PackedBoolList& isBoundaryEdge,
const bitSet& isBoundaryEdge,
const scalar featureAngle,
const bool concaveMultiCells,
const bool doNotPreserveFaceZones,
@ -390,7 +390,7 @@ int main(int argc, char *argv[])
// Mark boundary edges and points.
// (Note: in 1.4.2 we can use the built-in mesh point ordering
// facility instead)
PackedBoolList isBoundaryEdge(mesh.nEdges());
bitSet isBoundaryEdge(mesh.nEdges());
for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
{
const labelList& fEdges = mesh.faceEdges()[facei];

View File

@ -79,7 +79,7 @@ void printEdgeStats(const polyMesh& mesh)
scalar minOther = GREAT;
scalar maxOther = -GREAT;
PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh));
bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
const edgeList& edges = mesh.edges();

View File

@ -303,7 +303,7 @@ void subsetTopoSets
Info<< "Subsetting " << set.type() << " " << set.name() << endl;
// Map the data
PackedBoolList isSet(set.maxSize(mesh));
bitSet isSet(set.maxSize(mesh));
forAllConstIters(set, iter)
{
isSet.set(iter.key());