diff --git a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C index 30e5f5a6cfd59ff05a5a572921eaeee62a044cd8..065871725ea537253e3927a6405221c274fc6ebc 100644 --- a/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C +++ b/applications/solvers/combustion/PDRFoam/PDRFoamAutoRefine.C @@ -128,14 +128,14 @@ int main(int argc, char *argv[]) if (protectedCell.empty()) { protectedCell.setSize(mesh.nCells()); - protectedCell = 0; + protectedCell = false; } forAll(betav, celli) { if (betav[celli] < 0.99) { - protectedCell[celli] = 1; + protectedCell.set(celli); } } diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H index e13a2cc0a7c9d0d708fa1d4764097ff1bcc3cce8..9d7bf0bfef435fc43851538d7829e6ccd09b9fa7 100644 --- a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H @@ -41,7 +41,7 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1); && neiType == cellCellStencil::CALCULATED ) { - isOwnerInterpolatedFace[faceI] = true; + isOwnerInterpolatedFace.set(faceI); const vector& fc = mesh.faceCentres()[faceI]; @@ -106,7 +106,7 @@ labelList receptorNeigCell(mesh.nInternalFaces(), -1); && neiType == cellCellStencil::INTERPOLATED ) { - isNeiInterpolatedFace[faceI] = true; + isNeiInterpolatedFace.set(faceI); const vector& fc = mesh.faceCentres()[faceI]; for (label zoneI = 0; zoneI < nZones; zoneI++) diff --git a/applications/test/PackedList1/Test-PackedList1.C b/applications/test/PackedList1/Test-PackedList1.C index a963800e381f43bbaf7f0fd110c97f3bebe1baae..ce8bf9bd75accc5b318d17a5c44bd5ca25b79ab2 100644 --- a/applications/test/PackedList1/Test-PackedList1.C +++ b/applications/test/PackedList1/Test-PackedList1.C @@ -103,30 +103,6 @@ int main(int argc, char *argv[]) Info<< "[0] == [1] (unexpected)\n"; } - Info<< "\ntest operator== with iterator\n"; - { - PackedList<3>::iterator iter = list1[1]; - - if (iter != list1[8]) - { - Info<< "iter != [8] (expected)\n"; - } - else - { - Info<< "iter == [8] (unexpected)\n"; - } - - if (*iter != list1[8]) - { - Info<< "*iter != [8] (unexpected)\n"; - } - else - { - Info<< "*iter == [8] (expected)\n"; - } - } - - { const PackedList<3>& constLst = list1; Info<< "\ntest operator[] const with out-of-range index\n"; @@ -246,56 +222,10 @@ int main(int argc, char *argv[]) list1[32] = 2; list1[33] = 3; - Info<< "\ntest iterator\n"; - PackedList<3>::iterator iter = list1.begin(); - Info<< "begin():"; - iter.printInfo(Info) << "\n"; - - Info<< "iterator:" << *iter << "\n"; - *iter = 5; - iter.printInfo(Info); - list1.printInfo(Info, true); - - iter = list1[31]; - Info<< "iterator:" << *iter << "\n"; - iter.printInfo(Info); - - Info<< "\ntest get() method\n"; Info<< "get(10):" << list1.get(10) << " and list[10]:" << list1[10] << "\n"; list1.printInfo(Info, true); - Info<< "\ntest iterator indexing\n"; - Info<< "cend() "; - list1.cend().printInfo(Info) << "\n"; - - { - Info<< "\ntest assignment of iterator\n"; - list1.printInfo(Info, true); - Info<< "cend()\n"; - list1.end().printInfo(Info); - PackedList<3>::iterator cit = list1[100]; - Info<< "out-of-range: "; - cit.printInfo(Info); - cit = list1[15]; - Info<< "in-range: "; - cit.printInfo(Info); - Info<< "out-of-range: "; - cit = list1[1000]; - cit.printInfo(Info); - } - - - for - ( - PackedList<3>::iterator cit = list1[30]; - cit != list1.end(); - ++cit - ) - { - cit.printInfo(Info); - } - Info<< "\ntest operator[] auto-vivify\n"; Info<< "size:" << list1.size() << "\n"; diff --git a/applications/test/PackedList2/Test-PackedList2.C b/applications/test/PackedList2/Test-PackedList2.C index 090b64d973a4391dc6418e33f2223cca9a0dd417..053501e96e2a95b0db6185440bb83500a4948076 100644 --- a/applications/test/PackedList2/Test-PackedList2.C +++ b/applications/test/PackedList2/Test-PackedList2.C @@ -225,36 +225,6 @@ int main(int argc, char *argv[]) << " sum " << sum << nl; - // Read via iterator - sum = 0; - for (label iter = 0; iter < nIters; ++iter) - { - forAllIters(packed, it) - { - sum += it; - } - } - std::cout - << "Reading packed using iterator:" << timer.cpuTimeIncrement() - << " s" << nl - << " sum " << sum << nl; - - - // Read via iterator - sum = 0; - for (label iter = 0; iter < nIters; ++iter) - { - forAllConstIters(packed, cit) - { - sum += *cit; - } - } - std::cout - << "Reading packed using const_iterator():" << timer.cpuTimeIncrement() - << " s" << nl - << " sum " << sum << nl; - - // Read empty hash sum = 0; for (label iter = 0; iter < nIters; ++iter) @@ -367,18 +337,6 @@ int main(int argc, char *argv[]) Info<< "Writing packed using set:" << timer.cpuTimeIncrement() << " s" << nl; - // Write packed - for (label iter = 0; iter < nIters; ++iter) - { - forAllIters(packed, it) - { - *it = 1; - } - } - Info<< "Writing packed using iterator:" << timer.cpuTimeIncrement() - << " s" << nl; - - // Write packed for (label iter = 0; iter < nIters; ++iter) { diff --git a/applications/test/PackedList4/Test-PackedList4.C b/applications/test/PackedList4/Test-PackedList4.C index 5d6dea32165d7dd8b97888e4d1ea15afcaadf976..dd8780d7686b6e1ef878e235b4b31397d1c36b77 100644 --- a/applications/test/PackedList4/Test-PackedList4.C +++ b/applications/test/PackedList4/Test-PackedList4.C @@ -53,9 +53,10 @@ int main(int argc, char *argv[]) Info<< "\nalternating bit pattern\n"; list1.printInfo(Info, true); - PackedBoolList list2 = ~list1; + PackedBoolList list2(list1); + list2.flip(); - Info<< "\ncomplementary bit pattern\n"; + Info<< "\nflipped bit pattern\n"; list2.printBits(Info); // set every other on @@ -80,62 +81,6 @@ int main(int argc, char *argv[]) labelList list2Labels = list2.used(); - Info<< "\noperator|\n"; - - list1.printBits(Info); - list2.printBits(Info); - Info<< "==\n"; - (list1 | list2).printBits(Info); - - Info<< "\noperator& : does trim\n"; - (list1 & list2).printBits(Info); - - Info<< "\noperator^\n"; - (list1 ^ list2).printBits(Info); - - - Info<< "\noperator|=\n"; - { - PackedBoolList list3 = list1; - (list3 |= list2).printBits(Info); - } - - Info<< "\noperator|= with labelUList\n"; - { - PackedBoolList list3 = list1; - (list3 |= list2Labels).printBits(Info); - } - - Info<< "\noperator&=\n"; - { - PackedBoolList list3 = list1; - (list3 &= list2).printBits(Info); - } - - Info<< "\noperator+=\n"; - { - PackedBoolList list3 = list1; - (list3 += list2).printBits(Info); - } - - Info<< "\noperator+= with labelUList\n"; - { - PackedBoolList list3 = list1; - (list3 += list2Labels).printBits(Info); - } - - Info<< "\noperator-=\n"; - { - PackedBoolList list3 = list1; - (list3 -= list2).printBits(Info); - } - - Info<< "\noperator-= with labelUList\n"; - { - PackedBoolList list3 = list1; - (list3 -= list2Labels).printBits(Info); - } - PackedBoolList list4 ( ITstream @@ -151,7 +96,8 @@ int main(int argc, char *argv[]) Info<< list4 << " indices: " << list4.used() << nl; Info<< "\nassign from labelList\n"; - list4 = labelList{0, 1, 2, 3, 12, 13, 14, 19, 20, 21}; + list4.clear(); + list4.setMany(labelList{0, 1, 2, 3, 12, 13, 14, 19, 20, 21}); list4.printInfo(Info, true); Info<< list4 << " indices: " << list4.used() << nl; diff --git a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C index 6bd47c6bf7d9575117d4af47b1c71fd143fdb1b4..bb55c6990e0827edb5e671426ba9b5c011773091 100644 --- a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C +++ b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C @@ -84,7 +84,7 @@ void modifyOrAddFace PackedBoolList& modifiedFace ) { - if (!modifiedFace[facei]) + if (modifiedFace.set(facei)) { // First usage of face. Modify. meshMod.setAction @@ -102,7 +102,6 @@ void modifyOrAddFace zoneFlip // face flip in zone ) ); - modifiedFace[facei] = 1; } else { @@ -342,7 +341,7 @@ void subsetTopoSets PackedBoolList isSet(set.maxSize(mesh)); forAllConstIter(labelHashSet, set, iter) { - isSet[iter.key()] = true; + isSet.set(iter.key()); } label nSet = 0; forAll(map, i) @@ -375,7 +374,7 @@ void createCoupledBaffles fvMesh& mesh, const labelList& coupledWantedPatch, polyTopoChange& meshMod, - PackedBoolList& modifiedFace + PackedBoolList& modifiedFace ) { const faceZoneMesh& faceZones = mesh.faceZones(); @@ -443,7 +442,7 @@ void createCyclicCoupledBaffles const labelList& cyclicMasterPatch, const labelList& cyclicSlavePatch, polyTopoChange& meshMod, - PackedBoolList& modifiedFace + PackedBoolList& modifiedFace ) { const faceZoneMesh& faceZones = mesh.faceZones(); diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C index 3574e0cd0a15808470d1f5a11e2b6fbdb2824e3f..01dbfd1ce82e8f5242406bd32e63b794659f765c 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C +++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C @@ -588,7 +588,7 @@ int main(int argc, char *argv[]) label edgeI = iter.key(); const edge& e = edges[edgeI]; - collapseEdge[edgeI] = true; + collapseEdge.set(edgeI); collapsePointToLocation.set(e[1], points[e[0]]); newPoints[e[0]] = iter(); diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index f4bc4c55e88cf34dc487a701f3e7820055d61dec..6f16a6beb5ad8e21e4e48fd22d503ef01a286e72 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -907,7 +907,7 @@ int main(int argc, char *argv[]) Info<< "Merging edge " << e << " since length " << d << " << " << mergeDim << nl; - collapseEdge[edgeI] = true; + collapseEdge.set(edgeI); collapsePointToLocation.set(e[1], points[e[0]]); } } diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index 0bc28d03a2e3bc688cf2c936762c0f61fec71e4e..22277cabc8e2bfdf125dd5c3357025518a7ad706 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -2190,12 +2190,12 @@ int main(int argc, char *argv[]) // and generate space overlapping columns of cells. if (eFaces.size() != 2) { - nonManifoldEdge[edgeI] = 1; + nonManifoldEdge.set(edgeI); } } else { - nonManifoldEdge[edgeI] = 1; + nonManifoldEdge.set(edgeI); } } else if (eFaces.size() == 2) @@ -2222,7 +2222,7 @@ int main(int argc, char *argv[]) ePatches[1] = zoneZonePatch_min[index]; } - nonManifoldEdge[edgeI] = 1; + nonManifoldEdge.set(edgeI); } } else if (sidePatchID[edgeI] != -1) @@ -2260,7 +2260,7 @@ int main(int argc, char *argv[]) ePatches[i] = zoneSidePatch[zoneID[eFaces[i]]]; } } - nonManifoldEdge[edgeI] = 1; + nonManifoldEdge.set(edgeI); } } diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C index 470d0a3ae17afce29c2ed0c9a2dd8cd8feb30e6e..b855bbbe1ab9ab2180ca9318cb8a6fd891af9a2c 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C @@ -270,7 +270,7 @@ int main(int argc, char *argv[]) Info<< "Merging edge " << e << " since length " << d << " << " << mergeDim << nl; - collapseEdge[edgeI] = true; + collapseEdge.set(edgeI); collapsePointToLocation.set(e[1], points[e[0]]); } } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C index a3ca84da2c76c67135423cb90d58764808c2ba8b..b208e2a4b2a66afeae676308ddcca2203d3f7314 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C @@ -341,7 +341,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation if (!keep) { - keepVertex[vI] = false; + keepVertex.unset(vI); } } @@ -516,7 +516,7 @@ void Foam::controlMeshRefinement::initialMeshPopulation if (!keep) { - keepVertex[vI] = false; + keepVertex.unset(vI); } } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 66759a3adafe1743d3888587d97f30070d4b7e3e..7700aac5c1d1e2b7e163c69daafb088e56d04b73 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1081,11 +1081,7 @@ void Foam::conformalVoronoiMesh::move() Zero ); - PackedBoolList pointToBeRetained - ( - number_of_vertices(), - true - ); + PackedBoolList pointToBeRetained(number_of_vertices(), true); DynamicList<Point> pointsToInsert(number_of_vertices()); @@ -1170,8 +1166,8 @@ void Foam::conformalVoronoiMesh::move() if ( - pointToBeRetained[vA->index()] == true - && pointToBeRetained[vB->index()] == true + pointToBeRetained.test(vA->index()) + && pointToBeRetained.test(vB->index()) ) { const Foam::point pt(0.5*(dVA + dVB)); @@ -1185,12 +1181,12 @@ void Foam::conformalVoronoiMesh::move() if (vA->internalPoint() && !vA->referred() && !vA->fixed()) { - pointToBeRetained[vA->index()] = false; + pointToBeRetained.unset(vA->index()); } if (vB->internalPoint() && !vB->referred() && !vB->fixed()) { - pointToBeRetained[vB->index()] = false; + pointToBeRetained.unset(vB->index()); } // Do not consider this Delaunay edge any further @@ -1368,8 +1364,8 @@ void Foam::conformalVoronoiMesh::move() // removed. if ( - pointToBeRetained[vA->index()] == true - && pointToBeRetained[vB->index()] == true + pointToBeRetained.test(vA->index()) + && pointToBeRetained.test(vB->index()) ) { const Foam::point pt(0.5*(dVA + dVB)); @@ -1388,7 +1384,7 @@ void Foam::conformalVoronoiMesh::move() && !vA->fixed() ) { - pointToBeRetained[vA->index()] = false; + pointToBeRetained.unset(vA->index()); } if @@ -1398,7 +1394,7 @@ void Foam::conformalVoronoiMesh::move() && !vB->fixed() ) { - pointToBeRetained[vB->index()] = false; + pointToBeRetained.unset(vB->index()); } } else @@ -1454,7 +1450,7 @@ void Foam::conformalVoronoiMesh::move() { if (vit->internalPoint() && !vit->referred() && !vit->fixed()) { - if (pointToBeRetained[vit->index()] == true) + if (pointToBeRetained.test(vit->index())) { limitDisplacement ( @@ -1484,7 +1480,7 @@ void Foam::conformalVoronoiMesh::move() { if (vit->internalPoint() && !vit->referred() && !vit->fixed()) { - if (pointToBeRetained[vit->index()] == true) + if (pointToBeRetained.test(vit->index())) { // Convert vit->point() to FOAM vector (double) to do addition, // avoids memory increase because a record of the constructions @@ -1540,7 +1536,7 @@ void Foam::conformalVoronoiMesh::move() { if (vit->internalPoint() && !vit->referred()) { - if (pointToBeRetained[vit->index()] == true) + if (pointToBeRetained.test(vit->index())) { meshTools::writeOBJ(str, topoint(vit->point())); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index dd4ab67eef093d4b31100bcac93dafeedd6238be..5cfd3efee7fbef27de8226a46f55280a4d6fff14 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -1116,10 +1116,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality { const face f = pMesh.faces()[iter.key()]; - forAll(f, fPtI) - { - ptToBeLimited[f[fPtI]] = true; - } + ptToBeLimited.setMany(f); } // // Limit connected cells @@ -1153,10 +1150,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality // const labelList& cP = cellPts[celli]; - // forAll(cP, cPI) - // { - // ptToBeLimited[cP[cPI]] = true; - // } + // ptToBeLimited.setMany(cP); // } @@ -1176,7 +1170,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality if (cI >= 0) { - if (ptToBeLimited[cI] == true) + if (ptToBeLimited.test(cI)) { cit->filterCount()++; } @@ -2557,10 +2551,7 @@ void Foam::conformalVoronoiMesh::removeUnusedPoints { const face& f = faces[fI]; - forAll(f, fPtI) - { - ptUsed[f[fPtI]] = true; - } + ptUsed.setMany(f); } label pointi = 0; @@ -2572,7 +2563,7 @@ void Foam::conformalVoronoiMesh::removeUnusedPoints forAll(ptUsed, ptUI) { - if (ptUsed[ptUI] == true) + if (ptUsed.test(ptUI)) { oldToNew[ptUI] = pointi++; } @@ -2610,15 +2601,8 @@ Foam::labelList Foam::conformalVoronoiMesh::removeUnusedCells // Scan all faces to find all of the cells that are used - forAll(owner, oI) - { - cellUsed[owner[oI]] = true; - } - - forAll(neighbour, nI) - { - cellUsed[neighbour[nI]] = true; - } + cellUsed.setMany(owner); + cellUsed.setMany(neighbour); label celli = 0; @@ -2629,7 +2613,7 @@ Foam::labelList Foam::conformalVoronoiMesh::removeUnusedCells forAll(cellUsed, cellUI) { - if (cellUsed[cellUI] == true) + if (cellUsed.test(cellUI)) { oldToNew[cellUI] = celli++; } @@ -2645,7 +2629,7 @@ Foam::labelList Foam::conformalVoronoiMesh::removeUnusedCells forAll(cellUsed, cUI) { - if (cellUsed[cUI] == false) + if (!cellUsed.test(cUI)) { unusedCells.append(cUI); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index df280a407ff71b441c478c1b97ed51d538fb750e..af6f954a5019782e3b17b2ff1ed92d0b384ed60c 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -2290,7 +2290,7 @@ void Foam::conformalVoronoiMesh::reinsertSurfaceConformation() } else { - selectedElems[vI] = false; + selectedElems.unset(vI); } } } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index c9732eb44d3635371be99839edb334a14536e60e..f18bb544dc7929d3de89596adc6bd5ef0ffa15d8 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -949,18 +949,7 @@ void Foam::conformalVoronoiMesh::writeMesh orEqOp<unsigned int>() ); - labelList addr(boundaryFacesToRemove.count()); - label count = 0; - - forAll(boundaryFacesToRemove, facei) - { - if (boundaryFacesToRemove[facei]) - { - addr[count++] = facei; - } - } - - addr.setSize(count); + labelList addr(boundaryFacesToRemove.used()); faceSet indirectPatchFaces ( diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C index 1a540eaf8ddfe10d30d732fa4cdf28d0750235fe..9737050b2fcca4c498d81f92e5c68ed0d126021d 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/CV2D.C @@ -639,8 +639,8 @@ void Foam::CV2D::newPoints() // to be removed. if ( - pointToBeRetained[vA->index()] == true - && pointToBeRetained[vB->index()] == true + pointToBeRetained.test(vA->index()) + && pointToBeRetained.test(vB->index()) ) { pointsToInsert.push_back(toPoint(0.5*(dVA + dVB))); @@ -648,12 +648,12 @@ void Foam::CV2D::newPoints() if (vA->internalPoint()) { - pointToBeRetained[vA->index()] = false; + pointToBeRetained.unset(vA->index()); } if (vB->internalPoint()) { - pointToBeRetained[vB->index()] = false; + pointToBeRetained.unset(vB->index()); } } else @@ -689,7 +689,7 @@ void Foam::CV2D::newPoints() { if (vit->internalPoint()) { - if (pointToBeRetained[vit->index()]) + if (pointToBeRetained.test(vit->index())) { pointsToInsert.push_front ( diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C index c9b6475f5e158f5086b14a4a96a18d7c9abea54c..e825b6e23f32ad93fd935a7f44a2e7be1db01dec 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C @@ -309,7 +309,7 @@ void Foam::mergeAndWrite PackedBoolList isInSet(mesh.nCells()); forAllConstIter(cellSet, set, iter) { - isInSet[iter.key()] = true; + isInSet.set(iter.key()); } @@ -329,8 +329,8 @@ void Foam::mergeAndWrite DynamicList<label> outsideFaces(3*set.size()); for (label facei = 0; facei < mesh.nInternalFaces(); facei++) { - bool ownVal = isInSet[mesh.faceOwner()[facei]]; - bool neiVal = isInSet[mesh.faceNeighbour()[facei]]; + const bool ownVal = isInSet[mesh.faceOwner()[facei]]; + const bool neiVal = isInSet[mesh.faceNeighbour()[facei]]; if (ownVal != neiVal) { @@ -349,7 +349,7 @@ void Foam::mergeAndWrite { label facei = pp.start()+i; - bool neiVal = bndInSet[facei-mesh.nInternalFaces()]; + const bool neiVal = bndInSet[facei-mesh.nInternalFaces()]; if (isInSet[fc[i]] && !neiVal) { outsideFaces.append(facei); diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 9e3f2ca574abe6ce68b37c109d5c984af6fa99c9..fbda537bdb92a27587c0d0cd0e78c474c02d977b 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -195,7 +195,7 @@ void modifyOrAddFace PackedBoolList& modifiedFace ) { - if (!modifiedFace[facei]) + if (modifiedFace.set(facei)) { // First usage of face. Modify. meshMod.setAction @@ -213,7 +213,6 @@ void modifyOrAddFace zoneFlip // face flip in zone ) ); - modifiedFace[facei] = 1; } else { diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index 61d22ce8702c71b9ac8fcff82c26930c8ecbe229..1e00e9083057ca52d8ce9c661aa0d8805dd26595 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -157,7 +157,7 @@ void Foam::meshDualiser::generateDualBoundaryEdges { label edgeI = pEdges[pEdgeI]; - if (edgeToDualPoint_[edgeI] == -1 && isBoundaryEdge.get(edgeI) == 1) + if (edgeToDualPoint_[edgeI] == -1 && isBoundaryEdge.test(edgeI)) { const edge& e = mesh_.edges()[edgeI]; @@ -397,7 +397,7 @@ void Foam::meshDualiser::createFacesAroundEdge startFacei, // face true, // ownerSide fp, // fp - isBoundaryEdge.get(edgeI) == 1 // isBoundaryEdge + isBoundaryEdge.test(edgeI) // isBoundaryEdge ); ie.setCanonical(); @@ -509,7 +509,7 @@ void Foam::meshDualiser::createFacesAroundEdge { // Back at start face (for internal edge only). See if this needs // adding. - if (isBoundaryEdge.get(edgeI) == 0) + if (!isBoundaryEdge.test(edgeI)) { label startDual = faceToDualPoint_[startFaceLabel]; @@ -891,10 +891,7 @@ void Foam::meshDualiser::setRefinement { const labelList& fEdges = mesh_.faceEdges()[facei]; - forAll(fEdges, i) - { - isBoundaryEdge.set(fEdges[i], 1); - } + isBoundaryEdge.setMany(fEdges); } diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H index f6d93de2c8a3f4a3c9ab016c0c7b2612a0cb6dde..0cb7d2b913a0a463c45cd6837f7038f97857511d 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.H @@ -100,9 +100,9 @@ class meshDualiser // emanating from (boundary & feature) point void generateDualBoundaryEdges ( - const PackedBoolList&, + const PackedBoolList& isBoundaryEdge, const label pointi, - polyTopoChange& + polyTopoChange& meshMod ); //- Check that owner and neighbour of face have same dual cell @@ -143,10 +143,10 @@ class meshDualiser void createFacesAroundEdge ( const bool splitFace, - const PackedBoolList&, + const PackedBoolList& isBoundaryEdge, const label edgeI, const label startFacei, - polyTopoChange&, + polyTopoChange& meshMod, boolList& doneEFaces ) const; diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C b/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C index bb4cd5d5ad7eb281b5c76ec75f10b3d3e40fc561..9b68c7baf796c0debca4508dc63d79881779525c 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C @@ -397,7 +397,7 @@ int main(int argc, char *argv[]) forAll(fEdges, i) { - isBoundaryEdge.set(fEdges[i], 1); + isBoundaryEdge.set(fEdges[i]); } } diff --git a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C index 85fd727e3005d6e3295a47f317625c83c43543da..94ec49005b9020d9480c58650411f5aae73a8502 100644 --- a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C +++ b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C @@ -85,7 +85,7 @@ void printEdgeStats(const polyMesh& mesh) forAll(edges, edgeI) { - if (isMasterEdge[edgeI]) + if (isMasterEdge.test(edgeI)) { const edge& e = edges[edgeI]; diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 94e59afbc691ec73a7791c251602fbe61cf92fc4..7386075a64c408a7e53545dac696ff30602be36a 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -306,14 +306,14 @@ void subsetTopoSets PackedBoolList isSet(set.maxSize(mesh)); forAllConstIters(set, iter) { - isSet[iter.key()] = true; + isSet.set(iter.key()); } label nSet = 0; forAll(map, i) { if (isSet[map[i]]) { - nSet++; + ++nSet; } } diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index 00ef02bab7e973898cdf7106a7029e574066a660..30bd9223d5fd83d2bcb6663cf3bad8ed423bca83 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -528,7 +528,7 @@ int main(int argc, char *argv[]) newFacesFromSplit ); - visitedFace[hitSurfI][facei] = true; + visitedFace[hitSurfI].set(facei); forAll(newFacesFromSplit, newFacei) { diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C index 4bfbec9d21a2bf9d07c2994920bb1a98fdd28a94..83f5be06afed4a84e155ad7ae306d6f595d5afc1 100644 --- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C +++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C @@ -152,7 +152,7 @@ tmp<vectorField> calcPointNormals const edge& e = s.edges()[edgeI]; forAll(e, i) { - if (!isFeaturePoint[e[i]]) + if (!isFeaturePoint.test(e[i])) { pointNormals[e[i]] = Zero; } @@ -179,7 +179,7 @@ tmp<vectorField> calcPointNormals const edge& e = s.edges()[edgeI]; forAll(e, i) { - if (!isFeaturePoint[e[i]]) + if (!isFeaturePoint.test(e[i])) { pointNormals[e[i]] += n; nNormals[e[i]]++; @@ -242,7 +242,7 @@ void detectSelfIntersections if (hitInfo.hit()) { - isEdgeIntersecting[edgeI] = true; + isEdgeIntersecting.set(edgeI); } } } @@ -297,7 +297,7 @@ label detectIntersectionPoints { scale[pointI] = max(0.0, scale[pointI]-0.2); - isPointOnHitEdge[pointI] = true; + isPointOnHitEdge.set(pointI); nHits++; } } @@ -425,7 +425,7 @@ void minSmooth forAll(fld, pointI) { - if (isAffectedPoint.get(pointI) == 1) + if (isAffectedPoint.test(pointI)) { newFld[pointI] = min ( @@ -458,13 +458,13 @@ void lloydsSmoothing forAll(edges, edgeI) { const edge& e = edges[edgeI]; - if (isSmoothPoint[e[0]]) + if (isSmoothPoint.test(e[0])) { - newIsSmoothPoint[e[1]] = true; + newIsSmoothPoint.set(e[1]); } - if (isSmoothPoint[e[1]]) + if (isSmoothPoint.test(e[1])) { - newIsSmoothPoint[e[0]] = true; + newIsSmoothPoint.set(e[0]); } } Info<< "From points-to-smooth " << isSmoothPoint.count() @@ -545,11 +545,11 @@ void lloydsSmoothing const edge& e = edges[edgeI]; if (isSmoothPoint[e[0]]) { - newIsSmoothPoint[e[1]] = true; + newIsSmoothPoint.set(e[1]); } if (isSmoothPoint[e[1]]) { - newIsSmoothPoint[e[0]] = true; + newIsSmoothPoint.set(e[0]); } } Info<< "From points-to-smooth " << isSmoothPoint.count() @@ -662,15 +662,9 @@ int main(int argc, char *argv[]) << " out of " << s.nEdges() << nl << endl; - PackedBoolList isFeaturePoint(s.nPoints()); - forAll(features.featurePoints(), i) - { - label pointI = features.featurePoints()[i]; - isFeaturePoint[pointI] = true; - } - const List<surfaceFeatures::edgeStatus> edgeStat(features.toStatus()); - + PackedBoolList isFeaturePoint(s.nPoints(), features.featurePoints()); + const List<surfaceFeatures::edgeStatus> edgeStat(features.toStatus()); const pointField initialPoints(s.points()); @@ -809,9 +803,9 @@ int main(int argc, char *argv[]) // Accumulate all affected points forAll(isAffectedPoint, pointI) { - if (isAffectedPoint[pointI]) + if (isAffectedPoint.test(pointI)) { - isScaledPoint[pointI] = true; + isScaledPoint.set(pointI); } } diff --git a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C index 511f8ea43257f88ccf38672cc9f438fe435eb899..7eccb601376627bb5612fbcbd4c4e497e267cc3a 100644 --- a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C +++ b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C @@ -66,7 +66,7 @@ tmp<pointField> avg { vector& avgPos = avg[vertI]; - if (fixedPoints[vertI]) + if (fixedPoints.test(vertI)) { avgPos = s.localPoints()[vertI]; } @@ -121,7 +121,7 @@ void getFixedPoints { if (from0To1[fpI] != -1) { - fixedPoints[from0To1[fpI]] = true; + fixedPoints.set(from0To1[fpI]); } } } diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index bb8fec4040223125abed8a898cdf5e3e35ac7610..7d642541e064d49f119b26d193282b4b00ad1ef4 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -527,9 +527,10 @@ void Foam::fileMonitor::updateStates { forAll(state_, watchFd) { - stats[watchFd] = static_cast<unsigned int> + stats.set ( - localState_[watchFd] + watchFd, + static_cast<unsigned int>(localState_[watchFd]) ); } } diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index 80702424a44d747a2f33aab351db34168db1ad2a..0ac119e1b288d9d118c791d166c9104b6a7dae61 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -921,7 +921,7 @@ void Foam::ListOps::setValue for (label index = 0, used = 0; index < len && used < count; ++index) { - if (locations[index]) + if (locations.test(index)) { list[index] = val; ++used; diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C index 7179796b7e82a1da0925705454e14ee816c9db02..e47ee6f4f36c524d3d93f55bd06c1575f78400f3 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.C @@ -30,7 +30,7 @@ License bool Foam::PackedBoolList::bitorPrepare ( - const PackedList<1>& lst, + const PackedBoolList& lst, label& maxPackLen ) { @@ -90,71 +90,28 @@ bool Foam::PackedBoolList::bitorPrepare template<class LabelListType> -Foam::label Foam::PackedBoolList::setIndices(const LabelListType& indices) +void Foam::PackedBoolList::setIndices(const LabelListType& indices) { const label len = indices.size(); // No better information, just guess something from the size reserve(len); - label cnt = 0; for (label i = 0; i < len; ++i) { - if (set(indices[i])) - { - ++cnt; - } + set(indices[i]); } - - return cnt; } template<class LabelListType> -Foam::label Foam::PackedBoolList::unsetIndices(const LabelListType& indices) +void Foam::PackedBoolList::unsetIndices(const LabelListType& indices) { - label cnt = 0; const label len = indices.size(); for (label i = 0; i < len; ++i) { - if (unset(indices[i])) - { - ++cnt; - } + unset(indices[i]); } - - return cnt; -} - - -template<class LabelListType> -Foam::label Foam::PackedBoolList::subsetIndices(const LabelListType& indices) -{ - const label len = indices.size(); - - // Handle trivial case - if (empty() || !len) - { - clear(); - return 0; - } - - PackedBoolList result; - result.reserve(size()); - - label cnt = 0; - for (label i = 0; i < len; ++i) - { - const label index = indices[i]; - if (get(index)) - { - result.set(index); - ++cnt; - } - } - - transfer(result); - return cnt; } @@ -170,7 +127,7 @@ Foam::PackedBoolList::PackedBoolList(Istream& is) // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -void Foam::PackedBoolList::set(const PackedList<1>& lst) +void Foam::PackedBoolList::set(const PackedBoolList& lst) { // extend addressable area if needed, return maximum size possible label len = 0; @@ -192,19 +149,7 @@ void Foam::PackedBoolList::set(const PackedList<1>& lst) } -Foam::label Foam::PackedBoolList::set(const labelUList& indices) -{ - return setIndices(indices); -} - - -Foam::label Foam::PackedBoolList::set(const labelUIndList& indices) -{ - return setIndices(indices); -} - - -void Foam::PackedBoolList::unset(const PackedList<1>& lst) +void Foam::PackedBoolList::unset(const PackedBoolList& lst) { // operate directly with the underlying storage StorageList& lhs = this->storage(); @@ -220,48 +165,27 @@ void Foam::PackedBoolList::unset(const PackedList<1>& lst) } -Foam::label Foam::PackedBoolList::unset(const labelUList& indices) +void Foam::PackedBoolList::setMany(const labelUList& indices) { - return unsetIndices(indices); + setIndices(indices); } -Foam::label Foam::PackedBoolList::unset(const labelUIndList& indices) +void Foam::PackedBoolList::setMany(const labelUIndList& indices) { - return unsetIndices(indices); -} - - -void Foam::PackedBoolList::subset(const PackedList<1>& lst) -{ - // shrink addressable area if needed - if (this->size() > lst.size()) - { - this->resize(lst.size()); - } - - // operate directly with the underlying storage - StorageList& lhs = this->storage(); - const StorageList& rhs = lst.storage(); - - const label len = this->packedLength(); - - for (label i = 0; i < len; ++i) - { - lhs[i] &= rhs[i]; - } + setIndices(indices); } -Foam::label Foam::PackedBoolList::subset(const labelUList& indices) +void Foam::PackedBoolList::unsetMany(const labelUList& indices) { - return subsetIndices(indices); + unsetIndices(indices); } -Foam::label Foam::PackedBoolList::subset(const labelUIndList& indices) +void Foam::PackedBoolList::unsetMany(const labelUIndList& indices) { - return subsetIndices(indices); + unsetIndices(indices); } @@ -279,7 +203,7 @@ Foam::labelList Foam::PackedBoolList::used() const for (label i=0, usedi=0; (i < len && usedi < cnt); ++i) { - if (get(i)) + if (test(i)) { lst[usedi++] = i; } @@ -290,90 +214,4 @@ Foam::labelList Foam::PackedBoolList::used() const } -// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // - -void Foam::PackedBoolList::operator=(const UList<bool>& lst) -{ - const label len = lst.size(); - this->setSize(len); - - // Overwrite with new true/false values - for (label i = 0; i < len; ++i) - { - set(i, lst[i]); - } -} - - -Foam::PackedBoolList& -Foam::PackedBoolList::operator^=(const PackedList<1>& lst) -{ - // Extend addressable area if needed, return maximum size possible - label len = 0; - const bool needTrim = bitorPrepare(lst, len); - - // Operate directly with the underlying storage - StorageList& lhs = this->storage(); - const StorageList& rhs = lst.storage(); - - for (label i = 0; i < len; ++i) - { - lhs[i] ^= rhs[i]; - } - - if (needTrim) - { - trim(); - } - - return *this; -} - - -// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // - -Foam::PackedBoolList Foam::operator& -( - const PackedBoolList& lst1, - const PackedBoolList& lst2 -) -{ - PackedBoolList result(lst1); - result &= lst2; - - // Trim to bits actually used - result.trim(); - - return result; -} - - -Foam::PackedBoolList Foam::operator^ -( - const PackedBoolList& lst1, - const PackedBoolList& lst2 -) -{ - PackedBoolList result(lst1); - result ^= lst2; - - // Trim to bits actually used - result.trim(); - - return result; -} - - -Foam::PackedBoolList Foam::operator| -( - const PackedBoolList& lst1, - const PackedBoolList& lst2 -) -{ - PackedBoolList result(lst1); - result |= lst2; - return result; -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H index 717be74288efeb411da48c90716c7245da9ffaba..dd69d6f79f3994195b82cff75e339e0c529c7486 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolList.H @@ -69,22 +69,17 @@ class PackedBoolList //- Preparation, resizing before a bitor operation // returns true if the later result needs trimming - bool bitorPrepare(const PackedList<1>& lst, label& maxPackLen); + bool bitorPrepare(const PackedBoolList& lst, label& maxPackLen); //- Set the listed indices. Return number of elements changed. // Does auto-vivify for non-existent entries. template<class LabelListType> - label setIndices(const LabelListType& indices); + void setIndices(const LabelListType& indices); //- Unset the listed indices. Return number of elements changed. // Never auto-vivify entries. template<class LabelListType> - label unsetIndices(const LabelListType& indices); - - //- Subset with the listed indices. Return number of elements subsetted. - template<class LabelListType> - label subsetIndices(const LabelListType& indices); - + void unsetIndices(const LabelListType& indices); public: @@ -105,15 +100,9 @@ public: //- Copy construct inline PackedBoolList(const PackedBoolList& lst); - //- Copy construct - explicit inline PackedBoolList(const PackedList<1>& lst); - //- Move construct inline PackedBoolList(PackedBoolList&& lst); - //- Move construct - inline PackedBoolList(PackedList<1>&& lst); - //- Construct with given size and list of labels to set as true. inline PackedBoolList(const label size, const labelUList& indices); @@ -137,43 +126,26 @@ public: // Member Functions + // Query + + //- Test value at specified position. + // \note Method name compatibility with std::bitset + inline bool test(const label pos) const; + + // Access + //- Single index/value assign using PackedList<1>::set; + + //- Single index unassign using PackedList<1>::unset; //- Set specified bits. - void set(const PackedList<1>& lst); - - //- Set the listed indices. Return number of elements changed. - // Does auto-vivify for non-existent entries. - label set(const labelUList& indices); - - //- Set the listed indices. Return number of elements changed. - // Does auto-vivify for non-existent entries. - label set(const labelUIndList& indices); + void set(const PackedBoolList& lst); //- Unset specified bits. - void unset(const PackedList<1>& lst); - - //- Unset the listed indices. Return number of elements changed. - // Never auto-vivify entries. - label unset(const labelUList& indices); - - //- Unset the listed indices. Return number of elements changed. - // Never auto-vivify entries. - label unset(const labelUIndList& indices); - - //- Subset with the specified list. - void subset(const PackedList<1>& lst); - - //- Subset with the listed indices. - // Return number of elements subsetted. - label subset(const labelUList& indices); - - //- Subset with the listed indices. - // Return number of elements subsetted. - label subset(const labelUIndList& indices); + void unset(const PackedBoolList& lst); //- Return indices of the used (true) elements as a list of labels labelList used() const; @@ -185,116 +157,50 @@ public: //- and annul the argument list. inline void transfer(PackedBoolList& lst); - //- Transfer the contents of the argument list into this list - //- and annul the argument list. - inline void transfer(PackedList<1>& lst); + + // Convenience Methods + + //- Set the listed indices. Return number of elements changed. + // Does auto-vivify for non-existent entries. + void setMany(const labelUList& indices); + + //- Set the listed indices. Return number of elements changed. + // Does auto-vivify for non-existent entries. + void setMany(const labelUIndList& indices); + + //- Unset the listed indices. Return number of elements changed. + // Never auto-vivify entries. + void unsetMany(const labelUList& indices); + + //- Unset the listed indices. Return number of elements changed. + // Never auto-vivify entries. + void unsetMany(const labelUIndList& indices); // Member Operators - //- Assignment of all entries to the given value. + //- Assign all entries to the given value. inline void operator=(const bool val); //- Copy assignment inline void operator=(const PackedBoolList& lst); - //- Copy assignment - inline void operator=(const PackedList<1>& lst); - //- Move assignment inline void operator=(PackedBoolList&& lst); - //- Move assignment - inline void operator=(PackedList<1>&& lst); - - //- Assignment operator. - void operator=(const UList<bool>& lst); - - //- Assignment operator, - //- using the labels as indices to indicate which bits are set - inline void operator=(const labelUList& indices); - - //- Assignment operator, - //- using the labels as indices to indicate which bits are set - inline void operator=(const labelUIndList& indices); - //- Complement operator - inline PackedBoolList operator~() const; + // Housekeeping - //- And operator (lists may be dissimilar sizes) - inline PackedBoolList& operator&=(const PackedList<1>& lst); - - //- And operator (lists may be dissimilar sizes) - //- using the labels as indices to indicate which bits are set - inline PackedBoolList& operator&=(const labelUList& indices); - - //- And operator (lists may be dissimilar sizes) - //- using the labels as indices to indicate which bits are set - inline PackedBoolList& operator&=(const labelUIndList& indices); + //- No assignment from list. Use setMany for that. + void operator=(const labelUList&) = delete; - //- Xor operator (lists may be dissimilar sizes) - // Retains unique entries - PackedBoolList& operator^=(const PackedList<1>& lst); + //- No assignment from list. Use setMany for that. + void operator=(const labelUIndList&) = delete; - //- Or operator (lists may be dissimilar sizes) - inline PackedBoolList& operator|=(const PackedList<1>& lst); - //- Or operator (lists may be dissimilar sizes), - //- using the labels as indices to indicate which bits are set - inline PackedBoolList& operator|=(const labelUList& indices); - - //- Or operator (lists may be dissimilar sizes), - //- using the labels as indices to indicate which bits are set - inline PackedBoolList& operator|=(const labelUIndList& indices); - - - //- Add entries to this list, synonymous with the or operator - inline PackedBoolList& operator+=(const PackedList<1>& lst); - - //- Add entries to this list, synonymous with the or operator - inline PackedBoolList& operator+=(const labelUList& indices); - - //- Add entries to this list, synonymous with the or operator - inline PackedBoolList& operator+=(const labelUIndList& indices); - - //- Remove entries from this list - unset the specified bits - inline PackedBoolList& operator-=(const PackedList<1>& lst); - - //- Remove entries from this list - unset the specified bits - inline PackedBoolList& operator-=(const labelUList& indices); - - //- Remove entries from this list - unset the specified bits - inline PackedBoolList& operator-=(const labelUIndList& indices); }; -// Global Operators - -//- Intersect lists - the result is trimmed to the smallest intersecting size -PackedBoolList operator& -( - const PackedBoolList& lst1, - const PackedBoolList& lst2 -); - - -//- Combine to form a unique list (xor) -// The result is trimmed to the smallest intersecting size -PackedBoolList operator^ -( - const PackedBoolList& lst1, - const PackedBoolList& lst2 -); - - -//- Combine lists -PackedBoolList operator| -( - const PackedBoolList& lst1, - const PackedBoolList& lst2 -); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H index c1d4e7156f12b8db65a25851672094157f88cdbd..da76aff94b51e77d2aa5001af8f8a3f9df445646 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedBoolListI.H @@ -47,12 +47,6 @@ inline Foam::PackedBoolList::PackedBoolList(const PackedBoolList& lst) {} -inline Foam::PackedBoolList::PackedBoolList(const PackedList<1>& lst) -: - PackedList<1>(lst) -{} - - inline Foam::PackedBoolList::PackedBoolList(PackedBoolList&& lst) : PackedList<1>() @@ -61,14 +55,6 @@ inline Foam::PackedBoolList::PackedBoolList(PackedBoolList&& lst) } -inline Foam::PackedBoolList::PackedBoolList(PackedList<1>&& lst) -: - PackedList<1>() -{ - transfer(lst); -} - - inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst) : PackedList<1>(lst.size()) @@ -106,7 +92,7 @@ inline Foam::PackedBoolList::PackedBoolList : PackedList<1>(size) { - set(indices); + setMany(indices); } @@ -118,7 +104,7 @@ inline Foam::PackedBoolList::PackedBoolList : PackedList<1>(size) { - set(indices); + setMany(indices); } @@ -131,15 +117,15 @@ Foam::PackedBoolList::clone() const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline void Foam::PackedBoolList::transfer(PackedBoolList& lst) +inline bool Foam::PackedBoolList::test(const label pos) const { - PackedList<1>::transfer(static_cast<PackedList<1>&>(lst)); + return get(pos); } -inline void Foam::PackedBoolList::transfer(PackedList<1>& lst) +inline void Foam::PackedBoolList::transfer(PackedBoolList& lst) { - PackedList<1>::transfer(lst); + PackedList<1>::transfer(static_cast<PackedList<1>&>(lst)); } @@ -157,139 +143,10 @@ inline void Foam::PackedBoolList::operator=(const PackedBoolList& lst) } -inline void Foam::PackedBoolList::operator=(const PackedList<1>& lst) -{ - PackedList<1>::operator=(lst); -} - - inline void Foam::PackedBoolList::operator=(PackedBoolList&& lst) { transfer(lst); } -inline void Foam::PackedBoolList::operator=(PackedList<1>&& lst) -{ - transfer(lst); -} - - -inline void Foam::PackedBoolList::operator=(const labelUList& indices) -{ - clear(); - set(indices); -} - - -inline void Foam::PackedBoolList::operator=(const labelUIndList& indices) -{ - clear(); - set(indices); -} - - -inline Foam::PackedBoolList -Foam::PackedBoolList::operator~() const -{ - PackedBoolList result(*this); - result.flip(); - - return result; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator&=(const PackedList<1>& lst) -{ - subset(lst); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator&=(const labelUList& indices) -{ - subset(indices); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator&=(const labelUIndList& indices) -{ - subset(indices); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator|=(const PackedList<1>& lst) -{ - set(lst); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator|=(const labelUList& indices) -{ - set(indices); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator|=(const labelUIndList& indices) -{ - set(indices); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator+=(const PackedList<1>& lst) -{ - return operator|=(lst); -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator+=(const labelUList& indices) -{ - return operator|=(indices); -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator+=(const labelUIndList& indices) -{ - return operator|=(indices); -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator-=(const PackedList<1>& lst) -{ - unset(lst); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator-=(const labelUList& indices) -{ - unset(indices); - return *this; -} - - -inline Foam::PackedBoolList& -Foam::PackedBoolList::operator-=(const labelUIndList& indices) -{ - unset(indices); - return *this; -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.C b/src/OpenFOAM/containers/Lists/PackedList/PackedList.C index 63c0908961f3c69ebf77e445e851b17e9f56e6cf..72def35291e62a5a3e9bf0873d726a3903650168 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.C +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.C @@ -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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -154,23 +154,6 @@ Foam::labelList Foam::PackedList<nBits>::values() const } -template<unsigned nBits> -Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::printInfo -( - Ostream& os -) const -{ - os << "iterator<" << label(nBits) << "> [" - << this->index_ << "]" - << " segment:" << label(this->index_ / packing()) - << " offset:" << label(this->index_ % packing()) - << " value:" << this->get() - << nl; - - return os; -} - - template<unsigned nBits> Foam::Ostream& Foam::PackedList<nBits>::printBits ( @@ -294,7 +277,7 @@ Foam::Istream& Foam::PackedList<nBits>::read(Istream& is) { for (label i=0; i<len; ++i) { - lst[i] = lst.readValue(is); + lst.set(i, lst.readValue(is)); is.fatalCheck ( @@ -411,7 +394,6 @@ Foam::Ostream& Foam::PackedList<nBits>::writeList const label shortListLen ) const { - const bool indexedOutput = (shortListLen < 0); const PackedList<nBits>& lst = *this; const label len = lst.size(); @@ -419,7 +401,7 @@ Foam::Ostream& Foam::PackedList<nBits>::writeList if (os.format() == IOstream::ASCII) { // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (len > 1 && !indexedOutput); + bool uniform = (len > 1); if (uniform) { forAll(lst, i) @@ -437,26 +419,6 @@ Foam::Ostream& Foam::PackedList<nBits>::writeList // uniform values: os << len << token::BEGIN_BLOCK << lst[0] << token::END_BLOCK; } - else if (indexedOutput) - { - // indexed output - os << nl << token::BEGIN_BLOCK << nl; - - for - ( - typename PackedList<nBits>::const_iterator iter = lst.cbegin(); - iter != lst.cend(); - ++iter - ) - { - if (iter.writeIfSet(os)) - { - os << nl; - } - } - - os << token::END_BLOCK << nl; - } else if (!shortListLen || len <= shortListLen) { // Shorter list, or line-breaks suppressed diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 56167ad0c88e7c2ae18bc280eafa2b487a08d866..4abb6ce9af6b03243603a02260ad840e0ff66422 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,71 +25,44 @@ Class Foam::PackedList Description - A dynamically allocatable list of packed unsigned integers. + A dynamically list of packed unsigned integers, with the number of bits + per item specified by the \<nBits\> template parameter. - The list resizing is similar to DynamicList, thus the methods clear() - and setSize() behave like their DynamicList counterparts and the methods - reserve() and setCapacity() can be used to influence the allocation. - - The number of bits per item is specified by the template parameter nBits. + Resizing is similar to DynamicList so that clear() and resize() affect + the addessed size, but not the allocated size. The reserve() and + setCapacity() methods can be used to influence the allocation. Note In a const context, the '[]' operator simply returns the stored value, with out-of-range elements returned as zero. - In a non-const context, the '[]' operator returns an iteratorBase, which - might not have a valid reference for out-of-range elements. - The iteratorBase class handles the assignment of new values. - - Using the iteratorBase as a proxy allows assignment of values - between list elements. Thus the following bit of code works as expected: - \code - list[1] = list[5]; // value assignment, not iterator position - list[2] = list[5] = 4; // propagates value - list[1] = list[5] = list[6]; // propagates value - \endcode - Reading via the get() or the '[]' operator are identical. - Looping and reading via an iterator is approx. 15% slower, - but can be more flexible. + In a non-const context, the '[]' operator returns a reference to an + existing value. Some caution with out-of-range elements to ensure + that the const version of the [] operator is being called. + The get() method is functionally identical the the '[]' operator, but + is always const access. - Using the set() operator (and the '[]' operator) are marginally slower - (approx. 5%) than using an iterator, but the set() method has the - advantage of also returning a bool if the value changed. This can be - useful for branching on changed values. + The set() and unset() methods return a bool if the value changed. + This can be useful for branching on changed values. \code - list[5] = 4; + list.set(5, 4); changed = list.set(5, 8); if (changed) ... \endcode - The lazy evaluation used means that reading an out-of-range element - returns zero, but does not affect the list size. Even in a non-const - context, only the assigment itself causes the element to be created. + In a const context, reading an out-of-range element returns zero without + affecting the list size. For example, \code list.resize(4); - Info<< list[10] << "\n"; // print zero, but doesn't adjust list - list[8] = 1; + Info<< list.get(10) << "\n"; // print zero, but doesn't adjust list \endcode Also note that all unused internal storage elements are guaranteed to always be bit-wise zero. This property must not be violated by any inheriting classes. - In addition to the normal output format, PackedList also supports a - compact ASCII format that may be convenient for user input in some - situations. The general format is a group of index/value pairs: - \verbatim - { (index1 value1) (index2 value2) (index3 value3) } - \endverbatim - The bool specialization just uses the indices corresponding to - non-zero entries instead of a index/value pair: - \verbatim - { index1 index2 index3 } - \endverbatim - In both cases, the supplied indices can be randomly ordered. - See also Foam::DynamicList @@ -111,13 +84,11 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations +template<unsigned nBits> class PackedList; class Istream; class Ostream; -// Forward declaration of friend functions and operators -template<unsigned nBits> class PackedList; - template<unsigned nBits> Istream& operator>>(Istream& is, PackedList<nBits>& lst); template<unsigned nBits> @@ -197,6 +168,12 @@ protected: public: + // Forward declaration of access classes + + class reference; + typedef unsigned int const_reference; + + // Public data //- The max. number of bits that can be templated. @@ -214,13 +191,6 @@ public: inline static constexpr unsigned int maskLower(unsigned offset); - // Forward declaration of iterators - - class iteratorBase; - class iterator; - class const_iterator; - - // Constructors //- Null constructor @@ -253,7 +223,7 @@ public: // Member Functions - // Access + // Access //- The number of elements that can be stored before reallocating inline label capacity() const; @@ -312,8 +282,13 @@ public: //- Print information and bit patterns (with printBits) Ostream& printInfo(Ostream& os, const bool fullOutput=false) const; + // Check + + //- Check index is within valid range [0,size) + inline void checkIndex(const label i) const; + - // Edit + // Edit //- Trim any trailing zero elements bool trim(); @@ -357,7 +332,7 @@ public: inline void transfer(PackedList<nBits>& lst); - // IO + // IO //- Clear list and read from stream Istream& read(Istream& is); @@ -365,26 +340,13 @@ public: //- Write the List, with line-breaks in ASCII if the list length //- exceeds shortListLen. // Using '0' suppresses line-breaks entirely. - // A special indexed output (ASCII only) is triggered by specifying - // a negative value for shortListLen. - // - // The indexed output may be convenient in some situations. - // The general format is a group of index/value pairs: - // \verbatim - // { (index1 value1) (index2 value2) (index3 value3) } - // \endverbatim - // The bool specialization just uses the indices corresponding to - // non-zero entries instead of a index/value pair: - // \verbatim - // { index1 index2 index3 } - // \endverbatim Ostream& writeList(Ostream& os, const label shortListLen=0) const; //- Write as a dictionary entry with keyword void writeEntry(const word& keyword, Ostream& os) const; - // Member Operators + // Member Operators //- Append a value at the end of the list inline PackedList<nBits>& append(const unsigned int val); @@ -397,9 +359,8 @@ public: inline unsigned int operator[](const label i) const; //- Non-const access to value at index. - // Returns iterator to perform the actual operation. - // Does not auto-vivify entries, but will when assigned to. - inline iteratorBase operator[](const label i); + // Fatal for out-of-range indices + inline reference operator[](const label i); //- Assignment of all entries to the given value. Takes linear time. inline void operator=(const unsigned int val); @@ -419,207 +380,38 @@ public: // Iterators and helpers - //- The iterator base for PackedList - // Note: data and functions are protected, to allow reuse by iterator - // and prevent most external usage. - class iteratorBase + //- A reference for read/write access to an entry + class reference { - friend class PackedList; - - protected: - - // Protected Data - - //- Pointer to original list - // This also lets us use the default bitwise copy/assignment - PackedList* list_; - - //- Element index - label index_; + friend class PackedList; // Access for PackedList + void operator&() = delete; // Refuse to provide its address + unsigned int& ref_; //!< Reference to underlying block value + unsigned int shift_; //!< The bit shift for the sub-portion - // Constructors + //- Construct by taking reference of block from within the list + //- at the specified index. + inline reference(PackedList* lst, const label index); - //- Construct null - an end iterator - inline iteratorBase(); - - //- Construct from base list and position index - inline iteratorBase(const PackedList* lst, const label i); - - - // Protected Member Functions - - //- Limit index to the list size - avoid going past end() - // Eg, iter = iterator(list, Inf) - inline void bound(); - - //- Get value as unsigned, no range-checking - inline unsigned int get() const; - - //- Set value, returning true if changed, no range-checking - inline bool set(unsigned int val); - - //- Move backward through list - inline void prev(); - - //- Move forward through list - inline void next(); + //- Get value as unsigned, no range-checking + inline unsigned int get() const; + //- Set value, returning true if changed, no range-checking + inline bool set(unsigned int val); public: - // Member Functions - - //- Return the element index corresponding to the iterator - inline label key() const; - - //- Write index/value for a non-zero entry - // The bool specialization writes the index only - inline bool writeIfSet(Ostream& os) const; + //- Value assignment + inline void operator=(const reference& other); - // Member Operators + //- Value assignment + inline void operator=(const unsigned int val); - //- Compare values (not positions) - inline bool operator==(const iteratorBase& iter) const; - inline bool operator!=(const iteratorBase& iter) const; - - //- Assign value, not position. - // This allows packed[0] = packed[3] for assigning values - inline void operator=(const iteratorBase& iter); - - //- Assign value. - // A non-existent entry will be auto-vivified. - inline void operator=(const unsigned int val); - - //- Conversion operator - // Never auto-vivify entries. - inline operator unsigned int () const; - - //- Print information and values - Ostream& printInfo(Ostream& os) const; + //- Conversion operator + inline operator unsigned int () const; }; - //- The iterator class used for PackedList - class iterator - : - public iteratorBase - { - - //- Disallow copy constructor from const_iterator - // This would violate const-ness! - iterator(const const_iterator& iter) = delete; - - //- Disallow assignment from const_iterator - // This would violate const-ness! - void operator=(const const_iterator& iter) = delete; - - - public: - - // Constructors - - //- Construct null - inline iterator(); - - //- Construct from iterator base, eg iter(packedlist[i]) - // but also "iterator iter = packedlist[i];" - // An out-of-range iterator is assigned end() - inline iterator(const iteratorBase& iter); - - //- Construct from base list and position index - inline iterator(const PackedList* lst, const label i); - - - // Member Operators - - //- Compare positions (not values) - inline bool operator==(const iteratorBase& iter) const; - inline bool operator!=(const iteratorBase& iter) const; - - //- Assign from iteratorBase, eg iter = packedlist[i] - // An out-of-range iterator is assigned end() - inline void operator=(const iteratorBase& iter); - - //- Return value - inline unsigned int operator*() const; - - //- Return iteratorBase for assigning values - inline iteratorBase& operator*(); - - inline iterator& operator++(); - inline iterator operator++(int); - - inline iterator& operator--(); - inline iterator operator--(int); - - }; - - //- Iterator set to the beginning of the PackedList - inline iterator begin(); - - //- Iterator set to beyond the end of the PackedList - inline iterator end(); - - - //- The const_iterator for PackedList - class const_iterator - : - public iteratorBase - { - public: - - // Constructors - - //- Construct null - inline const_iterator(); - - //- Construct from iterator base, eg iter(packedlist[i]) - // but also "const_iterator iter = packedlist[i];" - // An out-of-range iterator is assigned cend() - inline const_iterator(const iteratorBase& iter); - - //- Construct from base list and position index - inline const_iterator(const PackedList* lst, const label i); - - //- Construct from iterator - inline const_iterator(const iterator& iter); - - - // Member operators - - //- Compare positions (not values) - inline bool operator==(const iteratorBase& iter) const; - inline bool operator!=(const iteratorBase& iter) const; - - //- Assign from iteratorBase or derived - // eg, iter = packedlist[i] or even iter = list.begin() - inline void operator=(const iteratorBase& iter); - - //- Return referenced value directly - inline unsigned int operator*() const; - - inline const_iterator& operator++(); - inline const_iterator operator++(int); - - inline const_iterator& operator--(); - inline const_iterator operator--(int); - }; - - - //- const_iterator set to the beginning of the PackedList - inline const_iterator cbegin() const; - - //- const_iterator set to beyond the end of the PackedList - inline const_iterator cend() const; - - //- const_iterator set to the beginning of the PackedList - inline const_iterator begin() const; - - //- const_iterator set to beyond the end of the PackedList - inline const_iterator end() const; - - // IOstream Operators friend Istream& operator>> <nBits> diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H index 9a3e0a8a4194973618598db2cf6e4e0a900c6dbc..c8a8073e03a7311d9390be70e1f217b633d0d712 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedListI.H @@ -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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include <climits> +#include "error.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -76,31 +77,16 @@ inline constexpr Foam::label Foam::PackedList<nBits>::packedLength namespace Foam { // Template specialization for bool entries - template<> - inline unsigned int Foam::PackedList<1>::readValue(Istream& is) + template<> inline unsigned int PackedList<1>::readValue(Istream& is) { return readBool(is); } // Template specialization for bool entries - template<> - inline void Foam::PackedList<1>::setPair(Istream& is) + template<> inline void PackedList<1>::setPair(Istream& is) { set(readLabel(is), true); } - - // Template specialization for bool entries - template<> - inline bool Foam::PackedList<1>::iteratorBase::writeIfSet(Ostream& os) const - { - if (this->get()) - { - os << index_; - return true; - } - - return false; - } } @@ -146,24 +132,6 @@ inline void Foam::PackedList<nBits>::setPair(Istream& is) } -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::iteratorBase::writeIfSet(Ostream& os) const -{ - const label val = this->get(); - - if (val) - { - os << token::BEGIN_LIST - << index_ << token::SPACE << val - << token::END_LIST; - - return true; - } - - return false; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<unsigned nBits> @@ -270,434 +238,96 @@ Foam::PackedList<nBits>::clone() const return autoPtr<PackedList<nBits>>::New(*this); } - -// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * // - -template<unsigned nBits> -inline Foam::PackedList<nBits>::iteratorBase::iteratorBase() -: - list_(nullptr), - index_(0) -{} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::iteratorBase::iteratorBase -( - const PackedList<nBits>* lst, - const label i -) -: - list_(const_cast<PackedList<nBits>*>(lst)), - index_(i) -{} - +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<unsigned nBits> -inline void Foam::PackedList<nBits>::iteratorBase::bound() +inline void Foam::PackedList<nBits>::checkIndex(const label i) const { - if (list_ && index_ > list_->size_) + if (!size_) { - index_ = list_->size_; + FatalErrorInFunction + << "attempt to access element " << i << " from zero sized list" + << abort(FatalError); + } + else if (i < 0 || i >= size_) + { + FatalErrorInFunction + << "index " << i << " out of range [0," << size_ << ")" + << abort(FatalError); } } -template<unsigned nBits> -inline void Foam::PackedList<nBits>::iteratorBase::prev() -{ - --index_; -} - +// * * * * * * * * * * * * * * * * Reference * * * * * * * * * * * * * * * * // template<unsigned nBits> -inline void Foam::PackedList<nBits>::iteratorBase::next() -{ - ++index_; -} +inline Foam::PackedList<nBits>::reference::reference +( + PackedList* list, + const label index +) +: + ref_(list->StorageList::operator[](index / packing())), + shift_(nBits * (index % packing())) +{} template<unsigned nBits> -inline unsigned int Foam::PackedList<nBits>::iteratorBase::get() const +inline unsigned int Foam::PackedList<nBits>::reference::get() const { - const unsigned int seg = index_ / packing(); - const unsigned int off = index_ % packing(); - - const unsigned int& stored = list_->StorageList::operator[](seg); - return (stored >> (nBits * off)) & max_value(); + return ((ref_ >> shift_) & max_value()); } template<unsigned nBits> -inline bool Foam::PackedList<nBits>::iteratorBase::set(const unsigned int val) +inline bool Foam::PackedList<nBits>::reference::set(const unsigned int val) { - const unsigned int seg = index_ / packing(); - const unsigned int off = index_ % packing(); - - const unsigned int startBit = nBits * off; - const unsigned int mask = max_value() << startBit; + const unsigned int prev = ref_; - unsigned int& stored = list_->StorageList::operator[](seg); - const unsigned int prev = stored; + const unsigned int mask = max_value() << shift_; if (val >= max_value()) { // Overflow is max_value, fill everything - stored |= mask; + ref_ |= mask; } else { - stored &= ~mask; - stored |= mask & (val << startBit); + ref_ &= ~mask; + ref_ |= mask & (val << shift_); } - return prev != stored; -} - - -template<unsigned nBits> -inline Foam::label Foam::PackedList<nBits>::iteratorBase::key() const -{ - return index_; -} - - -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::iteratorBase::operator== -( - const iteratorBase& iter -) const -{ - return this->get() == iter.get(); // Compare values -} - - -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::iteratorBase::operator!= -( - const iteratorBase& iter -) const -{ - return this->get() != iter.get(); // Compare values + return (prev != ref_); } template<unsigned nBits> -inline void Foam::PackedList<nBits>::iteratorBase::operator= +inline void Foam::PackedList<nBits>::reference::operator= ( - const iteratorBase& iter + const reference& other ) { - this->set(iter.get()); // Set values + this->set(other.get()); } template<unsigned nBits> -inline void Foam::PackedList<nBits>::iteratorBase::operator= +inline void Foam::PackedList<nBits>::reference::operator= ( const unsigned int val ) { - // Lazy evaluation - increase size on assigment - if (index_ >= list_->size_) - { - list_->resize(index_ + 1); - } - this->set(val); } template<unsigned nBits> -inline Foam::PackedList<nBits>::iteratorBase::operator -unsigned int () const -{ - // Lazy evaluation - return 0 for out-of-range - if (index_ >= list_->size_) - { - return 0; - } - - return this->get(); -} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::iterator::iterator() -: - iteratorBase() -{} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::const_iterator::const_iterator() -: - iteratorBase() -{} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::iterator::iterator -( - const iteratorBase& iter -) -: - iteratorBase(iter) -{ - this->bound(); -} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::const_iterator::const_iterator -( - const iteratorBase& iter -) -: - iteratorBase(iter) -{ - this->bound(); -} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::iterator::iterator -( - const PackedList<nBits>* lst, - const label i -) -: - iteratorBase(lst, i) -{} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::const_iterator::const_iterator -( - const PackedList<nBits>* lst, - const label i -) -: - iteratorBase(lst, i) -{} - - -template<unsigned nBits> -inline Foam::PackedList<nBits>::const_iterator::const_iterator -( - const iterator& iter -) -: - iteratorBase(static_cast<const iteratorBase&>(iter)) -{} - - -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::iterator::operator== -( - const iteratorBase& iter -) const -{ - return this->index_ == iter.index_; // Compare positions -} - - -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::iterator::operator!= -( - const iteratorBase& iter -) const -{ - return this->index_ != iter.index_; // Compare positions -} - - -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::const_iterator::operator== -( - const iteratorBase& iter -) const -{ - return this->index_ == iter.index_; // Compare positions -} - - -template<unsigned nBits> -inline bool Foam::PackedList<nBits>::const_iterator::operator!= -( - const iteratorBase& iter -) const -{ - return this->index_ != iter.index_; // Compare positions -} - - -template<unsigned nBits> -inline void Foam::PackedList<nBits>::iterator::operator= -( - const iteratorBase& iter -) -{ - this->list_ = iter.list_; - this->index_ = iter.index_; - - this->bound(); -} - - -template<unsigned nBits> -inline void Foam::PackedList<nBits>::const_iterator::operator= -( - const iteratorBase& iter -) -{ - this->list_ = iter.list_; - this->index_ = iter.index_; - - this->bound(); -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iterator& -Foam::PackedList<nBits>::iterator::operator++() -{ - this->next(); - return *this; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator& -Foam::PackedList<nBits>::const_iterator::operator++() -{ - this->next(); - return *this; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iterator -Foam::PackedList<nBits>::iterator::operator++(int) -{ - iterator old(*this); - this->next(); - return old; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator -Foam::PackedList<nBits>::const_iterator::operator++(int) -{ - const_iterator old(*this); - this->next(); - return old; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iterator& -Foam::PackedList<nBits>::iterator::operator--() -{ - this->prev(); - return *this; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator& -Foam::PackedList<nBits>::const_iterator::operator--() -{ - this->prev(); - return *this; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iterator -Foam::PackedList<nBits>::iterator::operator--(int) -{ - iterator old(*this); - this->prev(); - return old; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator -Foam::PackedList<nBits>::const_iterator::operator--(int) -{ - const_iterator old(*this); - this->prev(); - return old; -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iteratorBase& -Foam::PackedList<nBits>::iterator::operator*() -{ - return static_cast<iteratorBase&>(*this); -} - - -template<unsigned nBits> -inline unsigned int -Foam::PackedList<nBits>::const_iterator::operator*() const +inline Foam::PackedList<nBits>::reference::operator unsigned int () const { return this->get(); } -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iterator -Foam::PackedList<nBits>::begin() -{ - return iterator(this, 0); -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator -Foam::PackedList<nBits>::begin() const -{ - return const_iterator(this, 0); -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator -Foam::PackedList<nBits>::cbegin() const -{ - return const_iterator(this, 0); -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iterator -Foam::PackedList<nBits>::end() -{ - return iterator(this, size_); -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator -Foam::PackedList<nBits>::end() const -{ - return const_iterator(this, size_); -} - - -template<unsigned nBits> -inline typename Foam::PackedList<nBits>::const_iterator -Foam::PackedList<nBits>::cend() const -{ - return const_iterator(this, size_); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<unsigned nBits> @@ -951,14 +581,7 @@ inline unsigned int Foam::PackedList<nBits>::get(const label i) const return 0u; } - return iteratorBase(this, i).get(); -} - - -template<unsigned nBits> -inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const -{ - return get(i); + return reference(const_cast<PackedList<nBits>*>(this), i).get(); } @@ -986,7 +609,7 @@ inline bool Foam::PackedList<nBits>::set resize(i + 1); } - return iteratorBase(this, i).set(val); + return reference(this, i).set(val); } @@ -999,7 +622,7 @@ inline bool Foam::PackedList<nBits>::unset(const label i) return false; } - return iteratorBase(this, i).set(0u); + return reference(this, i).set(0u); } @@ -1011,7 +634,7 @@ Foam::PackedList<nBits>::append(const unsigned int val) reserve(idx + 1); size_++; - iteratorBase(this, idx).set(val); + reference(this, idx).set(val); return *this; } @@ -1028,18 +651,31 @@ inline unsigned int Foam::PackedList<nBits>::remove() << "List is empty" << abort(FatalError); } - const unsigned int val = iteratorBase(this, idx).get(); + const unsigned int val = reference(this, idx).get(); resize(idx); return val; } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template<unsigned nBits> +inline unsigned int Foam::PackedList<nBits>::operator[](const label i) const +{ + return get(i); +} + + template<unsigned nBits> -inline typename Foam::PackedList<nBits>::iteratorBase +inline typename Foam::PackedList<nBits>::reference Foam::PackedList<nBits>::operator[](const label i) { - return iteratorBase(this, i); + // Leave enabled during testing period (MAR-2018) + // #ifdef FULLDEBUG + checkIndex(i); + // #endif + return reference(this, i); } diff --git a/src/OpenFOAM/meshes/bandCompression/bandCompression.C b/src/OpenFOAM/meshes/bandCompression/bandCompression.C index 44ed6a1ba91cf0b22f179e4b4c08d0fc8619e862..ddb25eb6fea06c5935bfcb845d36a84959e7fba2 100644 --- a/src/OpenFOAM/meshes/bandCompression/bandCompression.C +++ b/src/OpenFOAM/meshes/bandCompression/bandCompression.C @@ -103,9 +103,9 @@ Foam::labelList Foam::bandCompression(const labelListList& cellCellAddressing) { currentCell = nextCell.removeHead(); - if (!visited[currentCell]) + if (visited.set(currentCell)) { - visited[currentCell] = 1; + // On first visit... // add into cellOrder newOrder[cellInOrder] = currentCell; @@ -230,7 +230,7 @@ Foam::labelList Foam::bandCompression if (!visited[currentCell]) { - visited[currentCell] = 1; + visited.set(currentCell); // add into cellOrder newOrder[cellInOrder] = currentCell; diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 2995a7659f198505631d7609c500feba2a53bbf8..609e108a4b3df430176375a57c82ef32ccbe9464 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -1215,7 +1215,7 @@ void Foam::globalMeshData::calcGlobalEdgeOrientation() const } else { - globalEdgeOrientation[edgeI] = (stat == 1); + globalEdgeOrientation.set(edgeI, (stat == 1)); } } } @@ -2439,7 +2439,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints // 1. Count number of masters on my processor. label nMaster = 0; - PackedBoolList isMaster(mesh_.nPoints(), 1); + PackedBoolList isMaster(mesh_.nPoints(), true); forAll(pointSlaves, pointi) { if (masterGlobalPoint[pointi] == -1) @@ -2459,7 +2459,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints else { // connected slave point - isMaster[cpp.meshPoints()[pointi]] = 0; + isMaster.unset(cpp.meshPoints()[pointi]); } } diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshCheck.C b/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshCheck.C index 91590e5467dfa6698e975dcfa2ecf235e02072f5..c5e58e284eaf4b5260727e713a58c69b0fbb7947 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshCheck.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshCheck/polyMeshCheck.C @@ -109,7 +109,7 @@ bool Foam::polyMesh::checkFaceOrthogonality } } - if (isMasterFace[facei]) + if (isMasterFace.test(facei)) { minDDotS = min(minDDotS, ortho[facei]); sumDDotS += ortho[facei]; @@ -235,9 +235,9 @@ bool Foam::polyMesh::checkFaceSkewness } } - if (isMasterFace[facei]) + if (isMasterFace.test(facei)) { - nWarnSkew++; + ++nWarnSkew; } } } @@ -534,7 +534,7 @@ bool Foam::polyMesh::checkFaceWeight } // Note: statistics only on master of coupled faces - if (isMasterFace[facei]) + if (isMasterFace.test(facei)) { minDet = min(minDet, faceWght[facei]); sumDet += faceWght[facei]; @@ -621,7 +621,7 @@ bool Foam::polyMesh::checkVolRatio } // Note: statistics only on master of coupled faces - if (isMasterFace[facei]) + if (isMasterFace.test(facei)) { minDet = min(minDet, volRatio[facei]); sumDet += volRatio[facei]; diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C index 828f4f82e060b57b08e1d3a746285560e1869c92..798db8f12ae2ced0f98580b47773548f31192d0f 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C @@ -85,9 +85,9 @@ Foam::PackedBoolList Foam::syncTools::getMasterPoints(const polyMesh& mesh) > 0 ) { - isMasterPoint[meshPointi] = true; + isMasterPoint.set(meshPointi); } - donePoint[meshPointi] = true; + donePoint.set(meshPointi); } @@ -98,7 +98,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterPoints(const polyMesh& mesh) { if (!donePoint[pointi]) { - isMasterPoint[pointi] = true; + isMasterPoint.set(pointi); } } @@ -129,9 +129,9 @@ Foam::PackedBoolList Foam::syncTools::getMasterEdges(const polyMesh& mesh) > 0 ) { - isMasterEdge[meshEdgeI] = true; + isMasterEdge.set(meshEdgeI); } - doneEdge[meshEdgeI] = true; + doneEdge.set(meshEdgeI); } @@ -142,7 +142,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterEdges(const polyMesh& mesh) { if (!doneEdge[edgeI]) { - isMasterEdge[edgeI] = true; + isMasterEdge.set(edgeI); } } @@ -152,7 +152,7 @@ Foam::PackedBoolList Foam::syncTools::getMasterEdges(const polyMesh& mesh) Foam::PackedBoolList Foam::syncTools::getMasterFaces(const polyMesh& mesh) { - PackedBoolList isMasterFace(mesh.nFaces(), 1); + PackedBoolList isMasterFace(mesh.nFaces(), true); const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -182,7 +182,7 @@ Foam::PackedBoolList Foam::syncTools::getInternalOrMasterFaces const polyMesh& mesh ) { - PackedBoolList isMasterFace(mesh.nFaces(), 1); + PackedBoolList isMasterFace(mesh.nFaces(), true); const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -218,7 +218,7 @@ Foam::PackedBoolList Foam::syncTools::getInternalOrCoupledFaces const polyMesh& mesh ) { - PackedBoolList isMasterFace(mesh.nFaces(), 1); + PackedBoolList isMasterFace(mesh.nFaces(), true); const polyBoundaryMesh& patches = mesh.boundaryMesh(); diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index 65877be82434cc08937550f97796d5e851958c03..b8635648d4fb64f19226bf72aacdda9e73849675 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -440,15 +440,18 @@ Foam::PackedBoolList Foam::ZoneMesh<ZoneType, MeshType>::findMatching const keyType& key ) const { - PackedBoolList lst; + PackedBoolList bitset; const labelList indices = this->findIndices(key); forAll(indices, i) { - lst |= static_cast<const labelList&>(this->operator[](indices[i])); + bitset.setMany + ( + static_cast<const labelList&>(this->operator[](indices[i])) + ); } - return lst; + return bitset; } diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsMatch.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsMatch.C index a3c9427ec52f5255a7d51ad922135b3fa1c284f1..718ed443bdbb28e346b97f009149a27797395132 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsMatch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsMatch.C @@ -97,7 +97,7 @@ void Foam::PatchTools::matchEdges p1EdgeLabels.setSize(p1.nEdges()); p2EdgeLabels.setSize(p1.nEdges()); sameOrientation.setSize(p1.nEdges()); - sameOrientation = 0; + sameOrientation = false; label nMatches = 0; @@ -124,8 +124,8 @@ void Foam::PatchTools::matchEdges { p1EdgeLabels[nMatches] = iter(); p2EdgeLabels[nMatches] = edgeI; - sameOrientation[nMatches] = (meshE[0] == iter.key()[0]); - nMatches++; + sameOrientation.set(nMatches, (meshE[0] == iter.key()[0])); + ++nMatches; } } p1EdgeLabels.setSize(nMatches); diff --git a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSearch.C b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSearch.C index 66fde47413d3e4d90256df4c893514b481dff35e..967cceae8d6969b609b4cf886138b9af3e425c57 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSearch.C +++ b/src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsSearch.C @@ -234,7 +234,7 @@ void Foam::PatchTools::calcBounds forAll(f, fp) { label pointi = f[fp]; - if (pointIsUsed.set(pointi, 1u)) + if (pointIsUsed.set(pointi)) { bb.add(points[pointi]); ++nPoints; diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index c5ed0860d07120fe7fdd9fdff9e4d2e1307673bc..be8216161c93dd0fb7502fbe1fcc0df0e25e9db2 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -294,9 +294,9 @@ protected: //- Check boundary for closedness bool checkClosedBoundary ( - const vectorField&, - const bool, - const PackedBoolList& + const vectorField& areas, + const bool report, + const PackedBoolList& internalOrCoupledFaces ) const; //- Check cells for closedness diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C index 57a7be528b1896af2fe50ed0481c30b942cda3b2..ae0bac1f085bfd51e7bb348c3b5f39875020e6d8 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C @@ -1684,7 +1684,7 @@ bool Foam::primitiveMesh::checkFaceFaces bool Foam::primitiveMesh::checkClosedBoundary(const bool report) const { - return checkClosedBoundary(faceAreas(), report, PackedBoolList(0)); + return checkClosedBoundary(faceAreas(), report, PackedBoolList()); } @@ -1693,7 +1693,7 @@ bool Foam::primitiveMesh::checkClosedCells const bool report, labelHashSet* setPtr, labelHashSet* aspectSetPtr, - const Vector<label>& solutionD + const Vector<label>& solutionD ) const { return checkClosedCells diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshTools.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshTools.C index 8d3c0c0a57a1f4b5ca3b59608cf730b061d0a552..020b3fa8ac2bfce376d15dc7ad647e2e91405a22 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshTools.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshTools.C @@ -495,7 +495,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::cellDeterminant forAll(curFaces, i) { - if (internalOrCoupledFace[curFaces[i]]) + if (internalOrCoupledFace.test(curFaces[i])) { avgArea += mag(faceAreas[curFaces[i]]); @@ -515,7 +515,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::cellDeterminant forAll(curFaces, i) { - if (internalOrCoupledFace[curFaces[i]]) + if (internalOrCoupledFace.test(curFaces[i])) { areaTensor += sqr(faceAreas[curFaces[i]]/avgArea); } diff --git a/src/conversion/ccm/reader/ccmReaderMesh.C b/src/conversion/ccm/reader/ccmReaderMesh.C index afd558ec150c55b16d6d883c94359bf2e14ed56e..f7ea2947b54c307fca62a0afbe784bb0c98a6e62 100644 --- a/src/conversion/ccm/reader/ccmReaderMesh.C +++ b/src/conversion/ccm/reader/ccmReaderMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,10 +32,10 @@ License #include "IOdictionary.H" #include "ccmBoundaryInfo.H" -#include "PackedList.H" #include "uindirectPrimitivePatch.H" #include "SortableList.H" #include "mergePoints.H" +#include "PackedBoolList.H" #include "ListOps.H" #include "ccmInternal.H" // include last to avoid any strange interactions diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C index 12d6f45d53a36ab8d94402500b74129d56c69b14..88ff6d468f01c707ee90906ffda2b2c11a7d2753 100644 --- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C +++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C @@ -103,9 +103,10 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells forAll(faceNeighbour(), facei) { label own = faceOwner()[facei]; - bool ownProtected = unrefineableCell.get(own); label nei = faceNeighbour()[facei]; - bool neiProtected = unrefineableCell.get(nei); + + bool ownProtected = unrefineableCell.test(own); + bool neiProtected = unrefineableCell.test(nei); if (ownProtected && (cellLevel[nei] > cellLevel[own])) { @@ -119,7 +120,7 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells for (label facei = nInternalFaces(); facei < nFaces(); facei++) { label own = faceOwner()[facei]; - bool ownProtected = unrefineableCell.get(own); + bool ownProtected = unrefineableCell.test(own); if ( ownProtected @@ -141,16 +142,14 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells if (seedFace[facei]) { label own = faceOwner()[facei]; - if (unrefineableCell.get(own) == 0) + if (unrefineableCell.set(own)) { - unrefineableCell.set(own, 1); hasExtended = true; } label nei = faceNeighbour()[facei]; - if (unrefineableCell.get(nei) == 0) + if (unrefineableCell.set(nei)) { - unrefineableCell.set(nei, 1); hasExtended = true; } } @@ -160,9 +159,8 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells if (seedFace[facei]) { label own = faceOwner()[facei]; - if (unrefineableCell.get(own) == 0) + if (unrefineableCell.set(own)) { - unrefineableCell.set(own, 1); hasExtended = true; } } @@ -433,7 +431,7 @@ Foam::dynamicRefineFvMesh::refine forAll(newProtectedCell, celli) { const label oldCelli = map.cellMap()[celli]; - newProtectedCell.set(celli, protectedCell_.get(oldCelli)); + newProtectedCell.set(celli, protectedCell_.test(oldCelli)); } protectedCell_.transfer(newProtectedCell); } @@ -598,7 +596,7 @@ Foam::dynamicRefineFvMesh::unrefine label oldCelli = map.cellMap()[celli]; if (oldCelli >= 0) { - newProtectedCell.set(celli, protectedCell_.get(oldCelli)); + newProtectedCell.set(celli, protectedCell_.test(oldCelli)); } } protectedCell_.transfer(newProtectedCell); @@ -717,7 +715,7 @@ void Foam::dynamicRefineFvMesh::selectRefineCandidates { if (cellError[celli] > 0) { - candidateCell.set(celli, 1); + candidateCell.set(celli); } } } @@ -754,11 +752,8 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectRefineCells if ( cellLevel[celli] < maxRefinement - && candidateCell.get(celli) - && ( - unrefineableCell.empty() - || !unrefineableCell.get(celli) - ) + && candidateCell.test(celli) + && !unrefineableCell.test(celli) ) { candidates.append(celli); @@ -775,11 +770,8 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectRefineCells if ( cellLevel[celli] == level - && candidateCell.get(celli) - && ( - unrefineableCell.empty() - || !unrefineableCell.get(celli) - ) + && candidateCell.test(celli) + && !unrefineableCell.test(celli) ) { candidates.append(celli); @@ -840,9 +832,9 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectUnrefinePoints { label cellI = pCells[pCellI]; - if (protectedCell_[cellI]) + if (protectedCell_.test(cellI)) { - protectedPoint[pointI] = true; + protectedPoint.set(pointI); break; } } @@ -882,7 +874,7 @@ Foam::labelList Foam::dynamicRefineFvMesh::selectUnrefinePoints forAll(pCells, pCelli) { - if (markedCell.get(pCells[pCelli])) + if (markedCell.test(pCells[pCelli])) { hasMarked = true; break; @@ -927,7 +919,7 @@ void Foam::dynamicRefineFvMesh::extendMarkedCells forAll(markedCell, celli) { - if (markedCell.get(celli)) + if (markedCell.test(celli)) { const cell& cFaces = cells()[celli]; @@ -945,15 +937,15 @@ void Foam::dynamicRefineFvMesh::extendMarkedCells { if (markedFace[facei]) { - markedCell.set(faceOwner()[facei], 1); - markedCell.set(faceNeighbour()[facei], 1); + markedCell.set(faceOwner()[facei]); + markedCell.set(faceNeighbour()[facei]); } } for (label facei = nInternalFaces(); facei < nFaces(); facei++) { if (markedFace[facei]) { - markedCell.set(faceOwner()[facei], 1); + markedCell.set(faceOwner()[facei]); } } } @@ -983,7 +975,7 @@ void Foam::dynamicRefineFvMesh::checkEightAnchorPoints // Check if cell has already 8 anchor points -> protect cell if (nAnchorPoints[celli] == 8) { - if (protectedCell.set(celli, true)) + if (protectedCell.set(celli)) { nProtected++; } @@ -1000,9 +992,9 @@ void Foam::dynamicRefineFvMesh::checkEightAnchorPoints forAll(protectedCell, celli) { - if (!protectedCell[celli] && nAnchorPoints[celli] != 8) + if (!protectedCell.test(celli) && nAnchorPoints[celli] != 8) { - protectedCell.set(celli, true); + protectedCell.set(celli); nProtected++; } } @@ -1017,7 +1009,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) meshCutter_(*this), dumpLevel_(false), nRefinementIterations_(0), - protectedCell_(nCells(), 0) + protectedCell_(nCells(), false) { // Read static part of dictionary readDict(); @@ -1046,7 +1038,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) { label celli = pCells[i]; - if (!protectedCell_.get(celli)) + if (!protectedCell_.test(celli)) { if (pointLevel[pointi] <= cellLevel[celli]) { @@ -1054,7 +1046,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) if (nAnchors[celli] > 8) { - protectedCell_.set(celli, 1); + protectedCell_.set(celli); nProtected++; } } @@ -1117,9 +1109,9 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) { if (protectedFace[facei]) { - protectedCell_.set(faceOwner()[facei], 1); + protectedCell_.set(faceOwner()[facei]); nProtected++; - protectedCell_.set(faceNeighbour()[facei], 1); + protectedCell_.set(faceNeighbour()[facei]); nProtected++; } } @@ -1127,7 +1119,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) { if (protectedFace[facei]) { - protectedCell_.set(faceOwner()[facei], 1); + protectedCell_.set(faceOwner()[facei]); nProtected++; } } @@ -1139,7 +1131,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) if (cFaces.size() < 6) { - if (protectedCell_.set(celli, 1)) + if (protectedCell_.set(celli)) { nProtected++; } @@ -1150,7 +1142,7 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) { if (faces()[cFaces[cFacei]].size() < 4) { - if (protectedCell_.set(celli, 1)) + if (protectedCell_.set(celli)) { nProtected++; } @@ -1170,7 +1162,6 @@ Foam::dynamicRefineFvMesh::dynamicRefineFvMesh(const IOobject& io) } else { - cellSet protectedCells(*this, "protectedCells", nProtected); forAll(protectedCell_, celli) { @@ -1335,15 +1326,15 @@ bool Foam::dynamicRefineFvMesh::update() if (oldCelli < 0) { - newRefineCell.set(celli, 1); + newRefineCell.set(celli); } else if (reverseCellMap[oldCelli] != celli) { - newRefineCell.set(celli, 1); + newRefineCell.set(celli); } else { - newRefineCell.set(celli, refineCell.get(oldCelli)); + newRefineCell.set(celli, refineCell.test(oldCelli)); } } refineCell.transfer(newRefineCell); diff --git a/src/dynamicMesh/createShellMesh/createShellMesh.C b/src/dynamicMesh/createShellMesh/createShellMesh.C index 76feaaf60a0120a1c2ef375683f20746eb3f6667..e49c9aabbdae7972547bb507e3114414bacfe7c2 100644 --- a/src/dynamicMesh/createShellMesh/createShellMesh.C +++ b/src/dynamicMesh/createShellMesh/createShellMesh.C @@ -143,7 +143,7 @@ void Foam::createShellMesh::syncEdges if (!isChangedEdge[patchEdgeI]) { changedEdges.append(patchEdgeI); - isChangedEdge[patchEdgeI] = true; + isChangedEdge.set(patchEdgeI); } } } @@ -236,7 +236,7 @@ void Foam::createShellMesh::calcPointRegions if (!isChangedEdge[edgeI]) { changedEdges.append(edgeI); - isChangedEdge[edgeI] = true; + isChangedEdge.set(edgeI); } } } @@ -289,7 +289,7 @@ void Foam::createShellMesh::calcPointRegions pointGlobalRegions[facei][fp0] = edgeData[0]; if (!isChangedFace[facei]) { - isChangedFace[facei] = true; + isChangedFace.set(facei); changedFaces.append(facei); } } @@ -300,7 +300,7 @@ void Foam::createShellMesh::calcPointRegions pointGlobalRegions[facei][fp1] = edgeData[1]; if (!isChangedFace[facei]) { - isChangedFace[facei] = true; + isChangedFace.set(facei); changedFaces.append(facei); } } @@ -349,7 +349,7 @@ void Foam::createShellMesh::calcPointRegions if (!isChangedEdge[edgeI]) { changedEdges.append(edgeI); - isChangedEdge[edgeI] = true; + isChangedEdge.set(edgeI); } } } diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C index d69b26e89fc66717ad8728429a127365c3366647..345f88a034dbc191604d23af05b145d4c7c4dcd3 100644 --- a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C @@ -152,7 +152,7 @@ void extrudePatchMesh::extrudeMesh(const List<polyPatch*>& regionPatches) { if (columnCells) { - nonManifoldEdge[edgeI] = true; + nonManifoldEdge.set(edgeI); } } @@ -307,7 +307,7 @@ void extrudePatchMesh::extrudeMesh(const List<polyPatch*>& regionPatches) { const labelList& eFaces = extrudedPatch_.edgeFaces()[edgeI]; - if (eFaces.size() != 2 || nonManifoldEdge[edgeI]) + if (eFaces.size() != 2 || nonManifoldEdge.test(edgeI)) { edgePatches[edgeI].setSize(eFaces.size(), sidePatchID); } diff --git a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C index 0b5945d31df5bf9612b53105525be09e1fc4f652..ba31bb9b0abeeb0c5412d1c543d01ae14a06bda3 100644 --- a/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C +++ b/src/dynamicMesh/motionSmoother/motionSmootherAlgo.C @@ -160,7 +160,7 @@ void Foam::motionSmootherAlgo::minSmooth forAll(meshPoints, i) { label pointi = meshPoints[i]; - if (isAffectedPoint.get(pointi) == 1) + if (isAffectedPoint.test(pointi)) { newFld[pointi] = min ( @@ -193,7 +193,7 @@ void Foam::motionSmootherAlgo::minSmooth forAll(fld, pointi) { - if (isAffectedPoint.get(pointi) == 1 && isInternalPoint(pointi)) + if (isAffectedPoint.test(pointi) && isInternalPoint(pointi)) { newFld[pointi] = min ( @@ -295,7 +295,7 @@ void Foam::motionSmootherAlgo::subtractField bool Foam::motionSmootherAlgo::isInternalPoint(const label pointi) const { - return isInternalPoint_.get(pointi) == 1; + return isInternalPoint_.test(pointi); } @@ -309,7 +309,7 @@ void Foam::motionSmootherAlgo::getAffectedFacesAndPoints ) const { isAffectedPoint.setSize(mesh_.nPoints()); - isAffectedPoint = 0; + isAffectedPoint = false; faceSet nbrFaces(mesh_, "checkFaces", wrongFaces); @@ -343,10 +343,7 @@ void Foam::motionSmootherAlgo::getAffectedFacesAndPoints forAllConstIter(faceSet, nbrFaces, iter) { const face& f = mesh_.faces()[iter.key()]; - forAll(f, fp) - { - isAffectedPoint.set(f[fp], 1); - } + isAffectedPoint.setMany(f); } } } @@ -377,7 +374,7 @@ Foam::motionSmootherAlgo::motionSmootherAlgo oldPoints_(oldPoints), adaptPatchIDs_(adaptPatchIDs), paramDict_(paramDict), - isInternalPoint_(mesh_.nPoints(), 1) + isInternalPoint_(mesh_.nPoints(), true) { updateMesh(); } @@ -525,8 +522,7 @@ void Foam::motionSmootherAlgo::setDisplacement // to them since we want 'proper' values from displacement to take // precedence. { - PackedBoolList isPatchPoint(mesh.nPoints()); - isPatchPoint.set(ppMeshPoints); + PackedBoolList isPatchPoint(mesh.nPoints(), ppMeshPoints); syncTools::syncPointList ( mesh, diff --git a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C index ef02360324622db1946318f29c615a598f797fc7..5865318818986e42f3935125485a2bee830c2877 100644 --- a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C +++ b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.C @@ -67,10 +67,10 @@ void Foam::displacementLayeredMotionMotionSolver::calcZoneMask if (cellZoneI == -1) { isZonePoint.setSize(mesh().nPoints()); - isZonePoint = 1; + isZonePoint = true; isZoneEdge.setSize(mesh().nEdges()); - isZoneEdge = 1; + isZoneEdge = true; } else { @@ -82,10 +82,9 @@ void Foam::displacementLayeredMotionMotionSolver::calcZoneMask const labelList& cPoints = mesh().cellPoints(cz[i]); forAll(cPoints, cPointi) { - if (!isZonePoint[cPoints[cPointi]]) + if (isZonePoint.set(cPoints[cPointi])) { - isZonePoint[cPoints[cPointi]] = 1; - nPoints++; + ++nPoints; } } } @@ -105,10 +104,9 @@ void Foam::displacementLayeredMotionMotionSolver::calcZoneMask const labelList& cEdges = mesh().cellEdges(cz[i]); forAll(cEdges, cEdgeI) { - if (!isZoneEdge[cEdges[cEdgeI]]) + if (isZoneEdge.set(cEdges[cEdgeI])) { - isZoneEdge[cEdges[cEdgeI]] = 1; - nEdges++; + ++nEdges; } } } diff --git a/src/dynamicMesh/polyMeshFilter/polyMeshFilter.H b/src/dynamicMesh/polyMeshFilter/polyMeshFilter.H index 05da5c8b9f54079f198df4d52350acc7d98aad75..5e85a1f65ff23043f2014bdc438fdde420fb5e24 100644 --- a/src/dynamicMesh/polyMeshFilter/polyMeshFilter.H +++ b/src/dynamicMesh/polyMeshFilter/polyMeshFilter.H @@ -53,8 +53,8 @@ namespace Foam class polyMesh; class fvMesh; -class PackedBoolList; class faceSet; +class PackedBoolList; /*---------------------------------------------------------------------------*\ Class polyMeshFilter Declaration diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C index ce81b0a63deded2d02d06aa803ebdb5b964c2b82..6c47590edc3600d54d5421bf9c962a6a78f1b0dd 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C @@ -97,10 +97,7 @@ Foam::label Foam::edgeCollapser::checkMeshQuality { const face& f = mesh.faces()[iter.key()]; - forAll(f, pI) - { - isErrorPoint[f[pI]] = true; - } + isErrorPoint.setMany(f); } syncTools::syncPointList @@ -225,10 +222,7 @@ void Foam::edgeCollapser::collapseToEdge labelList faceEdgesNeg = edgesFromPoints(facei, facePtsNeg); - forAll(faceEdgesNeg, edgeI) - { - collapseEdge[faceEdgesNeg[edgeI]] = true; - } + collapseEdge.setMany(faceEdgesNeg); forAll(facePtsNeg, pI) { @@ -272,10 +266,7 @@ void Foam::edgeCollapser::collapseToEdge labelList faceEdgesPos = edgesFromPoints(facei, facePtsPos); - forAll(faceEdgesPos, edgeI) - { - collapseEdge[faceEdgesPos[edgeI]] = true; - } + collapseEdge.setMany(faceEdgesPos); forAll(facePtsPos, pI) { @@ -373,11 +364,7 @@ void Foam::edgeCollapser::collapseToPoint const labelList& faceEdges = mesh_.faceEdges()[facei]; - forAll(faceEdges, eI) - { - const label edgeI = faceEdges[eI]; - collapseEdge[edgeI] = true; - } + collapseEdge.setMany(faceEdges); forAll(f, pI) { @@ -866,7 +853,7 @@ Foam::label Foam::edgeCollapser::breakStringsAtEdges forAll(edges, eI) { - if (markedEdges[eI]) + if (markedEdges.test(eI)) { const edge& e = edges[eI]; @@ -880,7 +867,7 @@ Foam::label Foam::edgeCollapser::breakStringsAtEdges if ( - !collapseEdge[eI] + !collapseEdge.test(eI) && startCollapseIndex == endCollapseIndex ) { @@ -897,11 +884,11 @@ Foam::label Foam::edgeCollapser::breakStringsAtEdges if ( - collapseEdge[edgeI] - && nbrIndex == startCollapseIndex + nbrIndex == startCollapseIndex + && collapseEdge.test(edgeI) ) { - collapseEdge[edgeI] = false; + collapseEdge.unset(edgeI); nUncollapsed++; } } @@ -948,7 +935,7 @@ void Foam::edgeCollapser::determineDuplicatePointsOnFace label index = allPointInfo[f[fpI]].collapseIndex(); if (duplicateCollapses.found(index)) { - markedPoints[f[fpI]] = true; + markedPoints.set(f[fpI]); } } } @@ -1385,7 +1372,7 @@ bool Foam::edgeCollapser::setRefinement faceList newFaces(mesh_.faces()); // Current cellCollapse status - boolList cellRemoved(mesh_.nCells(), false); + PackedBoolList cellRemoved(mesh_.nCells(), false); label nUnvisited = 0; label nUncollapsed = 0; @@ -1436,7 +1423,7 @@ bool Foam::edgeCollapser::setRefinement forAll(cells, celli) { - if (!cellRemoved[celli]) + if (!cellRemoved.test(celli)) { const cell& cFaces = cells[celli]; @@ -1468,7 +1455,7 @@ bool Foam::edgeCollapser::setRefinement } Pout<< endl; - cellRemoved[celli] = true; + cellRemoved.set(celli); // Collapse all edges of cell to nothing // collapseEdges(cellEdges[celli]); @@ -1494,15 +1481,15 @@ bool Foam::edgeCollapser::setRefinement // Keep track of faces that have been done already. - boolList doneFace(mesh_.nFaces(), false); + PackedBoolList doneFace(mesh_.nFaces(), false); { // Mark points used. - boolList usedPoint(mesh_.nPoints(), false); + PackedBoolList usedPoint(mesh_.nPoints(), false); forAll(cellRemoved, celli) { - if (cellRemoved[celli]) + if (cellRemoved.test(celli)) { meshMod.removeCell(celli, -1); } @@ -1518,25 +1505,22 @@ bool Foam::edgeCollapser::setRefinement meshMod.removeFace(facei, -1); meshChanged = true; - // Mark face as been done. - doneFace[facei] = true; + // Mark face as been done - i.e. ignore it later + doneFace.set(facei); } else { // Kept face. Mark vertices - forAll(f, fp) - { - usedPoint[f[fp]] = true; - } + usedPoint.setMany(f); } } // Remove unused vertices that have not been marked for removal already forAll(usedPoint, pointi) { - if (!usedPoint[pointi]) + if (!usedPoint.test(pointi)) { - removedPoints[pointi] = true; + removedPoints.set(pointi); meshMod.removePoint(pointi, -1); meshChanged = true; } @@ -1551,7 +1535,7 @@ bool Foam::edgeCollapser::setRefinement if ( - removedPoints[pointi] == false + !removedPoints.test(pointi) && collapseIndex != -1 && collapseIndex != -2 ) @@ -1573,7 +1557,7 @@ bool Foam::edgeCollapser::setRefinement // Renumber faces that use points forAll(allPointInfo, pointi) { - if (removedPoints[pointi] == true) + if (removedPoints.test(pointi)) { const labelList& changedFaces = pointFaces[pointi]; @@ -1581,9 +1565,9 @@ bool Foam::edgeCollapser::setRefinement { label facei = changedFaces[changedFacei]; - if (!doneFace[facei]) + if (doneFace.set(facei)) { - doneFace[facei] = true; + // On first visit... // Get current zone info label zoneID = faceZones.whichZone(facei); @@ -1689,7 +1673,7 @@ void Foam::edgeCollapser::consistentCollapse isCollapsedFace[facei] = isFaceCollapsed(f, allPointInfo); - if (isCollapsedFace[facei] < 1) + if (!isCollapsedFace.test(facei)) { determineDuplicatePointsOnFace ( @@ -1714,7 +1698,7 @@ void Foam::edgeCollapser::consistentCollapse // Mark all edges attached to the point for collapse forAll(markedPoints, pointi) { - if (markedPoints[pointi]) + if (markedPoints.test(pointi)) { const label index = allPointInfo[pointi].collapseIndex(); @@ -1727,9 +1711,9 @@ void Foam::edgeCollapser::consistentCollapse const label nbrIndex = allPointInfo[nbrPointi].collapseIndex(); - if (collapseEdge[edgeI] && nbrIndex == index) + if (nbrIndex == index && collapseEdge.test(edgeI)) { - collapseEdge[edgeI] = false; + collapseEdge.unset(edgeI); nUncollapsed++; } } @@ -1751,9 +1735,9 @@ void Foam::edgeCollapser::consistentCollapse { label facei = cFaces[fI]; - if (isCollapsedFace[facei]) + if (isCollapsedFace.test(facei)) { - nFaces--; + --nFaces; } } @@ -1770,18 +1754,17 @@ void Foam::edgeCollapser::consistentCollapse { label edgeI = fEdges[fEdgeI]; - if (collapseEdge[edgeI]) + if (collapseEdge.unset(edgeI)) { - collapseEdge[edgeI] = false; - nUncollapsed++; + ++nUncollapsed; } - markedEdges[edgeI] = true; + markedEdges.set(edgeI); } // Uncollapsed this face. - isCollapsedFace[facei] = false; - nFaces++; + isCollapsedFace.unset(facei); + ++nFaces; } } @@ -1844,11 +1827,11 @@ Foam::label Foam::edgeCollapser::markSmallEdges { const edge& e = edges[edgeI]; - if (!collapseEdge[edgeI]) + if (!collapseEdge.test(edgeI)) { if (e.mag(points) < minEdgeLen[edgeI]) { - collapseEdge[edgeI] = true; + collapseEdge.set(edgeI); label masterPointi = edgeMaster(pointPriority, e); @@ -1866,7 +1849,6 @@ Foam::label Foam::edgeCollapser::markSmallEdges collapsePointToLocation.set(masterPointi, collapsePt); } - nCollapsed++; } } @@ -1929,7 +1911,7 @@ Foam::label Foam::edgeCollapser::markMergeEdges if (e0length <= e1length) { - collapseEdge[e0] = true; + collapseEdge.set(e0); checkBoundaryPointMergeEdges ( @@ -1941,7 +1923,7 @@ Foam::label Foam::edgeCollapser::markMergeEdges } else { - collapseEdge[e1] = true; + collapseEdge.set(e1); checkBoundaryPointMergeEdges ( @@ -2159,7 +2141,7 @@ Foam::labelPair Foam::edgeCollapser::markFaceZoneEdges // // if (!keepEdge) // { -// collapseEdge[eI] = true; +// collapseEdge.set(eI); // // const Foam::point collapsePoint = // 0.5*(points[e.end()] + points[e.start()]); @@ -2178,7 +2160,7 @@ Foam::labelPair Foam::edgeCollapser::markFaceZoneEdges // // forAll(collapseEdge, eI) // { -// if (collapseEdge[eI]) +// if (collapseEdge.test(eI)) // { // const edge& e = edges[eI]; // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.H index 4f5f6e7feb465ed4756b209de0577c1b01ab909c..40c45943926724fb29ed6cc06325a9a9d6d3f027 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.H @@ -60,6 +60,7 @@ class globalIndex; class face; class edge; + /*---------------------------------------------------------------------------*\ Class edgeCollapser Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C index f7908b214658e07a539fb4a57e011b9d7c4a5b62..9bee5b3d068d973512b4cf1221a5afdc38fa9260 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C @@ -1573,9 +1573,9 @@ Foam::label Foam::hexRef8::faceConsistentRefinement for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) { label own = mesh_.faceOwner()[facei]; - label ownLevel = cellLevel_[own] + refineCell.get(own); - label nei = mesh_.faceNeighbour()[facei]; + + label ownLevel = cellLevel_[own] + refineCell.get(own); label neiLevel = cellLevel_[nei] + refineCell.get(nei); if (ownLevel > (neiLevel+1)) @@ -1653,18 +1653,14 @@ void Foam::hexRef8::checkWantedRefinementLevels const labelList& cellsToRefine ) const { - PackedBoolList refineCell(mesh_.nCells()); - forAll(cellsToRefine, i) - { - refineCell.set(cellsToRefine[i]); - } + PackedBoolList refineCell(mesh_.nCells(), cellsToRefine); for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) { label own = mesh_.faceOwner()[facei]; - label ownLevel = cellLevel_[own] + refineCell.get(own); - label nei = mesh_.faceNeighbour()[facei]; + + label ownLevel = cellLevel_[own] + refineCell.get(own); label neiLevel = cellLevel_[nei] + refineCell.get(nei); if (mag(ownLevel-neiLevel) > 1) @@ -2261,12 +2257,7 @@ Foam::labelList Foam::hexRef8::consistentRefinement // maxSet = false : unselect cells to refine // maxSet = true : select cells to refine - // Go to straight boolList. - PackedBoolList refineCell(mesh_.nCells()); - forAll(cellsToRefine, i) - { - refineCell.set(cellsToRefine[i]); - } + PackedBoolList refineCell(mesh_.nCells(), cellsToRefine); while (true) { @@ -2287,28 +2278,8 @@ Foam::labelList Foam::hexRef8::consistentRefinement } } - // Convert back to labelList. - label nRefined = 0; - - forAll(refineCell, celli) - { - if (refineCell.get(celli)) - { - nRefined++; - } - } - - labelList newCellsToRefine(nRefined); - nRefined = 0; - - forAll(refineCell, celli) - { - if (refineCell.get(celli)) - { - newCellsToRefine[nRefined++] = celli; - } - } + labelList newCellsToRefine(refineCell.used()); if (debug) { @@ -3137,28 +3108,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2 } // 3. Convert back to labelList. - label nRefined = 0; - - forAll(refineCell, celli) - { -// if (refineCell.get(celli)) - if (refineCell[celli]) - { - nRefined++; - } - } - - labelList newCellsToRefine(nRefined); - nRefined = 0; - - forAll(refineCell, celli) - { -// if (refineCell.get(celli)) - if (refineCell[celli]) - { - newCellsToRefine[nRefined++] = celli; - } - } + labelList newCellsToRefine(refineCell.used()); if (debug) { @@ -3184,11 +3134,8 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2 } // Extend to 2:1 - PackedBoolList refineCell(mesh_.nCells()); - forAll(newCellsToRefine, i) - { - refineCell.set(newCellsToRefine[i]); - } + PackedBoolList refineCell(mesh_.nCells(), newCellsToRefine); + const PackedBoolList savedRefineCell(refineCell); label nChanged = faceConsistentRefinement(true, refineCell); @@ -3200,7 +3147,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2 ); forAll(refineCell, celli) { - if (refineCell.get(celli)) + if (refineCell.test(celli)) { cellsOut2.insert(celli); } @@ -3215,7 +3162,7 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2 { forAll(refineCell, celli) { - if (refineCell.get(celli) && !savedRefineCell.get(celli)) + if (refineCell.test(celli) && !savedRefineCell.test(celli)) { dumpCell(celli); FatalErrorInFunction @@ -3806,10 +3753,7 @@ Foam::labelListList Foam::hexRef8::setRefinement { const cell& cFaces = mesh_.cells()[celli]; - forAll(cFaces, i) - { - affectedFace.set(cFaces[i]); - } + affectedFace.setMany(cFaces); } } @@ -3827,10 +3771,7 @@ Foam::labelListList Foam::hexRef8::setRefinement { const labelList& eFaces = mesh_.edgeFaces(edgeI); - forAll(eFaces, i) - { - affectedFace.set(eFaces[i]); - } + affectedFace.setMany(eFaces); } } } @@ -3846,7 +3787,7 @@ Foam::labelListList Foam::hexRef8::setRefinement forAll(faceMidPoint, facei) { - if (faceMidPoint[facei] >= 0 && affectedFace.get(facei)) + if (faceMidPoint[facei] >= 0 && affectedFace.test(facei)) { // Face needs to be split and hasn't yet been done in some way // (affectedFace - is impossible since this is first change but @@ -3997,7 +3938,7 @@ Foam::labelListList Foam::hexRef8::setRefinement { label facei = eFaces[i]; - if (faceMidPoint[facei] < 0 && affectedFace.get(facei)) + if (faceMidPoint[facei] < 0 && affectedFace.test(facei)) { // Unsplit face. Add edge splits to face. @@ -4097,7 +4038,7 @@ Foam::labelListList Foam::hexRef8::setRefinement forAll(affectedFace, facei) { - if (affectedFace.get(facei)) + if (affectedFace.test(facei)) { const face& f = mesh_.faces()[facei]; @@ -5341,16 +5282,8 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement // maxSet = false : unselect points to refine // maxSet = true: select points to refine - // Maintain boolList for pointsToUnrefine and cellsToUnrefine - PackedBoolList unrefinePoint(mesh_.nPoints()); - - forAll(pointsToUnrefine, i) - { - label pointi = pointsToUnrefine[i]; - - unrefinePoint.set(pointi); - } - + // Maintain bitset for pointsToUnrefine and cellsToUnrefine + PackedBoolList unrefinePoint(mesh_.nPoints(), pointsToUnrefine); while (true) { @@ -5361,14 +5294,11 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement forAll(unrefinePoint, pointi) { - if (unrefinePoint.get(pointi)) + if (unrefinePoint.test(pointi)) { const labelList& pCells = mesh_.pointCells(pointi); - forAll(pCells, j) - { - unrefineCell.set(pCells[j]); - } + unrefineCell.setMany(pCells); } } @@ -5383,9 +5313,9 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement for (label facei = 0; facei < mesh_.nInternalFaces(); facei++) { label own = mesh_.faceOwner()[facei]; - label ownLevel = cellLevel_[own] - unrefineCell.get(own); - label nei = mesh_.faceNeighbour()[facei]; + + label ownLevel = cellLevel_[own] - unrefineCell.get(own); label neiLevel = cellLevel_[nei] - unrefineCell.get(nei); if (ownLevel < (neiLevel-1)) @@ -5406,7 +5336,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement // << "problem cell already unset" // << abort(FatalError); // } - if (unrefineCell.get(own) == 0) + if (!unrefineCell.test(own)) { FatalErrorInFunction << "problem" << abort(FatalError); @@ -5424,7 +5354,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement } else { - if (unrefineCell.get(nei) == 0) + if (!unrefineCell.test(nei)) { FatalErrorInFunction << "problem" << abort(FatalError); @@ -5460,7 +5390,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement { if (!maxSet) { - if (unrefineCell.get(own) == 0) + if (!unrefineCell.test(own)) { FatalErrorInFunction << "problem" << abort(FatalError); @@ -5474,7 +5404,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement { if (maxSet) { - if (unrefineCell.get(own) == 1) + if (unrefineCell.test(own)) { FatalErrorInFunction << "problem" << abort(FatalError); @@ -5508,13 +5438,13 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement // Knock out any point whose cell neighbour cannot be unrefined. forAll(unrefinePoint, pointi) { - if (unrefinePoint.get(pointi)) + if (unrefinePoint.test(pointi)) { const labelList& pCells = mesh_.pointCells(pointi); forAll(pCells, j) { - if (!unrefineCell.get(pCells[j])) + if (!unrefineCell.test(pCells[j])) { unrefinePoint.unset(pointi); break; @@ -5530,7 +5460,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement forAll(unrefinePoint, pointi) { - if (unrefinePoint.get(pointi)) + if (unrefinePoint.test(pointi)) { nSet++; } @@ -5541,7 +5471,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement forAll(unrefinePoint, pointi) { - if (unrefinePoint.get(pointi)) + if (unrefinePoint.test(pointi)) { newPointsToUnrefine[nSet++] = pointi; } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 7c5ab3a12c13d72d6bcc609e76cc4b9b8c5ddce3..6170cd2fce59dfbe113f24273a539859a6abb968 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -630,7 +630,7 @@ Foam::label Foam::polyTopoChange::getCellOrder forAll(visited, celli) { // find the lowest connected cell that has not been visited yet - if (!cellRemoved(celli) && !visited[celli]) + if (!cellRemoved(celli) && !visited.test(celli)) { if (cellCellAddressing[celli].size() < minWeight) { @@ -662,9 +662,9 @@ Foam::label Foam::polyTopoChange::getCellOrder { currentCell = nextCell.removeHead(); - if (!visited[currentCell]) + if (visited.set(currentCell)) { - visited[currentCell] = 1; + // On first visit... // add into cellOrder newOrder[cellInOrder] = currentCell; @@ -682,7 +682,7 @@ Foam::label Foam::polyTopoChange::getCellOrder forAll(neighbours, nI) { label nbr = neighbours[nI]; - if (!cellRemoved(nbr) && !visited[nbr]) + if (!cellRemoved(nbr) && !visited.test(nbr)) { // not visited, add to the list nbrs.append(nbr); @@ -1690,7 +1690,7 @@ void Foam::polyTopoChange::resetZones const label index = nFaces[zonei]++; addressing[zonei][index] = facei; - flipMode[zonei][index] = faceZoneFlip_[facei]; + flipMode[zonei][index] = faceZoneFlip_.test(facei); } // Sort the addressing @@ -2815,7 +2815,7 @@ Foam::label Foam::polyTopoChange::addFace { faceZone_.insert(facei, zoneID); } - faceZoneFlip_[facei] = (zoneFlip ? 1 : 0); + faceZoneFlip_.set(facei, zoneFlip); return facei; } @@ -2844,8 +2844,8 @@ void Foam::polyTopoChange::modifyFace faceNeighbour_[facei] = nei; region_[facei] = patchID; - flipFaceFlux_[facei] = (flipFaceFlux ? 1 : 0); - faceZoneFlip_[facei] = (zoneFlip ? 1 : 0); + flipFaceFlux_.set(facei, flipFaceFlux); + faceZoneFlip_.set(facei, zoneFlip); if (zoneID >= 0) { @@ -2899,8 +2899,8 @@ void Foam::polyTopoChange::removeFace } faceFromEdge_.erase(facei); faceFromPoint_.erase(facei); - flipFaceFlux_[facei] = 0; - faceZoneFlip_[facei] = 0; + flipFaceFlux_.unset(facei); + faceZoneFlip_.unset(facei); faceZone_.erase(facei); } diff --git a/src/fileFormats/ensight/part/ensightFaces.C b/src/fileFormats/ensight/part/ensightFaces.C index db64d85adbc32e5701c9270eaf2948e950069d29..f6e4b9da3f45af94f5a831b75163e9f1626f3de3 100644 --- a/src/fileFormats/ensight/part/ensightFaces.C +++ b/src/fileFormats/ensight/part/ensightFaces.C @@ -268,7 +268,7 @@ void Foam::ensightFaces::classify { const label faceId = addressing[listi]; - if (!exclude[faceId]) + if (!exclude.test(faceId)) { const enum elemType what = whatType(faces[faceId]); sizes_[what]++; @@ -290,7 +290,7 @@ void Foam::ensightFaces::classify const label faceId = addressing[listi]; const bool doFlip = useFlip && flipMap[listi]; - if (!exclude[faceId]) + if (!exclude.test(faceId)) { add(faces[faceId], faceId, doFlip); } diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C index d5b25603293739717541e2f4463c520dad09af5b..894f41d6d540a51447923c1548aae7061fc3988c 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C @@ -108,12 +108,7 @@ void Foam::functionObjects::wallBoundedStreamLine::track() // These are the faces that need to be followed autoPtr<indirectPrimitivePatch> boundaryPatch(wallPatch()); - PackedBoolList isWallPatch(mesh_.nFaces()); - forAll(boundaryPatch().addressing(), i) - { - isWallPatch[boundaryPatch().addressing()[i]] = 1; - } - + PackedBoolList isWallPatch(mesh_.nFaces(), boundaryPatch().addressing()); // Find nearest wall particle for the seedPoints diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index a187bb47b763488b1633a33a7412103a939af02a..34699b1e44e59eaa4592eac1bccf1673ac1ae4b6 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -121,7 +121,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists() // This cell is in range of the Bb of the other // processor Bb, and so needs to be referred to it - cellInRangeOfCoupledPatch[celli] = true; + cellInRangeOfCoupledPatch.set(celli); cellIAndTToExchange.append ( diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C index 75a24d704d8916f5adbf1bd851f470436b9e18e3..f49931836388d33263f7797ac88936508a8e1497 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectedParticleInjection/InjectedParticleInjection.C @@ -248,7 +248,7 @@ void Foam::InjectedParticleInjection<CloudType>::updateMesh() ) ) { - keep[particlei] = false; + keep.unset(particlei); nRejected++; } } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C index 8a15f16d574d0d5c3363c3604faac07d32edc874..6a2480608d92a2d078b6c3ecedf30f0a9ed965f8 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ManualInjection/ManualInjection.C @@ -132,7 +132,7 @@ void Foam::ManualInjection<CloudType>::updateMesh() ) ) { - keep[pI] = false; + keep.unset(pI); nRejected++; } } diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/fieldSmoother/fieldSmoother.C b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/fieldSmoother/fieldSmoother.C index 363ea443fa12c133e5bf69e12a283af8470b8b96..cdfa8b2464119039194baad83b9e0f52ac601839 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/fieldSmoother/fieldSmoother.C +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/fieldSmoother/fieldSmoother.C @@ -71,7 +71,7 @@ void Foam::fieldSmoother::smoothNormals forAll(fixedPoints, i) { label meshPointI = fixedPoints[i]; - isFixedPoint.set(meshPointI, 1); + isFixedPoint.set(meshPointI); } // Make sure that points that are coupled to meshPoints but not on a patch @@ -125,7 +125,7 @@ void Foam::fieldSmoother::smoothNormals // Transfer to normals vector field forAll(average, pointI) { - if (isFixedPoint.get(pointI) == 0) + if (!isFixedPoint.test(pointI)) { //full smoothing neighbours + point value average[pointI] = 0.5*(normals[pointI]+average[pointI]); @@ -254,7 +254,7 @@ void Foam::fieldSmoother::smoothLambdaMuDisplacement forAll(displacement, i) { - if (isToBeSmoothed[i]) + if (isToBeSmoothed.test(i)) { displacement[i] = (1-lambda)*displacement[i]+lambda*average[i]; } @@ -275,7 +275,7 @@ void Foam::fieldSmoother::smoothLambdaMuDisplacement forAll(displacement, i) { - if (isToBeSmoothed[i]) + if (isToBeSmoothed.test(i)) { displacement[i] = (1-mu)*displacement[i]+mu*average[i]; } diff --git a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C index d018e5703ee4b12d84e172653988934c2ff30212..f617d649d60c3d8f91fc9d529512b80f61660ee9 100644 --- a/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C +++ b/src/mesh/snappyHexMesh/externalDisplacementMeshMover/medialAxisMeshMover.C @@ -1618,8 +1618,10 @@ void Foam::medialAxisMeshMover::calculateDisplacement forAll(displacement, i) { - isToBeSmoothed[i] = - medialRatio_[i] > SMALL && medialRatio_[i] < 1-SMALL; + if (medialRatio_[i] > SMALL && medialRatio_[i] < 1-SMALL) + { + isToBeSmoothed.set(i); + } } fieldSmoother_.smoothLambdaMuDisplacement diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 89f27066c8ce57117ac9cea91d54aa30b052b161..ca7765e8b96a0fa8a317cba0ea9b9c5a013b8128 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -263,9 +263,9 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces) label nMasterFaces = 0; forAll(isMasterFace, facei) { - if (isMasterFace.get(facei) == 1) + if (isMasterFace.test(facei)) { - nMasterFaces++; + ++nMasterFaces; } } reduce(nMasterFaces, sumOp<label>()); @@ -273,9 +273,9 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces) label nChangedFaces = 0; forAll(changedFaces, i) { - if (isMasterFace.get(changedFaces[i]) == 1) + if (isMasterFace.test(changedFaces[i])) { - nChangedFaces++; + ++nChangedFaces; } } reduce(nChangedFaces, sumOp<label>()); @@ -1260,9 +1260,9 @@ Foam::label Foam::meshRefinement::countHits() const forAll(surfaceIndex_, facei) { - if (surfaceIndex_[facei] >= 0 && isMasterFace.get(facei) == 1) + if (surfaceIndex_[facei] >= 0 && isMasterFace.test(facei)) { - nHits++; + ++nHits; } } return nHits; @@ -1562,7 +1562,7 @@ Foam::labelList Foam::meshRefinement::intersectedPoints() const forAll(f, fp) { - if (isBoundaryPoint.set(f[fp], 1u)) + if (isBoundaryPoint.set(f[fp])) { nBoundaryPoints++; } @@ -1588,7 +1588,7 @@ Foam::labelList Foam::meshRefinement::intersectedPoints() const // // forAll(f, fp) // { - // if (isBoundaryPoint.set(f[fp], 1u)) + // if (isBoundaryPoint.set(f[fp])) // nBoundaryPoints++; // } // } @@ -1603,7 +1603,7 @@ Foam::labelList Foam::meshRefinement::intersectedPoints() const nBoundaryPoints = 0; forAll(isBoundaryPoint, pointi) { - if (isBoundaryPoint.get(pointi) == 1u) + if (isBoundaryPoint.test(pointi)) { boundaryPoints[nBoundaryPoints++] = pointi; } @@ -2298,7 +2298,6 @@ void Foam::meshRefinement::findRegions { PackedBoolList insideCell(mesh.nCells()); - // Mark all cells reachable from locationsInMesh labelList insideRegions(locationsInMesh.size()); forAll(insideRegions, i) @@ -2319,7 +2318,7 @@ void Foam::meshRefinement::findRegions { if (cellRegion[celli] == regioni) { - insideCell[celli] = true; + insideCell.set(celli); } } } @@ -2736,7 +2735,7 @@ Foam::PackedBoolList Foam::meshRefinement::getMasterPoints { if (myPoints[pointi] == globalPoints.toGlobal(pointi)) { - isPatchMasterPoint[pointi] = true; + isPatchMasterPoint.set(pointi); } } @@ -2773,7 +2772,7 @@ Foam::PackedBoolList Foam::meshRefinement::getMasterEdges { if (myEdges[edgei] == globalEdges.toGlobal(edgei)) { - isMasterEdge[edgei] = true; + isMasterEdge.set(edgei); } } diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index b0e31ebe7d803182614581af1b7081de4bb142ad..62011f5545204059dfecc872c869788bd3e10f7f 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -2917,7 +2917,7 @@ void Foam::meshRefinement::calcPatchNumMasterFaces { const label meshFaceI = patch.addressing()[faceI]; - if (isMasterFace[meshFaceI]) + if (isMasterFace.test(meshFaceI)) { const labelList& fEdges = patch.faceEdges()[faceI]; forAll(fEdges, fEdgeI) @@ -3124,7 +3124,7 @@ void Foam::meshRefinement::consistentOrientation ( patchI != -1 && bm[patchI].coupled() - && !isMasterFace[meshFaceI] + && !isMasterFace.test(meshFaceI) ) { // Slave side. Mark so doesn't get visited. @@ -3290,7 +3290,7 @@ void Foam::meshRefinement::consistentOrientation ( patchI != -1 && bm[patchI].coupled() - && !isMasterFace[meshFaceI] + && !isMasterFace.test(meshFaceI) ) { // Slave side. Take flipped from neighbour @@ -3326,11 +3326,11 @@ void Foam::meshRefinement::consistentOrientation if (allFaceInfo[faceI] == orientedSurface::NOFLIP) { - meshFlipMap[meshFaceI] = false; + meshFlipMap.unset(meshFaceI); } else if (allFaceInfo[faceI] == orientedSurface::FLIP) { - meshFlipMap[meshFaceI] = true; + meshFlipMap.set(meshFaceI); } else { @@ -3375,7 +3375,7 @@ void Foam::meshRefinement::zonify if (ownZone == neiZone) { // free-standing face. Use geometrically derived orientation - flip = meshFlipMap[faceI]; + flip = meshFlipMap.test(faceI); } else { @@ -3428,7 +3428,7 @@ void Foam::meshRefinement::zonify if (ownZone == neiZone) { // free-standing face. Use geometrically derived orientation - flip = meshFlipMap[faceI]; + flip = meshFlipMap.test(faceI); } else { @@ -4700,13 +4700,13 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify { label meshFaceI = patch.addressing()[faceI]; - if (isMasterFace[meshFaceI]) + if (isMasterFace.test(meshFaceI)) { label n = 1; if ( - bool(posOrientation[meshFaceI]) - == meshFlipMap[meshFaceI] + posOrientation.test(meshFaceI) + == meshFlipMap.test(meshFaceI) ) { n = -1; diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C index 78c39347521e3a03dcbd28f5e2544a7c47108119..cc1351813f84ee791db912033bf549c68fae31c1 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C @@ -820,7 +820,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells else if (nBoundaryAnchors == 7 && nonBoundaryAnchor != -1) { // Mark the cell. Store the (single!) non-boundary anchor point. - hasSevenBoundaryAnchorPoints.set(celli, 1u); + hasSevenBoundaryAnchorPoints.set(celli); nonBoundaryAnchors.insert(nonBoundaryAnchor); } } @@ -843,7 +843,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells forAll(pCells, i) { - if (hasSevenBoundaryAnchorPoints.get(pCells[i]) == 1u) + if (hasSevenBoundaryAnchorPoints.test(pCells[i])) { n++; } @@ -856,7 +856,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells { label celli = pCells[i]; - if (hasSevenBoundaryAnchorPoints.get(celli) == 1u) + if (hasSevenBoundaryAnchorPoints.test(celli)) { if ( diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C index f66627f01edcfb287673998fd27859e2d28fb9c9..b3615d3ddd4196224a2a44d44a7a7a059c2ece19 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C @@ -142,12 +142,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces const label nInternalFaces = mesh.nInternalFaces(); // Mark refined cells on old mesh - PackedBoolList oldRefineCell(map.nOldCells()); - - forAll(oldCellsToRefine, i) - { - oldRefineCell.set(oldCellsToRefine[i], 1u); - } + PackedBoolList oldRefineCell(map.nOldCells(), oldCellsToRefine); // Mark refined faces PackedBoolList refinedInternalFace(nInternalFaces); @@ -161,17 +156,15 @@ Foam::labelList Foam::meshRefinement::getChangedFaces if ( - oldOwn >= 0 - && oldRefineCell.get(oldOwn) == 0u - && oldNei >= 0 - && oldRefineCell.get(oldNei) == 0u + oldOwn >= 0 && !oldRefineCell.test(oldOwn) + && oldNei >= 0 && !oldRefineCell.test(oldNei) ) { // Unaffected face since both neighbours were not refined. } else { - refinedInternalFace.set(faceI, 1u); + refinedInternalFace.set(faceI); } } @@ -190,7 +183,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces { label oldOwn = map.cellMap()[faceOwner[faceI]]; - if (oldOwn >= 0 && oldRefineCell.get(oldOwn) == 0u) + if (oldOwn >= 0 && !oldRefineCell.test(oldOwn)) { // owner did exist and wasn't refined. } @@ -218,7 +211,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces forAll(refinedInternalFace, faceI) { - if (refinedInternalFace.get(faceI) == 1u) + if (refinedInternalFace.test(faceI)) { const cell& ownFaces = cells[faceOwner[faceI]]; forAll(ownFaces, ownI) @@ -405,7 +398,7 @@ void Foam::meshRefinement::markFeatureCellLevel { label e0 = pointEdges[pointi][0]; label regioni = edgeRegion[e0]; - regionVisited[regioni] = 1u; + regionVisited.set(regioni); } } } @@ -415,7 +408,7 @@ void Foam::meshRefinement::markFeatureCellLevel // only be circular regions! forAll(featureMesh.edges(), edgei) { - if (regionVisited.set(edgeRegion[edgei], 1u)) + if (regionVisited.set(edgeRegion[edgei])) { const edge& e = featureMesh.edges()[edgei]; label pointi = e.start(); @@ -458,7 +451,7 @@ void Foam::meshRefinement::markFeatureCellLevel forAll(features_, featI) { featureEdgeVisited[featI].setSize(features_[featI].edges().size()); - featureEdgeVisited[featI] = 0u; + featureEdgeVisited[featI] = false; } // Database to pass into trackedParticle::move @@ -488,7 +481,7 @@ void Foam::meshRefinement::markFeatureCellLevel maxFeatureLevel = -1; forAll(features_, featI) { - featureEdgeVisited[featI] = 0u; + featureEdgeVisited[featI] = false; } @@ -519,7 +512,7 @@ void Foam::meshRefinement::markFeatureCellLevel { label edgeI = pEdges[pEdgeI]; - if (featureEdgeVisited[featI].set(edgeI, 1u)) + if (featureEdgeVisited[featI].set(edgeI)) { // Unvisited edge. Make the particle go to the other point // on the edge. @@ -581,7 +574,7 @@ void Foam::meshRefinement::markFeatureCellLevel { label edgeI = pEdges[i]; - if (featureEdgeVisited[featI].set(edgeI, 1u)) + if (featureEdgeVisited[featI].set(edgeI)) { // Unvisited edge. Make the particle go to the other point // on the edge. diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C index ceaf09f50c4aa8ca18ca67d8fdce7159645525eb..b492ceca1577ba76c01ecc6c63b5f419f0d11e38 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C @@ -75,7 +75,7 @@ T Foam::meshRefinement::gAverage forAll(values, i) { - if (isMasterElem[i]) + if (isMasterElem.test(i)) { sum += values[i]; n++; @@ -304,7 +304,7 @@ void Foam::meshRefinement::weightedSum forAll(edges, edgeI) { - if (isMasterEdge[edgeI]) + if (isMasterEdge.test(edgeI)) { const edge& e = edges[edgeI]; diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 4383716878d39ef561fc8219fbb64f2dfec58bd5..1f052776fe5abaf20d5879d9d607f858c708032e 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -616,10 +616,8 @@ void Foam::snappyLayerDriver::handleNonManifolds PackedBoolList isCoupledEdge(mesh.nEdges()); const labelList& cpEdges = mesh.globalData().coupledPatchMeshEdges(); - forAll(cpEdges, i) - { - isCoupledEdge[cpEdges[i]] = true; - } + isCoupledEdge.setMany(cpEdges); + syncTools::syncEdgeList ( mesh, @@ -4326,8 +4324,8 @@ void Foam::snappyLayerDriver::addLayers forAll(baffles, i) { const labelPair& baffle = baffles[i]; - oldBaffleFace[baffle[0]] = true; - oldBaffleFace[baffle[1]] = true; + oldBaffleFace.set(baffle[0]); + oldBaffleFace.set(baffle[1]); } // Collect candidate if @@ -4668,10 +4666,7 @@ void Foam::snappyLayerDriver::doLayers if (numLayers[mpi] > 0 || numLayers[spi]) { - forAll(fZone, i) - { - isExtrudedZoneFace[fZone[i]] = true; - } + isExtrudedZoneFace.setMany(fZone); } } } diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriverTemplates.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriverTemplates.C index 05b9d1f5ce6c7e3b68014537134828a386f707de..7fd7beba902e648c2870c02b91ce8192b318de99 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriverTemplates.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriverTemplates.C @@ -47,7 +47,7 @@ void Foam::snappyLayerDriver::averageNeighbours forAll(edges, edgeI) { - if (isMasterEdge.get(meshEdges[edgeI]) == 1) + if (isMasterEdge.test(meshEdges[edgeI])) { const edge& e = edges[edgeI]; //scalar eWeight = edgeWeights[edgeI]; diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C index efeef382f62a62e0744287cd7329608f012587c5..dd9c8b6086f52141577a29c5372e689908722a37 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -59,8 +59,8 @@ defineTypeNameAndDebug(snappySnapDriver, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Calculate geometrically collocated points, Requires PackedList to be -// sized and initalised! +// Calculate geometrically collocated points, Requires PackedBoolList to be +// sized and initialised! Foam::label Foam::snappySnapDriver::getCollocatedPoints ( const scalar tol, @@ -101,16 +101,16 @@ Foam::label Foam::snappySnapDriver::getCollocatedPoints else if (firstOldPoint[newPointi] == -2) { // Third or more reference of oldPointi -> non-manifold - isCollocatedPoint.set(oldPointi, 1u); + isCollocatedPoint.set(oldPointi); nCollocated++; } else { // Second reference of oldPointi -> non-manifold - isCollocatedPoint.set(firstOldPoint[newPointi], 1u); + isCollocatedPoint.set(firstOldPoint[newPointi]); nCollocated++; - isCollocatedPoint.set(oldPointi, 1u); + isCollocatedPoint.set(oldPointi); nCollocated++; // Mark with special value to save checking next time round @@ -136,11 +136,7 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement // Get the faces on the boundary - PackedBoolList isFront(mesh.nFaces()); - forAll(pp.addressing(), i) - { - isFront[pp.addressing()[i]] = true; - } + PackedBoolList isFront(mesh.nFaces(), pp.addressing()); // Walk out from the surface a bit. Poor man's FaceCellWave. // Commented out for now - not sure if needed and if so how much @@ -150,23 +146,17 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement // // forAll(isFront, facei) // { - // if (isFront[facei]) + // if (isFront.test(facei)) // { // label own = mesh.faceOwner()[facei]; // const cell& ownFaces = mesh.cells()[own]; - // forAll(ownFaces, i) - // { - // newIsFront[ownFaces[i]] = true; - // } + // newIsFront.setMany(ownFaces); // // if (mesh.isInternalFace(facei)) // { // label nei = mesh.faceNeighbour()[facei]; // const cell& neiFaces = mesh.cells()[nei]; - // forAll(neiFaces, i) - // { - // newIsFront[neiFaces[i]] = true; - // } + // newIsFront.setMany(neiFaces); // } // } // } @@ -196,12 +186,9 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement if (!isFront[facei] && ownLevel != neiLevel) { const face& f = mesh.faces()[facei]; - forAll(f, fp) - { - isMovingPoint[f[fp]] = true; - } + isMovingPoint.setMany(f); - nInterface++; + ++nInterface; } } @@ -216,12 +203,9 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement if (!isFront[facei] && ownLevel != neiLevel) { const face& f = mesh.faces()[facei]; - forAll(f, fp) - { - isMovingPoint[f[fp]] = true; - } + isMovingPoint.setMany(f); - nInterface++; + ++nInterface; } } @@ -241,7 +225,7 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement // face-cell wave we might have coupled points not being unmarked. forAll(pp.meshPoints(), pointi) { - isMovingPoint[pp.meshPoints()[pointi]] = false; + isMovingPoint.unset(pp.meshPoints()[pointi]); } // Make sure that points that are coupled to meshPoints but not on a patch @@ -348,12 +332,12 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothPatchDisplacement label f0 = baffles[i].first(); label f1 = baffles[i].second(); - if (isMasterFace.get(f0)) + if (isMasterFace.test(f0)) { // Make f1 a slave isMasterFace.unset(f1); } - else if (isMasterFace.get(f1)) + else if (isMasterFace.test(f1)) { isMasterFace.unset(f0); } @@ -382,7 +366,7 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothPatchDisplacement { label facei = pFaces[pfi]; - if (isMasterFace.get(pp.addressing()[facei])) + if (isMasterFace.test(pp.addressing()[facei])) { avgBoundary[patchPointi] += pp[facei].centre(points); nBoundary[patchPointi]++; @@ -539,7 +523,7 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothPatchDisplacement point newPos; - if (!nonManifoldPoint.get(i)) + if (!nonManifoldPoint.test(i)) { // Points that are manifold. Weight the internal and boundary // by their number of faces and blend with @@ -2268,7 +2252,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::snappySnapDriver::repatchToSurface { if (preserveFaces[facei] != -1) { - isZonedFace.set(facei, 1); + isZonedFace.set(facei); } } @@ -2281,10 +2265,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::snappySnapDriver::repatchToSurface const label zoneSurfi = zonedSurfaces[i]; const faceZone& fZone = fZones[surfZones[zoneSurfi].faceZoneName()]; - forAll(fZone, i) - { - isZonedFace.set(fZone[i], 1); - } + isZonedFace.setMany(fZone); } } @@ -2345,7 +2326,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::snappySnapDriver::repatchToSurface { label facei = pp.addressing()[i]; - if (hitSurface[i] != -1 && !isZonedFace.get(facei)) + if (hitSurface[i] != -1 && !isZonedFace.test(facei)) { closestPatch[i] = globalToMasterPatch_ [ diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H index 6173b50c8c9c24a05cfcaf60433bb8ce01d388be..fc39ea0963e7826608476ebb84a6a7eb6ef40d13 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.H @@ -74,7 +74,7 @@ class snappySnapDriver // Snapping //- Calculates (geometric) shared points - // Requires PackedList to be sized and initalised + // Requires PackedBoolList to be sized and initialised static label getCollocatedPoints ( const scalar tol, diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index 4179310609a7aa2e773b97beffa5810cf2076966..6440a7c663a40777c0247b54a36b8d3efe123363 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -271,11 +271,7 @@ void Foam::snappySnapDriver::calcNearestFace << exit(FatalError); } const faceZone& fZone = mesh.faceZones()[zonei]; - PackedBoolList isZonedFace(mesh.nFaces()); - forAll(fZone, i) - { - isZonedFace[fZone[i]] = 1; - } + PackedBoolList isZonedFace(mesh.nFaces(), fZone); DynamicList<label> ppFaces(fZone.size()); DynamicList<label> meshFaces(fZone.size()); @@ -575,14 +571,14 @@ void Foam::snappySnapDriver::calcNearestFacePointProperties if (eFaces.size() == 1) { // 'real' boundary edge - isBoundaryPoint[e[0]] = true; - isBoundaryPoint[e[1]] = true; + isBoundaryPoint.set(e[0]); + isBoundaryPoint.set(e[1]); } else if (eFaces.size() == 2 && bafflePair[eFaces[0]] == eFaces[1]) { // 'baffle' boundary edge - isBoundaryPoint[e[0]] = true; - isBoundaryPoint[e[1]] = true; + isBoundaryPoint.set(e[0]); + isBoundaryPoint.set(e[1]); } } @@ -2873,7 +2869,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures if (efn.size() == 2 && (efn[0]&efn[1]) < baffleFeatureCos) { - isBaffleEdge[edgei] = true; + isBaffleEdge.set(edgei); nBaffleEdges++; const edge& e = pp.edges()[edgei]; pointStatus[e[0]] = 0; diff --git a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C index 4bd52700e1a6eda14fc2b5a1d75d40185c4a5d86..9503df67a450e711887cdbebb8bc3fc626815d63 100644 --- a/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C +++ b/src/mesh/snappyHexMesh/trackedParticle/trackedParticle.C @@ -261,7 +261,7 @@ void Foam::trackedParticle::correctAfterParallelTransfer // Mark edge we're currently on (was set on sending processor but not // receiving sender) - td.featureEdgeVisited_[featI].set(edgeI, 1u); + td.featureEdgeVisited_[featI].set(edgeI); } } diff --git a/src/meshTools/algorithms/MeshWave/FaceCellWave.C b/src/meshTools/algorithms/MeshWave/FaceCellWave.C index a4394ae6e7ee3411b6dbfc7e09a2cba8814ce391..716ab9b979d714dddd75067979b6eb72be78be3b 100644 --- a/src/meshTools/algorithms/MeshWave/FaceCellWave.C +++ b/src/meshTools/algorithms/MeshWave/FaceCellWave.C @@ -141,7 +141,7 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateCell { if (!changedCell_[celli]) { - changedCell_[celli] = true; + changedCell_.set(celli); changedCells_.append(celli); } } @@ -188,9 +188,8 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace if (propagate) { - if (!changedFace_[facei]) + if (changedFace_.set(facei)) { - changedFace_[facei] = true; changedFaces_.append(facei); } } @@ -235,9 +234,8 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace if (propagate) { - if (!changedFace_[facei]) + if (changedFace_.set(facei)) { - changedFace_[facei] = true; changedFaces_.append(facei); } } @@ -284,13 +282,13 @@ void Foam::FaceCellWave<Type, TrackingData>::checkCyclic << abort(FatalError); } - if (changedFace_[i1] != changedFace_[i2]) + if (changedFace_.test(i1) != changedFace_.test(i2)) { FatalErrorInFunction << " faceInfo:" << allFaceInfo_[i1] << " otherfaceInfo:" << allFaceInfo_[i2] - << " changedFace:" << changedFace_[i1] - << " otherchangedFace:" << changedFace_[i2] + << " changedFace:" << changedFace_.test(i1) + << " otherchangedFace:" << changedFace_.test(i2) << abort(FatalError); } } @@ -336,7 +334,7 @@ void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo // Mark facei as changed, both on list and on face itself. - changedFace_[facei] = true; + changedFace_.set(facei); changedFaces_.append(facei); } } @@ -397,7 +395,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::getChangedPatchFaces label meshFacei = patch.start() + patchFacei; - if (changedFace_[meshFacei]) + if (changedFace_.test(meshFacei)) { changedPatchFaces[nChangedPatchFaces] = patchFacei; changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFacei]; @@ -829,14 +827,14 @@ void Foam::FaceCellWave<Type, TrackingData>::handleExplicitConnections() const labelPair& baffle = explicitConnections_[connI]; label f0 = baffle[0]; - if (changedFace_[f0]) + if (changedFace_.test(f0)) { f0Baffle.append(connI); f0Info.append(allFaceInfo_[f0]); } label f1 = baffle[1]; - if (changedFace_[f1]) + if (changedFace_.test(f1)) { f1Baffle.append(connI); f1Info.append(allFaceInfo_[f1]); @@ -1092,7 +1090,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell() forAll(changedFaces_, changedFacei) { label facei = changedFaces_[changedFacei]; - if (!changedFace_[facei]) + if (!changedFace_.test(facei)) { FatalErrorInFunction << "Face " << facei @@ -1141,7 +1139,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell() } // Reset status of face - changedFace_[facei] = false; + changedFace_.unset(facei); } // Handled all changed faces by now @@ -1202,7 +1200,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace() } // Reset status of cell - changedCell_[celli] = false; + changedCell_.unset(celli); } // Handled all changed cells by now diff --git a/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.C b/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.C index 2e481be288cfc960e6f47b602cf319b34a50eb6f..367fbfaa57786c33151c453ccc7e7c4cc3aac321 100644 --- a/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.C +++ b/src/meshTools/algorithms/PatchEdgeFaceWave/PatchEdgeFaceWave.C @@ -92,7 +92,7 @@ updateEdge { if (!changedEdge_[edgeI]) { - changedEdge_[edgeI] = true; + changedEdge_.set(edgeI); changedEdges_.append(edgeI); } } @@ -144,9 +144,8 @@ updateFace if (propagate) { - if (!changedFace_[facei]) + if (changedFace_.set(facei)) { - changedFace_[facei] = true; changedFaces_.append(facei); } } @@ -267,8 +266,8 @@ syncEdges() if (!changedEdge_[patchEdgeI]) { + changedEdge_.set(patchEdgeI); changedEdges_.append(patchEdgeI); - changedEdge_[patchEdgeI] = true; } } } @@ -473,7 +472,7 @@ setEdgeInfo if (!changedEdge_[edgeI]) { - changedEdge_[edgeI] = true; + changedEdge_.set(edgeI); changedEdges_.append(edgeI); } } @@ -497,7 +496,7 @@ faceToEdge() { label facei = changedFaces_[changedFacei]; - if (!changedFace_[facei]) + if (!changedFace_.test(facei)) { FatalErrorInFunction << "face " << facei diff --git a/src/meshTools/edgeMesh/edgeMesh.C b/src/meshTools/edgeMesh/edgeMesh.C index 61e9dcd0f64b2d388d31e270d84f4ca1ca3a6e02..de2a294f7d1f854d913e734a3f3f5027553fb403 100644 --- a/src/meshTools/edgeMesh/edgeMesh.C +++ b/src/meshTools/edgeMesh/edgeMesh.C @@ -256,11 +256,11 @@ void Foam::edgeMesh::mergeEdges() edges_[nUniqEdges].sort(); ++nUniqEdges; - if (pointIsUsed.set(e[0], 1)) + if (pointIsUsed.set(e[0])) { ++nUniqPoints; } - if (pointIsUsed.set(e[1], 1)) + if (pointIsUsed.set(e[1])) { ++nUniqPoints; } @@ -294,7 +294,7 @@ void Foam::edgeMesh::mergeEdges() label newId = 0; forAll(pointMap, pointi) { - if (pointIsUsed[pointi]) + if (pointIsUsed.test(pointi)) { pointMap[pointi] = newId; diff --git a/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C b/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C index afdc62b0551964e860882371ec88f3624aefa4a9..650db264fd5128f583674da2eb50c67d934712ec 100644 --- a/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C +++ b/src/meshTools/edgeMesh/edgeMeshFormats/nas/NASedgeFormat.C @@ -197,7 +197,7 @@ bool Foam::fileFormats::NASedgeFormat::read pointField& pts = storedPoints(); forAll(pts, pointi) { - if (usedPoints.get(pointi)) + if (usedPoints.test(pointi)) { if (nUsed != pointi) { diff --git a/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.C b/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.C index 3282ee24d4b5aa3650fc03bbe769065cda63b687..e9a7a09b167a7b72744b3de1160b90102ede0f3f 100644 --- a/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.C +++ b/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.C @@ -195,7 +195,7 @@ bool Foam::fileFormats::STARCDedgeFormat::read pointField& pts = storedPoints(); forAll(pts, pointi) { - if (usedPoints.get(pointi)) + if (usedPoints.test(pointi)) { if (nUsed != pointi) { diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C index 46994e4a547e8f9ed7c5c76e9b20b81902f2c5e2..d2bdc844854e6b1253a46b96957213e5fb525715 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMesh.C @@ -1481,18 +1481,12 @@ void Foam::extendedEdgeMesh::autoMap // Compact region edges labelList subRegionEdges; { - PackedBoolList isRegionEdge(edges().size()); - forAll(regionEdges(), i) - { - label edgeI = regionEdges()[i]; - isRegionEdge[edgeI] = true; - } + PackedBoolList isRegionEdge(edges().size(), regionEdges()); DynamicList<label> newRegionEdges(regionEdges().size()); forAll(edgeMap, subEdgeI) { - label edgeI = edgeMap[subEdgeI]; - if (isRegionEdge[edgeI]) + if (isRegionEdge.test(edgeMap[subEdgeI])) { newRegionEdges.append(subEdgeI); } @@ -1537,25 +1531,19 @@ void Foam::extendedEdgeMesh::autoMap label pointI = pointMap[subPointI]; const labelList& pNormals = featurePointNormals()[pointI]; - forAll(pNormals, i) - { - isSubNormal[pNormals[i]] = true; - } + isSubNormal.setMany(pNormals); } forAll(edgeMap, subEdgeI) { label edgeI = edgeMap[subEdgeI]; const labelList& eNormals = edgeNormals()[edgeI]; - forAll(eNormals, i) - { - isSubNormal[eNormals[i]] = true; - } + isSubNormal.setMany(eNormals); } forAll(isSubNormal, normalI) { - if (isSubNormal[normalI]) + if (isSubNormal.test(normalI)) { label subNormalI = normalMap.size(); reverseNormalMap[normalI] = subNormalI; diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C index c6c76c7f45637b35486e90df257d2d8e0a79f3c2..69dca97cc65de260ad1ec1955369f88db5b03864 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedEdgeMeshTemplates.C @@ -177,7 +177,7 @@ void Foam::extendedEdgeMesh::sortPointsAndEdges edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1); - if (isRegionFeatureEdge[i]) + if (isRegionFeatureEdge.test(i)) { regionEdges.append(i); } diff --git a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C index ad45bfb995eab12ac1ffa93dc6d48fd6098e680c..3edfff99b98ed8f9c3961f2a6281f5f142f031e3 100644 --- a/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C +++ b/src/meshTools/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshTemplates.C @@ -177,7 +177,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1); - if (isRegionFeatureEdge[i]) + if (isRegionFeatureEdge.test(i)) { regionEdges.append(i); } diff --git a/src/meshTools/indexedOctree/treeDataFace.C b/src/meshTools/indexedOctree/treeDataFace.C index 471336fea4583486ff02693de9285b46a8d4e04d..41b709f07339d346fd204c93e6c7f6544f282f87 100644 --- a/src/meshTools/indexedOctree/treeDataFace.C +++ b/src/meshTools/indexedOctree/treeDataFace.C @@ -47,10 +47,7 @@ Foam::treeBoundBox Foam::treeDataFace::calcBb(const label facei) const void Foam::treeDataFace::update() { - forAll(faceLabels_, i) - { - isTreeFace_.set(faceLabels_[i], 1); - } + isTreeFace_.setMany(faceLabels_); if (cacheBb_) { @@ -75,7 +72,7 @@ Foam::treeDataFace::treeDataFace : mesh_(mesh), faceLabels_(faceLabels), - isTreeFace_(mesh.nFaces(), 0), + isTreeFace_(mesh.nFaces(), false), cacheBb_(cacheBb) { update(); @@ -91,7 +88,7 @@ Foam::treeDataFace::treeDataFace : mesh_(mesh), faceLabels_(std::move(faceLabels)), - isTreeFace_(mesh.nFaces(), 0), + isTreeFace_(mesh.nFaces(), false), cacheBb_(cacheBb) { update(); @@ -106,7 +103,7 @@ Foam::treeDataFace::treeDataFace : mesh_(mesh), faceLabels_(identity(mesh_.nFaces())), - isTreeFace_(mesh.nFaces(), 0), + isTreeFace_(mesh.nFaces(), false), cacheBb_(cacheBb) { update(); @@ -124,7 +121,7 @@ Foam::treeDataFace::treeDataFace ( identity(patch.size(), patch.start()) ), - isTreeFace_(mesh_.nFaces(), 0), + isTreeFace_(mesh_.nFaces(), false), cacheBb_(cacheBb) { update(); @@ -255,7 +252,7 @@ Foam::volumeType Foam::treeDataFace::getVolumeType forAll(pFaces, i) { - if (isTreeFace_.get(pFaces[i]) == 1) + if (isTreeFace_.test(pFaces[i])) { vector n = mesh_.faceAreas()[pFaces[i]]; n /= mag(n) + VSMALL; @@ -324,7 +321,7 @@ Foam::volumeType Foam::treeDataFace::getVolumeType forAll(eFaces, i) { - if (isTreeFace_.get(eFaces[i]) == 1) + if (isTreeFace_.test(eFaces[i])) { vector n = mesh_.faceAreas()[eFaces[i]]; n /= mag(n) + VSMALL; diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 0eded7a081b7f4a1b403e5a9417b8f541d183970..c9a62c73cce5646efd709ebf50fc2a66f0b75f9b 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -725,11 +725,7 @@ void Foam::mappedPatchBase::calcMapping() const { label facei = map[i]; - if (used[facei] == 0) - { - used[facei] = 1; - } - else + if (used.test(facei)) { FatalErrorInFunction << "On patch " << patch_.name() @@ -737,11 +733,15 @@ void Foam::mappedPatchBase::calcMapping() const << " is assigned to more than once." << abort(FatalError); } + else + { + used.set(facei); + } } } forAll(used, facei) { - if (used[facei] == 0) + if (!used.test(facei)) { FatalErrorInFunction << "On patch " << patch_.name() diff --git a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C index 5a389bf3211230773ee5bc095836c8d8d31d00eb..e8cbde14c5c5483d1fe185b3891bcc6afbcda571 100644 --- a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C +++ b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C @@ -61,9 +61,10 @@ Foam::scalar Foam::targetVolumeToCell::volumeOfSet ) const { scalar sumVol = 0.0; + forAll(selected, celli) { - if (selected[celli]) + if (selected.test(celli)) { sumVol += mesh_.cellVolumes()[celli]; } @@ -79,7 +80,7 @@ Foam::label Foam::targetVolumeToCell::selectCells PackedBoolList& selected ) const { - selected.setSize(mesh_.nCells()); + selected.resize(mesh_.nCells()); selected = false; label nSelected = 0; @@ -90,7 +91,7 @@ Foam::label Foam::targetVolumeToCell::selectCells if (maskSet[celli] && ((cc&n_) < normalComp)) { - selected[celli] = true; + selected.set(celli); nSelected++; } } @@ -107,7 +108,7 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const } - PackedBoolList maskSet(mesh_.nCells(), 1); + PackedBoolList maskSet(mesh_.nCells(), true); label nTotCells = mesh_.globalData().nTotalCells(); if (maskSetName_.size()) { @@ -115,12 +116,12 @@ void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const Info<< " Operating on subset defined by cellSet " << maskSetName_ << endl; - maskSet = 0; + maskSet = false; cellSet subset(mesh_, maskSetName_); forAllConstIter(cellSet, subset, iter) { - maskSet[iter.key()] = 1; + maskSet.set(iter.key()); } nTotCells = returnReduce(subset.size(), sumOp<label>()); diff --git a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C index d030bc1623da30d8f09b38f64a8a2adb6f23c1c7..8d7db020fee77c04997add1609a110047e1dae71 100644 --- a/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C +++ b/src/overset/cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C @@ -62,7 +62,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront { // Current front PackedBoolList isFront(mesh_.nFaces()); - PackedBoolList doneCell(mesh_.nCells()); + // unused: PackedBoolList doneCell(mesh_.nCells()); const fvBoundaryMesh& fvm = mesh_.boundary(); @@ -77,7 +77,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront forAll(fvm[patchI], i) { - isFront[fvm[patchI].start()+i] = true; + isFront.set(fvm[patchI].start()+i); } } } @@ -100,7 +100,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront { //Pout<< "Front at face:" << faceI // << " at:" << mesh_.faceCentres()[faceI] << endl; - isFront[faceI] = true; + isFront.set(faceI); } } @@ -125,7 +125,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront { //Pout<< "Front at coupled face:" << faceI // << " at:" << mesh_.faceCentres()[faceI] << endl; - isFront[faceI] = true; + isFront.set(faceI); } } } @@ -146,7 +146,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront PackedBoolList newIsFront(mesh_.nFaces()); forAll(isFront, faceI) { - if (isFront[faceI]) + if (isFront.test(faceI)) { label own = mesh_.faceOwner()[faceI]; if (allCellTypes[own] != HOLE) @@ -162,7 +162,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront << " to " << fraction << endl; } allCellTypes[own] = INTERPOLATED; - newIsFront.set(mesh_.cells()[own]); + newIsFront.setMany(mesh_.cells()[own]); } } if (mesh_.isInternalFace(faceI)) @@ -182,7 +182,7 @@ void Foam::cellCellStencils::cellVolumeWeight::walkFront } allCellTypes[nei] = INTERPOLATED; - newIsFront.set(mesh_.cells()[nei]); + newIsFront.setMany(mesh_.cells()[nei]); } } } diff --git a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C index ef5a35724a3f3c9f0a8edd4838224541666a71d0..eac6cc1fef4bf9bdf90f22db9a9f8a03a2dc9735 100644 --- a/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C +++ b/src/overset/cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C @@ -1219,7 +1219,7 @@ void Foam::cellCellStencils::inverseDistance::walkFront // Note that acceptors might have been marked hole if // there are no donors in which case we do not want to // walk this out. This is an extreme situation. - isFront[fvm[patchI].start()+i] = true; + isFront.set(fvm[patchI].start()+i); } } } @@ -1243,7 +1243,7 @@ void Foam::cellCellStencils::inverseDistance::walkFront { //Pout<< "Front at face:" << faceI // << " at:" << mesh_.faceCentres()[faceI] << endl; - isFront[faceI] = true; + isFront.set(faceI); } } @@ -1268,7 +1268,7 @@ void Foam::cellCellStencils::inverseDistance::walkFront { //Pout<< "Front at coupled face:" << faceI // << " at:" << mesh_.faceCentres()[faceI] << endl; - isFront[faceI] = true; + isFront.set(faceI); } } } @@ -1279,7 +1279,7 @@ void Foam::cellCellStencils::inverseDistance::walkFront forAll(isFront, faceI) { - if (isFront[faceI]) + if (isFront.test(faceI)) { fraction[faceI] = 1.0; } @@ -1293,7 +1293,7 @@ void Foam::cellCellStencils::inverseDistance::walkFront scalarField newFraction(fraction); forAll(isFront, faceI) { - if (isFront[faceI]) + if (isFront.test(faceI)) { label own = mesh_.faceOwner()[faceI]; if (allCellTypes[own] != HOLE) @@ -1565,7 +1565,7 @@ void Foam::cellCellStencils::inverseDistance::createStencil ); // Mark cell as being done so it does not get sent over // again. - doneAcceptor[i] = true; + doneAcceptor.set(i); } } } diff --git a/src/renumber/renumberMethods/structuredRenumber/OppositeFaceCellWave.C b/src/renumber/renumberMethods/structuredRenumber/OppositeFaceCellWave.C index 33d7810da8cc501ed1c3e697ce8b3242c1108dfc..c1f476bea4c65581b96c200b9f17efbf46a406fb 100644 --- a/src/renumber/renumberMethods/structuredRenumber/OppositeFaceCellWave.C +++ b/src/renumber/renumberMethods/structuredRenumber/OppositeFaceCellWave.C @@ -148,7 +148,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell() { label facei = this->changedFaces_[changedFacei]; - if (!this->changedFace_[facei]) + if (!this->changedFace_.test(facei)) { FatalErrorInFunction << "Face " << facei @@ -231,7 +231,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::faceToCell() } // Reset status of face - this->changedFace_[facei] = false; + this->changedFace_.unset(facei); } // Handled all changed faces by now @@ -260,7 +260,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::cellToFace() label celli = this->changedCells_[changedCelli]; label facei = changedOppositeFaces_[changedCelli]; - if (!this->changedCell_[celli]) + if (!this->changedCell_.test(celli)) { FatalErrorInFunction << "Cell " << celli << " not marked as having been changed" @@ -289,7 +289,7 @@ Foam::label Foam::OppositeFaceCellWave<Type, TrackingData>::cellToFace() } // Reset status of cell - this->changedCell_[celli] = false; + this->changedCell_.unset(celli); } // Handled all changed cells by now diff --git a/src/sampling/surface/isoSurface/isoSurface.C b/src/sampling/surface/isoSurface/isoSurface.C index 136889368c58dc8212d46598bdd38cd938819044..6dc28a6ad9d72c84f6d90af6c6ce62d65a4ca730 100644 --- a/src/sampling/surface/isoSurface/isoSurface.C +++ b/src/sampling/surface/isoSurface/isoSurface.C @@ -94,7 +94,7 @@ Foam::PackedBoolList Foam::isoSurface::collocatedFaces { forAll(pp, i) { - collocated[i] = 1u; + collocated.set(i); } } } @@ -104,7 +104,7 @@ Foam::PackedBoolList Foam::isoSurface::collocatedFaces { forAll(pp, i) { - collocated[i] = 1u; + collocated.set(i); } } } @@ -691,7 +691,7 @@ void Foam::isoSurface::calcSnappedPoint forAll(mesh_.pointFaces(), pointi) { - if (isBoundaryPoint.get(pointi) == 1) + if (isBoundaryPoint.test(pointi)) { continue; } @@ -1527,10 +1527,7 @@ Foam::isoSurface::isoSurface { const face& f = mesh_.faces()[cpp.start()+i]; - forAll(f, fp) - { - isBoundaryPoint.set(f[fp], 1); - } + isBoundaryPoint.setMany(f); } } } @@ -1542,10 +1539,7 @@ Foam::isoSurface::isoSurface { const face& f = mesh_.faces()[pp.start()+i]; - forAll(f, fp) - { - isBoundaryPoint.set(f[fp], 1); - } + isBoundaryPoint.setMany(f); } } } diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C index 7e1ca5e4e538dfc1d6be6116a1d1bee0c0be34b3..7a750e9e04b6fa927fa4924e5d54dc5d9717aa12 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C @@ -89,7 +89,7 @@ Foam::isoSurfaceCell::cellCutType Foam::isoSurfaceCell::calcCutType { const cell& cFaces = mesh_.cells()[celli]; - if (isTet.get(celli) == 1) + if (isTet.test(celli)) { forAll(cFaces, cFacei) { @@ -381,7 +381,7 @@ void Foam::isoSurfaceCell::calcSnappedCc forAll(mesh_.cells(), celli) { - if (cellCutType_[celli] == CUT && isTet.get(celli) == 0) + if (cellCutType_[celli] == CUT && !isTet.test(celli)) { scalar cVal = cVals[celli]; @@ -771,7 +771,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint label facei = pFaces[pFacei]; label own = mesh_.faceOwner()[facei]; - if (isTet.get(own) == 1) + if (isTet.test(own)) { // Since tets have no cell centre to include make sure // we only generate a triangle once per point. @@ -797,7 +797,7 @@ void Foam::isoSurfaceCell::calcSnappedPoint { label nei = mesh_.faceNeighbour()[facei]; - if (isTet.get(nei) == 1) + if (isTet.test(nei)) { if (localPointCells.insert(nei)) { @@ -1327,7 +1327,7 @@ Foam::isoSurfaceCell::isoSurfaceCell { if (tet.isA(mesh_, celli)) { - isTet.set(celli, 1); + isTet.set(celli); } } } diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C index a2411f21831d29fbe1f2c46881539012a1d09193..fdac5fa958c22d175c04c40470a9e08897f01c87 100644 --- a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.C @@ -97,14 +97,14 @@ bool Foam::rawTopoChangerFvMesh::update() { if (faceMap[facei] >= 0) { - mappedFace[facei] = 1; + mappedFace.set(facei); } } for (label facei = nInternalFaces(); facei < nFaces(); facei++) { if (faceMap[facei] >= 0 && faceMap[facei] >= nOldInternal) { - mappedFace[facei] = 1; + mappedFace.set(facei); } } @@ -112,21 +112,21 @@ bool Foam::rawTopoChangerFvMesh::update() forAll(fromFaces, i) { - mappedFace[fromFaces[i].index()] = 1; + mappedFace.set(fromFaces[i].index()); } const List<objectMap>& fromEdges = topoChangeMap().facesFromEdgesMap(); forAll(fromEdges, i) { - mappedFace[fromEdges[i].index()] = 1; + mappedFace.set(fromEdges[i].index()); } const List<objectMap>& fromPts = topoChangeMap().facesFromPointsMap(); forAll(fromPts, i) { - mappedFace[fromPts[i].index()] = 1; + mappedFace.set(fromPts[i].index()); } // Set unmapped faces to zero diff --git a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H index 250b70d0b4295f4fde3ad07d5dc0be57b74620b1..7364a4882a53d326e3c3fe5827202defc96640f0 100644 --- a/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H +++ b/src/topoChangerFvMesh/rawTopoChangerFvMesh/rawTopoChangerFvMesh.H @@ -68,7 +68,7 @@ class rawTopoChangerFvMesh ); template<class Type, template<class> class PatchField, class GeoMesh> - void zeroUnmappedValues(const PackedBoolList&) const; + void zeroUnmappedValues(const PackedBoolList& mappedFace) const; //- Disallow default bitwise copy construct rawTopoChangerFvMesh(const rawTopoChangerFvMesh&);