STYLE: avoid unrestricted dictionary lookup in conversion, sampling, surfMesh

- aids with detection of excess tokens (issue #762)

- deprecated dictionary::operator[] in favour of the lookup() method
  which offers more flexibilty and clarity of purpose.
  Additionally, the read<> and get<> forms should generally be used
  instead anyhow.
This commit is contained in:
Mark Olesen
2018-07-18 13:33:00 +02:00
parent 956abe3f38
commit a592ebc073
59 changed files with 158 additions and 262 deletions

View File

@ -21,23 +21,8 @@
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
label index;
timeObject.lookup("index") >> index;
timeName = Foam::name(index);
const label timeIndex = IOdictionary(io).get<label>("index");
timeName = Foam::name(timeIndex);
}
else
{
@ -46,4 +31,3 @@
}
Info<< "\nTime [" << timeName << "] = " << runTime.timeName() << nl;

View File

@ -21,23 +21,8 @@
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
label index;
timeObject.lookup("index") >> index;
timeName = Foam::name(index);
const label timeIndex = IOdictionary(io).get<label>("index");
timeName = Foam::name(timeIndex);
}
else
{
@ -48,4 +33,3 @@
}
Info<< "\nTime [" << timeName << "] = " << runTime.timeName() << nl;

View File

@ -21,23 +21,8 @@
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
label index;
timeObject.lookup("index") >> index;
timeName = Foam::name(index);
const label timeIndex = IOdictionary(io).get<label>("index");
timeName = Foam::name(timeIndex);
}
else
{

View File

@ -21,23 +21,8 @@
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
);
label index;
timeObject.lookup("index") >> index;
timeName = Foam::name(index);
const label timeIndex = IOdictionary(io).get<label>("index");
timeName = Foam::name(timeIndex);
}
else
{

View File

@ -641,7 +641,8 @@ int main(int argc, char *argv[])
const dictionary& patchSources = dict.subDict("patches");
forAllConstIter(dictionary, patchSources, iter)
{
const word patchName(iter().dict()["name"]);
const word patchName(iter().dict().get<word>("name"));
bafflePatches.insert(patchName);
}
}
@ -649,6 +650,7 @@ int main(int argc, char *argv[])
{
const word masterName = selectors[selectorI].name() + "_master";
bafflePatches.insert(masterName);
const word slaveName = selectors[selectorI].name() + "_slave";
bafflePatches.insert(slaveName);
}
@ -685,7 +687,7 @@ int main(int argc, char *argv[])
const dictionary& patchSources = dict.subDict("patches");
forAllConstIter(dictionary, patchSources, iter)
{
const word patchName(iter().dict()["name"]);
const word patchName(iter().dict().get<word>("name"));
if (pbm.findPatchID(patchName) == -1)
{
@ -789,7 +791,7 @@ int main(int argc, char *argv[])
bool master = true;
forAllConstIter(dictionary, patchSources, iter)
{
const word patchName(iter().dict()["name"]);
const word patchName(iter().dict().get<word>("name"));
label patchi = pbm.findPatchID(patchName);
if (master)
{
@ -884,7 +886,7 @@ int main(int argc, char *argv[])
forAllConstIter(dictionary, patchSources, iter)
{
const word patchName(iter().dict()["name"]);
const word patchName(iter().dict().get<word>("name"));
label patchi = pbm.findPatchID(patchName);
if (iter().dict().found("patchFields"))

View File

@ -55,7 +55,7 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p)
{
if (patchNames_[patchi] == pName)
{
if (word(patchDicts_[patchi]["type"]) == pType)
if (patchDicts_[patchi].get<word>("type") == pType)
{
// Found name and types match
return patchi;

View File

@ -320,8 +320,8 @@ int main(int argc, char *argv[])
}
// Patch names
const word masterPatchName(dict["master"]);
const word slavePatchName(dict["slave"]);
const word masterPatchName(dict.get<word>("master"));
const word slavePatchName(dict.get<word>("slave"));
// Patch names
Info<< " " << masterPatchName
@ -454,8 +454,8 @@ int main(int argc, char *argv[])
}
// Patch names
const word masterPatchName(dict["master"]);
const word slavePatchName(dict["slave"]);
const word masterPatchName(dict.get<word>("master"));
const word slavePatchName(dict.get<word>("slave"));
// Zone names
const word mergePatchName(masterPatchName + slavePatchName);

View File

@ -95,7 +95,7 @@ void rewriteBoundary
{
const dictionary& patchDict = patches[patchi].dict();
if (word(patchDict["type"]) == cyclicPolyPatch::typeName)
if (patchDict.get<word>("type") == cyclicPolyPatch::typeName)
{
if (!patchDict.found("neighbourPatch"))
{
@ -130,7 +130,7 @@ void rewriteBoundary
if
(
word(patchDict["type"]) == cyclicPolyPatch::typeName
patchDict.get<word>("type") == cyclicPolyPatch::typeName
)
{
const word& name = oldPatches[patchi].keyword();
@ -167,10 +167,10 @@ void rewriteBoundary
}
else
{
label nFaces = readLabel(patchDict["nFaces"]);
label startFace = readLabel(patchDict["startFace"]);
label nFaces = patchDict.get<label>("nFaces");
label startFace = patchDict.get<label>("startFace");
Info<< "Detected old style " << word(patchDict["type"])
Info<< "Detected old style " << patchDict.get<word>("type")
<< " patch " << name << " with" << nl
<< " nFaces : " << nFaces << nl
<< " startFace : " << startFace << endl;
@ -213,17 +213,15 @@ void rewriteBoundary
Info<< "Replaced with patches" << nl
<< patches[patchi].keyword() << " with" << nl
<< " nFaces : "
<< readLabel(thisPatchDict.lookup("nFaces"))
<< nl
<< thisPatchDict.get<label>("nFaces") << nl
<< " startFace : "
<< readLabel(thisPatchDict.lookup("startFace")) << nl
<< thisPatchDict.get<label>("startFace") << nl
<< patches[addedPatchi].keyword() << " with" << nl
<< " nFaces : "
<< readLabel(nbrPatchDict.lookup("nFaces"))
<< nl
<< nbrPatchDict.get<label>("nFaces") << nl
<< " startFace : "
<< readLabel(nbrPatchDict.lookup("startFace"))
<< nl << endl;
<< nbrPatchDict.get<label>("startFace") << nl
<< endl;
addedPatchi++;
}

View File

@ -292,7 +292,7 @@ int main(int argc, char *argv[])
// message.
if (surfaceDict.found("surfaces") || !dictName.hasExt())
{
loader.select(wordReList(surfaceDict.lookup("surfaces")));
loader.select(surfaceDict.get<wordRes>("surfaces"));
}
else
{
@ -508,7 +508,7 @@ int main(int argc, char *argv[])
boolList surfBaffleRegions(surf.patches().size(), false);
if (surfaceDict.found("baffles"))
{
wordReList baffleSelect(surfaceDict.lookup("baffles"));
wordRes baffleSelect(surfaceDict.get<wordRes>("baffles"));
wordList patchNames(surf.patches().size());
forAll(surf.patches(), patchi)
@ -549,7 +549,11 @@ int main(int argc, char *argv[])
if (surfaceDict.isDict("addFeatures"))
{
const word addFeName = surfaceDict.subDict("addFeatures")["name"];
const word addFeName
(
surfaceDict.subDict("addFeatures").get<word>("name")
);
Info<< "Adding (without merging) features from " << addFeName
<< nl << endl;
@ -736,7 +740,7 @@ int main(int argc, char *argv[])
outputName,
feMesh,
surf,
readScalar(surfaceDict.lookup("maxFeatureProximity"))
surfaceDict.get<scalar>("maxFeatureProximity")
);
if (writeVTK)

View File

@ -64,7 +64,7 @@ Foam::ODESolver::ODESolver(const ODESystem& ode, const dictionary& dict)
n_(ode.nEqns()),
absTol_(n_, dict.lookupOrDefault<scalar>("absTol", SMALL)),
relTol_(n_, dict.lookupOrDefault<scalar>("relTol", 1e-4)),
maxSteps_(dict.lookupOrDefault<scalar>("maxSteps", 10000))
maxSteps_(dict.lookupOrDefault<label>("maxSteps", 10000))
{}
@ -149,7 +149,7 @@ void Foam::ODESolver::solve
stepState step(dxTry);
scalar x = xStart;
for (label nStep=0; nStep<maxSteps_; nStep++)
for (label nStep=0; nStep<maxSteps_; ++nStep)
{
// Store previous iteration dxTry
scalar dxTry0 = step.dxTry;

View File

@ -33,7 +33,7 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
const dictionary& dict
)
{
const word solverType(dict.lookup("solver"));
const word solverType(dict.get<word>("solver"));
Info<< "Selecting ODE solver " << solverType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(solverType);

View File

@ -810,12 +810,6 @@ void Foam::dictionary::transfer(dictionary& dict)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
Foam::ITstream& Foam::dictionary::operator[](const word& keyword) const
{
return lookup(keyword);
}
void Foam::dictionary::operator=(const dictionary& rhs)
{
if (this == &rhs)

View File

@ -1113,11 +1113,13 @@ public:
// Member Operators
//- Find and return an entry data stream (identical to #lookup method).
// Default search: non-recursive with patterns.
// Search: non-recursive with patterns.
//
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
ITstream& operator[](const word& keyword) const;
// \deprecated use lookup() method instead (deprecated JUL-2018)
ITstream& operator[](const word& keyword) const
{
return lookup(keyword);
}
//- Copy assignment
void operator=(const dictionary& rhs);

View File

@ -544,7 +544,7 @@ Foam::Istream& Foam::dimensionSet::read
scalar exponent = readScalar(exp);
dimensionedScalar s;
s.read(readSet[symbol], readSet);
s.read(readSet.lookup(symbol), readSet);
symbolSet.reset(pow(s.dimensions(), exponent));
// Round to nearest integer if close to it
@ -554,7 +554,7 @@ Foam::Istream& Foam::dimensionSet::read
else
{
dimensionedScalar s;
s.read(readSet[symbolPow], readSet);
s.read(readSet.lookup(symbolPow), readSet);
symbolSet.reset(s.dimensions());
multiplier *= s.value();

View File

@ -966,24 +966,15 @@ void Foam::argList::parse
// 5. '-fileHandler' commmand-line option
{
word handlerType
(
options_.lookup("fileHandler", getEnv("FOAM_FILEHANDLER"))
);
word handlerType =
options_.lookup("fileHandler", getEnv("FOAM_FILEHANDLER"));
if (handlerType.empty())
{
handlerType = fileOperation::defaultFileHandler;
}
autoPtr<fileOperation> handler
(
fileOperation::New
(
handlerType,
bannerEnabled()
)
);
auto handler = fileOperation::New(handlerType, bannerEnabled());
Foam::fileHandler(handler);
}
@ -1159,15 +1150,12 @@ void Foam::argList::parse
dictionary decompDict(decompDictStream);
dictNProcs = readLabel
(
decompDict.lookup("numberOfSubdomains")
);
dictNProcs = decompDict.get<label>("numberOfSubdomains");
if (decompDict.lookupOrDefault("distributed", false))
{
distributed_ = true;
decompDict.lookup("roots") >> roots;
decompDict.read("roots", roots);
}
}
@ -1700,8 +1688,8 @@ void Foam::argList::printCompat() const
void Foam::argList::displayDoc(bool source) const
{
const dictionary& docDict = debug::controlDict().subDict("Documentation");
List<fileName> docDirs(docDict.lookup("doxyDocDirs"));
fileName docExt(docDict.lookup("doxySourceFileExt"));
fileNameList docDirs(docDict.get<fileNameList>("doxyDocDirs"));
fileName docExt(docDict.get<fileName>("doxySourceFileExt"));
// For source code: change xxx_8C.html to xxx_8C_source.html
if (source)
@ -1746,7 +1734,7 @@ void Foam::argList::displayDoc(bool source) const
string docBrowser = getEnv("FOAM_DOC_BROWSER");
if (docBrowser.empty())
{
docDict.lookup("docBrowser") >> docBrowser;
docDict.read("docBrowser", docBrowser);
}
// Can use FOAM_DOC_BROWSER='application file://%f' if required

View File

@ -61,7 +61,7 @@ dimensionedScalar dimensionedConstant
<< std::endl;
}
const word unitSetCoeffs(word(dict.lookup("unitSet")) + "Coeffs");
const word unitSetCoeffs(dict.get<word>("unitSet") + "Coeffs");
if (!dict.found(unitSetCoeffs))
{

View File

@ -1179,7 +1179,7 @@ const Foam::fileOperation& Foam::fileHandler()
{
word handler(getEnv("FOAM_FILEHANDLER"));
if (!handler.size())
if (handler.empty())
{
handler = fileOperation::defaultFileHandler;
}
@ -1191,14 +1191,14 @@ const Foam::fileOperation& Foam::fileHandler()
}
void Foam::fileHandler(autoPtr<fileOperation>& newHandlerPtr)
void Foam::fileHandler(autoPtr<fileOperation>& newHandler)
{
if (fileOperation::fileHandlerPtr_.valid())
{
if
(
newHandlerPtr.valid()
&& newHandlerPtr->type() == fileOperation::fileHandlerPtr_->type()
newHandler.valid()
&& newHandler->type() == fileOperation::fileHandlerPtr_->type()
)
{
return;
@ -1206,9 +1206,9 @@ void Foam::fileHandler(autoPtr<fileOperation>& newHandlerPtr)
}
fileOperation::fileHandlerPtr_.clear();
if (newHandlerPtr.valid())
if (newHandler.valid())
{
fileOperation::fileHandlerPtr_ = std::move(newHandlerPtr);
fileOperation::fileHandlerPtr_ = std::move(newHandler);
}
}

View File

@ -563,7 +563,7 @@ public:
const fileOperation& fileHandler();
//- Reset file handler
void fileHandler(autoPtr<fileOperation>&);
void fileHandler(autoPtr<fileOperation>& newHandler);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -402,7 +402,7 @@ void Foam::ccm::reader::readProblemDescription_boundaryRegion
)
{
// Fallback
str = word(dict["BoundaryType"]) + "_" + ::Foam::name(Id);
str = dict.get<word>("BoundaryType") + "_" + ::Foam::name(Id);
}
if (!str.empty())

View File

@ -480,8 +480,10 @@ void Foam::ccm::reader::readCells
auto dictIter = boundaryRegion_.find(info.ccmIndex);
if (dictIter.found())
{
word patchName(dictIter()["Label"]);
word patchType(dictIter()["BoundaryType"]);
dictionary& dict = dictIter.object();
const word patchName(dict.get<word>("Label"));
const word patchType(dict.get<word>("BoundaryType"));
if (!patchName.empty())
{
@ -494,8 +496,8 @@ void Foam::ccm::reader::readCells
}
// Optional, but potentially useful information:
dictIter().add("BoundaryIndex", info.ccmIndex);
dictIter().add("size", info.size);
dict.add("BoundaryIndex", info.ccmIndex);
dict.add("size", info.size);
}
bndInfo.append(info);
@ -1039,7 +1041,7 @@ void Foam::ccm::reader::readMonitoring
word zoneName;
if (iter.found())
{
iter().lookup("Label") >> zoneName;
iter().read("Label", zoneName);
}
else
{
@ -2415,7 +2417,7 @@ void Foam::ccm::reader::addPatches
// provide some fallback values
forAll(newPatches, patchI)
{
word fallbackName("patch" + Foam::name(patchI));
const word fallbackName("patch" + Foam::name(patchI));
word patchName;
word patchType;
@ -2423,8 +2425,8 @@ void Foam::ccm::reader::addPatches
if (citer.found())
{
citer().lookup("Label") >> patchName;
citer().lookup("BoundaryType") >> patchType;
citer().read("Label", patchName);
citer().read("BoundaryType", patchType);
}
else
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// name for the topology file reference
// Name for the topology file reference
Foam::string Foam::ccm::writer::defaultMeshName = "meshExport";
@ -98,23 +98,19 @@ void Foam::ccm::writer::writeBoundaryRegion
forAllConstIters(boundaryRegion_, iter)
{
const dictionary& dict = iter();
word nameEntry;
word typeEntry;
if
(
dict.found("Label")
&& dict.found("BoundaryType")
dict.readIfPresent("Label", nameEntry)
&& dict.readIfPresent("BoundaryType", typeEntry)
&& !typeDict.found(nameEntry)
)
{
word nameEntry, typeEntry;
dict.lookup("Label") >> nameEntry;
dict.lookup("BoundaryType") >> typeEntry;
if (!typeDict.found(nameEntry))
{
typeDict.add(nameEntry, typeEntry);
}
}
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
@ -160,7 +156,7 @@ void Foam::ccm::writer::writeBoundaryRegion
}
else if (defaultId == -1 || regionId < defaultId)
{
regionId++;
++regionId;
}
// Use BoundaryType from constant/boundaryRegion
@ -223,15 +219,15 @@ void Foam::ccm::writer::writeCellTable
);
wordList toc = dict.toc();
forAll(toc, i)
for (const word& keyword : toc)
{
word keyword = toc[i];
int pos = keyword.find("Id");
// Tags containing 'Id' are integers
if (pos > 0)
{
dict.lookup(keyword) >> intVal;
dict.read(keyword, intVal);
CCMIOWriteOpti
(
nullptr,
@ -242,8 +238,7 @@ void Foam::ccm::writer::writeCellTable
}
else if (pos < 0)
{
word strVal;
dict.lookup(keyword) >> strVal;
const word strVal(dict.get<word>(keyword));
CCMIOWriteOptstr
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -352,7 +352,6 @@ void Foam::ccm::writer::writeSolution
// Get time information
const Time& runTime = mesh_.time();
label timeIndex = 0;
// scalar timeValue = runTime.timeName();
if
(
runTime.timeName() != runTime.constant()
@ -372,21 +371,7 @@ void Foam::ccm::writer::writeSolution
if (io.typeHeaderOk<IOdictionary>(true))
{
IOdictionary timeObject
(
IOobject
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
timeObject.lookup("index") >> timeIndex;
timeIndex = IOdictionary(io).get<label>("index");
}
}
@ -463,7 +448,7 @@ void Foam::ccm::writer::writeSolution
&phaseNode
);
forAllConstIter(IOobjectList, objects, iter)
forAllConstIters(objects, iter)
{
word fieldName = (*iter()).name();
bool variableGood =

View File

@ -272,7 +272,7 @@ void Foam::boundaryRegion::rename(const dictionary& mapDict)
dictionary& dict = operator[](iter.key());
Info<< "rename patch: " << iter()
<< " <- " << word(dict.lookup("Label")) << nl;
<< " <- " << dict.get<word>("Label") << nl;
dict.set("Label", iter());
}

View File

@ -186,13 +186,13 @@ void Foam::refinementFeatures::read
if (dict.found("levels"))
{
List<Tuple2<scalar, label>> distLevels(dict["levels"]);
List<Tuple2<scalar, label>> distLevels(dict.lookup("levels"));
if (dict.size() < 1)
{
FatalErrorInFunction
<< " : levels should be at least size 1" << endl
<< "levels : " << dict["levels"]
<< "levels : " << dict.lookup("levels")
<< exit(FatalError);
}

View File

@ -265,8 +265,8 @@ bool Foam::patchProbes::read(const dictionary& dict)
{
if (!dict.readIfPresent("patches", patchNames_))
{
patchNames_.setSize(1);
patchNames_[0] = wordRe(word(dict.lookup("patch")));
patchNames_.resize(1);
patchNames_.first() = dict.get<word>("patch");
}
return probes::read(dict);

View File

@ -315,8 +315,8 @@ Foam::probes::probes
bool Foam::probes::read(const dictionary& dict)
{
dict.lookup("probeLocations") >> *this;
dict.lookup("fields") >> fieldSelection_;
dict.read("probeLocations", static_cast<pointField&>(*this));
dict.read("fields", fieldSelection_);
dict.readIfPresent("fixedLocations", fixedLocations_);
if (dict.readIfPresent("interpolationScheme", interpolationScheme_))

View File

@ -175,8 +175,8 @@ Foam::arraySet::arraySet
:
sampledSet(name, mesh, searchEngine, dict),
coordSys_(dict),
pointsDensity_(dict.lookup("pointsDensity")),
spanBox_(dict.lookup("spanBox"))
pointsDensity_(dict.get<labelVector>("pointsDensity")),
spanBox_(dict.get<vector>("spanBox"))
{
genSamples();
}

View File

@ -47,6 +47,7 @@ SourceFiles
#define arraySet_H
#include "sampledSet.H"
#include "labelVector.H"
#include "DynamicList.H"
#include "coordinateSystem.H"
@ -73,10 +74,10 @@ class arraySet
coordinateSystem coordSys_;
//- Point density vector
Vector<label> pointsDensity_;
labelVector pointsDensity_;
//- Span box
Vector<scalar> spanBox_;
vector spanBox_;
// Private Member Functions

View File

@ -198,14 +198,11 @@ Foam::circleSet::circleSet
)
:
sampledSet(name, mesh, searchEngine, dict),
origin_(dict.lookup("origin")),
circleAxis_(dict.lookup("circleAxis")),
startPoint_(dict.lookup("startPoint")),
origin_(dict.get<point>("origin")),
circleAxis_(normalised(dict.get<vector>("circleAxis"))),
startPoint_(dict.get<point>("startPoint")),
dTheta_(dict.get<scalar>("dTheta"))
{
// Normalise circleAxis
circleAxis_ /= mag(circleAxis_);
genSamples();
}

View File

@ -205,7 +205,7 @@ Foam::cloudSet::cloudSet
)
:
sampledSet(name, mesh, searchEngine, dict),
sampleCoords_(dict.lookup("points"))
sampleCoords_(dict.get<pointField>("points"))
{
genSamples();
}

View File

@ -66,7 +66,7 @@ class cloudSet
// Private data
//- Sampling points
List<point> sampleCoords_;
pointField sampleCoords_;
// Private Member Functions

View File

@ -359,8 +359,8 @@ Foam::faceOnlySet::faceOnlySet
)
:
sampledSet(name, mesh, searchEngine, dict),
start_(dict.lookup("start")),
end_(dict.lookup("end"))
start_(dict.get<point>("start")),
end_(dict.get<point>("end"))
{
genSamples();
}

View File

@ -295,13 +295,10 @@ Foam::patchCloudSet::patchCloudSet
)
:
sampledSet(name, mesh, searchEngine, dict),
sampleCoords_(dict.lookup("points")),
sampleCoords_(dict.get<pointField>("points")),
patchSet_
(
mesh.boundaryMesh().patchSet
(
wordReList(dict.lookup("patches"))
)
mesh.boundaryMesh().patchSet(dict.get<wordRes>("patches"))
),
searchDist_(dict.get<scalar>("maxDistance"))
{

View File

@ -65,7 +65,7 @@ class patchCloudSet
// Private data
//- Sampling points
const List<point> sampleCoords_;
const pointField sampleCoords_;
//- Patches to sample
const labelHashSet patchSet_;

View File

@ -346,10 +346,7 @@ Foam::patchSeedSet::patchSeedSet
sampledSet(name, mesh, searchEngine, dict),
patchSet_
(
mesh.boundaryMesh().patchSet
(
wordReList(dict.lookup("patches"))
)
mesh.boundaryMesh().patchSet(dict.get<wordRes>("patches"))
),
maxPoints_(dict.get<label>("maxPoints")),
selectedLocations_

View File

@ -368,7 +368,7 @@ Foam::polyLineSet::polyLineSet
)
:
sampledSet(name, mesh, searchEngine, dict),
sampleCoords_(dict.lookup("points"))
sampleCoords_(dict.get<pointField>("points"))
{
genSamples();
}

View File

@ -63,7 +63,7 @@ class polyLineSet
// Private data
//- Sampling points
List<point> sampleCoords_;
pointField sampleCoords_;
// Private Member Functions

View File

@ -224,14 +224,13 @@ bool Foam::sampledSets::read(const dictionary& dict)
{
dict_ = dict;
bool setsFound = dict_.found("sets");
if (setsFound)
if (dict_.found("sets"))
{
dict_.lookup("fields") >> fieldSelection_;
dict_.read("fields", fieldSelection_);
clearFieldGroups();
dict.lookup("interpolationScheme") >> interpolationScheme_;
dict.lookup("setFormat") >> writeFormat_;
dict.read("interpolationScheme", interpolationScheme_);
dict.read("setFormat", writeFormat_);
PtrList<sampledSet> newList
(
@ -270,8 +269,7 @@ bool Foam::sampledSets::read(const dictionary& dict)
void Foam::sampledSets::correct()
{
bool setsFound = dict_.found("sets");
if (setsFound)
if (dict_.found("sets"))
{
searchEngine_.correct();

View File

@ -325,8 +325,8 @@ Foam::shortestPathSet::shortestPathSet
)
:
sampledSet(name, mesh, searchEngine, dict),
insidePoints_(dict.lookup("insidePoints")),
outsidePoints_(dict.lookup("outsidePoints"))
insidePoints_(dict.get<pointField>("insidePoints")),
outsidePoints_(dict.get<pointField>("outsidePoints"))
{
genSamples(mesh);
}

View File

@ -440,8 +440,8 @@ Foam::uniformSet::uniformSet
)
:
sampledSet(name, mesh, searchEngine, dict),
start_(dict.lookup("start")),
end_(dict.lookup("end")),
start_(dict.get<point>("start")),
end_(dict.get<point>("end")),
nPoints_(dict.get<label>("nPoints"))
{
genSamples();

View File

@ -466,8 +466,8 @@ Foam::sampledIsoSurface::sampledIsoSurface
)
:
sampledSurface(name, mesh, dict),
isoField_(dict.lookup("isoField")),
isoVal_(readScalar(dict.lookup("isoValue"))),
isoField_(dict.get<word>("isoField")),
isoVal_(dict.get<scalar>("isoValue")),
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
mergeTol_(dict.lookupOrDefault("mergeTol", 1e-6)),
regularise_(dict.lookupOrDefault("regularise", true)),
@ -491,7 +491,7 @@ Foam::sampledIsoSurface::sampledIsoSurface
if (zoneID_.index() != -1)
{
dict.lookup("exposedPatchName") >> exposedPatchName_;
dict.read("exposedPatchName", exposedPatchName_);
if (mesh.boundaryMesh().findPatchID(exposedPatchName_) == -1)
{

View File

@ -196,8 +196,8 @@ Foam::sampledIsoSurfaceCell::sampledIsoSurfaceCell
:
sampledSurface(name, mesh, dict),
MeshStorage(),
isoField_(dict.lookup("isoField")),
isoVal_(readScalar(dict.lookup("isoValue"))),
isoField_(dict.get<word>("isoField")),
isoVal_(dict.get<scalar>("isoValue")),
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
regularise_(dict.lookupOrDefault("regularise", true)),
average_(dict.lookupOrDefault("average", true)),

View File

@ -312,7 +312,7 @@ Foam::sampledCuttingPlane::sampledCuttingPlane
{
if (zoneID_.index() != -1)
{
dict.lookup("exposedPatchName") >> exposedPatchName_;
dict.read("exposedPatchName", exposedPatchName_);
if (mesh.boundaryMesh().findPatchID(exposedPatchName_) == -1)
{

View File

@ -66,7 +66,7 @@ Foam::sampledPatch::sampledPatch
)
:
sampledSurface(name, mesh, dict),
patchNames_(dict.lookup("patches")),
patchNames_(dict.get<wordRes>("patches")),
triangulate_(dict.lookupOrDefault("triangulate", false)),
needsUpdate_(true)
{}

View File

@ -61,17 +61,14 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
mappedPatchBase::offsetMode mode = mappedPatchBase::NORMAL;
if (dict.found("offsetMode"))
{
mode = mappedPatchBase::offsetModeNames_.read
(
dict.lookup("offsetMode")
);
mode = mappedPatchBase::offsetModeNames_.lookup("offsetMode", dict);
}
switch (mode)
{
case mappedPatchBase::NORMAL:
{
const scalar distance = readScalar(dict.lookup("distance"));
const scalar distance(dict.get<scalar>("distance"));
forAll(patchIDs(), i)
{
mappers_.set
@ -92,7 +89,7 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
case mappedPatchBase::UNIFORM:
{
const point offset(dict.lookup("offset"));
const point offset(dict.get<point>("offset"));
forAll(patchIDs(), i)
{
mappers_.set
@ -113,7 +110,7 @@ Foam::sampledPatchInternalField::sampledPatchInternalField
case mappedPatchBase::NONUNIFORM:
{
const pointField offsets(dict.lookup("offsets"));
const pointField offsets(dict.get<pointField>("offsets"));
forAll(patchIDs(), i)
{
mappers_.set

View File

@ -54,7 +54,7 @@ Foam::autoPtr<Foam::sampledSurface> Foam::sampledSurface::New
const dictionary& dict
)
{
const word sampleType(dict.lookup("type"));
const word sampleType(dict.get<word>("type"));
if (debug)
{

View File

@ -259,11 +259,11 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
{
sampleFaceScheme_ = dict.lookupOrDefault<word>("sampleScheme", "cell");
dict.lookup("interpolationScheme") >> sampleNodeScheme_;
dict.read("interpolationScheme", sampleNodeScheme_);
dict.lookup("fields") >> fieldSelection_;
dict.read("fields", fieldSelection_);
const word writeType(dict.lookup("surfaceFormat"));
const word writeType(dict.get<word>("surfaceFormat"));
// Define the surface formatter
// Optionally defined extra controls for the output formats

View File

@ -668,7 +668,7 @@ Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh
(
IOobject
(
dict.lookup("surface"),
dict.get<word>("surface"),
mesh.time().constant(), // instance
"triSurface", // local
mesh.time(), // registry

View File

@ -147,7 +147,7 @@ Foam::sampledThresholdCellFaces::sampledThresholdCellFaces
)
:
sampledSurface(name, mesh, dict),
fieldName_(dict.lookup("field")),
fieldName_(dict.get<word>("field")),
lowerThreshold_(dict.lookupOrDefault<scalar>("lowerLimit", -VGREAT)),
upperThreshold_(dict.lookupOrDefault<scalar>("upperLimit", VGREAT)),
zoneKey_(keyType::null),

View File

@ -349,7 +349,7 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
forAllConstIter(dictionary, fieldsDict, iter)
{
const dictionary& subDict = iter().dict();
const word fieldType(subDict.lookup("type"));
const word fieldType(subDict.get<word>("type"));
const word varName = subDict.lookupOrDefault
(
"name",

View File

@ -342,7 +342,8 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
separator_ = ",";
}
List<Pair<word>> fieldPairs(options.lookup("fields"));
List<Pair<word>> fieldPairs;
options.read("fields", fieldPairs);
for (const Pair<word>& item : fieldPairs)
{

View File

@ -217,7 +217,7 @@ Foam::rawSurfaceWriter::rawSurfaceWriter(const dictionary& options)
if (options.found("compression"))
{
writeCompression_ =
IOstream::compressionEnum(options.lookup("compression"));
IOstream::compressionEnum(options.get<word>("compression"));
}
}

View File

@ -75,7 +75,7 @@ Foam::surfMeshSample::New
const dictionary& dict
)
{
const word sampleType(dict.lookup("type"));
const word sampleType(dict.get<word>("type"));
auto cstrIter = wordConstructorTablePtr_->cfind(sampleType);

View File

@ -348,7 +348,7 @@ bool Foam::surfMeshSamplers::read(const dictionary& dict)
{
sampleScheme_ = dict.lookupOrDefault<word>("sampleScheme", "cell");
dict.lookup("fields") >> fieldSelection_;
dict.read("fields", fieldSelection_);
fieldSelection_.uniq();
Info<< type() << " fields: " << flatOutput(fieldSelection_) << nl;

View File

@ -52,7 +52,7 @@ Foam::distanceSurface::distanceSurface
(
searchableSurface::New
(
dict.lookup("surfaceType"),
dict.get<word>("surfaceType"),
IOobject
(
dict.lookupOrDefault("surfaceName", defaultSurfaceName),
@ -65,7 +65,7 @@ Foam::distanceSurface::distanceSurface
dict
)
),
distance_(readScalar(dict.lookup("distance"))),
distance_(dict.get<scalar>("distance")),
signed_(dict.get<bool>("signed")),
cell_(dict.lookupOrDefault("cell", true)),
regularise_(dict.lookupOrDefault("regularise", true)),

View File

@ -675,7 +675,7 @@ Foam::discreteSurface::discreteSurface
(
IOobject
(
dict.lookup("surface"),
dict.get<word>("surface"),
mesh.time().constant(), // instance
"triSurface", // local
mesh.time(), // registry

View File

@ -81,8 +81,8 @@ Foam::surfZone::surfZone
)
:
surfZoneIdentifier(name, dict, index),
size_(readLabel(dict.lookup("nFaces"))),
start_(readLabel(dict.lookup("startFace")))
size_(dict.get<label>("nFaces")),
start_(dict.get<label>("startFace"))
{}

View File

@ -61,8 +61,8 @@ Foam::surfZoneIOList::surfZoneIOList
{
const dictionary& dict = dictEntries[zoneI].dict();
label zoneSize = readLabel(dict.lookup("nFaces"));
label startFacei = readLabel(dict.lookup("startFace"));
const label zoneSize = dict.get<label>("nFaces");
const label startFacei = dict.get<label>("startFace");
zones[zoneI] = surfZone
(

View File

@ -87,8 +87,8 @@ Foam::surfacePatch::surfacePatch
)
:
geometricSurfacePatch(name, dict, index),
size_(readLabel(dict.lookup("nFaces"))),
start_(readLabel(dict.lookup("startFace")))
size_(dict.get<label>("nFaces")),
start_(dict.get<label>("startFace"))
{}