Commit bd78da22 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

ENH: for-range, forAllIters() ... in mesh/

- reduced clutter when iterating over containers
parent a766d386
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -168,8 +168,7 @@ public:
//- Destructor
virtual ~blockEdge()
{}
virtual ~blockEdge() = default;
// Member Functions
......
......@@ -913,13 +913,12 @@ Foam::label Foam::meshRefinement::splitFacesUndo
forAll(map.faceMap(), facei)
{
label oldFacei = map.faceMap()[facei];
Map<label>::iterator oldFaceFnd = splitFaceToIndex.find
(
oldFacei
);
if (oldFaceFnd != splitFaceToIndex.end())
const auto oldFaceFnd = splitFaceToIndex.cfind(oldFacei);
if (oldFaceFnd.found())
{
labelPair& twoFaces = facePairs[oldFaceFnd()];
labelPair& twoFaces = facePairs[oldFaceFnd.val()];
if (twoFaces[0] == -1)
{
twoFaces[0] = facei;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2014 OpenFOAM Foundation
......@@ -1235,10 +1235,10 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeBaffles
}
}
forAllConstIter(Map<label>, faceToPatch, iter)
forAllConstIters(faceToPatch, iter)
{
label faceI = iter.key();
label patchI = iter();
const label faceI = iter.key();
const label patchI = iter.val();
if (!mesh_.isInternalFace(faceI))
{
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
......@@ -1300,18 +1300,18 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric
}
forAllConstIter(faceSet, wrongFaces, iter)
for (const label facei : wrongFaces)
{
label patchi = mesh_.boundaryMesh().whichPatch(iter.key());
const label patchi = mesh_.boundaryMesh().whichPatch(facei);
if (patchi == -1 || mesh_.boundaryMesh()[patchi].coupled())
{
facePatch[iter.key()] = nearestAdaptPatch[iter.key()];
facePatch[facei] = nearestAdaptPatch[facei];
nBaffleFaces++;
//Pout<< " " << iter.key()
//Pout<< " " << facei
// //<< " on patch " << mesh_.boundaryMesh()[patchi].name()
// << " is destined for patch " << facePatch[iter.key()]
// << " is destined for patch " << facePatch[facei]
// << endl;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
......@@ -504,12 +504,10 @@ void Foam::meshRefinement::markFeatureCellLevel
Pout<< "Constructing cloud for cell marking" << endl;
}
forAllIter(Cloud<trackedParticle>, startPointCloud, iter)
for (const trackedParticle& startTp : startPointCloud)
{
const trackedParticle& startTp = iter();
label featI = startTp.i();
label pointI = startTp.j();
const label featI = startTp.i();
const label pointI = startTp.j();
const edgeMesh& featureMesh = features_[featI];
const labelList& pEdges = featureMesh.pointEdges()[pointI];
......@@ -562,12 +560,10 @@ void Foam::meshRefinement::markFeatureCellLevel
cloud.move(cloud, td, maxTrackLen);
// Make particle follow edge.
forAllIter(Cloud<trackedParticle>, cloud, iter)
for (trackedParticle& tp : cloud)
{
trackedParticle& tp = iter();
label featI = tp.i();
label pointI = tp.j();
const label featI = tp.i();
const label pointI = tp.j();
const edgeMesh& featureMesh = features_[featI];
const labelList& pEdges = featureMesh.pointEdges()[pointI];
......
......@@ -209,11 +209,10 @@ void Foam::meshRefinement::addPatchFields
mesh.objectRegistry::lookupClass<GeoField>()
);
forAllIter(typename HashTable<GeoField*>, flds, iter)
forAllIters(flds, iter)
{
GeoField& fld = *iter();
typename GeoField::Boundary& fldBf =
fld.boundaryFieldRef();
auto& fldBf = fld.boundaryFieldRef();
label sz = fldBf.size();
fldBf.setSize(sz+1);
......@@ -243,7 +242,7 @@ void Foam::meshRefinement::reorderPatchFields
mesh.objectRegistry::lookupClass<GeoField>()
);
forAllIter(typename HashTable<GeoField*>, flds, iter)
forAllIters(flds, iter)
{
iter()->boundaryFieldRef().reorder(oldToNew);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
......@@ -461,11 +461,11 @@ Foam::refinementSurfaces::refinementSurfaces
}
// Overwrite with region specific information
forAllConstIter(Map<label>, regionMinLevel[surfI], iter)
forAllConstIters(regionMinLevel[surfI], iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
minLevel_[globalRegionI] = iter();
minLevel_[globalRegionI] = iter.val();
maxLevel_[globalRegionI] = regionMaxLevel[surfI][iter.key()];
gapLevel_[globalRegionI] =
maxLevel_[globalRegionI]
......@@ -475,7 +475,7 @@ Foam::refinementSurfaces::refinementSurfaces
extendedGapMode_[globalRegionI] =
regionGapMode[surfI][iter.key()];
}
forAllConstIter(Map<scalar>, regionAngle[surfI], iter)
forAllConstIters(regionAngle[surfI], iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
......@@ -483,11 +483,12 @@ Foam::refinementSurfaces::refinementSurfaces
}
const Map<autoPtr<dictionary>>& localInfo = regionPatchInfo[surfI];
forAllConstIter(Map<autoPtr<dictionary>>, localInfo, iter)
forAllConstIters(localInfo, iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
const dictionary& dict = *(iter.val());
patchInfo_.set(globalRegionI, iter()().clone());
patchInfo_.set(globalRegionI, dict.clone());
}
}
}
......
......@@ -314,18 +314,7 @@ void Foam::snappyLayerDriver::countCommonPoints
if (facei < nbFacei)
{
// Only check once for each combination of two faces.
Map<label>::iterator fnd = nCommonPoints.find(nbFacei);
if (fnd == nCommonPoints.end())
{
// First common vertex found.
nCommonPoints.insert(nbFacei, 1);
}
else
{
fnd()++;
}
++(nCommonPoints(nbFacei, 0));
}
}
}
......@@ -437,10 +426,10 @@ void Foam::snappyLayerDriver::checkCommonOrder
List<extrudeMode>& extrudeStatus
) const
{
forAllConstIter(Map<label>, nCommonPoints, iter)
forAllConstIters(nCommonPoints, iter)
{
label nbFacei = iter.key();
label nCommon = iter();
const label nbFacei = iter.key();
const label nCommon = iter.val();
const face& curFace = pp[facei];
const face& nbFace = pp[nbFacei];
......@@ -1415,10 +1404,10 @@ void Foam::snappyLayerDriver::determineSidePatches
forAll(edgePatchID, i)
{
label patchi = edgePatchID[i];
Map<label>::const_iterator fnd = wantedToAddedPatch.find(patchi);
if (fnd != wantedToAddedPatch.end())
const auto fnd = wantedToAddedPatch.cfind(patchi);
if (fnd.found())
{
edgePatchID[i] = fnd();
edgePatchID[i] = fnd.val();
}
}
......@@ -2098,10 +2087,8 @@ Foam::label Foam::snappyLayerDriver::truncateDisplacement
const Map<label>& meshPointMap = pp.meshPointMap();
forAllConstIter(faceSet, illegalPatchFaces, iter)
for (const label facei : illegalPatchFaces)
{
label facei = iter.key();
if (mesh.isInternalFace(facei))
{
FatalErrorInFunction
......@@ -2115,9 +2102,10 @@ Foam::label Foam::snappyLayerDriver::truncateDisplacement
forAll(f, fp)
{
if (meshPointMap.found(f[fp]))
const auto fnd = meshPointMap.cfind(f[fp]);
if (fnd.found())
{
label patchPointi = meshPointMap[f[fp]];
const label patchPointi = fnd.val();
if (extrudeStatus[patchPointi] != NOEXTRUDE)
{
......@@ -2820,8 +2808,8 @@ Foam::List<Foam::labelPair> Foam::snappyLayerDriver::getBafflesOnAddedMesh
{
label oldFacei = newToOldFaces[facei];
Map<label>::const_iterator faceFnd = baffleSet.find(oldFacei);
if (faceFnd != baffleSet.end())
const auto faceFnd = baffleSet.find(oldFacei);
if (faceFnd.found())
{
label bafflei = faceFnd();
labelPair& p = newBaffles[bafflei];
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
......@@ -1113,9 +1113,8 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine
// Pass2: check for oppositeness
//forAllConstIter(cellSet, transitionCells, iter)
//for (const label celli : transitionCells)
//{
// const label celli : iter.key();
// const cell& cFaces = cells[celli];
// const point& cc = cellCentres[celli];
// const scalar rCVol = pow(cellVolumes[celli], -5.0/3.0);
......@@ -1226,9 +1225,8 @@ Foam::label Foam::snappyRefineDriver::refinementInterfaceRefine
const scalar oppositeCos = Foam::cos(degToRad(135.0));
forAllConstIter(cellSet, transitionCells, iter)
for (const label celli : transitionCells)
{
label celli = iter.key();
const cell& cFaces = cells[celli];
label cLevel = cutter.cellLevel()[celli];
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2015 OpenFOAM Foundation
......@@ -225,10 +225,7 @@ Foam::tmp<Foam::pointField> Foam::snappySnapDriver::smoothInternalDisplacement
// Unmark any point on the boundary. If we're doing zero iterations of
// face-cell wave we might have coupled points not being unmarked.
forAll(pp.meshPoints(), pointi)
{
isMovingPoint.unset(pp.meshPoints()[pointi]);
}
isMovingPoint.unset(pp.meshPoints());
// Make sure that points that are coupled to meshPoints but not on a patch
// are unmarked as well
......@@ -962,12 +959,11 @@ Foam::labelList Foam::snappySnapDriver::getZoneSurfacePoints
{
label meshPointi = f[fp];
Map<label>::const_iterator iter =
pp.meshPointMap().find(meshPointi);
const auto iter = pp.meshPointMap().cfind(meshPointi);
if (iter != pp.meshPointMap().end())
if (iter.found())
{
label pointi = iter();
const label pointi = iter.val();
pointOnZone[pointi] = true;
}
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2015 OpenFOAM Foundation
......@@ -49,12 +49,11 @@ Foam::labelList Foam::snappySnapDriver::getFacePoints
{
label meshPointi = f[fp];
Map<label>::const_iterator iter =
pp.meshPointMap().find(meshPointi);
const auto iter = pp.meshPointMap().cfind(meshPointi);
if (iter != pp.meshPointMap().end())
if (iter.found())
{
label pointi = iter();
const label pointi = iter.val();
pointOnZone[pointi] = true;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment