From 10941280cb4dd3743b04ddd8fc8304fbddac2d45 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 7 Jun 2018 14:43:10 +0200 Subject: [PATCH] BUG: incorrect bitSet auto-vivify in snappy - should use bitSet::set() and not bitSet::operator[] to auto-vivify out-of-range entries - use bitSet::test() instead of bitSet::operator[] when testing non-const variables - circumvents any potential out-of-range issues. --- .../meshRefinement/meshRefinement.C | 8 ++++---- .../meshRefinement/meshRefinementBaffles.C | 6 +++--- .../meshRefinementProblemCells.C | 4 ++-- .../meshRefinement/meshRefinementRefine.C | 2 +- .../snappyHexMeshDriver/snappyLayerDriver.C | 6 +++--- .../snappyHexMeshDriver/snappySnapDriver.C | 6 +++--- .../snappySnapDriverFeature.C | 18 +++++++++--------- .../trackedParticle/trackedParticle.H | 7 +++---- 8 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C index 2bf1272938..cb31a5c878 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C @@ -2754,9 +2754,9 @@ const label nMasterFaces = 0; forAll(isMasterFace, i) { - if (isMasterFace[i]) + if (isMasterFace.test(i)) { - nMasterFaces++; + ++nMasterFaces; } } @@ -2764,9 +2764,9 @@ const label nMasterPoints = 0; forAll(isMeshMasterPoint, i) { - if (isMeshMasterPoint[i]) + if (isMeshMasterPoint.test(i)) { - nMasterPoints++; + ++nMasterPoints; } } diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C index 34ae55b76e..03279701c4 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C @@ -2333,20 +2333,20 @@ void Foam::meshRefinement::getIntersections ) { namedSurfaceIndex[faceI] = surface2[i]; - posOrientation[faceI] = ((area&normal2[i]) > 0); + posOrientation.set(faceI, ((area&normal2[i]) > 0)); nSurfFaces[surface2[i]]++; } else { namedSurfaceIndex[faceI] = surface1[i]; - posOrientation[faceI] = ((area&normal1[i]) > 0); + posOrientation.set(faceI, ((area&normal1[i]) > 0)); nSurfFaces[surface1[i]]++; } } else if (surface2[i] != -1) { namedSurfaceIndex[faceI] = surface2[i]; - posOrientation[faceI] = ((area&normal2[i]) > 0); + posOrientation.set(faceI, ((area&normal2[i]) > 0)); nSurfFaces[surface2[i]]++; } } diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C index 9a6fe089df..714aad7bc9 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C @@ -1025,9 +1025,9 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells else { facePatch[facei] = nearestAdaptPatch[facei]; - if (isMasterFace[facei]) + if (isMasterFace.test(facei)) { - nBaffleFaces++; + ++nBaffleFaces; } // Do NOT update boundary data since this would grow diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C index 9954987315..7643ab1822 100644 --- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C @@ -261,7 +261,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces forAll(changedFace, faceI) { - if (changedFace[faceI] && isMasterFace[faceI]) + if (changedFace[faceI] && isMasterFace.test(faceI)) { nMasterChanged++; } diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C index 9894260265..e109e96d30 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C @@ -634,7 +634,7 @@ void Foam::snappyLayerDriver::handleNonManifolds ( pp.edgeFaces()[edgei].size() == 1 && edgeGlobalFaces[edgei].size() == 1 - && isCoupledEdge[meshEdgei] + && isCoupledEdge.test(meshEdgei) ) { // Edge of patch but no continuation across processor. @@ -4336,7 +4336,7 @@ void Foam::snappyLayerDriver::addLayers ) { label oldFacei = map.faceMap()[facei]; - if (oldFacei != -1 && oldBaffleFace[oldFacei]) + if (oldFacei != -1 && oldBaffleFace.test(oldFacei)) { const face& f = mesh.faces()[facei]; forAll(f, fp) @@ -4680,7 +4680,7 @@ void Foam::snappyLayerDriver::doLayers facei++ ) { - if (intOrCoupled[facei] && isExtrudedZoneFace[facei]) + if (intOrCoupled[facei] && isExtrudedZoneFace.test(facei)) { faceZoneOnCoupledFace = true; break; diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C index c7a165672a..e25b4185fa 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriver.C @@ -183,7 +183,7 @@ Foam::tmp Foam::snappySnapDriver::smoothInternalDisplacement label ownLevel = cellLevel[mesh.faceOwner()[facei]]; label neiLevel = cellLevel[mesh.faceNeighbour()[facei]]; - if (!isFront[facei] && ownLevel != neiLevel) + if (!isFront.test(facei) && ownLevel != neiLevel) { const face& f = mesh.faces()[facei]; isMovingPoint.set(f); @@ -200,7 +200,7 @@ Foam::tmp Foam::snappySnapDriver::smoothInternalDisplacement label ownLevel = cellLevel[mesh.faceOwner()[facei]]; label neiLevel = neiCellLevel[facei-mesh.nInternalFaces()]; - if (!isFront[facei] && ownLevel != neiLevel) + if (!isFront.test(facei) && ownLevel != neiLevel) { const face& f = mesh.faces()[facei]; isMovingPoint.set(f); @@ -239,7 +239,7 @@ Foam::tmp Foam::snappySnapDriver::smoothInternalDisplacement forAll(isMovingPoint, pointi) { - if (isMovingPoint[pointi]) + if (isMovingPoint.test(pointi)) { const labelList& pCells = mesh.pointCells(pointi); diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C index b4c2dc996a..e7f391fdc4 100644 --- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C +++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappySnapDriverFeature.C @@ -271,7 +271,7 @@ void Foam::snappySnapDriver::calcNearestFace << exit(FatalError); } const faceZone& fZone = mesh.faceZones()[zonei]; - bitSet isZonedFace(mesh.nFaces(), fZone); + const bitSet isZonedFace(mesh.nFaces(), fZone); DynamicList