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

- reduced clutter when iterating over containers
This commit is contained in:
Mark Olesen 2019-01-07 09:20:51 +01:00
parent 1458b4f689
commit 14a404170b
76 changed files with 592 additions and 728 deletions

View File

@ -72,7 +72,7 @@ public:
void testCallbackFunction() const
{
forAllConstIter(callbackRegistry, *this, iter)
forAllConstIters(*this, iter)
{
iter().testCallbackFunction();
}

View File

@ -55,7 +55,7 @@ int main(int argc, char *argv[])
Info<< fvc::div(U);
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -54,7 +54,7 @@ int main()
a = h + i + j;
Info<< a << endl;
Info<< "end" << endl;
Info<< "End" << endl;
return 0;
}

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[])
Info<< (gradx4a - gradx4[i])/gradx4a << endl;
}
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
mesh
);
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -65,7 +65,7 @@ int main()
);
phi.write("phi", "xmgr");
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -57,7 +57,7 @@ int main()
"xmgr"
);
Info<< "end" << endl;
Info<< "End" << endl;
}

View File

@ -57,7 +57,7 @@ int main()
graph("r", "x", "r", x, r).write("r", "xmgr");
Info<< "end" << endl;
Info<< "End" << endl;
return 0;
}

View File

@ -59,11 +59,11 @@ int main(int argc, char *argv[])
Pout<< "Adding a particle." << endl;
particles.addParticle(new passiveParticle(mesh, Zero, -1));
forAllConstIter(passiveParticleCloud, particles, iter)
for (const passiveParticle& p : particles)
{
Pout<< " " << iter().position() << " cell:" << iter().cell()
<< " origProc:" << iter().origProc()
<< " origId:" << iter().origId()
Pout<< " " << p.position() << " cell:" << p.cell()
<< " origProc:" << p.origProc()
<< " origId:" << p.origId()
<< endl;
}
@ -80,11 +80,11 @@ int main(int argc, char *argv[])
passiveParticleCloud particles(mesh, cloudName);
Pout<< "Reread particles:" << particles.size() << endl;
forAllConstIter(passiveParticleCloud, particles, iter)
for (const passiveParticle& p : particles)
{
Pout<< " " << iter().position() << " cell:" << iter().cell()
<< " origProc:" << iter().origProc()
<< " origId:" << iter().origId()
Pout<< " " << p.position() << " cell:" << p.cell()
<< " origProc:" << p.origProc()
<< " origId:" << p.origId()
<< endl;
}
}

View File

@ -261,10 +261,10 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
}
// 2. Does sparseData contain more?
forAllConstIter(Map<point>, sparseData, iter)
forAllConstIters(sparseData, iter)
{
const point& sparsePt = iter();
label meshPointi = iter.key();
const label meshPointi = iter.key();
const point& sparsePt = iter.val();
const point& fullPt = fullData[meshPointi];
if (fullPt != sparsePt)
@ -350,9 +350,9 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
{
const edge& e = mesh.edges()[meshEdgeI];
EdgeMap<point>::const_iterator iter = sparseData.find(e);
const auto iter = sparseData.cfind(e);
if (iter != sparseData.end())
if (iter.found())
{
const point& sparsePt = iter();
const point& fullPt = fullData[meshEdgeI];

View File

@ -711,18 +711,18 @@ int main(int argc, char *argv[])
setsAndPatches[setI][1]
);
forAllConstIter(faceSet, fSet, iter)
for (const label facei : fSet)
{
if (wantedPatch[iter.key()] != -1)
if (wantedPatch[facei] != -1)
{
FatalErrorInFunction
<< "Face " << iter.key()
<< "Face " << facei
<< " is in faceSet " << setsAndPatches[setI][0]
<< " destined for patch " << setsAndPatches[setI][1]
<< " but also in patch " << wantedPatch[iter.key()]
<< " but also in patch " << wantedPatch[facei]
<< exit(FatalError);
}
wantedPatch[iter.key()] = patchi;
wantedPatch[facei] = patchi;
}
}
@ -749,20 +749,21 @@ int main(int argc, char *argv[])
faceSet fSet(mesh, coupledAndPatches[setI][0]);
label patchi = findPatch(patches, coupledAndPatches[setI][1]);
forAllConstIter(faceSet, fSet, iter)
for (const label facei : fSet)
{
if (coupledWantedPatch[iter.key()] != -1)
if (coupledWantedPatch[facei] != -1)
{
FatalErrorInFunction
<< "Face " << iter.key()
<< "Face " << facei
<< " is in faceSet " << coupledAndPatches[setI][0]
<< " destined for patch " << coupledAndPatches[setI][1]
<< " but also in patch " << coupledWantedPatch[iter.key()]
<< " but also in patch " << coupledWantedPatch[facei]
<< exit(FatalError);
}
coupledWantedPatch[iter.key()] = patchi;
cyclicWantedPatch_half0[iter.key()] = cyclicId;
cyclicWantedPatch_half1[iter.key()] = cyclicSlaveId;
coupledWantedPatch[facei] = patchi;
cyclicWantedPatch_half0[facei] = cyclicId;
cyclicWantedPatch_half1[facei] = cyclicSlaveId;
}
}

View File

