diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C index 49c37aa877..8553623202 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,18 +44,18 @@ void Foam::syncTools::swapBoundaryCellPositions const polyBoundaryMesh& patches = mesh.boundaryMesh(); - label nBnd = mesh.nFaces()-mesh.nInternalFaces(); + neighbourCellData.resize(mesh.nFaces()-mesh.nInternalFaces()); - neighbourCellData.setSize(nBnd); - - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; + label bFacei = pp.start()-mesh.nInternalFaces(); + const labelUList& faceCells = pp.faceCells(); - forAll(faceCells, i) + + for (const label celli : faceCells) { - label bFacei = pp.start()+i-mesh.nInternalFaces(); - neighbourCellData[bFacei] = cellData[faceCells[i]]; + neighbourCellData[bFacei] = cellData[celli]; + ++bFacei; } } syncTools::swapBoundaryFacePositions(mesh, neighbourCellData); @@ -64,7 +64,7 @@ void Foam::syncTools::swapBoundaryCellPositions Foam::bitSet Foam::syncTools::getMasterPoints(const polyMesh& mesh) { - bitSet isMasterPoint(mesh.nPoints()); + bitSet isMaster(mesh.nPoints()); bitSet donePoint(mesh.nPoints()); const globalMeshData& globalData = mesh.globalData(); @@ -75,7 +75,7 @@ Foam::bitSet Foam::syncTools::getMasterPoints(const polyMesh& mesh) forAll(meshPoints, coupledPointi) { - label meshPointi = meshPoints[coupledPointi]; + const label meshPointi = meshPoints[coupledPointi]; if ( ( @@ -85,7 +85,7 @@ Foam::bitSet Foam::syncTools::getMasterPoints(const polyMesh& mesh) > 0 ) { - isMasterPoint.set(meshPointi); + isMaster.set(meshPointi); } donePoint.set(meshPointi); } @@ -98,17 +98,17 @@ Foam::bitSet Foam::syncTools::getMasterPoints(const polyMesh& mesh) { if (!donePoint.test(pointi)) { - isMasterPoint.set(pointi); + isMaster.set(pointi); } } - return isMasterPoint; + return isMaster; } Foam::bitSet Foam::syncTools::getMasterEdges(const polyMesh& mesh) { - bitSet isMasterEdge(mesh.nEdges()); + bitSet isMaster(mesh.nEdges()); bitSet doneEdge(mesh.nEdges()); const globalMeshData& globalData = mesh.globalData(); @@ -119,7 +119,7 @@ Foam::bitSet Foam::syncTools::getMasterEdges(const polyMesh& mesh) forAll(meshEdges, coupledEdgeI) { - label meshEdgeI = meshEdges[coupledEdgeI]; + const label meshEdgeI = meshEdges[coupledEdgeI]; if ( ( @@ -129,7 +129,7 @@ Foam::bitSet Foam::syncTools::getMasterEdges(const polyMesh& mesh) > 0 ) { - isMasterEdge.set(meshEdgeI); + isMaster.set(meshEdgeI); } doneEdge.set(meshEdgeI); } @@ -142,38 +142,38 @@ Foam::bitSet Foam::syncTools::getMasterEdges(const polyMesh& mesh) { if (!doneEdge.test(edgeI)) { - isMasterEdge.set(edgeI); + isMaster.set(edgeI); } } - return isMasterEdge; + return isMaster; } Foam::bitSet Foam::syncTools::getMasterFaces(const polyMesh& mesh) { - bitSet isMasterFace(mesh.nFaces(), true); + bitSet isMaster(mesh.nFaces(), true); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - if (patches[patchi].coupled()) + if (pp.coupled()) { - const coupledPolyPatch& pp = - refCast(patches[patchi]); + const coupledPolyPatch& cpp = + refCast(pp); - if (!pp.owner()) + if (!cpp.owner()) { forAll(pp, i) { - isMasterFace.unset(pp.start()+i); + isMaster.unset(cpp.start()+i); } } } } - return isMasterFace; + return isMaster; } @@ -182,21 +182,19 @@ Foam::bitSet Foam::syncTools::getInternalOrMasterFaces const polyMesh& mesh ) { - bitSet isMasterFace(mesh.nFaces(), true); + bitSet isMaster(mesh.nFaces(), true); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; - if (pp.coupled()) { if (!refCast(pp).owner()) { forAll(pp, i) { - isMasterFace.unset(pp.start()+i); + isMaster.unset(pp.start()+i); } } } @@ -204,12 +202,12 @@ Foam::bitSet Foam::syncTools::getInternalOrMasterFaces { forAll(pp, i) { - isMasterFace.unset(pp.start()+i); + isMaster.unset(pp.start()+i); } } } - return isMasterFace; + return isMaster; } @@ -218,24 +216,22 @@ Foam::bitSet Foam::syncTools::getInternalOrCoupledFaces const polyMesh& mesh ) { - bitSet isMasterFace(mesh.nFaces(), true); + bitSet isMaster(mesh.nFaces(), true); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - const polyPatch& pp = patches[patchi]; - if (!pp.coupled()) { forAll(pp, i) { - isMasterFace.unset(pp.start()+i); + isMaster.unset(pp.start()+i); } } } - return isMasterFace; + return isMaster; } diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index d20017a897..36386b3cda 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -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) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,11 +44,11 @@ void Foam::syncTools::combine const T& val ) { - typename Map::iterator iter = pointValues.find(index); + auto iter = pointValues.find(index); - if (iter != pointValues.end()) + if (iter.found()) { - cop(iter(), val); + cop(*iter, val); } else { @@ -66,11 +66,11 @@ void Foam::syncTools::combine const T& val ) { - typename EdgeMap::iterator iter = edgeValues.find(index); + auto iter = edgeValues.find(index); - if (iter != edgeValues.end()) + if (iter.found()) { - cop(iter(), val); + cop(*iter, val); } else { @@ -100,6 +100,7 @@ void Foam::syncTools::syncPointMap { // meshPoint per local index const labelList& sharedPtLabels = pd.sharedPointLabels(); + // global shared index per local index const labelList& sharedPtAddr = pd.sharedPointAddr(); @@ -108,19 +109,16 @@ void Foam::syncTools::syncPointMap // Fill my entries in the shared points forAll(sharedPtLabels, i) { - label meshPointi = sharedPtLabels[i]; + const auto fnd = pointValues.cfind(sharedPtLabels[i]); - typename Map::const_iterator fnd = - pointValues.find(meshPointi); - - if (fnd != pointValues.end()) + if (fnd.found()) { combine ( sharedPointValues, cop, sharedPtAddr[i], // index - fnd() // value + *fnd // value ); } } @@ -133,16 +131,12 @@ void Foam::syncTools::syncPointMap // Send - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - if - ( - isA(patches[patchi]) - && patches[patchi].nPoints() > 0 - ) + if (isA(pp) && pp.nPoints() > 0) { const processorPolyPatch& procPatch = - refCast(patches[patchi]); + refCast(pp); // Get data per patchPoint in neighbouring point numbers. @@ -155,12 +149,11 @@ void Foam::syncTools::syncPointMap forAll(meshPts, i) { - typename Map::const_iterator iter = - pointValues.find(meshPts[i]); + const auto iter = pointValues.cfind(meshPts[i]); - if (iter != pointValues.end()) + if (iter.found()) { - patchInfo.insert(nbrPts[i], iter()); + patchInfo.insert(nbrPts[i], *iter); } } @@ -173,16 +166,12 @@ void Foam::syncTools::syncPointMap // Receive and combine. - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - if - ( - isA(patches[patchi]) - && patches[patchi].nPoints() > 0 - ) + if (isA(pp) && pp.nPoints() > 0) { const processorPolyPatch& procPatch = - refCast(patches[patchi]); + refCast(pp); UIPstream fromNb(procPatch.neighbProcNo(), pBufs); Map nbrPatchInfo(fromNb); @@ -193,14 +182,14 @@ void Foam::syncTools::syncPointMap const labelList& meshPts = procPatch.meshPoints(); // Only update those values which come from neighbour - forAllConstIter(typename Map, nbrPatchInfo, nbrIter) + forAllConstIters(nbrPatchInfo, nbrIter) { combine ( pointValues, cop, meshPts[nbrIter.key()], - nbrIter() + nbrIter.object() ); } } @@ -208,12 +197,12 @@ void Foam::syncTools::syncPointMap } // Do the cyclics. - forAll(patches, patchi) + for (const polyPatch& pp : patches) { - if (isA(patches[patchi])) + if (isA(pp)) { const cyclicPolyPatch& cycPatch = - refCast(patches[patchi]); + refCast(pp); if (cycPatch.owner()) { @@ -232,20 +221,18 @@ void Foam::syncTools::syncPointMap { const edge& e = coupledPoints[i]; - typename Map::const_iterator point0Fnd = - pointValues.find(meshPtsA[e[0]]); + const auto point0Fnd = pointValues.cfind(meshPtsA[e[0]]); - if (point0Fnd != pointValues.end()) + if (point0Fnd.found()) { - half0Values.insert(i, point0Fnd()); + half0Values.insert(i, *point0Fnd); } - typename Map::const_iterator point1Fnd = - pointValues.find(meshPtsB[e[1]]); + const auto point1Fnd = pointValues.cfind(meshPtsB[e[1]]); - if (point1Fnd != pointValues.end()) + if (point1Fnd.found()) { - half1Values.insert(i, point1Fnd()); + half1Values.insert(i, *point1Fnd); } } @@ -257,31 +244,29 @@ void Foam::syncTools::syncPointMap { const edge& e = coupledPoints[i]; - typename Map::const_iterator half0Fnd = - half0Values.find(i); + const auto half0Fnd = half0Values.cfind(i); - if (half0Fnd != half0Values.end()) + if (half0Fnd.found()) { combine ( pointValues, cop, meshPtsB[e[1]], - half0Fnd() + *half0Fnd ); } - typename Map::const_iterator half1Fnd = - half1Values.find(i); + const auto half1Fnd = half1Values.cfind(i); - if (half1Fnd != half1Values.end()) + if (half1Fnd.found()) { combine ( pointValues, cop, meshPtsA[e[0]], - half1Fnd() + *half1Fnd ); } } @@ -315,14 +300,14 @@ void Foam::syncTools::syncPointMap Map nbrValues(fromSlave); // Merge neighbouring values with my values - forAllConstIter(typename Map, nbrValues, iter) + forAllConstIters(nbrValues, iter) { combine ( sharedPointValues, cop, - iter.key(), // edge - iter() // value + iter.key(), // edge + iter.object() // value ); } } @@ -373,15 +358,14 @@ void Foam::syncTools::syncPointMap sharedToMeshPoint.insert(sharedPtAddr[i], sharedPtLabels[i]); } - forAllConstIter(Map