mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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
|
||||
{
|
||||
|
||||
@ -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"))
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user