STYLE: use guards for dictionary lookup()

This commit is contained in:
Mark Olesen
2020-01-27 13:38:26 +01:00
parent 500a3b62ca
commit ae40bd9f9b
10 changed files with 48 additions and 35 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -69,7 +69,7 @@ void Foam::ConeNozzleInjection<CloudType>::setInjectionMethod()
case injectionMethod::imPoint:
case injectionMethod::imDisc:
{
position_ = this->coeffDict().lookup("position");
this->coeffDict().readEntry("position", position_);
break;
}
case injectionMethod::imMovingPoint:

View File

@ -67,7 +67,10 @@ void Foam::moleculeCloud::buildConstProps()
const word& id = idList[i];
const dictionary& molDict = moleculePropertiesDict.subDict(id);
List<word> siteIdNames = molDict.lookup("siteIds");
List<word> siteIdNames
(
molDict.lookup("siteIds")
);
List<label> siteIds(siteIdNames.size());

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,7 +48,10 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict)
const dictionary& molDict(moleculePropertiesDict.subDict(id));
List<word> siteIdNames = molDict.lookup("siteIds");
List<word> siteIdNames
(
molDict.lookup("siteIds")
);
forAll(siteIdNames, sI)
{
@ -59,7 +63,10 @@ void Foam::potential::setSiteIdList(const dictionary& moleculePropertiesDict)
}
}
List<word> pairPotSiteIds = molDict.lookup("pairPotentialSiteIds");
List<word> pairPotSiteIds
(
molDict.lookup("pairPotentialSiteIds")
);
forAll(pairPotSiteIds, sI)
{
@ -111,7 +118,7 @@ void Foam::potential::potential::readPotentialDict()
)
);
idList_ = List<word>(idListDict.lookup("idList"));
idListDict.readEntry("idList", idList_);
setSiteIdList
(
@ -156,10 +163,10 @@ void Foam::potential::potential::readPotentialDict()
potentialDict.readEntry("potentialEnergyLimit", potentialEnergyLimit_);
if (potentialDict.found("removalOrder"))
{
List<word> remOrd = potentialDict.lookup("removalOrder");
List<word> remOrd;
if (potentialDict.readIfPresent("removalOrder", remOrd))
{
removalOrder_.setSize(remOrd.size());
forAll(removalOrder_, rO)

View File

@ -1057,7 +1057,6 @@ Foam::mappedPatchBase::mappedPatchBase
case NONUNIFORM:
{
//offsets_ = pointField(dict.lookup("offsets"));
offsets_ = readListOrField("offsets", dict, patch_.size());
}
break;
@ -1076,7 +1075,6 @@ Foam::mappedPatchBase::mappedPatchBase
else if (dict.found("offsets"))
{
offsetMode_ = NONUNIFORM;
//offsets_ = pointField(dict.lookup("offsets"));
offsets_ = readListOrField("offsets", dict, patch_.size());
}
else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)

View File

@ -731,10 +731,10 @@ Foam::surfaceFeatures::surfaceFeatures
dictionary featInfoDict(str);
featureEdges_ = labelList(featInfoDict.lookup("featureEdges"));
featurePoints_ = labelList(featInfoDict.lookup("featurePoints"));
externalStart_ = featInfoDict.get<label>("externalStart");
internalStart_ = featInfoDict.get<label>("internalStart");
featInfoDict.readEntry("featureEdges", featureEdges_);
featInfoDict.readEntry("featurePoints", featurePoints_);
featInfoDict.readEntry("externalStart", externalStart_);
featInfoDict.readEntry("internalStart", internalStart_);
}

View File

@ -159,9 +159,9 @@ bool Foam::RBD::restraints::linearAxialAngularSpring::read
<< exit(FatalError);
}
axis_ = coeffs_.lookup("axis");
coeffs_.readEntry("axis", axis_);
scalar magAxis(mag(axis_));
const scalar magAxis(mag(axis_));
if (magAxis > VSMALL)
{

View File

@ -176,9 +176,9 @@ bool Foam::RBD::restraints::prescribedRotation::read
<< exit(FatalError);
}
axis_ = coeffs_.lookup("axis");
coeffs_.readEntry("axis", axis_);
scalar magAxis(mag(axis_));
const scalar magAxis(mag(axis_));
if (magAxis > VSMALL)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -162,9 +162,9 @@ bool Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::read
<< exit(FatalError);
}
axis_ = sDoFRBMRCoeffs_.lookup("axis");
sDoFRBMRCoeffs_.readEntry("axis", axis_);
scalar magAxis(mag(axis_));
const scalar magAxis(mag(axis_));
if (magAxis > VSMALL)
{