@ -80,25 +80,24 @@ Foam::label Foam::cellSplitter::newOwner
const Map<labelList>& cellToCells
) const
{
label oldOwn = mesh_.faceOwner()[facei];
const label old = mesh_.faceOwner()[facei];
Map<labelList>::const_iterator fnd = cellToCells.find(oldOwn);
const auto iter = cellToCells.cfind(old);
if (fnd == cellToCells.end())
if (!iter.found())
{
// Unsplit cell
return oldOwn;
return old;
}
else
{
// Look up index of face in the cells' faces.
const labelList& newCells = fnd();
const cell& cFaces = mesh_.cells()[oldOwn];
// Look up index of face in the cells' faces.
return newCells[cFaces.find(facei)];
}
const labelList& newCells = *iter;
const cell& cFaces = mesh_.cells()[old];
return newCells[cFaces.find(facei)];
}
@ -108,31 +107,29 @@ Foam::label Foam::cellSplitter::newNeighbour
const Map<labelList>& cellToCells
) const
{
label oldNbr = mesh_.faceNeighbour()[facei];
const label old = mesh_.faceNeighbour()[facei];
Map<labelList>::const_iterator fnd = cellToCells.find(oldNbr);
const auto iter = cellToCells.cfind(old);
if (fnd == cellToCells.end())
if (!iter.found())
{
// Unsplit cell
return oldNbr;
return old;
}
else
{
// Look up index of face in the cells' faces.
const labelList& newCells = fnd();
const cell& cFaces = mesh_.cells()[oldNbr];
// Look up index of face in the cells' faces.
return newCells[cFaces.find(facei)];
}
const labelList& newCells = *iter;
const cell& cFaces = mesh_.cells()[old];
return newCells[cFaces.find(facei)];
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::cellSplitter::cellSplitter(const polyMesh& mesh)
:
mesh_(mesh),
@ -140,12 +137,6 @@ Foam::cellSplitter::cellSplitter(const polyMesh& mesh)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellSplitter::~cellSplitter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cellSplitter::setRefinement
@ -162,9 +153,9 @@ void Foam::cellSplitter::setRefinement
// Introduce cellToMidPoints.
//
forAllConstIter(Map<point>, cellToMidPoint, iter)
forAllConstIters(cellToMidPoint, iter)
{
label celli = iter.key();
const label celli = iter.key();
label anchorPoint = mesh_.cellPoints()[celli][0];
@ -173,7 +164,7 @@ void Foam::cellSplitter::setRefinement
(
polyAddPoint
(
iter(), // point
iter.val(), // point
anchorPoint, // master point
-1, // zone for point
true // supports a cell
@ -193,9 +184,9 @@ void Foam::cellSplitter::setRefinement
Map<labelList> cellToCells(cellToMidPoint.size());
forAllConstIter(Map<point>, cellToMidPoint, iter)
forAllConstIters(cellToMidPoint, iter)
{
label celli = iter.key();
const label celli = iter.key();
const cell& cFaces = mesh_.cells()[celli];
@ -238,9 +229,9 @@ void Foam::cellSplitter::setRefinement
// point.
//
forAllConstIter(Map<point>, cellToMidPoint, iter)
forAllConstIters(cellToMidPoint, iter)
{
label celli = iter.key();
const label celli = iter.key();
label midPointi = addedPoints_[celli];
@ -368,9 +359,9 @@ void Foam::cellSplitter::setRefinement
// Mark off affected face.
bitSet faceUpToDate(mesh_.nFaces(), true);
forAllConstIter(Map<point>, cellToMidPoint, iter)
forAllConstIters(cellToMidPoint, iter)
{
label celli = iter.key();
const label celli = iter.key();
const cell& cFaces = mesh_.cells()[celli];
@ -462,15 +453,13 @@ void Foam::cellSplitter::updateMesh(const mapPolyMesh& morphMap)
// point get mapped do they get inserted.
Map<label> newAddedPoints(addedPoints_.size());
forAllConstIter(Map<label>, addedPoints_, iter)
forAllConstIters(addedPoints_, iter)
{
label oldCelli = iter.key();
const label oldCelli = iter.key();
const label oldPointi = iter.val();
label newCelli = morphMap.reverseCellMap()[oldCelli];
label oldPointi = iter();
label newPointi = morphMap.reversePointMap()[oldPointi];
const label newCelli = morphMap.reverseCellMap()[oldCelli];
const label newPointi = morphMap.reversePointMap()[oldPointi];
if (newCelli >= 0 && newPointi >= 0)
{

View File

@ -109,7 +109,7 @@ public:
//- Destructor
~cellSplitter();
~cellSplitter() = default;
// Member Functions

View File

@ -83,10 +83,8 @@ label findPoint(const primitivePatch& pp, const point& nearPoint)
scalar almostMinDistSqr = GREAT;
label almostMinI = -1;
forAll(meshPoints, i)
for (const label pointi : meshPoints)
{
label pointi = meshPoints[i];
scalar distSqr = magSqr(nearPoint - points[pointi]);
if (distSqr < minDistSqr)
@ -147,10 +145,8 @@ label findEdge
scalar almostMinDist = GREAT;
label almostMinI = -1;
forAll(edges, edgeI)
for (const edge& e : edges)
{
const edge& e = edges[edgeI];
pointHit pHit(e.line(localPoints).nearestDist(nearPoint));
if (pHit.hit())
@ -296,10 +292,8 @@ label findCell(const primitiveMesh& mesh, const point& nearPoint)
label minI = -1;
scalar minDistSqr = GREAT;
forAll(cPoints, i)
for (const label pointi : cPoints)
{
label pointi = cPoints[i];
scalar distSqr = magSqr(nearPoint - mesh.points()[pointi]);
if (distSqr < minDistSqr)
@ -432,11 +426,9 @@ int main(int argc, char *argv[])
Info<< nl << "Looking up points to move ..." << nl << endl;
Map<point> pointToPos(pointsToMove.size());
forAll(pointsToMove, i)
for (const Pair<point>& pts : pointsToMove)
{
const Pair<point>& pts = pointsToMove[i];
label pointi = findPoint(allBoundary, pts.first());
const label pointi = findPoint(allBoundary, pts.first());
if (pointi == -1 || !pointToPos.insert(pointi, pts.second()))
{
@ -450,10 +442,8 @@ int main(int argc, char *argv[])
Info<< nl << "Looking up edges to split ..." << nl << endl;
Map<List<point>> edgeToCuts(edgesToSplit.size());
forAll(edgesToSplit, i)
for (const Pair<point>& pts : edgesToSplit)
{
const Pair<point>& pts = edgesToSplit[i];
label edgeI = findEdge(mesh, allBoundary, pts.first());
if
@ -473,10 +463,8 @@ int main(int argc, char *argv[])
Info<< nl << "Looking up faces to triangulate ..." << nl << endl;
Map<point> faceToDecompose(facesToTriangulate.size());
forAll(facesToTriangulate, i)
for (const Pair<point>& pts : facesToTriangulate)
{
const Pair<point>& pts = facesToTriangulate[i];
label facei = findFace(mesh, allBoundary, pts.first());
if (facei == -1 || !faceToDecompose.insert(facei, pts.second()))
@ -494,10 +482,8 @@ int main(int argc, char *argv[])
Info<< nl << "Looking up cells to convert to pyramids around"
<< " cell centre ..." << nl << endl;
Map<point> cellToPyrCentre(cellsToPyramidise.size());
forAll(cellsToPyramidise, i)
for (const Pair<point>& pts : cellsToPyramidise)
{
const Pair<point>& pts = cellsToPyramidise[i];
label celli = findCell(mesh, pts.first());
if (celli == -1 || !cellToPyrCentre.insert(celli, pts.second()))
@ -513,10 +499,8 @@ int main(int argc, char *argv[])
Info<< nl << "Looking up edges to collapse ..." << nl << endl;
Map<point> edgeToPos(edgesToCollapse.size());
forAll(edgesToCollapse, i)
for (const Pair<point>& pts : edgesToCollapse)
{
const Pair<point>& pts = edgesToCollapse[i];
label edgeI = findEdge(mesh, allBoundary, pts.first());
if (edgeI == -1 || !edgeToPos.insert(edgeI, pts.second()))
@ -590,7 +574,7 @@ int main(int argc, char *argv[])
Map<point> collapsePointToLocation(mesh.nPoints());
// Get new positions and construct collapse network
forAllConstIter(Map<point>, edgeToPos, iter)
forAllConstIters(edgeToPos, iter)
{
label edgeI = iter.key();
const edge& e = edges[edgeI];
@ -598,7 +582,7 @@ int main(int argc, char *argv[])
collapseEdge.set(edgeI);
collapsePointToLocation.set(e[1], points[e[0]]);
newPoints[e[0]] = iter();
newPoints[e[0]] = iter.val();
}
// Move master point to destination.

View File

@ -222,10 +222,8 @@ bool splitHex
const cell& cFaces = mesh.cells()[celli];
forAll(cFaces, i)
for (const label facei : cFaces)
{
label facei = cFaces[i];
const face& f = faces[facei];
label fp0 = f.find(e[0]);
@ -399,15 +397,12 @@ void collectCuts
boolList edgeIsCut(mesh.nEdges(), false);
scalarField edgeWeight(mesh.nEdges(), -GREAT);
forAllConstIter(cellSet, cellsToCut, iter)
for (const label celli : cellsToCut)
{
const label celli = iter.key();
const labelList& cEdges = cellEdges[celli];
forAll(cEdges, i)
for (const label edgeI : cEdges)
{
label edgeI = cEdges[i];
label f0, f1;
meshTools::getEdgeFaces(mesh, celli, edgeI, f0, f1);

View File

@ -197,7 +197,7 @@ elementType ^{space}"TYPE"{cspace}
forAll(slPatchCells, i)
{
if (!slPatchCells(i))
if (!slPatchCells.set(i))
{
slPatchCells.set(i, new SLList<label>);
}
@ -210,7 +210,7 @@ elementType ^{space}"TYPE"{cspace}
forAll(slPatchCells, i)
{
if (!slPatchCellFaces(i))
if (!slPatchCellFaces.set(i))
{
slPatchCellFaces.set(i, new SLList<label>);
}
@ -344,19 +344,19 @@ int main(int argc, char *argv[])
pointField points(slPoints.size());
label i = 0;
forAllConstIter(SLList<point>, slPoints, pointIter)
for (const point& pt : slPoints)
{
// Scale points for the given scale factor
points[i++] = scaleFactor * pointIter();
points[i++] = scaleFactor * pt;
}
labelList pointMap(maxNodei+1);
i = 0;
forAllConstIter(SLList<label>, slPointMap, pointMapIter)
for (const label pointi : slPointMap)
{
pointMap[pointMapIter()] = i++;
pointMap[pointi] = i++;
}
Info<< "Creating cells" << endl;
@ -364,9 +364,9 @@ int main(int argc, char *argv[])
labelList cellMap(maxCelli+1);
i = 0;
forAllConstIter(SLList<label>, slCellMap, cellMapIter)
for (const label celli : slCellMap)
{
cellMap[cellMapIter()] = i++;
cellMap[celli] = i++;
}
@ -383,66 +383,66 @@ int main(int argc, char *argv[])
cellShapeList cellShapes(slCellLabels.size());
label nCells = 0;
forAllConstIter(SLPtrList<labelList>, slCellLabels, cellIter)
for (const labelList& labels : slCellLabels)
{
if // Tetrahedron
(
cellIter()[2] == cellIter()[3]
&& cellIter()[4] == cellIter()[5]
&& cellIter()[5] == cellIter()[6]
&& cellIter()[6] == cellIter()[7]
labels[2] == labels[3]
&& labels[4] == labels[5]
&& labels[5] == labels[6]
&& labels[6] == labels[7]
)
{
labelsTet[0] = pointMap[cellIter()[0] ];
labelsTet[1] = pointMap[cellIter()[1] ];
labelsTet[2] = pointMap[cellIter()[2] ];
labelsTet[3] = pointMap[cellIter()[4] ];
labelsTet[0] = pointMap[labels[0]];
labelsTet[1] = pointMap[labels[1]];
labelsTet[2] = pointMap[labels[2]];
labelsTet[3] = pointMap[labels[4]];
cellShapes[nCells++] = cellShape(tet, labelsTet);
}
else if // Square-based pyramid
(
cellIter()[4] == cellIter()[5]
&& cellIter()[5] == cellIter()[6]
&& cellIter()[6] == cellIter()[7]
labels[4] == labels[5]
&& labels[5] == labels[6]
&& labels[6] == labels[7]
)
{
labelsPyramid[0] = pointMap[cellIter()[0] ];
labelsPyramid[1] = pointMap[cellIter()[1] ];
labelsPyramid[2] = pointMap[cellIter()[2] ];
labelsPyramid[3] = pointMap[cellIter()[3] ];
labelsPyramid[4] = pointMap[cellIter()[4] ];
labelsPyramid[0] = pointMap[labels[0]];
labelsPyramid[1] = pointMap[labels[1]];
labelsPyramid[2] = pointMap[labels[2]];
labelsPyramid[3] = pointMap[labels[3]];
labelsPyramid[4] = pointMap[labels[4]];
cellShapes[nCells++] = cellShape(pyr, labelsPyramid);
}
else if // Triangular prism
(
cellIter()[2] == cellIter()[3]
&& cellIter()[6] == cellIter()[7]
labels[2] == labels[3]
&& labels[6] == labels[7]
)
{
labelsPrism[0] = pointMap[cellIter()[0] ];
labelsPrism[1] = pointMap[cellIter()[1] ];
labelsPrism[2] = pointMap[cellIter()[2] ];
labelsPrism[3] = pointMap[cellIter()[4] ];
labelsPrism[4] = pointMap[cellIter()[5] ];
labelsPrism[5] = pointMap[cellIter()[6] ];
labelsPrism[0] = pointMap[labels[0]];
labelsPrism[1] = pointMap[labels[1]];
labelsPrism[2] = pointMap[labels[2]];
labelsPrism[3] = pointMap[labels[4]];
labelsPrism[4] = pointMap[labels[5]];
labelsPrism[5] = pointMap[labels[6]];
cellShapes[nCells++] = cellShape(prism, labelsPrism);
}
else // Hex
{
labelsHex[0] = pointMap[cellIter()[0] ];
labelsHex[1] = pointMap[cellIter()[1] ];
labelsHex[2] = pointMap[cellIter()[2] ];
labelsHex[3] = pointMap[cellIter()[3] ];
labelsHex[4] = pointMap[cellIter()[4] ];
labelsHex[5] = pointMap[cellIter()[5] ];
labelsHex[6] = pointMap[cellIter()[6] ];
labelsHex[7] = pointMap[cellIter()[7] ];
labelsHex[0] = pointMap[labels[0]];
labelsHex[1] = pointMap[labels[1]];
labelsHex[2] = pointMap[labels[2]];
labelsHex[3] = pointMap[labels[3]];
labelsHex[4] = pointMap[labels[4]];
labelsHex[5] = pointMap[labels[5]];
labelsHex[6] = pointMap[labels[6]];
labelsHex[7] = pointMap[labels[7]];
cellShapes[nCells++] = cellShape(hex, labelsHex);
}
@ -474,7 +474,7 @@ int main(int argc, char *argv[])
// Warning: tet face order has changed between version 1.9.6 and 2.0
//
label faceIndex[7][6] =
const label faceIndex[7][6] =
{
{-1, -1, -1, -1, -1, -1}, // 0
{-1, -1, -1, -1, -1, -1}, // 1
@ -494,14 +494,13 @@ int main(int argc, char *argv[])
{
SLList<face> patchFaces;
SLList<label>::iterator cellIter(slPatchCells[patchi].begin());
SLList<label>::iterator faceIter(slPatchCellFaces[patchi].begin());
auto cellIter = slPatchCells[patchi].cbegin();
auto faceIter = slPatchCellFaces[patchi].cbegin();
for
(
;
cellIter != slPatchCells[patchi].end()
&& faceIter != slPatchCellFaces[patchi].end();
cellIter.good() && faceIter.good();
++cellIter, ++faceIter
)
{
@ -519,7 +518,7 @@ int main(int argc, char *argv[])
}
boundary[patchi] = patchFaces;
patchNames[patchi] = word("patch") + name(patchi + 1);
patchNames[patchi] = "patch" + Foam::name(patchi + 1);
}
@ -660,20 +659,20 @@ int main(int argc, char *argv[])
// CellZones
labelList types = cellTypes.sortedToc();
forAll(types, j)
forAll(types, typei)
{
label cellType = types[j];
const label cellType = types[typei];
// Pick up cells in zone
DynamicList<label> addr;
SLList<label>::iterator cellMapIter = slCellMap.begin();
SLList<label>::iterator typeIter = slCellType.begin();
auto cellMapIter = slCellMap.cbegin();
auto typeIter = slCellType.cbegin();
for
(
;
typeIter != slCellType.end();
typeIter.good();
++typeIter, ++cellMapIter
)
{
@ -692,7 +691,7 @@ int main(int argc, char *argv[])
(
cellTypes[cellType],
addr,
j,
typei,
pShapeMesh.cellZones()
)
);
@ -709,7 +708,7 @@ int main(int argc, char *argv[])
pShapeMesh.removeFiles();
pShapeMesh.write();
Info<< nl << "end" << endl;
Info<< nl << "End" << endl;
return 0;
}

View File

@ -1057,9 +1057,9 @@ int main(int argc, char *argv[])
uniquify(name, patchNames);
HashTable<word>::const_iterator iter = fluentToFoamType.find(type);
const auto iter = fluentToFoamType.cfind(type);
if (iter != fluentToFoamType.end())
if (iter.found())
{
// See if we have a periodic and can derive the other side.
word neighbPatchName;

View File

@ -1236,9 +1236,9 @@ int main(int argc, char *argv[])
for
(
;
faceGroupZoneIDIter != faceGroupZoneID.end()
&& faceGroupStartIndexIter != faceGroupStartIndex.end()
&& faceGroupEndIndexIter != faceGroupEndIndex.end();
faceGroupZoneIDIter.good()
&& faceGroupStartIndexIter.good()
&& faceGroupEndIndexIter.good();
++faceGroupZoneIDIter,
++faceGroupStartIndexIter,
++faceGroupEndIndexIter
@ -1613,7 +1613,7 @@ int main(int argc, char *argv[])
SLList<label>::iterator start = cellGroupStartIndex.begin();
SLList<label>::iterator end = cellGroupEndIndex.begin();
for (; cg != cellGroupZoneID.end(); ++cg, ++start, ++end)
for (; cg.good(); ++cg, ++start, ++end)
{
const word& name = patchNameIDs[cg()];
const word& type = patchTypeIDs[cg()];
@ -1736,7 +1736,7 @@ int main(int argc, char *argv[])
// Note: cellGroupXXX are all Fluent indices (starting at 1)
// so offset before using.
for (; cg != cellGroupZoneID.end(); ++cg, ++start, ++end)
for (; cg.good(); ++cg, ++start, ++end)
{
const word& name=patchNameIDs[cg()];
const word& type=patchTypeIDs[cg()];

View File

@ -219,27 +219,27 @@ void storeCellInZone
List<DynamicList<label>>& zoneCells
)
{
Map<label>::const_iterator zoneFnd = physToZone.find(regPhys);
const auto zoneFnd = physToZone.cfind(regPhys);
if (zoneFnd == physToZone.end())
{
// New region. Allocate zone for it.
label zoneI = zoneCells.size();
zoneCells.setSize(zoneI+1);
zoneToPhys.setSize(zoneI+1);
Info<< "Mapping region " << regPhys << " to Foam cellZone "
<< zoneI << endl;
physToZone.insert(regPhys, zoneI);
zoneToPhys[zoneI] = regPhys;
zoneCells[zoneI].append(celli);
}
else
if (zoneFnd.found())
{
// Existing zone for region
zoneCells[zoneFnd()].append(celli);
}
else
{
// New region. Allocate zone for it.
const label zonei = zoneCells.size();
zoneCells.setSize(zonei+1);
zoneToPhys.setSize(zonei+1);
Info<< "Mapping region " << regPhys << " to Foam cellZone "
<< zonei << endl;
physToZone.insert(regPhys, zonei);
zoneToPhys[zonei] = regPhys;
zoneCells[zonei].append(celli);
}
}
@ -516,10 +516,15 @@ void readCells
renumber(mshToFoam, triPoints);
Map<label>::iterator regFnd = physToPatch.find(regPhys);
const auto regFnd = physToPatch.cfind(regPhys);
label patchi = -1;
if (regFnd == physToPatch.end())
if (regFnd.found())
{
// Existing patch for region
patchi = regFnd();
}
else
{
// New region. Allocate patch for it.
patchi = patchFaces.size();
@ -532,11 +537,6 @@ void readCells
physToPatch.insert(regPhys, patchi);
patchToPhys[patchi] = regPhys;
}
else
{
// Existing patch for region
patchi = regFnd();
}
// Add triangle to correct patchFaces.
patchFaces[patchi].append(triPoints);
@ -549,10 +549,15 @@ void readCells
renumber(mshToFoam, quadPoints);
Map<label>::iterator regFnd = physToPatch.find(regPhys);
const auto regFnd = physToPatch.cfind(regPhys);
label patchi = -1;
if (regFnd == physToPatch.end())
if (regFnd.found())
{
// Existing patch for region
patchi = regFnd();
}
else
{
// New region. Allocate patch for it.
patchi = patchFaces.size();
@ -565,11 +570,6 @@ void readCells
physToPatch.insert(regPhys, patchi);
patchToPhys[patchi] = regPhys;
}
else
{
// Existing patch for region
patchi = regFnd();
}
// Add quad to correct patchFaces.
patchFaces[patchi].append(quadPoints);
@ -748,15 +748,15 @@ void readCells
Info<< "CellZones:" << nl
<< "Zone\tSize" << endl;
forAll(zoneCells, zoneI)
forAll(zoneCells, zonei)
{
zoneCells[zoneI].shrink();
zoneCells[zonei].shrink();
const labelList& zCells = zoneCells[zoneI];
const labelList& zCells = zoneCells[zonei];
if (zCells.size())
{
Info<< " " << zoneI << '\t' << zCells.size() << endl;
Info<< " " << zonei << '\t' << zCells.size() << endl;
}
}
Info<< endl;
@ -870,11 +870,11 @@ int main(int argc, char *argv[])
label nValidCellZones = 0;
forAll(zoneCells, zoneI)
forAll(zoneCells, zonei)
{
if (zoneCells[zoneI].size())
if (zoneCells[zonei].size())
{
nValidCellZones++;
++nValidCellZones;
}
}
@ -895,18 +895,13 @@ int main(int argc, char *argv[])
forAll(boundaryPatchNames, patchi)
{
label physReg = patchToPhys[patchi];
boundaryPatchNames[patchi] =
physicalNames.lookup
(
patchToPhys[patchi],
"patch" + Foam::name(patchi) // default name
);
Map<word>::const_iterator iter = physicalNames.find(physReg);
if (iter != physicalNames.end())
{
boundaryPatchNames[patchi] = iter();
}
else
{
boundaryPatchNames[patchi] = word("patch") + name(patchi);
}
Info<< "Patch " << patchi << " gets name "
<< boundaryPatchNames[patchi] << endl;
}
@ -1001,17 +996,17 @@ int main(int argc, char *argv[])
Info<< "FaceZones:" << nl
<< "Zone\tSize" << endl;
forAll(zoneFaces, zoneI)
forAll(zoneFaces, zonei)
{
zoneFaces[zoneI].shrink();
zoneFaces[zonei].shrink();
const labelList& zFaces = zoneFaces[zoneI];
const labelList& zFaces = zoneFaces[zonei];
if (zFaces.size())
{
nValidFaceZones++;
++nValidFaceZones;
Info<< " " << zoneI << '\t' << zFaces.size() << endl;
Info<< " " << zonei << '\t' << zFaces.size() << endl;
}
}
Info<< endl;
@ -1036,31 +1031,30 @@ int main(int argc, char *argv[])
nValidCellZones = 0;
forAll(zoneCells, zoneI)
forAll(zoneCells, zonei)
{
if (zoneCells[zoneI].size())
if (zoneCells[zonei].size())
{
label physReg = zoneToPhys[zoneI];
const word zoneName
(
physicalNames.lookup
(
zoneToPhys[zonei],
"cellZone_" + Foam::name(zonei) // default name
)
);
Map<word>::const_iterator iter = physicalNames.find(physReg);
word zoneName = "cellZone_" + name(zoneI);
if (iter != physicalNames.end())
{
zoneName = iter();
}
Info<< "Writing zone " << zoneI << " to cellZone "
Info<< "Writing zone " << zonei << " to cellZone "
<< zoneName << " and cellSet"
<< endl;
cellSet cset(mesh, zoneName, zoneCells[zoneI]);
cellSet cset(mesh, zoneName, zoneCells[zonei]);
cset.write();
cz[nValidCellZones] = new cellZone
(
zoneName,
zoneCells[zoneI],
zoneCells[zonei],
nValidCellZones,
mesh.cellZones()
);
@ -1075,31 +1069,30 @@ int main(int argc, char *argv[])
nValidFaceZones = 0;
forAll(zoneFaces, zoneI)
forAll(zoneFaces, zonei)
{
if (zoneFaces[zoneI].size())
if (zoneFaces[zonei].size())
{
label physReg = patchToPhys[zoneI];
const word zoneName
(
physicalNames.lookup
(
patchToPhys[zonei],
"faceZone_" + Foam::name(zonei) // default name
)
);
Map<word>::const_iterator iter = physicalNames.find(physReg);
word zoneName = "faceZone_" + name(zoneI);
if (iter != physicalNames.end())
{
zoneName = iter();
}
Info<< "Writing zone " << zoneI << " to faceZone "
Info<< "Writing zone " << zonei << " to faceZone "
<< zoneName << " and faceSet"
<< endl;
faceSet fset(mesh, zoneName, zoneFaces[zoneI]);
faceSet fset(mesh, zoneName, zoneFaces[zonei]);
fset.write();
fz[nValidFaceZones] = new faceZone
(
zoneName,
zoneFaces[zoneI],
zoneFaces[zonei],
true, // all are flipped
nValidFaceZones,
mesh.faceZones()

View File

@ -327,10 +327,8 @@ if
{
scalar minz = GREAT;
forAllConstIter(SLList<face>, pFaces[CYLINDERHEAD][0], iter)
for (const face& pf : pFaces[CYLINDERHEAD][0])
{
const face& pf = iter();
forAll(pf, pfi)
{
minz = min(minz, points[pf[pfi]].z());
@ -341,10 +339,8 @@ if
SLList<face> newLinerFaces;
forAllConstIter(SLList<face>, pFaces[LINER][0], iter)
for (const face& pf : pFaces[LINER][0])
{
const face& pf = iter();
scalar minfz = GREAT;
forAll(pf, pfi)
{
@ -370,10 +366,8 @@ if
SLList<face> newCylinderHeadFaces;
forAllConstIter(SLList<face>, pFaces[CYLINDERHEAD][0], iter)
for (const face& pf : pFaces[CYLINDERHEAD][0])
{
const face& pf = iter();
scalar minfz = GREAT;
forAll(pf, pfi)
{
@ -421,12 +415,13 @@ if (pFaces[WEDGE].size() && pFaces[WEDGE][0].size())
const scalar tanTheta = Foam::tan(degToRad(2.5));
SLList<face>::iterator iterf = pFaces[WEDGE][0].begin();
SLList<face>::iterator iterb = pFaces[WEDGE][1].begin();
auto iterf = pFaces[WEDGE][0].begin();
auto iterb = pFaces[WEDGE][1].begin();
for
(
;
iterf != pFaces[WEDGE][0].end() && iterb != pFaces[WEDGE][1].end();
iterf.good() && iterb.good();
++iterf, ++iterb
)
{
@ -441,9 +436,9 @@ if (pFaces[WEDGE].size() && pFaces[WEDGE][0].size())
{
pFaces[CYCLIC].setSize(1);
pFaces[CYCLIC][0] = pFaces[WEDGE][0];
forAllIter(SLList<face>, pFaces[WEDGE][1], iterb)
for (const face& pf : pFaces[WEDGE][1])
{
pFaces[CYCLIC][0].append(iterb());
pFaces[CYCLIC][0].append(pf);
}
pFaces[WEDGE].clear();

View File

@ -213,18 +213,16 @@ int main(int argc, char *argv[])
// Get the four (outwards pointing) faces of the cell
faceList tris(cll.faces());
forAll(tris, i)
for (const face& f : tris)
{
const face& f = tris[i];
// Is there any boundary face with same vertices?
// (uses commutative hash)
auto iter = vertsToBoundary.find(triFace(f[0], f[1], f[2]));
if (iter.found())
{
label facei = iter.object();
const triFace& tri = iter.key();
const label facei = iter.val();
// Determine orientation of tri v.s. cell centre.
point cc(cll.centre(points));

View File

@ -438,23 +438,22 @@ int main(int argc, char *argv[])
// Get Foam patchID and update region->patch table.
label patchi = 0;
Map<label>::iterator patchFind =
regionToPatch.find(region);
const auto patchFind = regionToPatch.cfind(region);
if (patchFind == regionToPatch.end())
if (patchFind.found())
{
patchi = *patchFind;
}
else
{
patchi = nPatches;
Info<< "Mapping tetgen region " << region
<< " to Foam patch "
<< " to patch "
<< patchi << endl;
regionToPatch.insert(region, nPatches++);
}
else
{
patchi = patchFind();
}
boundaryPatch[facei] = patchi;
@ -479,7 +478,7 @@ int main(int argc, char *argv[])
// Print region to patch mapping
Info<< "Regions:" << endl;
forAllConstIter(Map<label>, regionToPatch, iter)
forAllConstIters(regionToPatch, iter)
{
Info<< " region:" << iter.key() << '\t' << "patch:"
<< iter() << endl;
@ -493,7 +492,7 @@ int main(int argc, char *argv[])
forAll(patchNames, patchi)
{
patchNames[patchi] = word("patch") + name(patchi);
patchNames[patchi] = "patch" + Foam::name(patchi);
}
wordList patchTypes(nPatches, polyPatch::typeName);

View File

@ -119,32 +119,32 @@ void writePoints
label v0;
Map<label>::iterator e0Fnd = pointToObj.find(e[0]);
const auto e0Fnd = pointToObj.cfind(e[0]);
if (e0Fnd == pointToObj.end())
if (e0Fnd.found())
{
meshTools::writeOBJ(str, mesh.points()[e[0]]);
v0 = vertI++;
pointToObj.insert(e[0], v0);
v0 = *e0Fnd;
}
else
{
v0 = e0Fnd();
v0 = vertI++;
meshTools::writeOBJ(str, mesh.points()[e[0]]);
pointToObj.insert(e[0], v0);
}
label v1;
Map<label>::iterator e1Fnd = pointToObj.find(e[1]);
const auto e1Fnd = pointToObj.cfind(e[1]);
if (e1Fnd == pointToObj.end())
if (e1Fnd.found())
{
meshTools::writeOBJ(str, mesh.points()[e[1]]);
v1 = vertI++;
pointToObj.insert(e[1], v1);
v1 = *e1Fnd;
}
else
{
v1 = e1Fnd();
v1 = vertI++;
meshTools::writeOBJ(str, mesh.points()[e[1]]);
pointToObj.insert(e[1], v1);
}

View File

@ -68,7 +68,7 @@
forAllConstIters(zoneMap, iter)
{
const word& zoneName = iter.key();
const label zonei = iter.object();
const label zonei = iter.val();
cz[zonei] = new cellZone
(

View File

@ -1796,9 +1796,8 @@ int main(int argc, char *argv[])
forAll(zones, i)
{
const faceSet& fz = zones[i];
forAllConstIter(faceSet, fz, iter)
for (const label facei : fz)
{
label facei = iter.key();
if (mesh.isInternalFace(facei))
{
FatalIOErrorInFunction(dict)
@ -1834,9 +1833,9 @@ int main(int argc, char *argv[])
}
label nShadowFaces = 0;
forAll(shadowZones, i)
for (const faceSet& fz : shadowZones)
{
nShadowFaces += shadowZones[i].size();
nShadowFaces += fz.size();
}
if (nExtrudeFaces != nShadowFaces)
@ -1856,9 +1855,8 @@ int main(int argc, char *argv[])
forAll(shadowZones, i)
{
const faceSet& fz = shadowZones[i];
forAllConstIter(faceSet, fz, iter)
for (const label facei : fz)
{
label facei = iter.key();
if (mesh.isInternalFace(facei))
{
FatalIOErrorInFunction(dict)
@ -1885,7 +1883,6 @@ int main(int argc, char *argv[])
checkZoneInside(mesh, zoneNames, zoneID, extrudeMeshFaces, isInternal);
const pointField& extrudePoints = extrudePatch.localPoints();
const faceList& extrudeFaces = extrudePatch.localFaces();
const labelListList& edgeFaces = extrudePatch.edgeFaces();

View File

@ -154,7 +154,7 @@ void Foam::patchToPoly2DMesh::addPatchFacesToFaces()
forAll(patchNames_, patchi)
{
forAllConstIter(EdgeMap<label>, mapEdgesRegion_, eIter)
forAllConstIters(mapEdgesRegion_, eIter)
{
if (eIter() == patchi)
{

View File

@ -409,18 +409,15 @@ void Foam::DistributedDelaunayMesh<Triangulation>::markVerticesToRefer
continue;
}
Map<labelList>::const_iterator iter =
circumsphereOverlaps.find(cit->cellIndex());
const auto iter = circumsphereOverlaps.cfind(cit->cellIndex());
// Pre-tested circumsphere potential influence
if (iter != circumsphereOverlaps.cend())
if (iter.found())
{
const labelList& citOverlaps = iter();
forAll(citOverlaps, cOI)
for (const label proci : citOverlaps)
{
label proci = citOverlaps[cOI];
for (int i = 0; i < 4; i++)
{
Vertex_handle v = cit->vertex(i);
@ -1025,13 +1022,4 @@ Foam::DistributedDelaunayMesh<Triangulation>::rangeInsertReferredWithInfo
}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -96,12 +96,12 @@ void Foam::PrintTable<KeyType, DataType>::print
Map<DataType>& key = combinedTable[iter.key()];
key.insert(proci, iter.object());
key.insert(proci, iter.val());
forAllConstIters(key, dataIter)
{
std::ostringstream buf;
buf << dataIter.object();
buf << dataIter.val();
largestDataLength = max
(

View File

@ -212,10 +212,8 @@ bool Foam::linearDistance::setCellSize(const pointField& pts)
{
// labelHashSet surfaceAlreadyHit(surfaceCellSize_.size());
// forAll(pts, ptI)
// for (const Foam::point& pt : pts)
// {
// const Foam::point& pt = pts[ptI];
// List<pointIndexHit> hits;
// surface_.findNearest

View File

@ -192,10 +192,8 @@ bool Foam::uniformDistance::setCellSize
{
// labelHashSet surfaceAlreadyHit(surface_.size());
//
// forAll(pts, ptI)
// for (const Foam::point& pt : pts)
// {
// const Foam::point& pt = pts[ptI];
//
// List<pointIndexHit> hits;
//
// surface_.findNearest

View File

@ -2278,11 +2278,11 @@ void Foam::conformalVoronoiMesh::reinsertSurfaceConformation()
Vb& v = surfaceConformationVertices_[vI];
label& vIndex = v.index();
Map<label>::const_iterator iter = oldToNewIndices.find(vIndex);
const auto iter = oldToNewIndices.cfind(vIndex);
if (iter != oldToNewIndices.end())
if (iter.found())
{
const label newIndex = iter();
const label newIndex = *iter;
if (newIndex != -1)
{

View File

@ -411,7 +411,7 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating
);
forAllConstIter(Map<Foam::point>, masterPoints, iter)
forAllConstIters(masterPoints, iter)
{
const Foam::point& pt = masterPoints[iter.key()];
const vertexType ptType = masterPointsTypes[iter.key()];

View File

@ -618,12 +618,11 @@ void Foam::featurePointConformer::reIndexPointPairs
{
const label currentIndex = featurePointVertices_[vI].index();
Map<label>::const_iterator newIndexIter =
oldToNewIndices.find(currentIndex);
const auto newIndexIter = oldToNewIndices.cfind(currentIndex);
if (newIndexIter != oldToNewIndices.end())
if (newIndexIter.found())
{
featurePointVertices_[vI].index() = newIndexIter();
featurePointVertices_[vI].index() = *newIndexIter;
}
}

View File

@ -78,7 +78,7 @@ Foam::Ostream& Foam::operator<<
os << " "
<< extendedFeatureEdgeMesh::edgeStatusNames_[iter.key()]
<< " = "
<< iter.object()
<< iter.val()
<< endl;
}

View File

@ -509,7 +509,7 @@ Foam::conformationSurfaces::conformationSurfaces
}
}
forAllConstIter(Map<sideVolumeType>, regionVolumeTypes[surfI], iter)
forAllConstIters(regionVolumeTypes[surfI], iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();
@ -518,7 +518,7 @@ Foam::conformationSurfaces::conformationSurfaces
}
const Map<autoPtr<dictionary>>& localInfo = regionPatchInfo[surfI];
forAllConstIter(Map<autoPtr<dictionary>>, localInfo, iter)
forAllConstIters(localInfo, iter)
{
label globalRegionI = regionOffset_[surfI] + iter.key();

View File

@ -117,10 +117,8 @@ inline bool Foam::pointPairs<Triangulation>::addPointPair
const DynamicList<labelPair>& slaves
)
{
forAll(slaves, sI)
for (const labelPair& slave : slaves)
{
const labelPair& slave = slaves[sI];
addPointPair(master, slave);
}
@ -190,10 +188,9 @@ void Foam::pointPairs<Triangulation>::reIndex(const Map<label>& oldToNewIndices)
if (start.second() == Pstream::myProcNo())
{
Map<label>::const_iterator iter2 =
oldToNewIndices.find(start.first());
const auto iter2 = oldToNewIndices.cfind(start.first());
if (iter2 != oldToNewIndices.end())
if (iter2.found())
{
if (iter2() != -1)
{
@ -208,10 +205,9 @@ void Foam::pointPairs<Triangulation>::reIndex(const Map<label>& oldToNewIndices)
if (end.second() == Pstream::myProcNo())
{
Map<label>::const_iterator iter2 =
oldToNewIndices.find(end.first());
const auto iter2 = oldToNewIndices.cfind(end.first());
if (iter2 != oldToNewIndices.end())
if (iter2.found())
{
if (iter2() != -1)
{

View File

@ -55,7 +55,7 @@ void Foam::shortEdgeFilter2D::assignBoundaryPointRegions
List<DynamicList<label>>& boundaryPointRegions
) const
{
forAllConstIter(EdgeMap<label>, mapEdgesRegion_, iter)
forAllConstIters(mapEdgesRegion_, iter)
{
const edge& e = iter.key();
const label& regionI = iter();
@ -188,7 +188,7 @@ Foam::shortEdgeFilter2D::shortEdgeFilter2D
Info<< "Writing indirectPatchEdges to " << str.name() << endl;
forAllConstIter(EdgeMap<label>, indirectPatchEdge_, iter)
forAllConstIters(indirectPatchEdge_, iter)
{
const edge& e = iter.key();

View File

@ -293,7 +293,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
}
// Overwrite with region specific information
forAllConstIter(Map<label>, regionMinLevel[surfi], iter)
forAllConstIters(regionMinLevel[surfi], iter)
{
label globalRegioni = regionOffset[surfi] + iter.key();
@ -305,7 +305,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
}
const Map<autoPtr<dictionary>>& localInfo = regionPatchInfo[surfi];
forAllConstIter(Map<autoPtr<dictionary>>, localInfo, iter)
forAllConstIters(localInfo, iter)
{
label globalRegioni = regionOffset[surfi] + iter.key();
patchInfo.set(globalRegioni, iter()().clone());
@ -403,7 +403,7 @@ void extractSurface
// Allocate zone/patch for all patches
HashTable<label> compactZoneID(1024);
forAllConstIter(HashTable<label>, patchSize, iter)
forAllConstIters(patchSize, iter)
{
label sz = compactZoneID.size();
compactZoneID.insert(iter.key(), sz);
@ -413,7 +413,7 @@ void extractSurface
// Rework HashTable into labelList just for speed of conversion
labelList patchToCompactZone(bMesh.size(), -1);
forAllConstIter(HashTable<label>, compactZoneID, iter)
forAllConstIters(compactZoneID, iter)
{
label patchi = bMesh.findPatchID(iter.key());
if (patchi != -1)
@ -504,7 +504,7 @@ void extractSurface
// Zones
surfZoneIdentifierList surfZones(compactZoneID.size());
forAllConstIter(HashTable<label>, compactZoneID, iter)
forAllConstIters(compactZoneID, iter)
{
surfZones[iter()] = surfZoneIdentifier(iter.key(), iter());
Info<< "surfZone " << iter() << " : " << surfZones[iter()].name()

View File

@ -241,7 +241,7 @@ bool Foam::checkWedges
if (setPtr)
{
setPtr->resize(2*nEdgesInError);
forAllConstIter(EdgeMap<label>, edgesInError, iter)
forAllConstIters(edgesInError, iter)
{
if (iter() >= 0)
{

View File

@ -307,9 +307,9 @@ void Foam::mergeAndWrite
// Determine faces on outside of cellSet
bitSet isInSet(mesh.nCells());
forAllConstIter(cellSet, set, iter)
for (const label celli : set)
{
isInSet.set(iter.key());
isInSet.set(celli);
}

View File

@ -157,9 +157,9 @@ void subsetVolFields
(
mesh.objectRegistry::lookupClass<GeoField>()
);
forAllConstIter(typename HashTable<const GeoField*>, fields, iter)
forAllConstIters(fields, iter)
{
const GeoField& fld = *iter();
const GeoField& fld = *iter.val();
Info<< "Mapping field " << fld.name() << endl;
@ -211,9 +211,9 @@ void subsetSurfaceFields
(
mesh.objectRegistry::lookupClass<GeoField>()
);
forAllConstIter(typename HashTable<const GeoField*>, fields, iter)
forAllConstIters(fields, iter)
{
const GeoField& fld = *iter();
const GeoField& fld = *iter.val();
Info<< "Mapping field " << fld.name() << endl;
@ -278,19 +278,16 @@ void addToInterface
max(ownRegion, neiRegion)
);
EdgeMap<Map<label>>::iterator iter = regionsToSize.find
(
interface
);
auto iter = regionsToSize.find(interface);
if (iter != regionsToSize.end())
if (iter.found())
{
// Check if zone present
Map<label>::iterator zoneFnd = iter().find(zoneID);
if (zoneFnd != iter().end())
auto zoneIter = iter().find(zoneID);
if (zoneIter.found())
{
// Found zone. Increment count.
zoneFnd()++;
++(*zoneIter);
}
else
{
@ -398,29 +395,26 @@ void getInterfaceSizes
EdgeMap<Map<label>> slaveSizes(fromSlave);
forAllConstIter(EdgeMap<Map<label>>, slaveSizes, slaveIter)
forAllConstIters(slaveSizes, slaveIter)
{
EdgeMap<Map<label>>::iterator masterIter =
regionsToSize.find(slaveIter.key());
const Map<label>& slaveInfo = *slaveIter;
if (masterIter != regionsToSize.end())
auto masterIter = regionsToSize.find(slaveIter.key());
if (masterIter.found())
{
// Same inter-region
const Map<label>& slaveInfo = slaveIter();
Map<label>& masterInfo = masterIter();
Map<label>& masterInfo = *masterIter;
forAllConstIter(Map<label>, slaveInfo, iter)
forAllConstIters(slaveInfo, iter)
{
label zoneID = iter.key();
label slaveSize = iter();
const label zoneID = iter.key();
const label slaveSize = iter.val();
Map<label>::iterator zoneFnd = masterInfo.find
(
zoneID
);
if (zoneFnd != masterInfo.end())
auto zoneIter = masterInfo.find(zoneID);
if (zoneIter.found())
{
zoneFnd() += slaveSize;
*zoneIter += slaveSize;
}
else
{
@ -430,7 +424,7 @@ void getInterfaceSizes
}
else
{
regionsToSize.insert(slaveIter.key(), slaveIter());
regionsToSize.insert(slaveIter.key(), slaveInfo);
}
}
}
@ -458,9 +452,9 @@ void getInterfaceSizes
// Now we have the global sizes of all inter-regions.
// Invert this on master and distribute.
label nInterfaces = 0;
forAllConstIter(EdgeMap<Map<label>>, regionsToSize, iter)
forAllConstIters(regionsToSize, iter)
{
const Map<label>& info = iter();
const Map<label>& info = iter.val();
nInterfaces += info.size();
}
@ -470,14 +464,15 @@ void getInterfaceSizes
EdgeMap<Map<label>> regionsToInterface(nInterfaces);
nInterfaces = 0;
forAllConstIter(EdgeMap<Map<label>>, regionsToSize, iter)
forAllConstIters(regionsToSize, iter)
{
const edge& e = iter.key();
const Map<label>& info = iter.val();
const word& name0 = regionNames[e[0]];
const word& name1 = regionNames[e[1]];
const Map<label>& info = iter();
forAllConstIter(Map<label>, info, infoIter)
forAllConstIters(info, infoIter)
{
interfaces[nInterfaces] = iter.key();
label zoneID = infoIter.key();
@ -1666,9 +1661,9 @@ int main(int argc, char *argv[])
blockedFace.setSize(mesh.nFaces(), false);
forAllConstIter(faceSet, blockedFaceSet, iter)
for (const label facei : blockedFaceSet)
{
blockedFace[iter.key()] = true;
blockedFace[facei] = true;
}
}

View File

@ -842,16 +842,11 @@ int main(int argc, char *argv[])
label i = 0;
forAllIter
(
Cloud<indexedParticle>,
lagrangianPositions[cloudI],
iter
)
for (indexedParticle& p : lagrangianPositions[cloudI])
{
iter().index() = i++;
p.index() = i++;
label celli = iter().cell();
label celli = p.cell();
// Check
if (celli < 0 || celli >= mesh.nCells())
@ -859,14 +854,14 @@ int main(int argc, char *argv[])
FatalErrorInFunction
<< "Illegal cell number " << celli
<< " for particle with index "
<< iter().index()
<< p.index()
<< " at position "
<< iter().position() << nl
<< p.position() << nl
<< "Cell number should be between 0 and "
<< mesh.nCells()-1 << nl
<< "On this mesh the particle should"
<< " be in cell "
<< mesh.findCell(iter().position())
<< mesh.findCell(p.position())
<< exit(FatalError);
}
@ -876,7 +871,7 @@ int main(int argc, char *argv[])
new SLList<indexedParticle*>();
}
cellParticles[cloudI][celli]->append(&iter());
cellParticles[cloudI][celli]->append(&p);
}
// Read fields

View File

@ -55,16 +55,16 @@ void Foam::domainDecomposition::addInterProcFace
List<DynamicList<DynamicList<label>>>& interPatchFaces
) const
{
Map<label>::iterator patchiter = nbrToInterPatch[ownerProc].find(nbrProc);
// Introduce turning index only for internal faces (are duplicated).
label ownerIndex = facei+1;
label nbrIndex = -(facei+1);
const label ownerIndex = facei+1;
const label nbrIndex = -(facei+1);
if (patchiter != nbrToInterPatch[ownerProc].end())
const auto patchiter = nbrToInterPatch[ownerProc].cfind(nbrProc);
if (patchiter.found())
{
// Existing interproc patch. Add to both sides.
label toNbrProcPatchi = patchiter();
const label toNbrProcPatchi = *patchiter;
interPatchFaces[ownerProc][toNbrProcPatchi].append(ownerIndex);
if (isInternalFace(facei))
@ -76,8 +76,9 @@ void Foam::domainDecomposition::addInterProcFace
else
{
// Create new interproc patches.
label toNbrProcPatchi = nbrToInterPatch[ownerProc].size();
const label toNbrProcPatchi = nbrToInterPatch[ownerProc].size();
nbrToInterPatch[ownerProc].insert(nbrProc, toNbrProcPatchi);
DynamicList<label> oneFace;
oneFace.append(ownerIndex);
interPatchFaces[ownerProc].append(oneFace);

View File

@ -435,59 +435,55 @@ void Foam::faMeshDecomposition::decomposeMesh()
// inside boundaries for the owner processor and try to find
// this inter-processor patch.
const label ownerProc = faceToProc_[owner[edgeI]];
const label neighbourProc = faceToProc_[neighbour[edgeI]];
SLList<label>::iterator curInterProcBdrsOwnIter =
interProcBoundaries[ownerProc].begin();
SLList<SLList<label>>::iterator curInterProcBEdgesOwnIter =
interProcBEdges[ownerProc].begin();
bool interProcBouFound = false;
const label ownProc = faceToProc_[owner[edgeI]];
const label neiProc = faceToProc_[neighbour[edgeI]];
auto curInterProcBdrsOwnIter =
interProcBoundaries[ownProc].cbegin();
auto curInterProcBEdgesOwnIter =
interProcBEdges[ownProc].begin();
// WARNING: Synchronous SLList iterators
for
(
;
curInterProcBdrsOwnIter
!= interProcBoundaries[ownerProc].end()
&& curInterProcBEdgesOwnIter
!= interProcBEdges[ownerProc].end();
++curInterProcBdrsOwnIter, ++curInterProcBEdgesOwnIter
curInterProcBdrsOwnIter.good()
&& curInterProcBEdgesOwnIter.good();
++curInterProcBdrsOwnIter,
++curInterProcBEdgesOwnIter
)
{
if (curInterProcBdrsOwnIter() == neighbourProc)
if (curInterProcBdrsOwnIter() == neiProc)
{
// the inter - processor boundary exists. Add the face
interProcBouFound = true;
bool neighbourFound = false;
curInterProcBEdgesOwnIter().append(edgeI);
SLList<label>::iterator curInterProcBdrsNeiIter =
interProcBoundaries[neighbourProc].begin();
auto curInterProcBdrsNeiIter =
interProcBoundaries[neiProc].cbegin();
SLList<SLList<label>>::iterator
curInterProcBEdgesNeiIter =
interProcBEdges[neighbourProc].begin();
bool neighbourFound = false;
auto curInterProcBEdgesNeiIter =
interProcBEdges[neiProc].begin();
// WARNING: Synchronous SLList iterators
for
(
;
curInterProcBdrsNeiIter !=
interProcBoundaries[neighbourProc].end()
&& curInterProcBEdgesNeiIter !=
interProcBEdges[neighbourProc].end();
curInterProcBdrsNeiIter.good()
&& curInterProcBEdgesNeiIter.good();
++curInterProcBdrsNeiIter,
++curInterProcBEdgesNeiIter
)
{
if (curInterProcBdrsNeiIter() == ownerProc)
if (curInterProcBdrsNeiIter() == ownProc)
{
// boundary found. Add the face
neighbourFound = true;
@ -504,7 +500,7 @@ void Foam::faMeshDecomposition::decomposeMesh()
("faDomainDecomposition::decomposeMesh()")
<< "Inconsistency in inter - "
<< "processor boundary lists for processors "
<< ownerProc << " and " << neighbourProc
<< ownProc << " and " << neiProc
<< abort(FatalError);
}
}
@ -520,12 +516,13 @@ void Foam::faMeshDecomposition::decomposeMesh()
// set the new addressing information
// owner
interProcBoundaries[ownerProc].append(neighbourProc);
interProcBEdges[ownerProc].append(SLList<label>(edgeI));
interProcBoundaries[ownProc].append(neiProc);
interProcBEdges[ownProc].append(SLList<label>(edgeI));
// neighbour
interProcBoundaries[neighbourProc].append(ownerProc);
interProcBEdges[neighbourProc].append
interProcBoundaries[neiProc].append(ownProc);
interProcBEdges[neiProc]
.append
(
SLList<label>(edgeI)
);
@ -624,64 +621,59 @@ void Foam::faMeshDecomposition::decomposeMesh()
cyclicParallel_ = true;
label ownerProc = faceToProc_[firstEdgeFaces[edgeI]];
label neighbourProc =
bool interProcBouFound = false;
const label ownProc =
faceToProc_[firstEdgeFaces[edgeI]];
const label neiProc =
faceToProc_[secondEdgeFaces[edgeI]];
SLList<label>::iterator curInterProcBdrsOwnIter =
interProcBoundaries[ownerProc].begin();
auto curInterProcBdrsOwnIter =
interProcBoundaries[ownProc].cbegin();
SLList<SLList<label>>::iterator
curInterProcBEdgesOwnIter =
interProcBEdges[ownerProc].begin();
bool interProcBouFound = false;
auto curInterProcBEdgesOwnIter =
interProcBEdges[ownProc].begin();
// WARNING: Synchronous SLList iterators
for
(
;
curInterProcBdrsOwnIter !=
interProcBoundaries[ownerProc].end()
&& curInterProcBEdgesOwnIter !=
interProcBEdges[ownerProc].end();
curInterProcBdrsOwnIter.good()
&& curInterProcBEdgesOwnIter.good();
++curInterProcBdrsOwnIter,
++curInterProcBEdgesOwnIter
)
{
if (curInterProcBdrsOwnIter() == neighbourProc)
if (curInterProcBdrsOwnIter() == neiProc)
{
// the inter - processor boundary exists.
// Add the face
interProcBouFound = true;
curInterProcBEdgesOwnIter().append
(patchStart + edgeI);
SLList<label>::iterator curInterProcBdrsNeiIter
= interProcBoundaries[neighbourProc].begin();
SLList<SLList<label>>::iterator
curInterProcBEdgesNeiIter =
interProcBEdges[neighbourProc].begin();
bool neighbourFound = false;
curInterProcBEdgesOwnIter()
.append(patchStart + edgeI);
auto curInterProcBdrsNeiIter
= interProcBoundaries[neiProc].cbegin();
auto curInterProcBEdgesNeiIter =
interProcBEdges[neiProc].begin();
// WARNING: Synchronous SLList iterators
for
(
;
curInterProcBdrsNeiIter
!= interProcBoundaries[neighbourProc].end()
&& curInterProcBEdgesNeiIter
!= interProcBEdges[neighbourProc].end();
curInterProcBdrsNeiIter.good()
&& curInterProcBEdgesNeiIter.good();
++curInterProcBdrsNeiIter,
++curInterProcBEdgesNeiIter
)
{
if (curInterProcBdrsNeiIter() == ownerProc)
if (curInterProcBdrsNeiIter() == ownProc)
{
// boundary found. Add the face
neighbourFound = true;
@ -705,7 +697,7 @@ void Foam::faMeshDecomposition::decomposeMesh()
"faDomainDecomposition::decomposeMesh()"
) << "Inconsistency in inter-processor "
<< "boundary lists for processors "
<< ownerProc << " and " << neighbourProc
<< ownProc << " and " << neiProc
<< " in cyclic boundary matching"
<< abort(FatalError);
}
@ -722,15 +714,13 @@ void Foam::faMeshDecomposition::decomposeMesh()
// set the new addressing information
// owner
interProcBoundaries[ownerProc]
.append(neighbourProc);
interProcBEdges[ownerProc]
interProcBoundaries[ownProc].append(neiProc);
interProcBEdges[ownProc]
.append(SLList<label>(patchStart + edgeI));
// neighbour
interProcBoundaries[neighbourProc]
.append(ownerProc);
interProcBEdges[neighbourProc]
interProcBoundaries[neiProc].append(ownProc);
interProcBEdges[neiProc]
.append
(
SLList<label>
@ -745,13 +735,13 @@ void Foam::faMeshDecomposition::decomposeMesh()
else
{
// This cyclic edge remains on the processor
label ownerProc = faceToProc_[firstEdgeFaces[edgeI]];
label ownProc = faceToProc_[firstEdgeFaces[edgeI]];
// add the edge
procEdgeList[ownerProc].append(patchStart + edgeI);
procEdgeList[ownProc].append(patchStart + edgeI);
// increment the number of edges for this patch
procPatchSize_[ownerProc][patchI]++;
procPatchSize_[ownProc][patchI]++;
// Note: I cannot add the other side of the cyclic
// boundary here because this would violate the order.
@ -771,14 +761,14 @@ void Foam::faMeshDecomposition::decomposeMesh()
)
{
// This cyclic edge remains on the processor
label ownerProc = faceToProc_[firstEdgeFaces[edgeI]];
label ownProc = faceToProc_[firstEdgeFaces[edgeI]];
// add the second edge
procEdgeList[ownerProc].append
procEdgeList[ownProc].append
(patchStart + cycOffset + edgeI);
// increment the number of edges for this patch
procPatchSize_[ownerProc][patchI]++;
procPatchSize_[ownProc][patchI]++;
}
}
}
@ -806,15 +796,9 @@ void Foam::faMeshDecomposition::decomposeMesh()
// calculate the size
label nEdgesOnProcessor = curProcEdges.size();
for
(
SLList<SLList<label>>::iterator curInterProcBEdgesIter =
interProcBEdges[procI].begin();
curInterProcBEdgesIter != interProcBEdges[procI].end();
++curInterProcBEdgesIter
)
for (const auto& bedges : interProcBEdges)
{
nEdgesOnProcessor += curInterProcBEdgesIter().size();
nEdgesOnProcessor += bedges.size();
}
curProcEdgeAddressing.setSize(nEdgesOnProcessor);
@ -830,16 +814,11 @@ void Foam::faMeshDecomposition::decomposeMesh()
// Add internal and boundary edges
// Remember to increment the index by one such that the
// turning index works properly.
for
(
SLList<label>::iterator curProcEdgeIter = curProcEdges.begin();
curProcEdgeIter != curProcEdges.end();
++curProcEdgeIter
)
for (const label procEdgei : curProcEdges)
{
curProcEdgeAddressing[nEdges] = curProcEdgeIter();
// curProcEdgeAddressing[nEdges] = curProcEdgeIter() + 1;
nEdges++;
curProcEdgeAddressing[nEdges] = procEdgei;
// curProcEdgeAddressing[nEdges] = procEdgei + 1;
++nEdges;
}
// Add inter-processor boundary edges. At the beginning of each
@ -862,18 +841,19 @@ void Foam::faMeshDecomposition::decomposeMesh()
label nProcPatches = 0;
SLList<label>::iterator curInterProcBdrsIter =
interProcBoundaries[procI].begin();
auto curInterProcBdrsIter =
interProcBoundaries[procI].cbegin();
SLList<SLList<label>>::iterator curInterProcBEdgesIter =
interProcBEdges[procI].begin();
auto curInterProcBEdgesIter =
interProcBEdges[procI].cbegin();
for
(
;
curInterProcBdrsIter != interProcBoundaries[procI].end()
&& curInterProcBEdgesIter != interProcBEdges[procI].end();
++curInterProcBdrsIter, ++curInterProcBEdgesIter
curInterProcBdrsIter.good()
&& curInterProcBEdgesIter.good();
++curInterProcBdrsIter,
++curInterProcBEdgesIter
)
{
curProcNeighbourProcessors[nProcPatches] =
@ -889,37 +869,31 @@ void Foam::faMeshDecomposition::decomposeMesh()
// add faces for this processor boundary
for
(
SLList<label>::iterator curEdgesIter =
curInterProcBEdgesIter().begin();
curEdgesIter != curInterProcBEdgesIter().end();
++curEdgesIter
)
for (const label edgei : *curInterProcBEdgesIter)
{
// add the edges
// Remember to increment the index by one such that the
// turning index works properly.
if (faceToProc_[owner[curEdgesIter()]] == procI)
if (faceToProc_[owner[edgei]] == procI)
{
curProcEdgeAddressing[nEdges] = curEdgesIter();
// curProcEdgeAddressing[nEdges] = curEdgesIter() + 1;
curProcEdgeAddressing[nEdges] = edgei;
// curProcEdgeAddressing[nEdges] = edgei + 1;
}
else
{
// turning edge
curProcEdgeAddressing[nEdges] = curEdgesIter();
// curProcEdgeAddressing[nEdges] = -(curEdgesIter() + 1);
curProcEdgeAddressing[nEdges] = edgei;
// curProcEdgeAddressing[nEdges] = -(edgei + 1);
}
// increment the size
curSize++;
++curSize;
nEdges++;
++nEdges;
}
nProcPatches++;
++nProcPatches;
}
}
}

View File

@ -62,7 +62,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
{
SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
forAllConstIter(SLList<indexedParticle*>, particlePtrs, iter)
forAllConstIters(particlePtrs, iter)
{
const indexedParticle& ppi = *iter();
particleIndices_[pi++] = ppi.index();

View File

@ -592,7 +592,7 @@ int main(int argc, char *argv[])
const word cloudName = word::validate(iter.key());
// Objects (on arbitrary processor)
const IOobjectList& cloudObjs = iter.object();
const IOobjectList& cloudObjs = iter.val();
Info<< "Reconstructing lagrangian fields for cloud "
<< cloudName << nl << endl;
@ -831,15 +831,15 @@ int main(int argc, char *argv[])
cellSet& cSet = cellSets[setI];
cSet.instance() = runTime.timeName();
forAllConstIter(cellSet, procSet, iter)
for (const label celli : procSet)
{
cSet.insert(cellMap[iter.key()]);
cSet.insert(cellMap[celli]);
}
}
// faceSets
const labelList& faceMap =
procMeshes.faceProcAddressing()[proci];
procMeshes.faceProcAddressing()[proci];
IOobjectList fSets
(
@ -867,9 +867,9 @@ int main(int argc, char *argv[])
faceSet& fSet = faceSets[setI];
fSet.instance() = runTime.timeName();
forAllConstIter(faceSet, procSet, iter)
for (const label facei : procSet)
{
fSet.insert(mag(faceMap[iter.key()])-1);
fSet.insert(mag(faceMap[facei])-1);
}
}
// pointSets
@ -901,25 +901,26 @@ int main(int argc, char *argv[])
pointSet& pSet = pointSets[setI];
pSet.instance() = runTime.timeName();
forAllConstIter(pointSet, propSet, iter)
for (const label pointi : propSet)
{
pSet.insert(pointMap[iter.key()]);
pSet.insert(pointMap[pointi]);
}
}
}
// Write sets
forAll(cellSets, i)
for (const auto& set : cellSets)
{
cellSets[i].write();
set.write();
}
forAll(faceSets, i)
for (const auto& set : faceSets)
{
faceSets[i].write();
set.write();
}
forAll(pointSets, i)
for (const auto& set : pointSets)
{
pointSets[i].write();
set.write();
}
}

View File

@ -151,10 +151,8 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
labelList destProc(lpi.size());
label particleI = 0;
forAllIter(passivePositionParticleCloud, lpi, iter)
for (passivePositionParticle& ppi : lpi)
{
passivePositionParticle& ppi = iter();
const label destProcI = destinationProcID_[ppi.cell()];
const label destCellI = destinationCell_[ppi.cell()];
@ -222,14 +220,8 @@ Foam::parLagrangianRedistributor::redistributeLagrangianPositions
passivePositionParticle::iNew(tgtMesh_)
);
forAllIter
(
IDLList<passivePositionParticle>,
newParticles,
newpIter
)
for (passivePositionParticle& newp : newParticles)
{
passivePositionParticle& newp = newpIter();
lagrangianPositions.addParticle(newParticles.remove(&newp));
}
}

View File

@ -284,7 +284,7 @@ Foam::label Foam::parLagrangianRedistributor::redistributeStoredFields
label nFields = 0;
forAllIters(fields, iter)
{
Container& field = *(iter.object());
Container& field = *(iter.val());
if (!nFields++)
{

View File

@ -746,7 +746,7 @@ void correctCoupledBoundaryConditions(fvMesh& mesh)
mesh.objectRegistry::lookupClass<GeoField>()
);
forAllIter(typename HashTable<GeoField*>, flds, iter)
forAllIters(flds, iter)
{
GeoField& fld = *iter();
@ -1944,16 +1944,11 @@ void readLagrangian
);
//forAllConstIter
//(
// unmappedPassivePositionParticleCloud,
// clouds[i],
// iter
//)
//for (passivePositionParticle& p : clouds[i]))
//{
// Pout<< "Particle position:" << iter().position()
// << " cell:" << iter().cell()
// << " with cc:" << mesh.cellCentres()[iter().cell()]
// Pout<< "Particle position:" << p.position()
// << " cell:" << p.cell()
// << " with cc:" << mesh.cellCentres()[p.cell()]
// << endl;
//}

View File

@ -74,7 +74,7 @@ if (doLagrangian)
forAllConstIters(theseCloudFields, fieldIter)
{
const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter.object();
const word& fieldType = fieldIter.val();
IOobject fieldObject
(

View File

@ -73,7 +73,7 @@ if (doLagrangian)
forAllConstIters(theseCloudFields, fieldIter)
{
const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter.object();
const word& fieldType = fieldIter.val();
IOobject fieldObject
(

View File

@ -1,19 +1,19 @@
gmvFile << "tracers " << particles.size() << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().x() << ' ';
gmvFile << p.position().x() << ' ';
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().y() << ' ';
gmvFile << p.position().y() << ' ';
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().z() << ' ';
gmvFile << p.position().z() << ' ';
}
gmvFile << nl;
@ -36,9 +36,9 @@ for (const word& name : lagrangianScalarNames)
{
gmvFile << name << nl;
forAll(fld, n)
for (const scalar& val : fld)
{
gmvFile << fld[n] << token::SPACE;
gmvFile << val << token::SPACE;
}
gmvFile << nl;
}

View File

@ -1,48 +1,48 @@
gmvFile << "tracers " << particles.size() << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().x() << " ";
gmvFile << p.position().x() << " ";
}
gmvFile << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().y() << " ";
gmvFile << p.position().y() << " ";
}
gmvFile << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().z() << " ";
gmvFile << p.position().z() << " ";
}
gmvFile << nl;
gmvFile << "U" << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().velocity().x() << " ";
gmvFile << p.velocity().x() << " ";
}
gmvFile << nl;
gmvFile << "V" << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().velocity().y() << " ";
gmvFile << p.velocity().y() << " ";
}
gmvFile << nl;
gmvFile << "W" << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
{
gmvFile << iter().velocity().z() << " ";
gmvFile << p.velocity().z() << " ";
}
gmvFile << nl;
gmvFile << "Diam" << nl;
forAllConstIter(discretePhase, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().d() << " ";
gmvFile << p.d() << " ";
}
gmvFile << "endtrace"<< nl;

View File

@ -1,19 +1,19 @@
gmvFile << "tracers " << particles.size() << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().x() << " ";
gmvFile << p.position().x() << " ";
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().y() << " ";
gmvFile << p.position().y() << " ";
}
gmvFile << nl;
forAllConstIter(Cloud<passiveParticle>, particles, iter)
for (const passiveParticle& p : particles)
{
gmvFile << iter().position().z() << " ";
gmvFile << p.position().z() << " ";
}
gmvFile << nl;

View File

@ -118,7 +118,7 @@ Foam::label Foam::foamPvCore::addToSelection
if (iter.found())
{
return addToArray(select, prefix, iter.object().sortedToc());
return addToArray(select, prefix, iter.val().sortedToc());
}
return 0;
@ -137,7 +137,7 @@ Foam::label Foam::foamPvCore::addToSelection
if (iter.found())
{
return addToArray(select, iter.object().sortedToc(), suffix);
return addToArray(select, iter.val().sortedToc(), suffix);
}
return 0;

View File

@ -144,9 +144,9 @@ bool Foam::vtkPVFoam::addOutputBlock
const word shortName = getFoamName(longName);
auto iter = cache.find(longName);
if (iter.found() && iter.object().dataset)
if (iter.found() && iter.val().dataset)
{
auto dataset = iter.object().dataset;
auto dataset = iter.val().dataset;
if (singleDataset)
{
@ -540,13 +540,13 @@ void Foam::vtkPVFoam::Update
// Eliminate cached values that would be unreliable
forAllIters(cachedVtp_, iter)
{
iter.object().clearGeom();
iter.object().clear();
iter.val().clearGeom();
iter.val().clear();
}
forAllIters(cachedVtu_, iter)
{
iter.object().clearGeom();
iter.object().clear();
iter.val().clearGeom();
iter.val().clear();
}
}
else if (oldDecomp != decomposePoly_)
@ -554,8 +554,8 @@ void Foam::vtkPVFoam::Update
// poly-decompose changed - dispose of cached values
forAllIters(cachedVtu_, iter)
{
iter.object().clearGeom();
iter.object().clear();
iter.val().clearGeom();
iter.val().clear();
}
}
}

View File

@ -91,13 +91,13 @@ void Foam::vtkPVFoam::convertVolField
const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtpData& vtpData = iter.object();
foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset;
const labelUList& patchIds = vtpData.additionalIds();
@ -195,13 +195,13 @@ void Foam::vtkPVFoam::convertVolField
const word zoneName = getFoamName(longName);
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtpData& vtpData = iter.object();
foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset;
const faceZoneMesh& zMesh = mesh.faceZones();
@ -236,12 +236,12 @@ void Foam::vtkPVFoam::convertVolField
const word selectName = getFoamName(longName);
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtpData& vtpData = iter.object();
foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertFaceFieldToVTK
@ -270,7 +270,7 @@ void Foam::vtkPVFoam::convertVolFields
forAllConstIters(objects, iter)
{
// Restrict to GeometricField<Type, ...>
const auto& ioobj = *(iter.object());
const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() == FieldType::typeName)
{
@ -320,7 +320,7 @@ void Foam::vtkPVFoam::convertDimFields
forAllConstIters(objects, iter)
{
// Restrict to DimensionedField<Type, ...>
const auto& ioobj = *(iter.object());
const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() != FieldType::typeName)
{
@ -404,13 +404,13 @@ void Foam::vtkPVFoam::convertVolFieldBlock
const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtu_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtuData& vtuData = iter.object();
foamVtuData& vtuData = iter.val();
auto dataset = vtuData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertVolFieldToVTK
@ -459,7 +459,7 @@ void Foam::vtkPVFoam::convertAreaFields
forAllConstIters(objects, iter)
{
// Restrict to GeometricField<Type, ...>
const auto& ioobj = *(iter.object());
const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() == FieldType::typeName)
{
@ -478,14 +478,14 @@ void Foam::vtkPVFoam::convertAreaFields
const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk
// geometry
continue;
}
foamVtpData& vtpData = iter.object();
foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset;
vtkSmartPointer<vtkFloatArray> cdata = convertFieldToVTK
@ -535,7 +535,7 @@ void Foam::vtkPVFoam::convertPointFields
forAllConstIters(objects, iter)
{
// Restrict to this GeometricField<Type, ...>
const auto& ioobj = *(iter.object());
const auto& ioobj = *(iter.val());
const word& fieldName = ioobj.name();
if (ioobj.headerClassName() != FieldType::typeName)
@ -568,13 +568,13 @@ void Foam::vtkPVFoam::convertPointFields
const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtpData& vtpData = iter.object();
foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset;
const labelUList& patchIds = vtpData.additionalIds();
@ -605,13 +605,13 @@ void Foam::vtkPVFoam::convertPointFields
const word zoneName = getFoamName(longName);
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtpData& vtpData = iter.object();
foamVtpData& vtpData = iter.val();
auto dataset = vtpData.dataset;
const label zoneId = mesh.faceZones().findZoneID(zoneName);
@ -673,13 +673,13 @@ void Foam::vtkPVFoam::convertPointFieldBlock
const auto& longName = selectedPartIds_[partId];
auto iter = cachedVtu_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
foamVtuData& vtuData = iter.object();
foamVtuData& vtuData = iter.val();
auto dataset = vtuData.dataset;
vtkSmartPointer<vtkFloatArray> pdata = convertPointField
@ -794,7 +794,7 @@ void Foam::vtkPVFoam::convertLagrangianFields
forAllConstIters(objects, iter)
{
// Restrict to IOField<Type>
const auto& ioobj = *(iter.object());
const auto& ioobj = *(iter.val());
if (ioobj.headerClassName() == IOField<Type>::typeName)
{

View File

@ -255,12 +255,12 @@ void Foam::vtkPVFoam::convertLagrangianFields()
const word cloudName = getFoamName(longName);
auto iter = cachedVtp_.find(longName);
if (!iter.found() || !iter.object().dataset)
if (!iter.found() || !iter.val().dataset)
{
// Should not happen, but for safety require a vtk geometry
continue;
}
auto dataset = iter.object().dataset;
auto dataset = iter.val().dataset;
// Get the Lagrangian fields for this time and this cloud
// but only keep selected fields

View File

@ -80,9 +80,9 @@ vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::lagrangianVTKMesh
vtkpoints->SetNumberOfPoints(parcels.size());
vtkIdType particleId = 0;
forAllConstIters(parcels, iter)
for (const passiveParticle& p : parcels)
{
vtkpoints->SetPoint(particleId, iter().position().v_);
vtkpoints->SetPoint(particleId, p.position().v_);
++particleId;
}

View File

@ -276,7 +276,7 @@ void Foam::vtkPVFoam::updateInfoPatches
forAllConstIters(groups, iter)
{
const auto& groupName = iter.key();
const auto& patchIDs = iter.object();
const auto& patchIDs = iter.val();
label nFaces = 0;
for (auto patchId : patchIDs)
@ -392,7 +392,7 @@ void Foam::vtkPVFoam::updateInfoPatches
forAllConstIters(groups, iter)
{
const auto& groupName = iter.key();
const auto& patchIDs = iter.object();
const auto& patchIDs = iter.val();
const string dpyName = "group/" + groupName;
displayNames.append(dpyName);
@ -715,7 +715,7 @@ void Foam::vtkPVFoam::updateInfoLagrangianFields
forAllConstIters(localFields, iter)
{
fields(iter.key()) |= iter.object();
fields(iter.key()) |= iter.val();
}
}
}

View File

@ -42,12 +42,12 @@ int USERD_get_part_coords
{
label indx = 1;
forAllConstIter(Cloud<passiveParticle>, *sprayPtr, iter)
forAllConstIters(*sprayPtr, iter)
{
coord_array[0][indx] = float(iter().position().x());
coord_array[1][indx] = float(iter().position().y());
coord_array[2][indx] = float(iter().position().z());
indx++;
++indx;
}
}

View File

@ -36,7 +36,7 @@ int USERD_get_part_node_ids
{
label indx = 0;
forAllConstIter(Cloud<passiveParticle>, *sprayPtr, iter)
forAllConstIters(*sprayPtr, iter)
{
nodeid_array[indx] = indx + 1;
indx++;

View File

@ -85,10 +85,10 @@ int main(int argc, char *argv[])
Info<< " Read " << returnReduce(myCloud.size(), sumOp<label>())
<< " particles" << endl;
forAllConstIter(passiveParticleCloud, myCloud, iter)
for (const passiveParticle& p : myCloud)
{
label origId = iter().origId();
label origProc = iter().origProc();
const label origId = p.origId();
const label origProc = p.origProc();
if (origProc >= maxIds.size())
{
@ -157,16 +157,16 @@ int main(int argc, char *argv[])
myCloud.size(),
point::zero
);
allOrigIds[Pstream::myProcNo()].setSize(myCloud.size(), 0);
allOrigProcs[Pstream::myProcNo()].setSize(myCloud.size(), 0);
allOrigIds[Pstream::myProcNo()].setSize(myCloud.size(), Zero);
allOrigProcs[Pstream::myProcNo()].setSize(myCloud.size(), Zero);
label i = 0;
forAllConstIter(passiveParticleCloud, myCloud, iter)
for (const passiveParticle& p : myCloud)
{
allPositions[Pstream::myProcNo()][i] = iter().position();
allOrigIds[Pstream::myProcNo()][i] = iter().origId();
allOrigProcs[Pstream::myProcNo()][i] = iter().origProc();
i++;
allPositions[Pstream::myProcNo()][i] = p.position();
allOrigIds[Pstream::myProcNo()][i] = p.origId();
allOrigProcs[Pstream::myProcNo()][i] = p.origProc();
++i;
}
// Collect the track data on the master processor

View File

@ -159,7 +159,7 @@ int main(int argc, char *argv[])
particles.setSize(ppc.size());
label i = 0;
forAllIter(passiveParticleCloud, ppc, iter)
forAllIters(ppc, iter)
{
particles.set(i++, ppc.remove(&iter()));
}
@ -178,18 +178,19 @@ int main(int argc, char *argv[])
const label origProc = particles[i].origProc();
const label origId = particles[i].origId();
labelPairLookup::const_iterator iter =
trackTable.find(labelPair(origProc, origId));
const labelPair key(origProc, origId);
if (iter == trackTable.end())
const auto iter = trackTable.cfind(key);
if (iter.found())
{
particleToTrack[i] = nTracks;
trackTable.insert(labelPair(origProc, origId), nTracks);
nTracks++;
particleToTrack[i] = *iter;
}
else
{
particleToTrack[i] = iter();
particleToTrack[i] = nTracks;
trackTable.insert(key, nTracks);
++nTracks;
}
}
}
@ -205,10 +206,9 @@ int main(int argc, char *argv[])
// Determine length of each track
labelList trackLengths(nTracks, Zero);
forAll(particleToTrack, i)
for (const label tracki : particleToTrack)
{
const label trackI = particleToTrack[i];
trackLengths[trackI]++;
++trackLengths[tracki];
}
// Particle "age" property used to sort the tracks

View File

@ -107,23 +107,23 @@ HashTable<wordList> extractPatchGroups(const dictionary& boundaryDict)
const word& patchName = dEntry.keyword();
const dictionary& patchDict = dEntry.dict();
wordList groups;
if (patchDict.readIfPresent("inGroups", groups))
wordList groupNames;
patchDict.readIfPresent("inGroups", groupNames);
for (const word& groupName : groupNames)
{
forAll(groups, i)
auto groupIter = groupToPatch.find(groupName);
if (groupIter.found())
{
auto fndGroup = groupToPatch.find(groups[i]);
if (!fndGroup.found())
{
groupToPatch.insert(groups[i], wordList(1, patchName));
}
else
{
fndGroup().append(patchName);
}
(*groupIter).append(patchName);
}
else
{
groupToPatch.insert(groupName, wordList(one(), patchName));
}
}
}
return groupToPatch;
}

View File

@ -301,7 +301,7 @@ void rewriteField
forAllConstIters(thisNames, iter)
{
const word& patchName = iter.key();
const word& newName = iter.object();
const word& newName = iter.val();
Info<< "Looking for entry for patch " << patchName << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -157,15 +157,15 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
// This requires there to be no boundary in the way.
forAllConstIters(sourceParcels, iter)
for (const passiveParticle& p : sourceParcels)
{
bool foundCell = false;
// Assume that cell from read parcel is the correct one...
if (iter().cell() >= 0)
if (p.cell() >= 0)
{
const labelList& targetCells =
sourceToTargets[iter().cell()];
sourceToTargets[p.cell()];
// Particle probably in one of the targetcells. Try
// all by tracking from their cell centre to the parcel
@ -187,7 +187,7 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
);
passiveParticle& newP = newPtr();
newP.track(iter().position() - newP.position(), 0);
newP.track(p.position() - newP.position(), 0);
if (!newP.onFace())
{
@ -221,12 +221,12 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
{
sourceParticleI = 0;
forAllIters(sourceParcels, iter)
for (passiveParticle& p : sourceParcels)
{
if (unmappedSource.found(sourceParticleI))
{
const label targetCell =
findCell(targetParcels, iter().position());
findCell(targetParcels, p.position());
if (targetCell >= 0)
{
@ -237,11 +237,11 @@ void mapLagrangian(const meshToMesh0& meshToMesh0Interp)
new passiveParticle
(
meshTarget,
iter().position(),
p.position(),
targetCell
)
);
sourceParcels.remove(&iter());
sourceParcels.remove(&p);
}
}
sourceParticleI++;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -154,15 +154,15 @@ void mapLagrangian(const meshToMesh& interp)
// This requires there to be no boundary in the way.
forAllConstIters(sourceParcels, iter)
for (const passiveParticle& p : sourceParcels)
{
bool foundCell = false;
// Assume that cell from read parcel is the correct one...
if (iter().cell() >= 0)
if (p.cell() >= 0)
{
const labelList& targetCells =
sourceToTarget[iter().cell()];
sourceToTarget[p.cell()];
// Particle probably in one of the targetcells. Try
// all by tracking from their cell centre to the parcel
@ -184,7 +184,7 @@ void mapLagrangian(const meshToMesh& interp)
);
passiveParticle& newP = newPtr();
newP.track(iter().position() - newP.position(), 0);
newP.track(p.position() - newP.position(), 0);
if (!newP.onFace())
{
@ -218,12 +218,12 @@ void mapLagrangian(const meshToMesh& interp)
{
sourceParticleI = 0;
forAllIters(sourceParcels, iter)
for (passiveParticle& p : sourceParcels)
{
if (unmappedSource.found(sourceParticleI))
{
const label targetCell =
findCell(targetParcels, iter().position());
findCell(targetParcels, p.position());
if (targetCell >= 0)
{
@ -234,11 +234,11 @@ void mapLagrangian(const meshToMesh& interp)
new passiveParticle
(
meshTarget,
iter().position(),
p.position(),
targetCell
)
);
sourceParcels.remove(&iter());
sourceParcels.remove(&p);
}
}
sourceParticleI++;

View File

@ -201,18 +201,10 @@ int main(int argc, char *argv[])
forAll(surface1.patches(), i)
{
const word& name = surface1.patches()[i].name();
auto iter = nameToPatch.find(name);
label combinedi;
if (iter.found())
{
combinedi = iter.object();
}
else
{
combinedi = nameToPatch.size();
nameToPatch.insert(name, combinedi);
}
// Lookup or insert
const label combinedi = nameToPatch(name, nameToPatch.size());
patch1Map[i] = combinedi;
}
@ -221,18 +213,10 @@ int main(int argc, char *argv[])
forAll(surface2.patches(), i)
{
const word& name = surface2.patches()[i].name();
auto iter = nameToPatch.find(name);
label combinedi;
if (iter.found())
{
combinedi = iter.object();
}
else
{
combinedi = nameToPatch.size();
nameToPatch.insert(name, combinedi);
}
// Lookup or insert
const label combinedi = nameToPatch(name, nameToPatch.size());
patch2Map[i] = combinedi;
}

View File

@ -1257,7 +1257,7 @@ autoPtr<extendedFeatureEdgeMesh> createEdgeMesh
forAllConstIters(inter.facePairToEdgeId(), iter)
{
const labelPair& facePair = iter.key();
const label cutEdgeI = iter.object();
const label cutEdgeI = iter.val();
const edge& fE = inter.cutEdges()[cutEdgeI];

View File

@ -81,7 +81,7 @@ Foam::surfaceFeaturesExtraction::method::New
<< exit(FatalIOError);
}
return autoPtr<method>(cstrIter.object()(dict));
return autoPtr<method>(cstrIter.val()(dict));
}

View File

@ -273,12 +273,12 @@ int main(int argc, char *argv[])
label patchi = bMesh.findPatchID(iter.key());
if (patchi != -1)
{
patchToCompactZone[patchi] = iter();
patchToCompactZone[patchi] = iter.val();
}
else
{
label zoneI = fzm.findZoneID(iter.key());
faceZoneToCompactZone[zoneI] = iter();
faceZoneToCompactZone[zoneI] = iter.val();
}
}
@ -382,11 +382,11 @@ int main(int argc, char *argv[])
// Zones
surfZoneIdentifierList surfZones(compactZoneID.size());
forAllConstIter(HashTable<label>, compactZoneID, iter)
forAllConstIters(compactZoneID, iter)
{
surfZones[iter()] = surfZoneIdentifier(iter.key(), iter());
Info<< "surfZone " << iter()
<< " : " << surfZones[iter()].name()
surfZones[*iter] = surfZoneIdentifier(iter.key(), *iter);
Info<< "surfZone " << *iter
<< " : " << surfZones[*iter].name()
<< endl;
}

View File

@ -131,7 +131,7 @@ void dumpFaces
OFstream os(fName);
forAllConstIter(Map<label>, connectedFaces, iter)
forAllConstIters(connectedFaces, iter)
{
point ctr = surf.localFaces()[iter.key()].centre(surf.localPoints());
@ -461,7 +461,7 @@ label sharedFace
label startIndex = f.find(e.start());
// points in face in same order as edge
bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end());
const bool edgeOrder = (f[f.fcIndex(startIndex)] == e.end());
// Get faces using edge in sorted order. (sorted such that walking
// around them in anti-clockwise order corresponds to edge vector
@ -469,7 +469,7 @@ label sharedFace
const labelList& eFaces = surf.sortedEdgeFaces()[sharedEdgeI];
// Get position of face in sorted edge faces
label faceIndex = eFaces.find(firstFacei);
const label faceIndex = eFaces.find(firstFacei);
if (edgeOrder)
{
@ -500,9 +500,9 @@ void calcPointVecs
boolList edgeDone(surf.nEdges(), false);
forAllConstIter(Map<label>, faceToEdge, iter)
forAllConstIters(faceToEdge, iter)
{
const label edgeI = iter();
const label edgeI = iter.val();
if (!edgeDone[edgeI])
{
@ -611,7 +611,7 @@ void renumberFaces
List<triSurface::FaceType>& newTris
)
{
forAllConstIter(Map<label>, faceToEdge, iter)
forAllConstIters(faceToEdge, iter)
{
const label facei = iter.key();
const triSurface::FaceType& f = surf.localFaces()[facei];

View File

@ -284,10 +284,8 @@ int main(int argc, char *argv[])
faceSet faceLabels(mesh, setName);
Info<< "Read " << faceLabels.size() << " faces to repatch ..." << endl;
forAllConstIter(faceSet, faceLabels, iter)
for (const label facei : faceLabels)
{
label facei = iter.key();
if (repatchFace(mesh, bMesh, nearest, patchMap, facei, meshMod))
{
nChanged++;
@ -298,11 +296,11 @@ int main(int argc, char *argv[])
{
forAll(nearest, bFacei)
{
label facei = mesh.nInternalFaces() + bFacei;
const label facei = mesh.nInternalFaces() + bFacei;
if (repatchFace(mesh, bMesh, nearest, patchMap, facei, meshMod))
{
nChanged++;
++nChanged;
}
}
}

View File

@ -214,7 +214,7 @@ int main(int argc, char *argv[])
Info<< "Tad = " << Tad << nl << endl;
}
Info<< nl << "end" << endl;
Info<< nl << "End" << endl;
return 0;
}

View File

@ -126,9 +126,9 @@ int main(int argc, char *argv[])
);
forAllConstIter(SLPtrList<thermo>, EQreactions, iter)
for (const thermo& react : EQreactions)
{
Info<< "Kc(EQreactions) = " << iter().Kc(P, T) << endl;
Info<< "Kc(EQreactions) = " << react.Kc(P, T) << endl;
}
Info<< nl << "End" << nl << endl;