Commit 0c893278 authored by Mark Olesen's avatar Mark Olesen

STYLE: update iterator looping

- use range-for when iterating over HashSet

- prefer forAllIters(), forAllConstIters() with automatic decltype
parent a8278f71
...@@ -154,8 +154,7 @@ void cartesianMeshExtractor::createPolyMesh() ...@@ -154,8 +154,7 @@ void cartesianMeshExtractor::createPolyMesh()
label nProcBoundaries(nFaces), patchI(0); label nProcBoundaries(nFaces), patchI(0);
// allocate memory for processor patches // allocate memory for processor patches
std::map<label, labelLongList>::const_iterator iter; forAllConstIters(procFaces, iter)
for (iter = procFaces.begin(); iter!=procFaces.end(); ++iter)
{ {
const label procI = iter->first; const label procI = iter->first;
...@@ -182,7 +181,7 @@ void cartesianMeshExtractor::createPolyMesh() ...@@ -182,7 +181,7 @@ void cartesianMeshExtractor::createPolyMesh()
// create processor faces // create processor faces
// they need to be created here because of the correct ordering // they need to be created here because of the correct ordering
patchI = 0; patchI = 0;
for (iter = procFaces.begin(); iter!=procFaces.end(); ++iter) forAllConstIters(procFaces, iter)
{ {
procBoundaries[patchI].patchStart() = nProcBoundaries; procBoundaries[patchI].patchStart() = nProcBoundaries;
......
...@@ -203,12 +203,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) ...@@ -203,12 +203,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing(); const Map<label>& globalToLocal = mse.globalToLocalBndPointAddressing();
const labelList& bPoints = mse.boundaryPoints(); const labelList& bPoints = mse.boundaryPoints();
for forAllConstIters(globalToLocal, iter)
(
Map<label>::const_iterator iter = globalToLocal.begin();
iter!=globalToLocal.end();
++iter
)
{ {
const label bpI = iter(); const label bpI = iter();
procPoint[bPoints[bpI]] = true; procPoint[bPoints[bpI]] = true;
...@@ -376,8 +371,6 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) ...@@ -376,8 +371,6 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
} }
// create cells for corner nodes // create cells for corner nodes
typedef std::map<std::pair<label, label>, label> mPairToLabelType;
typedef std::map<label, mPairToLabelType> mPointsType;
typedef std::map<label, DynList<label, 3>> ppType; typedef std::map<label, DynList<label, 3>> ppType;
ppType nodePatches; ppType nodePatches;
...@@ -397,7 +390,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) ...@@ -397,7 +390,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
ppfType parPointFaces; ppfType parPointFaces;
ppType parPointPatches; ppType parPointPatches;
forAllConstIter(mPointsType, otherVrts_, iter) forAllConstIters(otherVrts_, iter)
{ {
// skip points on feature edges // skip points on feature edges
if (iter->second.size() == 2) if (iter->second.size() == 2)
...@@ -504,7 +497,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) ...@@ -504,7 +497,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
} }
// sort faces sharing corners at the parallel boundaries // sort faces sharing corners at the parallel boundaries
forAllIter(ppfType, parPointFaces, iter) forAllIters(parPointFaces, iter)
{ {
DynList<DynList<label, 8>, 8>& pFaces = iter->second; DynList<DynList<label, 8>, 8>& pFaces = iter->second;
DynList<label, 3>& fPatches = parPointPatches[iter->first]; DynList<label, 3>& fPatches = parPointPatches[iter->first];
...@@ -545,7 +538,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) ...@@ -545,7 +538,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
} }
// sort out point which are not at inter-processor boundaries // sort out point which are not at inter-processor boundaries
forAllConstIter(mPointsType, otherVrts_, iter) forAllConstIters(otherVrts_, iter)
{ {
if (iter->second.size() == 2) if (iter->second.size() == 2)
{ {
...@@ -598,7 +591,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels) ...@@ -598,7 +591,7 @@ void boundaryLayers::createLayerCells(const labelList& patchLabels)
} }
// create layer cells for corner nodes // create layer cells for corner nodes
forAllIter(ppType, nodePatches, iter) forAllIters(nodePatches, iter)
{ {
const DynList<label, 3>& patchIDs = iter->second; const DynList<label, 3>& patchIDs = iter->second;
DynList<label, 3> pKeys; DynList<label, 3> pKeys;
...@@ -812,13 +805,7 @@ void boundaryLayers::createNewFacesFromPointsParallel ...@@ -812,13 +805,7 @@ void boundaryLayers::createNewFacesFromPointsParallel
help::exchangeMap(exchangeData, receivedMap); help::exchangeMap(exchangeData, receivedMap);
exchangeData.clear(); exchangeData.clear();
for forAllConstIters(receivedMap, iter)
(
std::map<label, List<labelledPair>>::const_iterator
iter = receivedMap.begin();
iter!=receivedMap.end();
++iter
)
{ {
const List<labelledPair>& receivedData = iter->second; const List<labelledPair>& receivedData = iter->second;
......
...@@ -97,10 +97,8 @@ void boundaryLayers::findPatchesToBeTreatedTogether() ...@@ -97,10 +97,8 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
// patches must be treated together if there exist a corner where // patches must be treated together if there exist a corner where
// more than three patches meet // more than three patches meet
const labelHashSet& corners = mPart.corners(); const labelHashSet& corners = mPart.corners();
forAllConstIter(labelHashSet, corners, it) for (const label bpI : corners)
{ {
const label bpI = it.key();
if (mPart.numberOfFeatureEdgesAtPoint(bpI) > 3) if (mPart.numberOfFeatureEdgesAtPoint(bpI) > 3)
{ {
labelHashSet commonPatches; labelHashSet commonPatches;
...@@ -227,7 +225,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether() ...@@ -227,7 +225,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
} }
// store faces for sending // store faces for sending
forAllConstIter(Map<label>, otherFaceProc, it) forAllConstIters(otherFaceProc, it)
{ {
const label beI = it.key(); const label beI = it.key();
...@@ -359,8 +357,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether() ...@@ -359,8 +357,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
mesh_.points().setSize(nPoints_); mesh_.points().setSize(nPoints_);
} }
std::map<std::pair<label, label>, Pair<label>>::const_iterator it; forAllConstIters(edgeClassification, it)
for (it = edgeClassification.begin(); it!=edgeClassification.end(); ++it)
{ {
const std::pair<label, label>& edgePair = it->first; const std::pair<label, label>& edgePair = it->first;
const Pair<label>& nConvexAndConcave = it->second; const Pair<label>& nConvexAndConcave = it->second;
...@@ -481,12 +478,12 @@ void boundaryLayers::findPatchesToBeTreatedTogether() ...@@ -481,12 +478,12 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
} }
} }
forAllConstIter(std::set<label>, commonPatches, it) forAllConstIters(commonPatches, it)
{ {
const label patchJ = *it; const label patchJ = *it;
treatPatchesWithPatch_[patchJ].clear(); treatPatchesWithPatch_[patchJ].clear();
forAllConstIter(std::set<label>, commonPatches, iter) forAllConstIters(commonPatches, iter)
{ {
treatPatchesWithPatch_[patchJ].append(*iter); treatPatchesWithPatch_[patchJ].append(*iter);
} }
...@@ -494,7 +491,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether() ...@@ -494,7 +491,7 @@ void boundaryLayers::findPatchesToBeTreatedTogether()
} }
# ifdef DEBUGLayer # ifdef DEBUGLayer
for (it = edgeClassification.begin(); it!=edgeClassification.end(); ++it) forAllConstIters(edgeClassification, it)
{ {
const std::pair<label, label>& edgePair = it->first; const std::pair<label, label>& edgePair = it->first;
const Pair<label>& nConvexAndConcave = it->second; const Pair<label>& nConvexAndConcave = it->second;
......
...@@ -212,12 +212,7 @@ void boundaryLayers::createNewFacesParallel ...@@ -212,12 +212,7 @@ void boundaryLayers::createNewFacesParallel
label nTreatedEdges(0); label nTreatedEdges(0);
boolList treatEdge(edgeFaces.size(), false); boolList treatEdge(edgeFaces.size(), false);
for forAllConstIters(globalToLocal, iter)
(
Map<label>::const_iterator iter = globalToLocal.begin();
iter!=globalToLocal.end();
++iter
)
{ {
const label beI = iter(); const label beI = iter();
......
...@@ -45,12 +45,11 @@ label boundaryLayers::findNewNodeLabel ...@@ -45,12 +45,11 @@ label boundaryLayers::findNewNodeLabel
if (it != otherVrts_.end()) if (it != otherVrts_.end())
{ {
const std::map<std::pair<label, label>, label>& m = it->second; const auto& m = it->second;
std::map<std::pair<label, label>, label>::const_iterator mit;
if (m.size() == 2) if (m.size() == 2)
{ {
for (mit = m.begin(); mit!=m.end(); ++mit) forAllConstIters(m, mit)
{ {
if (mit->first.first != pKey) if (mit->first.first != pKey)
{ {
...@@ -60,7 +59,7 @@ label boundaryLayers::findNewNodeLabel ...@@ -60,7 +59,7 @@ label boundaryLayers::findNewNodeLabel
} }
else else
{ {
for (mit = m.begin(); mit!=m.end(); ++mit) forAllConstIters(m, mit)
{ {
if (mit->first.first == pKey) if (mit->first.first == pKey)
{ {
...@@ -101,13 +100,12 @@ inline void boundaryLayers::createNewCellFromEdge ...@@ -101,13 +100,12 @@ inline void boundaryLayers::createNewCellFromEdge
Info<< "Creating cell for edge with nodes " << e << endl; Info<< "Creating cell for edge with nodes " << e << endl;
Info<< "pKeyI " << pKeyI << endl; Info<< "pKeyI " << pKeyI << endl;
Info<< "pKeyJ " << pKeyJ << endl; Info<< "pKeyJ " << pKeyJ << endl;
std::map<std::pair<label, label>, label>::const_iterator iter; forAllConstIters(ms, iter)
for (iter = ms.begin(); iter!=ms.end(); ++iter)
{ {
Info<< "1. Pair(" << iter->first.first << ", " Info<< "1. Pair(" << iter->first.first << ", "
<< iter->first.second << ") has value " << iter->second << endl; << iter->first.second << ") has value " << iter->second << endl;
} }
for (iter = me.begin(); iter!=me.end(); ++iter) forAllConstIters(me, iter)
{ {
Info<< "2. Pair(" << iter->first.first << ", " Info<< "2. Pair(" << iter->first.first << ", "
<< iter->first.second << ") has value " << iter->second << endl; << iter->first.second << ") has value " << iter->second << endl;
...@@ -124,8 +122,7 @@ inline void boundaryLayers::createNewCellFromEdge ...@@ -124,8 +122,7 @@ inline void boundaryLayers::createNewCellFromEdge
} }
else else
{ {
std::map<std::pair<label, label>, label>::const_iterator it; forAllConstIters(ms, it)
for (it = ms.begin(); it!=ms.end(); ++it)
{ {
if if
( (
...@@ -161,8 +158,7 @@ inline void boundaryLayers::createNewCellFromEdge ...@@ -161,8 +158,7 @@ inline void boundaryLayers::createNewCellFromEdge
} }
else else
{ {
std::map<std::pair<label, label>, label>::const_iterator it; forAllConstIters(me, it)
for (it = me.begin(); it!=me.end(); ++it)
{ {
if if
( (
......
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
exchangeData[mse_.beNeiProcs()[procI]].clear(); exchangeData[mse_.beNeiProcs()[procI]].clear();
} }
forAllConstIter(Map<label>, globalToLocal, it) forAllConstIters(globalToLocal, it)
{ {
const label beI = it(); const label beI = it();
...@@ -467,12 +467,7 @@ void detectBoundaryLayers::analyseLayers() ...@@ -467,12 +467,7 @@ void detectBoundaryLayers::analyseLayers()
layerAtPatch_[i].clear(); layerAtPatch_[i].clear();
} }
for forAllConstIters(patchToLayer, it)
(
patchToLayerType::const_iterator it = patchToLayer.begin();
it!=patchToLayer.end();
++it
)
{ {
const DynList<label>& layersAtPatch = it->second; const DynList<label>& layersAtPatch = it->second;
......
...@@ -260,7 +260,7 @@ void extrudeLayer::createNewVertices() ...@@ -260,7 +260,7 @@ void extrudeLayer::createNewVertices()
} }
// collect the information about markes points at processor boundaries // collect the information about markes points at processor boundaries
forAllConstIter(Map<label>, globalToLocal, it) forAllConstIters(globalToLocal, it)
{ {
if (frontPoints[it()] & FRONTVERTEX) if (frontPoints[it()] & FRONTVERTEX)
{ {
...@@ -331,7 +331,7 @@ void extrudeLayer::createNewVertices() ...@@ -331,7 +331,7 @@ void extrudeLayer::createNewVertices()
dualEdgesMap procPointsDual; dualEdgesMap procPointsDual;
// fill in local data // fill in local data
forAllConstIter(Map<label>, globalToLocal, it) forAllConstIters(globalToLocal, it)
{ {
if (frontPoints[it()] & FRONTVERTEXPROCBND) if (frontPoints[it()] & FRONTVERTEXPROCBND)
{ {
...@@ -364,7 +364,7 @@ void extrudeLayer::createNewVertices() ...@@ -364,7 +364,7 @@ void extrudeLayer::createNewVertices()
{ {
if (Pstream::myProcNo() == procI) if (Pstream::myProcNo() == procI)
{ {
forAllConstIter(dualEdgesMap, procPointsDual, it) forAllConstIters(procPointsDual, it)
{ {
Pout<< "Point " << it->first Pout<< "Point " << it->first
<< " local dual edges " << it->second << endl; << " local dual edges " << it->second << endl;
...@@ -461,7 +461,7 @@ void extrudeLayer::createNewVertices() ...@@ -461,7 +461,7 @@ void extrudeLayer::createNewVertices()
} }
// fill in the exchangeData map // fill in the exchangeData map
forAllConstIter(dualEdgesMap, procPointsDual, dIter) forAllConstIters(procPointsDual, dIter)
{ {
const label pointI = dIter->first; const label pointI = dIter->first;
...@@ -516,7 +516,7 @@ void extrudeLayer::createNewVertices() ...@@ -516,7 +516,7 @@ void extrudeLayer::createNewVertices()
{ {
if (Pstream::myProcNo() == procI) if (Pstream::myProcNo() == procI)
{ {
forAllConstIter(dualEdgesMap, procPointsDual, it) forAllConstIters(procPointsDual, it)
{ {
Pout<< "Point " << it->first Pout<< "Point " << it->first
<< " dual edges " << it->second << endl; << " dual edges " << it->second << endl;
...@@ -529,7 +529,7 @@ void extrudeLayer::createNewVertices() ...@@ -529,7 +529,7 @@ void extrudeLayer::createNewVertices()
// Finally, find groups of faces and create new vertices // Finally, find groups of faces and create new vertices
returnReduce(1, sumOp<label>()); returnReduce(1, sumOp<label>());
Pout << "Finding groups of edges at vertex" << endl; Pout << "Finding groups of edges at vertex" << endl;
forAllConstIter(dualEdgesMap, procPointsDual, dIter) forAllConstIters(procPointsDual, dIter)
{ {
const label pointI = dIter->first; const label pointI = dIter->first;
const DynList<edge>& dEdges = dIter->second; const DynList<edge>& dEdges = dIter->second;
...@@ -834,7 +834,7 @@ void extrudeLayer::movePoints() ...@@ -834,7 +834,7 @@ void extrudeLayer::movePoints()
} }
// create displacements from local data // create displacements from local data
forAllConstIter(Map<label>, globalToLocal, it) forAllConstIters(globalToLocal, it)
{ {
if (it() >= nOrigPoints_) if (it() >= nOrigPoints_)
{ {
...@@ -910,17 +910,12 @@ void extrudeLayer::movePoints() ...@@ -910,17 +910,12 @@ void extrudeLayer::movePoints()
} }
// calculate displacements of vertices at processor boundaries // calculate displacements of vertices at processor boundaries
for forAllConstIters(normals, it)
(
std::map<label, vector>::const_iterator it = normals.begin();
it!=normals.end();
++it
)
{ {
vector n = it->second; vector n = it->second;
if (mag(n) > VSMALL) if (mag(n) > VSMALL)
{ {
n /= mag(n); n /= mag(n);
} }
displacements[it->first - nOrigPoints_] = n*distances[it->first]; displacements[it->first - nOrigPoints_] = n*distances[it->first];
} }
......
...@@ -301,12 +301,7 @@ void refineBoundaryLayers::activateSpecialMode() ...@@ -301,12 +301,7 @@ void refineBoundaryLayers::activateSpecialMode()
void refineBoundaryLayers::refineLayers() void refineBoundaryLayers::refineLayers()
{ {
bool refinePatch(false); bool refinePatch(false);
for forAllConstIters(numLayersForPatch_, it)
(
std::map<word, label>::const_iterator it = numLayersForPatch_.begin();
it!=numLayersForPatch_.end();
++it
)
{ {
if (it->second > 1) if (it->second > 1)
{ {
......
...@@ -1074,13 +1074,7 @@ void checkMeshDict::updateRenameBoundary ...@@ -1074,13 +1074,7 @@ void checkMeshDict::updateRenameBoundary
// current state of the dictionary // current state of the dictionary
const dictionary& patchDicts = dict.subDict("newPatchNames"); const dictionary& patchDicts = dict.subDict("newPatchNames");
std::map<word, wordList>::const_iterator it; forAllConstIters(patchesFromPatch, it)
for
(
it = patchesFromPatch.begin();
it!=patchesFromPatch.end();
++it
)
{ {
const word& pName = it->first; const word& pName = it->first;
const wordList& newNames = it->second; const wordList& newNames = it->second;
...@@ -1154,8 +1148,7 @@ void checkMeshDict::updateRenameBoundary ...@@ -1154,8 +1148,7 @@ void checkMeshDict::updateRenameBoundary
} }
} }
std::map<word, wordList>::const_iterator it; forAllConstIters(patchesFromPatch, it)
for (it = patchesFromPatch.begin(); it!=patchesFromPatch.end(); ++it)
{ {
const word& pName = it->first; const word& pName = it->first;
const wordList& newNames = it->second; const wordList& newNames = it->second;
...@@ -1186,8 +1179,7 @@ void checkMeshDict::updateRenameBoundary ...@@ -1186,8 +1179,7 @@ void checkMeshDict::updateRenameBoundary
// newPatchNames is not used // newPatchNames is not used
dictionary& newPatchesDict = newDict.subDict("newPatchNames"); dictionary& newPatchesDict = newDict.subDict("newPatchNames");
std::map<word, wordList>::const_iterator it; forAllConstIters(patchesFromPatch, it)
for (it = patchesFromPatch.begin(); it!=patchesFromPatch.end(); ++it)
{ {
const wordList& newPatchNames = it->second; const wordList& newPatchNames = it->second;
...@@ -1213,8 +1205,7 @@ void checkMeshDict::updateRenameBoundary ...@@ -1213,8 +1205,7 @@ void checkMeshDict::updateRenameBoundary
// create the dictionary if it has not existed before // create the dictionary if it has not existed before
dictionary& newPatchesDict = newDict.subDict("newPatchNames");