STYLE: direct iteration over dictionary entries

This commit is contained in:
Mark Olesen
2021-11-25 19:53:22 +01:00
parent bcf8a48c68
commit f459b11e24
6 changed files with 20 additions and 29 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,11 +111,8 @@ bool Foam::loopControl::checkConverged() const
const fvMesh& regionMesh = *(meshIter.val()); const fvMesh& regionMesh = *(meshIter.val());
const dictionary& solverDict = regionMesh.solverPerformanceDict(); const dictionary& solverDict = regionMesh.solverPerformanceDict();
for (const entry& dataDictEntry : solverDict)
forAllConstIters(solverDict, iter)
{ {
const entry& dataDictEntry = *iter;
const word& variableName = dataDictEntry.keyword(); const word& variableName = dataDictEntry.keyword();
const scalar absTol = const scalar absTol =

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -73,10 +73,8 @@ bool Foam::pimpleControl::criteriaSatisfied()
bool checked = false; // safety that some checks were indeed performed bool checked = false; // safety that some checks were indeed performed
const dictionary& solverDict = mesh_.solverPerformanceDict(); const dictionary& solverDict = mesh_.solverPerformanceDict();
forAllConstIters(solverDict, iter) for (const entry& solverPerfDictEntry : solverDict)
{ {
const entry& solverPerfDictEntry = *iter;
const word& fieldName = solverPerfDictEntry.keyword(); const word& fieldName = solverPerfDictEntry.keyword();
const label fieldi = applyToField(fieldName); const label fieldi = applyToField(fieldName);

View File

@ -57,10 +57,8 @@ bool Foam::simpleControl::criteriaSatisfied()
bool checked = false; // safety that some checks were indeed performed bool checked = false; // safety that some checks were indeed performed
const dictionary& solverDict = mesh_.solverPerformanceDict(); const dictionary& solverDict = mesh_.solverPerformanceDict();
forAllConstIters(solverDict, iter) for (const entry& solverPerfDictEntry : solverDict)
{ {
const entry& solverPerfDictEntry = *iter;
const word& fieldName = solverPerfDictEntry.keyword(); const word& fieldName = solverPerfDictEntry.keyword();
const label fieldi = applyToField(fieldName); const label fieldi = applyToField(fieldName);

View File

@ -236,19 +236,18 @@ electrostaticDepositionFvPatchScalarField
sigmas_.setSize(phasesDict_.size()); sigmas_.setSize(phasesDict_.size());
label phasei = 0; label phasei = 0;
forAllConstIters(phasesDict_, iter) for (const entry& dEntry : phasesDict_)
{ {
const word& key = iter().keyword(); const word& key = dEntry.keyword();
if (!phasesDict_.isDict(key)) if (!dEntry.isDict())
{ {
FatalErrorInFunction FatalIOErrorInFunction(phasesDict_)
<< "Found non-dictionary entry " << iter() << "Entry " << key << " is not a dictionary" << nl
<< " in top-level dictionary " << phasesDict_ << exit(FatalIOError);
<< exit(FatalError);
} }
const dictionary& subDict = phasesDict_.subDict(key); const dictionary& subDict = dEntry.dict();
phaseNames_[phasei] = key; phaseNames_[phasei] = key;

View File

@ -243,19 +243,18 @@ bool Foam::functionObjects::electricPotential::read(const dictionary& dict)
} }
label phasei = 0; label phasei = 0;
forAllConstIters(phasesDict_, iter) for (const entry& dEntry : phasesDict_)
{ {
const word& key = iter().keyword(); const word& key = dEntry.keyword();
if (!phasesDict_.isDict(key)) if (!dEntry.isDict())
{ {
FatalErrorInFunction FatalIOErrorInFunction(phasesDict_)
<< "Found non-dictionary entry " << iter() << "Entry " << key << " is not a dictionary" << nl
<< " in top-level dictionary " << phasesDict_ << exit(FatalIOError);
<< exit(FatalError);
} }
const dictionary& subDict = phasesDict_.subDict(key); const dictionary& subDict = dEntry.dict();
phaseNames_[phasei] = key; phaseNames_[phasei] = key;

View File

@ -1982,7 +1982,7 @@ void Foam::snappyLayerDriver::getPatchDisplacement
// } // }
// } // }
// //
// forAllConstIter(Map<labelList>, cellToFaces, iter) // forAllConstIters(cellToFaces, iter)
// { // {
// if (iter().size() == 2) // if (iter().size() == 2)
// { // {