diff --git a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C index 354b7e9440ee9896257ba5f21de50371a3a92882..2a2c57780f229a4c7e766af83f59db861c5c6c90 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C +++ b/src/functionObjects/field/fieldAverage/fieldAverageItem/fieldAverageItemTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,17 +106,16 @@ bool Foam::functionObjects::fieldAverageItem::calculateMeanField // Note: looks up all window fields from the registry meanField = 0*baseField; - FIFOStack<scalar>::const_iterator timeIter = - windowTimes_.begin(); - FIFOStack<word>::const_iterator nameIter = - windowFieldNames_.begin(); + + auto timeIter = windowTimes_.cbegin(); + auto nameIter = windowFieldNames_.cbegin(); const Type* wOld = nullptr; for ( ; - timeIter != windowTimes_.end(); + timeIter.good(); ++timeIter, ++nameIter ) { @@ -223,10 +222,9 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField { // Not storing old time mean fields - treat all as TIME (integrated) prime2MeanField = 0*prime2MeanField; - FIFOStack<scalar>::const_iterator timeIter = - windowTimes_.begin(); - FIFOStack<word>::const_iterator nameIter = - windowFieldNames_.begin(); + + auto timeIter = windowTimes_.cbegin(); + auto nameIter = windowFieldNames_.cbegin(); switch (base_) { @@ -236,7 +234,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField ++timeIter; ++nameIter; - if (timeIter == windowTimes_.end()) return false; + if (!timeIter.good()) return false; break; } @@ -252,7 +250,7 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField for ( ; - timeIter != windowTimes_.end(); + timeIter.good(); ++timeIter, ++nameIter ) { @@ -272,7 +270,6 @@ bool Foam::functionObjects::fieldAverageItem::calculatePrime2MeanField prime2MeanField /= windowLength; - break; } default: diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index 4cb6a968139cb37c10f76c6b5574dd01c045a934..e89fa2984868551883e27333906f0fda89d61736 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -160,9 +160,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing() ); InfoInFunction << "Dumping tracks to " << str.name() << endl; - forAllConstIter(Cloud<findCellParticle>, cloud, iter) + for (const findCellParticle& tp : cloud) { - const findCellParticle& tp = iter(); str.write(linePointRef(tp.position(), tp.end())); } } @@ -186,9 +185,8 @@ void Foam::functionObjects::nearWallFields::calcAddressing() { start.setSize(nPatchFaces); nPatchFaces = 0; - forAllConstIter(Cloud<findCellParticle>, cloud, iter) + for (const findCellParticle& tp : cloud) { - const findCellParticle& tp = iter(); start[nPatchFaces++] = tp.position(); } } diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 989f01fe941f6cc7733b15caf2695d8fcde9f736..ef13e3a533bac273583fd811fcb57601268498d9 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2013-2016 OpenFOAM Foundation @@ -121,7 +121,7 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields // Knock out any cell not in patchRegions forAll(liquidCore, celli) { - label regioni = regions[celli]; + const label regioni = regions[celli]; if (patchRegions.found(regioni)) { backgroundAlpha[celli] = 0; @@ -130,7 +130,7 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields { liquidCore[celli] = 0; - scalar regionVol = regionVolume[regioni]; + const scalar regionVol = regionVolume[regioni]; if (regionVol < maxDropletVol) { backgroundAlpha[celli] = 0; @@ -144,8 +144,8 @@ void Foam::functionObjects::regionSizeDistribution::writeAlphaFields { Info<< " Volume of liquid-core = " << fvc::domainIntegrate(liquidCore).value() - << endl; - Info<< " Volume of background = " + << nl + << " Volume of background = " << fvc::domainIntegrate(backgroundAlpha).value() << endl; } @@ -549,19 +549,18 @@ bool Foam::functionObjects::regionSizeDistribution::write() << token::TAB << "Volume(mesh)" << token::TAB << "Volume(" << alpha.name() << "):" << token::TAB << "nCells" - << endl; + << nl; scalar meshSumVol = 0.0; scalar alphaSumVol = 0.0; label nCells = 0; - Map<scalar>::const_iterator vIter = allRegionVolume.begin(); - Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin(); - Map<label>::const_iterator numIter = allRegionNumCells.begin(); + auto vIter = allRegionVolume.cbegin(); + auto aIter = allRegionAlphaVolume.cbegin(); + auto numIter = allRegionNumCells.cbegin(); for ( ; - vIter != allRegionVolume.end() - && aIter != allRegionAlphaVolume.end(); + vIter.good() && aIter.good(); ++vIter, ++aIter, ++numIter ) { @@ -569,7 +568,7 @@ bool Foam::functionObjects::regionSizeDistribution::write() << token::TAB << vIter() << token::TAB << aIter() << token::TAB << numIter() - << endl; + << nl; meshSumVol += vIter(); alphaSumVol += aIter(); @@ -583,20 +582,20 @@ bool Foam::functionObjects::regionSizeDistribution::write() } - if (log) { - Info<< " Patch connected regions (liquid core):" << endl; + Info<< " Patch connected regions (liquid core):" << nl; Info<< token::TAB << " Region" << token::TAB << "Volume(mesh)" << token::TAB << "Volume(" << alpha.name() << "):" - << endl; + << nl; + forAllConstIters(patchRegions, iter) { const label regioni = iter.key(); Info<< " " << token::TAB << regioni << token::TAB << allRegionVolume[regioni] - << token::TAB << allRegionAlphaVolume[regioni] << endl; + << token::TAB << allRegionAlphaVolume[regioni] << nl; } Info<< endl; @@ -604,19 +603,19 @@ bool Foam::functionObjects::regionSizeDistribution::write() if (log) { - Info<< " Background regions:" << endl; + Info<< " Background regions:" << nl; Info<< " " << token::TAB << "Region" << token::TAB << "Volume(mesh)" << token::TAB << "Volume(" << alpha.name() << "):" - << endl; - Map<scalar>::const_iterator vIter = allRegionVolume.begin(); - Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin(); + << nl; + + auto vIter = allRegionVolume.cbegin(); + auto aIter = allRegionAlphaVolume.cbegin(); for ( ; - vIter != allRegionVolume.end() - && aIter != allRegionAlphaVolume.end(); + vIter.good() && aIter.good(); ++vIter, ++aIter ) { @@ -628,7 +627,7 @@ bool Foam::functionObjects::regionSizeDistribution::write() { Info<< " " << token::TAB << vIter.key() << token::TAB << vIter() - << token::TAB << aIter() << endl; + << token::TAB << aIter() << nl; } } Info<< endl; @@ -651,9 +650,9 @@ bool Foam::functionObjects::regionSizeDistribution::write() // allRegionAlphaVolume since background might not have alpha in it. // Deleting regions where the volume-alpha-weighted is lower than // threshold - forAllIter(Map<scalar>, allRegionVolume, vIter) + forAllIters(allRegionVolume, vIter) { - label regioni = vIter.key(); + const label regioni = vIter.key(); if ( patchRegions.found(regioni) @@ -783,14 +782,14 @@ bool Foam::functionObjects::regionSizeDistribution::write() << " " << token::TAB << "Bin" << token::TAB << "Min distance" << token::TAB << "Count:" - << endl; + << nl; scalar delta = 0.0; forAll(binDownCount, bini) { Info<< " " << token::TAB << bini << token::TAB << delta - << token::TAB << binDownCount[bini] << endl; + << token::TAB << binDownCount[bini] << nl; delta += deltaX; } Info<< endl; @@ -836,14 +835,14 @@ bool Foam::functionObjects::regionSizeDistribution::write() << " " << token::TAB << "Bin" << token::TAB << "Min diameter" << token::TAB << "Count:" - << endl; + << nl; scalar diam = 0.0; forAll(binCount, bini) { Info<< " " << token::TAB << bini << token::TAB << diam - << token::TAB << binCount[bini] << endl; + << token::TAB << binCount[bini] << nl; diam += delta; } diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistributionTemplates.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistributionTemplates.C index 251d2ce9a88e3a7599075b7ee0c55a77d1cf1a48..90195dbc9a535791d9a3fb425972974fbc4a7db3 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistributionTemplates.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistributionTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2012-2016 OpenFOAM Foundation @@ -43,18 +43,10 @@ Foam::Map<Type> Foam::functionObjects::regionSizeDistribution::regionSum forAll(fld, celli) { - label regioni = regions[celli]; - - typename Map<Type>::iterator fnd = regionToSum.find(regioni); - if (fnd == regionToSum.end()) - { - regionToSum.insert(regioni, fld[celli]); - } - else - { - fnd() += fld[celli]; - } + const label regioni = regions[celli]; + regionToSum(regioni, Type(Zero)) += fld[celli]; } + Pstream::mapCombineGather(regionToSum, plusEqOp<Type>()); Pstream::mapCombineScatter(regionToSum); diff --git a/src/functionObjects/field/streamLine/streamLineParticle.C b/src/functionObjects/field/streamLine/streamLineParticle.C index 974ad7aa6e81129f3ade10a4b5e75369d6a78115..385747ca1ae87ecf3ca97c38c5a5d28de7191b5c 100644 --- a/src/functionObjects/field/streamLine/streamLineParticle.C +++ b/src/functionObjects/field/streamLine/streamLineParticle.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -389,11 +389,11 @@ void Foam::streamLineParticle::readFields(Cloud<streamLineParticle>& c) c.checkFieldIOobject(c, sampledPositions); label i = 0; - forAllIter(Cloud<streamLineParticle>, c, iter) + for (streamLineParticle& p : c) { - iter().lifeTime_ = lifeTime[i]; - iter().sampledPositions_.transfer(sampledPositions[i]); - i++; + p.lifeTime_ = lifeTime[i]; + p.sampledPositions_.transfer(sampledPositions[i]); + ++i; } } @@ -402,7 +402,7 @@ void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c) { particle::writeFields(c); - label np = c.size(); + const label np = c.size(); IOField<label> lifeTime ( @@ -416,11 +416,11 @@ void Foam::streamLineParticle::writeFields(const Cloud<streamLineParticle>& c) ); label i = 0; - forAllConstIter(Cloud<streamLineParticle>, c, iter) + for (const streamLineParticle& p : c) { - lifeTime[i] = iter().lifeTime_; - sampledPositions[i] = iter().sampledPositions_; - i++; + lifeTime[i] = p.lifeTime_; + sampledPositions[i] = p.sampledPositions_; + ++i; } lifeTime.write(np > 0); diff --git a/src/functionObjects/field/surfaceInterpolate/surfaceInterpolateTemplates.C b/src/functionObjects/field/surfaceInterpolate/surfaceInterpolateTemplates.C index 2e86a75feab65a4ebef9855a35b22e2bd6590405..770dc61f913d7867eca63a30bc718d41f1c717e9 100644 --- a/src/functionObjects/field/surfaceInterpolate/surfaceInterpolateTemplates.C +++ b/src/functionObjects/field/surfaceInterpolate/surfaceInterpolateTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -46,7 +46,7 @@ void Foam::functionObjects::surfaceInterpolate::interpolateFields() HashTable<const VolFieldType*> flds(obr_.lookupClass<VolFieldType>()); - forAllConstIter(typename HashTable<const VolFieldType*>, flds, iter) + forAllConstIters(flds, iter) { const VolFieldType& fld = *iter(); diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C index efebdceef346fe5f5d8e1fe3efa162feb82d0379..53429780e5fe6d7f1b9e812e1f5d172a4df746a7 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLine.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -305,16 +305,8 @@ bool Foam::functionObjects::wallBoundedStreamLine::read(const dictionary& dict) forAll(f, fp) { const edge e(f[fp], f.nextLabel(fp)); - EdgeMap<label>::iterator eFnd = numFacesPerEdge.find(e); - - if (eFnd != numFacesPerEdge.end()) - { - eFnd()++; - } - else - { - numFacesPerEdge.insert(e, 1); - } + + ++(numFacesPerEdge(e, 0)); } } diff --git a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.C b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.C index c4fea71aeb92a74fc96a2dfd7e620e49b726d361..7e5a9253803a99903d11cc8bb70c538fddbbeaad 100644 --- a/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.C +++ b/src/functionObjects/field/wallBoundedStreamLine/wallBoundedStreamLineParticle.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -218,11 +218,11 @@ void Foam::wallBoundedStreamLineParticle::readFields c.checkFieldIOobject(c, sampledPositions); label i = 0; - forAllIter(Cloud<wallBoundedStreamLineParticle>, c, iter) + for (wallBoundedStreamLineParticle& p : c) { - iter().lifeTime_ = lifeTime[i]; - iter().sampledPositions_.transfer(sampledPositions[i]); - i++; + p.lifeTime_ = lifeTime[i]; + p.sampledPositions_.transfer(sampledPositions[i]); + ++i; } } @@ -234,7 +234,7 @@ void Foam::wallBoundedStreamLineParticle::writeFields { wallBoundedParticle::writeFields(c); - label np = c.size(); + const label np = c.size(); IOField<label> lifeTime ( @@ -248,11 +248,11 @@ void Foam::wallBoundedStreamLineParticle::writeFields ); label i = 0; - forAllConstIter(Cloud<wallBoundedStreamLineParticle>, c, iter) + for (const wallBoundedStreamLineParticle& p : c) { - lifeTime[i] = iter().lifeTime_; - sampledPositions[i] = iter().sampledPositions_; - i++; + lifeTime[i] = p.lifeTime_; + sampledPositions[i] = p.sampledPositions_; + ++i; } lifeTime.write(); diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 12b82b4f34c5dc5d1599b018c8ba1967ad23c990..07586297aee27fde8c6993e1f8a618d82e7e3036 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -240,7 +240,7 @@ void Foam::functionObjects::forces::initialiseBins() const scalarField dd(mesh_.C() & binDir_); - forAllConstIter(HashTable<const porosityModel*>, models, iter) + forAllConstIters(models, iter) { const porosityModel& pm = *iter(); const labelList& cellZoneIDs = pm.cellZoneIDs(); diff --git a/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageConditionTemplates.C b/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageConditionTemplates.C index 26b8fa2c4cfe163f2253c8698ee5ac722489cb0a..48ab3b09dd6c620a13d227e48eb2282c1d3138be 100644 --- a/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageConditionTemplates.C +++ b/src/functionObjects/utilities/runTimeControl/runTimeCondition/averageCondition/averageConditionTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2016, 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2015 OpenFOAM Foundation @@ -121,10 +121,8 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc windowValues.push(currentValue); // Calculate the window average - typename FIFOStack<scalar>::const_iterator timeIter = - windowTimes.begin(); - typename FIFOStack<Type>::const_iterator valueIter = - windowValues.begin(); + auto timeIter = windowTimes.cbegin(); + auto valueIter = windowValues.cbegin(); meanValue = pTraits<Type>::zero; Type valueOld(pTraits<Type>::zero); @@ -132,7 +130,7 @@ void Foam::functionObjects::runTimeControls::averageCondition::calc for ( label i = 0; - timeIter != windowTimes.end(); + timeIter.good(); ++i, ++timeIter, ++valueIter ) {