From cdbc3e2de632fac9e4dd76baef043bce57e3cad2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 6 Apr 2021 12:29:26 +0200 Subject: [PATCH] ENH: List/DynamicList appendUniq() method - affords some code reduction. STYLE: use HashSet insert() without found() check in more places --- .../Test-checkDecomposePar.C | 5 +- .../conformalVoronoiMeshCalcDualMesh.C | 11 +-- .../conformalVoronoiMeshConformToSurface.C | 14 +-- .../conformalVoronoiMeshI.H | 12 +-- .../foamyQuadMesh/shortEdgeFilter2D.C | 28 +----- .../foamyQuadMesh/shortEdgeFilter2D.H | 8 +- .../manipulation/polyDualMesh/meshDualiser.C | 6 +- .../MSwindows/fileMonitor/fileMonitor.C | 6 +- .../POSIX/fileMonitor/fileMonitor.C | 6 +- .../Lists/DynamicList/DynamicList.H | 4 + .../Lists/DynamicList/DynamicListI.H | 15 ++++ src/OpenFOAM/containers/Lists/List/List.H | 4 + src/OpenFOAM/containers/Lists/List/ListI.H | 15 ++++ .../polyPatches/derived/wall/wallPolyPatch.C | 11 +-- .../polyPatches/polyPatch/polyPatch.C | 20 ++--- .../primitiveMesh/primitiveMeshCellEdges.C | 19 ++-- src/Pstream/mpi/UPstream.C | 7 +- .../interfaceTrackingFvMesh.C | 17 +--- .../meshCut/cellLooper/geomCellLooper.C | 23 +++-- src/dynamicMesh/polyMeshAdder/polyMeshAdder.C | 28 ++---- .../polyTopoChange/combineFaces.C | 5 +- .../polyTopoChange/hexRef8/hexRef8.C | 7 +- .../enrichedPatch/enrichedPatchPointPoints.C | 14 +-- .../faMesh/faMeshDemandDrivenData.C | 88 +++++-------------- .../CFCFaceToCellStencil.C | 33 +++---- .../snappyHexMeshDriver/snappyLayerDriver.C | 7 +- src/meshTools/cellDist/cellDistFuncs.C | 10 +-- src/meshTools/cellFeatures/cellFeatures.C | 10 +-- .../mappedPolyPatch/mappedPolyPatch.C | 11 +-- .../mappedPolyPatch/mappedWallPolyPatch.C | 11 +-- src/meshTools/regionSplit/localPointRegion.C | 8 +- .../oversetPolyPatch/oversetPolyPatch.C | 12 +-- .../calcMethod/mapNearest/mapNearestMethod.C | 12 +-- .../meshToMeshMethod/meshToMeshMethod.C | 10 +-- .../chemkinReader/chemkinLexer.L | 5 +- .../foamChemistryReader/foamChemistryReader.C | 5 +- 36 files changed, 166 insertions(+), 341 deletions(-) diff --git a/applications/test/checkDecomposePar/Test-checkDecomposePar.C b/applications/test/checkDecomposePar/Test-checkDecomposePar.C index d664615503..805b57b9ec 100644 --- a/applications/test/checkDecomposePar/Test-checkDecomposePar.C +++ b/applications/test/checkDecomposePar/Test-checkDecomposePar.C @@ -100,10 +100,7 @@ int main(int argc, char *argv[]) const wordList& regions = iter(); forAll(regions, i) { - if (!regionNames.found(regions[i])) - { - regionNames.append(regions[i]); - } + regionNames.appendUniq(regions[i]); } } regionDirs = regionNames; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 4a548c89ef..14a2f32fd5 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -894,15 +894,8 @@ void Foam::conformalVoronoiMesh::checkCellSizing() const label faceOwner = pMesh.faceOwner()[facei]; const label faceNeighbour = pMesh.faceNeighbour()[facei]; - if (!cellsToResizeMap.found(faceOwner)) - { - cellsToResizeMap.insert(faceOwner); - } - - if (!cellsToResizeMap.found(faceNeighbour)) - { - cellsToResizeMap.insert(faceNeighbour); - } + cellsToResizeMap.insert(faceOwner); + cellsToResizeMap.insert(faceNeighbour); } cellsToResizeMap += protrudingCells; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 4affaa5758..fa734f5a18 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -727,11 +727,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseSurfaceTrees if (nearest.hit() || nearestEdge.hit()) { nStoppedInsertion++; - - if (!hits[proci].found(peI)) - { - hits[proci].insert(peI); - } + hits[proci].insert(peI); } } } @@ -822,11 +818,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees // << endl; nStoppedInsertion++; - - if (!hits[proci].found(peI)) - { - hits[proci].insert(peI); - } + hits[proci].insert(peI); } } } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index caac10dbc8..9d71ce889c 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -467,15 +468,8 @@ inline Foam::List Foam::conformalVoronoiMesh::processorsAttached forAll(c1Procs, aPI) { - if (!procsAttached.found(c1Procs[aPI])) - { - procsAttached.append(c1Procs[aPI]); - } - - if (!procsAttached.found(c2Procs[aPI])) - { - procsAttached.append(c2Procs[aPI]); - } + procsAttached.appendUniq(c1Procs[aPI]); + procsAttached.appendUniq(c2Procs[aPI]); } return List