From 4fe8ed8245c9f33270d774c0d427851709007a63 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 6 Mar 2018 00:29:03 +0100 Subject: [PATCH] STYLE: use direct iteration for HashSet - The iterator for a HashSet dereferences directly to its key. - Eg, for (const label patchi : patchSet) { ... } vs. forAllConstIter(labelHashSet, patchSet, iter) { const label patchi = iter.key(); ... } --- .../VoFPatchTransfer/VoFPatchTransfer.C | 5 +- .../utilities/mesh/advanced/PDRMesh/PDRMesh.C | 16 ++-- .../combinePatchFaces/combinePatchFaces.C | 36 ++++---- .../snappyRefineMesh/snappyRefineMesh.C | 18 ++-- .../conversion/writeMeshObj/writeMeshObj.C | 6 +- .../conformalVoronoiMeshCalcDualMesh.C | 20 ++--- .../generation/snappyHexMesh/snappyHexMesh.C | 10 +-- .../createBaffles/createBaffles.C | 6 +- .../manipulation/createPatch/createPatch.C | 6 +- .../manipulation/renumberMesh/renumberMesh.C | 5 +- .../mesh/manipulation/splitMesh/regionSide.C | 17 ++-- .../viewFactorsGen/viewFactorsGen.C | 8 +- .../surfaceMeshTriangulate.C | 19 ++-- src/OpenFOAM/fields/ReadFields/ReadFields.C | 4 +- .../fields/ReadFields/ReadFieldsTemplates.C | 4 +- .../fileOperation/fileOperation.C | 9 +- .../masterUncollatedFileOperation.C | 9 +- .../primitiveMesh/primitiveMeshCellPoints.C | 46 +++++----- .../meshes/primitiveMesh/primitiveMeshEdges.C | 88 +++++++++---------- .../globalIndexAndTransformI.H | 6 +- src/conversion/fire/checkFireEdges.C | 9 +- .../dynamicRefineFvMesh/dynamicRefineFvMesh.C | 6 +- .../fvMeshDistribute/fvMeshDistribute.C | 10 +-- .../layerAdditionRemoval/removeCellLayer.C | 6 +- .../meshCut/edgeVertex/edgeVertex.C | 13 ++- .../motionSmoother/motionSmootherAlgo.C | 26 +++--- .../perfectInterface/perfectInterface.C | 5 +- .../pointPatchDist/pointPatchDist.C | 8 +- .../polyTopoChange/combineFaces.C | 6 +- .../polyTopoChange/faceCollapser.C | 6 +- .../polyTopoChange/removeFaces.C | 26 +++--- .../polyTopoChange/removePoints.C | 6 +- .../cfdTools/general/MRF/MRFZone.C | 6 +- .../globalIndexStencils/cellToCellStencil.C | 30 +++---- .../extendedUpwindCellToFaceStencil.C | 14 +-- .../FECCellToFaceStencil.C | 24 +++-- .../globalIndexStencils/cellToFaceStencil.C | 36 ++++---- .../advectionDiffusionPatchDistMethod.C | 5 +- .../patchDistMethodTemplates.C | 6 +- .../fvMesh/wallDist/wallDist/wallDist.C | 5 +- .../field/nearWallFields/nearWallFields.C | 8 +- .../nearWallFields/nearWallFieldsTemplates.C | 6 +- .../regionSizeDistribution.C | 19 ++-- .../surfaceInterpolateTemplates.C | 6 +- .../field/wallHeatFlux/wallHeatFlux.C | 8 +- .../field/wallShearStress/wallShearStress.C | 12 +-- src/functionObjects/forces/forces/forces.C | 19 ++-- .../utilities/ensightWrite/ensightWrite.C | 4 +- .../MGridGenGAMGAgglomeration.C | 5 +- .../inverseFaceDistanceDiffusivity.C | 16 ++-- .../inversePointDistanceDiffusivity.C | 16 ++-- .../meshRefinement/meshRefinement.C | 16 ++-- .../meshRefinement/meshRefinementMerge.C | 48 +++++----- .../meshRefinementProblemCells.C | 46 ++++------ .../layerParameters/layerParameters.C | 6 +- .../snappyHexMeshDriver/snappyRefineDriver.C | 8 +- .../faceAreaWeightAMI/faceAreaWeightAMI.C | 7 +- .../PatchEdgeFaceWave/patchPatchDist.C | 10 +-- .../cellClassification/cellClassification.C | 13 ++- .../faceSources/patchToFace/patchToFace.C | 6 +- src/meshTools/sets/topoSets/topoSet.C | 65 +++++++------- src/meshTools/surfaceSets/surfaceSets.C | 29 +++--- .../triSurfaceTools/triSurfaceTools.C | 24 ++--- .../contactAngleForce/contactAngleForce.C | 5 +- .../injectionModelList/injectionModelList.C | 4 +- .../patchInjection/patchInjection.C | 5 +- .../structuredRenumber/structuredRenumber.C | 10 +-- .../rigidBodyMeshMotionSolver.C | 4 +- src/sampling/meshToMesh/meshToMesh.C | 6 +- .../sampledSet/patchCloud/patchCloudSet.C | 10 +-- .../sampledSet/patchSeed/patchSeedSet.C | 10 +-- .../solarLoad/faceShading/faceShading.C | 21 ++--- .../radiationModels/solarLoad/solarLoad.C | 14 ++- 73 files changed, 475 insertions(+), 602 deletions(-) diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C index b3a646e93b..c6be4477da 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFPatchTransfer/VoFPatchTransfer.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -85,9 +85,8 @@ VoFPatchTransfer::VoFPatchTransfer Info<< " applying to patches:" << nl; label pidi = 0; - forAllConstIter(labelHashSet, patchSet, iter) + for (const label patchi : patchSet) { - const label patchi = iter.key(); patchIDs_[pidi++] = patchi; Info<< " " << pbm[patchi].name() << endl; } diff --git a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C index 58b2e3468e..62d6a8cc4c 100644 --- a/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.C +++ b/applications/utilities/mesh/advanced/PDRMesh/PDRMesh.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) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -339,16 +339,17 @@ void subsetTopoSets // Map the data bitSet isSet(set.maxSize(mesh)); - forAllConstIter(labelHashSet, set, iter) + for (const label id : set) { - isSet.set(iter.key()); + isSet.set(id); } + label nSet = 0; - forAll(map, i) + for (const label id : map) { - if (isSet[map[i]]) + if (isSet.test(id)) { - nSet++; + ++nSet; } } @@ -358,9 +359,10 @@ void subsetTopoSets new TopoSet(subMesh, set.name(), nSet, IOobject::AUTO_WRITE) ); TopoSet& subSet = subSets[i]; + forAll(map, i) { - if (isSet[map[i]]) + if (isSet.test(map[i])) { subSet.insert(i); } diff --git a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C index 3423d69865..20db80ffa0 100644 --- a/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C +++ b/applications/utilities/mesh/advanced/combinePatchFaces/combinePatchFaces.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -92,12 +92,12 @@ label mergePatchFaces { // Store the faces of the face sets List allFaceSetsFaces(allFaceSets.size()); - forAll(allFaceSets, setI) + forAll(allFaceSets, seti) { - allFaceSetsFaces[setI] = UIndirectList + allFaceSetsFaces[seti] = UIndirectList ( mesh.faces(), - allFaceSets[setI] + allFaceSets[seti] ); } @@ -146,13 +146,13 @@ label mergePatchFaces // Sets where the master is in error labelHashSet errorSets; - forAll(allFaceSets, setI) + forAll(allFaceSets, seti) { - label newMasterI = map().reverseFaceMap()[allFaceSets[setI][0]]; + label newMasterI = map().reverseFaceMap()[allFaceSets[seti][0]]; if (errorFaces.found(newMasterI)) { - errorSets.insert(setI); + errorSets.insert(seti); } } label nErrorSets = returnReduce(errorSets.size(), sumOp