diff --git a/src/sampling/meshToMesh/meshToMeshParallelOps.C b/src/sampling/meshToMesh/meshToMeshParallelOps.C index 417ecd458e8fae47c8f644397f6a4dfbd6e1f1e6..c340b14c5a2b581a800114bd9ebd08bd07aef746 100644 --- a/src/sampling/meshToMesh/meshToMeshParallelOps.C +++ b/src/sampling/meshToMesh/meshToMeshParallelOps.C @@ -638,10 +638,9 @@ void Foam::meshToMesh::distributeAndMergeCells key[1] = max(proci, nbrProci[i]); key[2] = localFacei[i]; - procCoupleInfo::const_iterator fnd = - procFaceToGlobalCell.find(key); + const auto fnd = procFaceToGlobalCell.cfind(key); - if (fnd == procFaceToGlobalCell.end()) + if (!fnd.found()) { procFaceToGlobalCell.insert(key, -1); } @@ -754,9 +753,9 @@ void Foam::meshToMesh::distributeAndMergeCells key[1] = max(proci, nbrProci[i]); key[2] = localFacei[i]; - procCoupleInfo::iterator fnd = procFaceToGlobalCell.find(key); + auto fnd = procFaceToGlobalCell.find(key); - if (fnd != procFaceToGlobalCell.end()) + if (fnd.found()) { label tgtFacei = fnd(); if (tgtFacei == -1) diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C index 2785f28132171c5beaa1f330ba49708e9682d4f1..1a70d09e11f246e773839ec15d1b7628085f6583 100644 --- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C +++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C @@ -367,7 +367,7 @@ void Foam::UnsortedMeshedSurface<Face>::setZones { zoneToc_[zonei] = surfZoneIdentifier ( - word("zone") + ::Foam::name(zonei), + "zone" + ::Foam::name(zonei), zonei ); @@ -477,53 +477,39 @@ Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones // Step 1: get zone sizes and store (origId => zoneI) Map<label> lookup; - forAll(zoneIds_, facei) + for (const label origId : zoneIds_) { - const label origId = zoneIds_[facei]; - - Map<label>::iterator fnd = lookup.find(origId); - if (fnd != lookup.end()) - { - fnd()++; - } - else - { - lookup.insert(origId, 1); - } + ++(lookup(origId, 0)); } // Step 2: assign start/size (and name) to the newZones // re-use the lookup to map (zoneId => zoneI) surfZoneList zoneLst(lookup.size()); label start = 0; - label zoneI = 0; - forAllIter(Map<label>, lookup, iter) + label zonei = 0; + forAllIters(lookup, iter) { - label origId = iter.key(); + const label origId = iter.key(); - word name; - Map<word>::const_iterator fnd = zoneNames.find(origId); - if (fnd != zoneNames.end()) - { - name = fnd(); - } - else - { - name = word("zone") + ::Foam::name(zoneI); - } + const word zoneName = + zoneNames.lookup + ( + origId, + "zone" + ::Foam::name(zonei) // default name + ); - zoneLst[zoneI] = surfZone + zoneLst[zonei] = surfZone ( - name, + zoneName, 0, // initialize with zero size start, - zoneI + zonei ); // increment the start for the next zone // and save the (zoneId => zoneI) mapping start += iter(); - iter() = zoneI++; + iter() = zonei++; } @@ -532,7 +518,7 @@ Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones forAll(zoneIds_, facei) { - label zonei = lookup[zoneIds_[facei]]; + const label zonei = lookup[zoneIds_[facei]]; faceMap[facei] = zoneLst[zonei].start() + zoneLst[zonei].size()++; } @@ -575,10 +561,9 @@ Foam::UnsortedMeshedSurface<Face>::subsetMesh newFaces[facei] = Face(locFaces[origFacei]); // Renumber labels for face - Face& f = newFaces[facei]; - forAll(f, fp) + for (label& pointi : newFaces[facei]) { - f[fp] = oldToNew[f[fp]]; + pointi = oldToNew[pointi]; } newZones[facei] = zoneIds_[origFacei];