mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use range-for when looping dictionary entries.
- as part of the cleanup of dictionary access methods (c6520033c9)
made the dictionary class single inheritance from IDLList<entry>.
This eliminates any ambiguities for iterators and allows
for simple use of range-for looping.
Eg,
for (const entry& e : topDict))
{
Info<< "entry:" << e.keyword() << " is dict:" << e.isDict() << nl;
}
vs
forAllConstIter(dictionary, topDict, iter))
{
Info<< "entry:" << iter().keyword()
<< " is dict:" << iter().isDict() << nl;
}
This commit is contained in:
@ -650,17 +650,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Per faceSet the patch to put the coupled baffles into
|
||||
DynamicList<FixedList<word, 3>> coupledAndPatches(10);
|
||||
|
||||
const dictionary& functionDicts = dict.subDict("coupledFaces");
|
||||
forAllConstIter(dictionary, functionDicts, iter)
|
||||
|
||||
for (const entry& dEntry : functionDicts)
|
||||
{
|
||||
// safety:
|
||||
if (!iter().isDict())
|
||||
if (!dEntry.isDict()) // Safety
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const word& key = iter().keyword();
|
||||
|
||||
const dictionary& dict = iter().dict();
|
||||
const word& key = dEntry.keyword();
|
||||
const dictionary& dict = dEntry.dict();
|
||||
|
||||
const word cyclicName = dict.get<word>("cyclicMasterPatch");
|
||||
const word wallName = dict.get<word>("wallPatch");
|
||||
FixedList<word, 3> nameAndType;
|
||||
|
||||
@ -93,14 +93,10 @@ Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
|
||||
{
|
||||
label functionI = 0;
|
||||
|
||||
forAllConstIter(dictionary, shapeControlDict_, iter)
|
||||
for (const entry& dEntry : shapeControlDict_)
|
||||
{
|
||||
word shapeControlEntryName = iter().keyword();
|
||||
|
||||
const dictionary& controlFunctionDict
|
||||
(
|
||||
shapeControlDict_.subDict(shapeControlEntryName)
|
||||
);
|
||||
const word& shapeControlEntryName = dEntry.keyword();
|
||||
const dictionary& controlFunctionDict = dEntry.dict();
|
||||
|
||||
Info<< nl << "Shape Control : " << shapeControlEntryName << endl;
|
||||
Info<< incrIndent;
|
||||
|
||||
@ -535,16 +535,12 @@ Foam::conformationSurfaces::conformationSurfaces
|
||||
Info<< nl << "Reading additionalFeatures" << endl;
|
||||
}
|
||||
|
||||
forAllConstIter(dictionary, additionalFeaturesDict, iter)
|
||||
for (const entry& dEntry : additionalFeaturesDict)
|
||||
{
|
||||
word featureName = iter().keyword();
|
||||
const word& featureName = dEntry.keyword();
|
||||
const dictionary& featureSubDict = dEntry.dict();
|
||||
|
||||
Info<< nl << " " << iter().keyword() << endl;
|
||||
|
||||
const dictionary& featureSubDict
|
||||
(
|
||||
additionalFeaturesDict.subDict(featureName)
|
||||
);
|
||||
Info<< nl << " " << featureName << endl;
|
||||
|
||||
readFeatures(featureSubDict, featureName, featureI);
|
||||
}
|
||||
|
||||
@ -474,27 +474,24 @@ int main(int argc, char *argv[])
|
||||
|
||||
const dictionary& selectionsDict = dict.subDict("baffles");
|
||||
|
||||
label n = 0;
|
||||
forAllConstIter(dictionary, selectionsDict, iter)
|
||||
selectors.resize(selectionsDict.size());
|
||||
|
||||
label nselect = 0;
|
||||
for (const entry& dEntry : selectionsDict)
|
||||
{
|
||||
if (iter().isDict())
|
||||
{
|
||||
n++;
|
||||
}
|
||||
}
|
||||
selectors.setSize(n);
|
||||
n = 0;
|
||||
forAllConstIter(dictionary, selectionsDict, iter)
|
||||
{
|
||||
if (iter().isDict())
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
selectors.set
|
||||
(
|
||||
n++,
|
||||
faceSelection::New(iter().keyword(), mesh, iter().dict())
|
||||
nselect,
|
||||
faceSelection::New(dEntry.keyword(), mesh, dEntry.dict())
|
||||
);
|
||||
|
||||
++nselect;
|
||||
}
|
||||
}
|
||||
|
||||
selectors.resize(nselect);
|
||||
}
|
||||
|
||||
|
||||
@ -641,10 +638,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (dict.found("patches"))
|
||||
{
|
||||
const dictionary& patchSources = dict.subDict("patches");
|
||||
forAllConstIter(dictionary, patchSources, iter)
|
||||
for (const entry& dEntry : dict.subDict("patches"))
|
||||
{
|
||||
const word patchName(iter().dict().get<word>("name"));
|
||||
const word patchName(dEntry.dict().get<word>("name"));
|
||||
|
||||
bafflePatches.insert(patchName);
|
||||
}
|
||||
@ -687,14 +683,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (dict.found("patches"))
|
||||
{
|
||||
const dictionary& patchSources = dict.subDict("patches");
|
||||
forAllConstIter(dictionary, patchSources, iter)
|
||||
for (const entry& dEntry : dict.subDict("patches"))
|
||||
{
|
||||
const word patchName(iter().dict().get<word>("name"));
|
||||
const dictionary& dict = dEntry.dict();
|
||||
|
||||
const word patchName(dict.get<word>("name"));
|
||||
|
||||
if (pbm.findPatchID(patchName) == -1)
|
||||
{
|
||||
dictionary patchDict = iter().dict();
|
||||
dictionary patchDict = dict;
|
||||
patchDict.set("nFaces", 0);
|
||||
patchDict.set("startFace", 0);
|
||||
|
||||
@ -789,13 +786,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (dict.found("patches"))
|
||||
{
|
||||
const dictionary& patchSources = dict.subDict("patches");
|
||||
|
||||
bool master = true;
|
||||
forAllConstIter(dictionary, patchSources, iter)
|
||||
|
||||
for (const entry& dEntry : dict.subDict("patches"))
|
||||
{
|
||||
const word patchName(iter().dict().get<word>("name"));
|
||||
label patchi = pbm.findPatchID(patchName);
|
||||
const word patchName(dEntry.dict().get<word>("name"));
|
||||
|
||||
const label patchi = pbm.findPatchID(patchName);
|
||||
|
||||
if (master)
|
||||
{
|
||||
newMasterPatches.append(patchi);
|
||||
@ -885,17 +883,18 @@ int main(int argc, char *argv[])
|
||||
const dictionary& dict = selectors[selectorI].dict();
|
||||
if (dict.found("patches"))
|
||||
{
|
||||
const dictionary& patchSources = dict.subDict("patches");
|
||||
|
||||
forAllConstIter(dictionary, patchSources, iter)
|
||||
for (const entry& dEntry : dict.subDict("patches"))
|
||||
{
|
||||
const word patchName(iter().dict().get<word>("name"));
|
||||
const dictionary& dict = dEntry.dict();
|
||||
|
||||
const word patchName(dict.get<word>("name"));
|
||||
|
||||
label patchi = pbm.findPatchID(patchName);
|
||||
|
||||
if (iter().dict().found("patchFields"))
|
||||
if (dEntry.dict().found("patchFields"))
|
||||
{
|
||||
const dictionary& patchFieldsDict =
|
||||
iter().dict().subDict
|
||||
dEntry.dict().subDict
|
||||
(
|
||||
"patchFields"
|
||||
);
|
||||
@ -928,11 +927,11 @@ int main(int argc, char *argv[])
|
||||
if (sameGroup)
|
||||
{
|
||||
// Add coupleGroup to all entries
|
||||
forAllIter(dictionary, patchFieldsDict, iter)
|
||||
for (entry& dEntry : patchFieldsDict)
|
||||
{
|
||||
if (iter().isDict())
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
dictionary& dict = iter().dict();
|
||||
dictionary& dict = dEntry.dict();
|
||||
dict.set("coupleGroup", groupName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,16 +292,17 @@ int main(int argc, char *argv[])
|
||||
// Suppress duplicate names
|
||||
wordHashSet requestedPatches;
|
||||
|
||||
forAllConstIters(stitchDict, iter)
|
||||
for (const entry& dEntry : stitchDict)
|
||||
{
|
||||
if (!iter().isDict())
|
||||
if (!dEntry.isDict())
|
||||
{
|
||||
Info<< "Ignoring non-dictionary entry: "
|
||||
<< iter().keyword() << nl;
|
||||
<< dEntry.keyword() << nl;
|
||||
continue;
|
||||
}
|
||||
|
||||
const dictionary& dict = iter().dict();
|
||||
const keyType& key = dEntry.keyword();
|
||||
const dictionary& dict = dEntry.dict();
|
||||
|
||||
// Match type
|
||||
word matchName;
|
||||
@ -358,7 +359,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Input was validated
|
||||
|
||||
validatedDict.add(iter().keyword(), iter().dict());
|
||||
validatedDict.add(key, dict);
|
||||
}
|
||||
}
|
||||
|
||||
@ -433,9 +434,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Step through the topology changes
|
||||
label actioni = 0;
|
||||
forAllConstIters(validatedDict, iter)
|
||||
for (const entry& dEntry : validatedDict)
|
||||
{
|
||||
const dictionary& dict = iter().dict();
|
||||
const dictionary& dict = dEntry.dict();
|
||||
|
||||
// Match type
|
||||
bool perfect = false;
|
||||
|
||||
@ -97,10 +97,10 @@ HashTable<wordList> extractPatchGroups(const dictionary& boundaryDict)
|
||||
{
|
||||
HashTable<wordList> groupToPatch;
|
||||
|
||||
forAllConstIter(dictionary, boundaryDict, iter)
|
||||
for (const entry& dEntry : boundaryDict)
|
||||
{
|
||||
const word& patchName = iter().keyword();
|
||||
const dictionary& patchDict = iter().dict();
|
||||
const word& patchName = dEntry.keyword();
|
||||
const dictionary& patchDict = dEntry.dict();
|
||||
|
||||
wordList groups;
|
||||
if (patchDict.readIfPresent("inGroups", groups))
|
||||
@ -243,9 +243,9 @@ bool merge
|
||||
|
||||
// Pass 1. All literal matches
|
||||
|
||||
forAllConstIter(IDLList<entry>, mergeDict, mergeIter)
|
||||
for (const entry& mergeEntry : mergeDict)
|
||||
{
|
||||
const keyType& key = mergeIter().keyword();
|
||||
const keyType& key = mergeEntry.keyword();
|
||||
|
||||
if (key[0] == '~')
|
||||
{
|
||||
@ -274,7 +274,7 @@ bool merge
|
||||
(
|
||||
thisDict,
|
||||
*eptr,
|
||||
mergeIter(),
|
||||
mergeEntry,
|
||||
literalRE,
|
||||
shortcuts
|
||||
)
|
||||
@ -287,8 +287,8 @@ bool merge
|
||||
{
|
||||
if (addNonExisting)
|
||||
{
|
||||
// not found - just add
|
||||
thisDict.add(mergeIter().clone(thisDict).ptr());
|
||||
// Not found - just add
|
||||
thisDict.add(mergeEntry.clone(thisDict).ptr());
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
@ -309,9 +309,9 @@ bool merge
|
||||
// Pick up remaining dictionary entries
|
||||
wordList thisKeys(thisKeysSet.toc());
|
||||
|
||||
forAllConstIter(IDLList<entry>, mergeDict, mergeIter)
|
||||
for (const entry& mergeEntry : mergeDict)
|
||||
{
|
||||
const keyType& key = mergeIter().keyword();
|
||||
const keyType& key = mergeEntry.keyword();
|
||||
|
||||
if (key[0] == '~')
|
||||
{
|
||||
@ -364,7 +364,7 @@ bool merge
|
||||
(
|
||||
thisDict,
|
||||
*eptr,
|
||||
mergeIter(),
|
||||
mergeEntry,
|
||||
literalRE,
|
||||
HashTable<wordList>(0) // no shortcuts
|
||||
// at deeper levels
|
||||
@ -462,7 +462,7 @@ int main(int argc, char *argv[])
|
||||
const bool enableEntries = args.found("enableFunctionEntries");
|
||||
if (enableEntries)
|
||||
{
|
||||
Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')."
|
||||
Info<< "Allowing dictionary preprocessing (#include, #codeStream)."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -550,9 +550,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Temporary convert to dictionary
|
||||
dictionary fieldDict;
|
||||
forAll(dictList, i)
|
||||
for (const entry& e : dictList)
|
||||
{
|
||||
fieldDict.add(dictList[i].keyword(), dictList[i].dict());
|
||||
fieldDict.add(e.keyword(), e.dict());
|
||||
}
|
||||
|
||||
if (dictList.size())
|
||||
@ -582,9 +582,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Every replacement is a dictionary name and a keyword in this
|
||||
|
||||
forAllConstIter(dictionary, replaceDicts, fieldIter)
|
||||
for (const entry& replaceEntry : replaceDicts)
|
||||
{
|
||||
const word& fieldName = fieldIter().keyword();
|
||||
const word& fieldName = replaceEntry.keyword();
|
||||
const dictionary& replaceDict = replaceEntry.dict();
|
||||
|
||||
Info<< "Replacing entries in dictionary " << fieldName << endl;
|
||||
|
||||
// Handle 'boundary' specially:
|
||||
@ -595,11 +597,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "Special handling of " << fieldName
|
||||
<< " as polyMesh/boundary file." << endl;
|
||||
|
||||
// Get the replacement dictionary for the field
|
||||
const dictionary& replaceDict = fieldIter().dict();
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
|
||||
// Merge the replacements in. Do not add non-existing entries.
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
merge(false, fieldDict, replaceDict, literalRE, patchGroups);
|
||||
|
||||
Info<< "fieldDict:" << fieldDict << endl;
|
||||
@ -627,9 +626,9 @@ int main(int argc, char *argv[])
|
||||
// Add remaining entries
|
||||
label sz = dictList.size();
|
||||
dictList.setSize(nEntries);
|
||||
forAllConstIter(dictionary, fieldDict, iter)
|
||||
for (const entry& e : fieldDict)
|
||||
{
|
||||
dictList.set(sz++, iter().clone());
|
||||
dictList.set(sz++, e.clone());
|
||||
}
|
||||
|
||||
Info<< "Writing modified " << fieldName << endl;
|
||||
@ -672,11 +671,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "Loaded dictionary " << fieldName
|
||||
<< " with entries " << fieldDict.toc() << endl;
|
||||
|
||||
// Get the replacement dictionary for the field
|
||||
const dictionary& replaceDict = fieldIter().dict();
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
|
||||
// Merge the replacements in (allow adding)
|
||||
Info<< "Merging entries from " << replaceDict.toc() << endl;
|
||||
merge(true, fieldDict, replaceDict, literalRE, patchGroups);
|
||||
|
||||
Info<< "Writing modified fieldDict " << fieldName << endl;
|
||||
|
||||
@ -54,9 +54,9 @@ Foam::boundaryTemplates::boundaryTemplates
|
||||
)
|
||||
);
|
||||
|
||||
forAllConstIter(dictionary, regionBCs, iter)
|
||||
for (const entry& dEntry : regionBCs)
|
||||
{
|
||||
const word& regionType = iter().keyword();
|
||||
const word& regionType = dEntry.keyword();
|
||||
wordList patchTypes(regionBCs.lookup(regionType));
|
||||
|
||||
dictionary regionTemplate = dictionary::null;
|
||||
@ -175,7 +175,7 @@ Foam::dictionary Foam::boundaryTemplates::generatePatchDict
|
||||
// look for inlet, outlet, wall etc
|
||||
if (regionTemplates.found(category))
|
||||
{
|
||||
const dictionary& categoryDict(regionTemplates.subDict(category));
|
||||
const dictionary& categoryDict = regionTemplates.subDict(category);
|
||||
|
||||
// look for subSonic, slip etc
|
||||
if (categoryDict.found(patchType))
|
||||
@ -199,10 +199,8 @@ Foam::dictionary Foam::boundaryTemplates::generatePatchDict
|
||||
|
||||
const wordList requiredOptions(patchDict.lookup("OPTIONS"));
|
||||
|
||||
forAll(requiredOptions, i)
|
||||
for (const word& option : requiredOptions)
|
||||
{
|
||||
const word& option = requiredOptions[i];
|
||||
|
||||
word selected;
|
||||
if (!conditionOptions.readIfPresent(option, selected))
|
||||
{
|
||||
@ -252,18 +250,19 @@ Foam::dictionary Foam::boundaryTemplates::generatePatchDict
|
||||
dictionary dict(dictionary::null);
|
||||
const dictionary& fieldDict(patchDict.subDict(fieldName));
|
||||
|
||||
forAllConstIter(IDLList<entry>, fieldDict, iter)
|
||||
for (const entry& dEntry : fieldDict)
|
||||
{
|
||||
OStringStream oss;
|
||||
oss << iter();
|
||||
oss << dEntry;
|
||||
|
||||
string s(oss.str());
|
||||
s.replace(iter().keyword(), "");
|
||||
s.replace(dEntry.keyword(), "");
|
||||
s.replace
|
||||
(
|
||||
"VALUE",
|
||||
"boundaryConditions." + condition + ".values"
|
||||
);
|
||||
dict.add(iter().keyword(), s.c_str());
|
||||
dict.add(dEntry.keyword(), s.c_str());
|
||||
}
|
||||
|
||||
return dict;
|
||||
@ -344,7 +343,7 @@ bool Foam::boundaryTemplates::optionsRequired
|
||||
|
||||
if (regionTemplates.found(category))
|
||||
{
|
||||
const dictionary& categoryDict(regionTemplates.subDict(category));
|
||||
const dictionary& categoryDict = regionTemplates.subDict(category);
|
||||
|
||||
if (categoryDict.found(patchType))
|
||||
{
|
||||
|
||||
@ -86,9 +86,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
label nCoarseFaces = 0;
|
||||
|
||||
forAllConstIter(dictionary, agglomDict, iter)
|
||||
for (const entry& dEntry : agglomDict)
|
||||
{
|
||||
labelList patchids = boundary.indices(iter().keyword());
|
||||
labelList patchids = boundary.indices(dEntry.keyword());
|
||||
|
||||
for (const label patchi : patchids)
|
||||
{
|
||||
const polyPatch& pp = boundary[patchi];
|
||||
|
||||
@ -241,14 +241,15 @@ int main(int argc, char *argv[])
|
||||
// Where to write VTK output files
|
||||
const fileName vtkOutputDir = runTime.constantPath()/"triSurface";
|
||||
|
||||
forAllConstIters(dict, iter)
|
||||
for (const entry& dEntry : dict)
|
||||
{
|
||||
if (!iter().isDict() || iter().keyword().isPattern())
|
||||
if (!dEntry.isDict() || dEntry.keyword().isPattern()) // safety
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const dictionary& surfaceDict = iter().dict();
|
||||
const word& dictName = dEntry.keyword();
|
||||
const dictionary& surfaceDict = dEntry.dict();
|
||||
|
||||
if (!surfaceDict.found("extractionMethod"))
|
||||
{
|
||||
@ -257,7 +258,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// The output name based in dictionary name (without extensions)
|
||||
const word& dictName = iter().keyword();
|
||||
const word outputName = dictName.lessExt();
|
||||
|
||||
autoPtr<surfaceFeaturesExtraction::method> extractor =
|
||||
|
||||
@ -84,12 +84,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
const dictionary& surfacesDict = meshDict.subDict("surfaces");
|
||||
|
||||
forAllConstIter(dictionary, surfacesDict, surfacesIter)
|
||||
for (const entry& dEntry : surfacesDict)
|
||||
{
|
||||
if (surfacesIter().isDict())
|
||||
if (dEntry.isDict())
|
||||
{
|
||||
const word& surfName = surfacesIter().keyword();
|
||||
const dictionary& surfDict = surfacesIter().dict();
|
||||
const word& surfName = dEntry.keyword();
|
||||
const dictionary& surfDict = dEntry.dict();
|
||||
|
||||
// Look up surface
|
||||
searchableSurface& surf = allGeometry[surfName];
|
||||
@ -120,10 +120,11 @@ int main(int argc, char *argv[])
|
||||
if (surfDict.found("regions"))
|
||||
{
|
||||
const dictionary& regionsDict = surfDict.subDict("regions");
|
||||
forAllConstIter(dictionary, regionsDict, regionsIter)
|
||||
|
||||
for (const entry& e : regionsDict)
|
||||
{
|
||||
const dictionary& regionDict = regionsIter().dict();
|
||||
const keyType& regionName = regionsIter().keyword();
|
||||
const keyType& regionName = e.keyword();
|
||||
const dictionary& regionDict = e.dict();
|
||||
|
||||
autoPtr<searchableSurfaceModifier> modifier
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user