From d597b3f959de444a5fdb8eef28ba7ec2492bd1e0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Feb 2023 15:52:55 +0100 Subject: [PATCH] STYLE: check iterator validity with good() instead of found() - aligns better with other container checks --- .../multiphaseMixtureThermo.C | 4 +- .../multiphaseMixture/multiphaseMixture.C | 4 +- applications/test/Map/Test-Map.C | 4 +- applications/test/syncTools/Test-syncTools.C | 4 +- .../mesh/advanced/modifyMesh/cellSplitter.C | 4 +- .../fluent3DMeshToFoam/fluent3DMeshToFoam.L | 2 +- .../mesh/conversion/gmshToFoam/gmshToFoam.C | 10 ++-- .../netgenNeutralToFoam/netgenNeutralToFoam.C | 2 +- .../conversion/tetgenToFoam/tetgenToFoam.C | 2 +- .../conversion/writeMeshObj/writeMeshObj.C | 4 +- .../DelaunayMesh/DistributedDelaunayMesh.C | 2 +- .../conformalVoronoiMeshConformToSurface.C | 2 +- .../featurePointConformer.C | 2 +- .../pointPairs/pointPairs.C | 4 +- .../splitMeshRegions/splitMeshRegions.C | 8 ++-- .../foamDictionary/foamDictionary.C | 6 +-- .../decomposePar/domainDecompositionMesh.C | 2 +- .../redistributePar/redistributePar.C | 2 +- .../particleTracks/particleTracks.C | 2 +- .../steadyParticleTracks.C | 4 +- .../changeDictionary/changeDictionary.C | 2 +- src/OSspecific/MSwindows/MSwindows.C | 4 +- src/OSspecific/MSwindows/fileStat/fileStat.H | 10 +++- src/OSspecific/MSwindows/memInfo/memInfo.C | 6 +-- src/OSspecific/MSwindows/memInfo/memInfo.H | 41 +++++++---------- src/OSspecific/POSIX/POSIX.C | 4 +- src/OSspecific/POSIX/fileStat/fileStat.H | 10 +++- src/OSspecific/POSIX/memInfo/memInfo.C | 4 +- src/OSspecific/POSIX/memInfo/memInfo.H | 40 +++++++--------- .../DictionaryBase/DictionaryBase.C | 18 ++++---- .../Lists/ListOps/ListOpsTemplates.C | 4 +- .../dynamicLibrary/dynamicCode/dynamicCode.C | 2 +- .../functionObject/functionObject.C | 2 +- .../functionObjectList/functionObjectList.C | 2 +- .../db/objectRegistry/objectRegistry.C | 6 +-- .../objectRegistry/objectRegistryTemplates.C | 4 +- .../construction/runTimeSelectionTables.H | 6 +-- .../exprDriver/exprDriverFunctions.C | 2 +- .../exprDriver/exprDriverTemplates.C | 2 +- .../exprResult/exprResultGlobals.C | 8 ++-- src/OpenFOAM/global/argList/argList.C | 10 ++-- .../fileOperation/fileOperation.C | 2 +- .../masterUncollatedFileOperation.C | 6 +-- .../GAMGAgglomerateLduAddressing.C | 2 +- .../cyclicGAMGInterface/cyclicGAMGInterface.C | 2 +- .../processorGAMGInterface.C | 2 +- .../Identifiers/patch/coupleGroupIdentifier.C | 2 +- .../meshes/lduMesh/lduPrimitiveMesh.C | 2 +- .../meshShapes/cellMatcher/cellMatcher.C | 2 +- .../meshes/meshShapes/face/oppositeFace.H | 5 +- .../polyMesh/globalMeshData/globalMeshData.C | 18 ++++---- .../polyMesh/globalMeshData/globalPoints.C | 8 ++-- .../polyBoundaryMesh/polyBoundaryMesh.C | 6 +-- .../constraint/cyclic/cyclicPolyPatch.C | 6 +-- .../polyMesh/syncTools/syncToolsTemplates.C | 46 +++++++++---------- .../meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C | 2 +- .../PatchTools/PatchToolsMatch.C | 4 +- .../PatchTools/PatchToolsNormals.C | 4 +- src/OpenFOAM/primitives/enums/NamedEnum.C | 6 +-- .../primitives/strings/stringOps/stringOps.C | 4 +- src/Pstream/mpi/UPstreamWrappingTemplates.C | 2 +- .../LES/LESdeltas/LESdelta/LESdelta.C | 2 +- .../combustionModelTemplates.C | 4 +- src/conversion/ccm/reader/ccmReaderAux.C | 2 +- src/conversion/ccm/reader/ccmReaderMesh.C | 6 +-- src/conversion/common/reader/meshReaderAux.C | 2 +- src/conversion/common/tables/cellTable.C | 8 ++-- src/conversion/starcd/STARCDMeshReader.C | 2 +- .../attachDetach/attachInterface.C | 2 +- .../createShellMesh/createShellMesh.C | 2 +- .../fvMeshDistribute/fvMeshDistribute.C | 6 +-- .../layerAdditionRemoval/removeCellLayer.C | 2 +- .../layerAdditionRemoval/setLayerPairing.C | 2 +- src/dynamicMesh/meshCut/cellCuts/cellCuts.C | 4 +- .../boundaryCutter/boundaryCutter.C | 6 +-- .../meshCutAndRemove/meshCutAndRemove.C | 4 +- .../meshModifiers/meshCutter/meshCutter.C | 4 +- .../multiDirRefinement/multiDirRefinement.C | 4 +- .../undoableMeshCutter/undoableMeshCutter.C | 4 +- .../displacementLayeredMotionMotionSolver.C | 2 +- .../polyMeshAdder/faceCoupleInfo.C | 2 +- src/dynamicMesh/polyMeshAdder/polyMeshAdder.C | 14 +++--- .../polyTopoChange/addPatchCellLayer.C | 2 +- .../polyTopoChange/combineFaces.C | 6 +-- .../polyTopoChange/hexRef8/hexRef8.C | 10 ++-- .../enrichedPatch/enrichedPatchCutFaces.C | 6 +-- .../slidingInterface/slidingInterface.C | 4 +- src/fileFormats/abaqus/ABAQUSCore.C | 2 +- src/fileFormats/stl/STLAsciiParseI.H | 2 +- src/fileFormats/stl/STLReader.C | 2 +- .../vtk/file/foamVtkSeriesWriter.C | 4 +- .../faMesh/faBoundaryMesh/faBoundaryMesh.C | 2 +- .../fvMeshSubset/fvMeshSubsetTemplates.C | 2 +- .../singleCellFvMesh/singleCellFvMesh.C | 2 +- .../volPointInterpolation/pointConstraints.C | 6 +-- .../binField/binModels/binModel/binModelNew.C | 2 +- .../field/externalCoupled/externalCoupled.C | 2 +- .../utilities/runTimeControl/runTimeControl.C | 2 +- .../semiImplicitSource/SemiImplicitSource.C | 8 ++-- .../genericPatchFieldBase.C | 10 ++-- .../blockMesh/blockMesh/blockMeshCreate.C | 2 +- .../meshRefinement/meshRefinement.C | 2 +- .../meshRefinement/meshRefinementBlock.C | 8 ++-- .../snappyHexMeshDriver/snappyLayerDriver.C | 12 ++--- .../snappyHexMeshDriver/snappySnapDriver.C | 4 +- .../snappySnapDriverTemplates.C | 2 +- .../cyclicACMIGAMGInterface.C | 4 +- .../cyclicAMIGAMGInterface.C | 4 +- src/meshTools/meshStructure/meshStructure.C | 2 +- .../multiWorld/multiWorldConnectionsObject.C | 6 +-- src/meshTools/regionSplit/localPointRegion.C | 4 +- src/meshTools/regionSplit/regionSplit.C | 2 +- .../cellSources/surfaceToCell/surfaceToCell.C | 2 +- .../faceSources/holeToFace/holeToFace.C | 2 +- src/meshTools/topoSet/topoSets/faceZoneSet.C | 6 +-- .../surfaceFeatures/surfaceFeatures.C | 2 +- .../adjoint/global/createZeroField.H | 2 +- .../GAMG/calculatedProcessorGAMGInterface.C | 2 +- .../oversetGAMGInterface.C | 2 +- .../distributedTriSurfaceMesh.C | 2 +- .../faReconstruct/faMeshReconstructor.C | 4 +- .../multiphaseSystem/multiphaseSystem.C | 14 +++--- .../nucleateFluxModel/nucleateFluxModel.C | 2 +- .../meshToMesh/meshToMeshParallelOps.C | 4 +- src/sampling/probes/probes.C | 2 +- .../sampledSet/sampledSets/sampledSets.C | 2 +- .../surfaceFormats/nas/NASsurfaceFormat.C | 6 +-- .../surfaceFormats/obj/OBJsurfaceFormat.C | 2 +- .../starcd/STARCDsurfaceFormat.C | 4 +- src/surfMesh/surfaceFormats/tri/TRIReader.C | 2 +- .../basic/basicThermo/basicThermoTemplates.C | 4 +- .../chemkinReader/chemkinLexer.L | 14 +++--- 132 files changed, 342 insertions(+), 340 deletions(-) diff --git a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C index eb41aa2bbf..4f3d9c75fc 100644 --- a/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C +++ b/applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C @@ -779,7 +779,7 @@ Foam::multiphaseMixtureThermo::surfaceTensionForce() const auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2)); - if (!sigma.found()) + if (!sigma.good()) { FatalErrorInFunction << "Cannot find interface " << interfacePair(alpha1, alpha2) @@ -907,7 +907,7 @@ void Foam::multiphaseMixtureThermo::correctContactAngle const auto tp = acap.thetaProps().cfind(interfacePair(alpha1, alpha2)); - if (!tp.found()) + if (!tp.good()) { FatalErrorInFunction << "Cannot find interface " << interfacePair(alpha1, alpha2) diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C index da3547d18a..7fefaa1642 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C @@ -287,7 +287,7 @@ Foam::multiphaseMixture::surfaceTensionForce() const auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2)); - if (!sigma.found()) + if (!sigma.good()) { FatalErrorInFunction << "Cannot find interface " << interfacePair(alpha1, alpha2) @@ -463,7 +463,7 @@ void Foam::multiphaseMixture::correctBoundaryContactAngle const auto tp = acap.thetaProps().cfind(interfacePair(alpha1, alpha2)); - if (!tp.found()) + if (!tp.good()) { FatalErrorInFunction << "Cannot find interface " << interfacePair(alpha1, alpha2) diff --git a/applications/test/Map/Test-Map.C b/applications/test/Map/Test-Map.C index d4cb2933ac..9df5bc1a25 100644 --- a/applications/test/Map/Test-Map.C +++ b/applications/test/Map/Test-Map.C @@ -52,13 +52,13 @@ int main(int argc, char *argv[]) // Same, but with non-const access // Map::iterator map1Iter = map1.find(5); - if (!map1Iter.found()) // same as (map1Iter == map1.end()) + if (!map1Iter.good()) { Info<< "not found" << endl; } else { - Info<< "5 is " << *map1Iter << endl; + Info<< "5 is " << map1Iter.val() << endl; } // Repeat with std::map diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C index 509ad1d34e..70c288274d 100644 --- a/applications/test/syncTools/Test-syncTools.C +++ b/applications/test/syncTools/Test-syncTools.C @@ -353,9 +353,9 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) const auto iter = sparseData.cfind(e); - if (iter.found()) + if (iter.good()) { - const point& sparsePt = iter(); + const point& sparsePt = iter.val(); const point& fullPt = fullData[meshEdgeI]; if (fullPt != sparsePt) diff --git a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C index 3a17697164..037e3a18b2 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C +++ b/applications/utilities/mesh/advanced/modifyMesh/cellSplitter.C @@ -86,7 +86,7 @@ Foam::label Foam::cellSplitter::newOwner const auto iter = cellToCells.cfind(old); - if (!iter.found()) + if (!iter.good()) { // Unsplit cell return old; @@ -113,7 +113,7 @@ Foam::label Foam::cellSplitter::newNeighbour const auto iter = cellToCells.cfind(old); - if (!iter.found()) + if (!iter.good()) { // Unsplit cell return old; diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index 46809fe804..3700bc8b87 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -1063,7 +1063,7 @@ int main(int argc, char *argv[]) const auto iter = fluentToFoamType.cfind(type); - if (iter.found()) + if (iter.good()) { // See if we have a periodic and can derive the other side. word neighbPatchName; diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index 77dc4d738e..4e6a5b3a7c 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -225,7 +225,7 @@ void storeCellInZone { const auto zoneFnd = physToZone.cfind(regPhys); - if (zoneFnd.found()) + if (zoneFnd.good()) { // Existing zone for region zoneCells[zoneFnd()].append(celli); @@ -592,7 +592,7 @@ void readCellsLegacy const auto regFnd = physToPatch.cfind(regPhys); label patchi = -1; - if (regFnd.found()) + if (regFnd.good()) { // Existing patch for region patchi = regFnd(); @@ -625,7 +625,7 @@ void readCellsLegacy const auto regFnd = physToPatch.cfind(regPhys); label patchi = -1; - if (regFnd.found()) + if (regFnd.good()) { // Existing patch for region patchi = regFnd(); @@ -934,7 +934,7 @@ void readCells const auto regFnd = physToPatch.cfind(regPhys); label patchi = -1; - if (regFnd.found()) + if (regFnd.good()) { // Existing patch for region patchi = regFnd(); @@ -972,7 +972,7 @@ void readCells const auto regFnd = physToPatch.cfind(regPhys); label patchi = -1; - if (regFnd.found()) + if (regFnd.good()) { // Existing patch for region patchi = regFnd(); diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index 79145cdae3..1b29209c13 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) // (uses commutative hash) auto iter = vertsToBoundary.find(triFace(f[0], f[1], f[2])); - if (iter.found()) + if (iter.good()) { const triFace& tri = iter.key(); const label facei = iter.val(); diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index c9928cee38..97c67c26a8 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -443,7 +443,7 @@ int main(int argc, char *argv[]) const auto patchFind = regionToPatch.cfind(region); - if (patchFind.found()) + if (patchFind.good()) { patchi = *patchFind; } diff --git a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C index 6c647b2938..9a594ec2da 100644 --- a/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C +++ b/applications/utilities/mesh/conversion/writeMeshObj/writeMeshObj.C @@ -124,7 +124,7 @@ void writePoints const auto e0Fnd = pointToObj.cfind(e[0]); - if (e0Fnd.found()) + if (e0Fnd.good()) { v0 = *e0Fnd; } @@ -139,7 +139,7 @@ void writePoints const auto e1Fnd = pointToObj.cfind(e[1]); - if (e1Fnd.found()) + if (e1Fnd.good()) { v1 = *e1Fnd; } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C index 77774439ce..3000cf0aed 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C @@ -416,7 +416,7 @@ void Foam::DistributedDelaunayMesh::markVerticesToRefer const auto iter = circumsphereOverlaps.cfind(cit->cellIndex()); // Pre-tested circumsphere potential influence - if (iter.found()) + if (iter.good()) { const labelList& citOverlaps = iter(); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 7e857a1e27..4f04583e46 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -2263,7 +2263,7 @@ void Foam::conformalVoronoiMesh::reinsertSurfaceConformation() const auto iter = oldToNewIndices.cfind(vIndex); - if (iter.found()) + if (iter.good()) { const label newIndex = *iter; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C index 338a38669d..cb77753c88 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/featurePointConformer/featurePointConformer.C @@ -611,7 +611,7 @@ void Foam::featurePointConformer::reIndexPointPairs const auto newIndexIter = oldToNewIndices.cfind(currentIndex); - if (newIndexIter.found()) + if (newIndexIter.good()) { featurePointVertices_[vI].index() = *newIndexIter; } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C index 6800b09498..b4f3e88b16 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/pointPairs/pointPairs.C @@ -193,7 +193,7 @@ void Foam::pointPairs::reIndex(const Map