ENH: unify use of dictionary method names

- previously introduced `getOrDefault` as a dictionary _get_ method,
  now complete the transition and use it everywhere instead of
  `lookupOrDefault`. This avoids mixed usage of the two methods that
  are identical in behaviour, makes for shorter names, and promotes
  the distinction between "lookup" access (ie, return a token stream,
  locate and return an entry) and "get" access (ie, the above with
  conversion to concrete types such as scalar, label etc).
This commit is contained in:
Mark Olesen
2020-06-02 16:38:55 +02:00
parent f721b5344f
commit 3e43edf056
624 changed files with 2109 additions and 1954 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -148,7 +149,7 @@ bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
{
fieldExpression::read(dict);
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
rhoName_ = dict.getOrDefault<word>("rho", "rho");
return true;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -152,7 +152,7 @@ Foam::functionObjects::PecletNo::~PecletNo()
bool Foam::functionObjects::PecletNo::read(const dictionary& dict)
{
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
rhoName_ = dict.getOrDefault<word>("rho", "rho");
return true;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -115,7 +115,7 @@ bool Foam::functionObjects::blendingFactor::read(const dictionary& dict)
{
if (fieldExpression::read(dict) && writeFile::read(dict))
{
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
phiName_ = dict.getOrDefault<word>("phi", "phi");
tolerance_ = 0.001;
if

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -116,7 +116,7 @@ Foam::functionObjects::ddt2::ddt2
resultName_(word::null),
blacklist_(),
results_(),
mag_(dict.lookupOrDefault("mag", false))
mag_(dict.getOrDefault("mag", false))
{
read(dict);
}
@ -141,7 +141,7 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict)
Info<< type() << " fields: " << selectFields_ << nl;
resultName_ = dict.lookupOrDefault<word>
resultName_ = dict.getOrDefault<word>
(
"result",
( mag_ ? "mag(ddt(@@))" : "magSqr(ddt(@@))" )

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -199,7 +199,7 @@ bool Foam::functionObjects::derivedFields::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict),
rhoRef_ = dict.lookupOrDefault<scalar>("rhoRef", 1);
rhoRef_ = dict.getOrDefault<scalar>("rhoRef", 1);
wordList derivedNames(dict.get<wordList>("derived"));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -568,7 +568,7 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
timeFunctionObject::read(dict);
externalFileCoupler::readDict(dict);
calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1);
calcFrequency_ = dict.getOrDefault("calcFrequency", 1);
// Leave trigger intact

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -122,7 +122,7 @@ externalCoupledTemperatureMixedFvPatchScalarField
outTempType_(outputTemperatureType::WALL),
refTempType_
(
refTemperatureNames.lookupOrDefault
refTemperatureNames.getOrDefault
(
"htcRefTemperature",
dict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,7 +73,7 @@ Foam::Istream& Foam::functionObjects::operator>>
faItem.mean_ = dict.get<bool>("mean");
faItem.prime2Mean_ = dict.get<bool>("prime2Mean");
faItem.base_ = faItem.baseTypeNames_.get("base", dict);
faItem.window_ = dict.lookupOrDefault<scalar>("window", -1.0);
faItem.window_ = dict.getOrDefault<scalar>("window", -1);
if (faItem.window_ > 0)
{
@ -93,7 +93,7 @@ Foam::Istream& Foam::functionObjects::operator>>
<< exit(FatalIOError);
}
faItem.windowName_ = dict.lookupOrDefault<word>("windowName", "");
faItem.windowName_ = dict.getOrDefault<word>("windowName", "");
if (faItem.windowType_ == fieldAverageItem::windowType::EXACT)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2017 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -132,9 +132,9 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
location_ = dict.lookupOrDefault("location", true);
location_ = dict.getOrDefault("location", true);
mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
mode_ = modeTypeNames_.getOrDefault("mode", dict, modeType::mdMag);
fieldSet_.read(dict);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -104,7 +104,7 @@ bool Foam::functionObjects::fieldValue::read(const dictionary& dict)
dict.readEntry("fields", fields_);
dict.readEntry("writeFields", writeFields_);
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
scaleFactor_ = dict.getOrDefault<scalar>("scaleFactor", 1);
return true;
}

View File

@ -876,7 +876,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read
weightFieldName_ = "none";
needsUpdate_ = true;
writeArea_ = dict.lookupOrDefault("writeArea", false);
writeArea_ = dict.getOrDefault("writeArea", false);
totalArea_ = 0;
nFaces_ = 0;
faceId_.clear();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,7 +81,7 @@ Foam::functionObjects::flux::flux
)
:
fieldExpression(name, runTime, dict),
rhoName_(dict.lookupOrDefault<word>("rho", "none"))
rhoName_(dict.getOrDefault<word>("rho", "none"))
{}

View File

@ -974,9 +974,9 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
needsUpdate_ = true;
mode_ = modeTypeNames_.get("mode", dict);
phiName_ = dict.lookupOrDefault<word>("phi", "phi");
scaleFactor_ = dict.lookupOrDefault<scalar>("scaleFactor", 1.0);
tolerance_ = dict.lookupOrDefault<scalar>("tolerance", 0.8);
phiName_ = dict.getOrDefault<word>("phi", "phi");
scaleFactor_ = dict.getOrDefault<scalar>("scaleFactor", 1);
tolerance_ = dict.getOrDefault<scalar>("tolerance", 0.8);
zoneNames_.clear();
zoneDirections_.clear();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -110,8 +110,8 @@ bool Foam::functionObjects::histogram::read(const dictionary& dict)
dict.readEntry("field", fieldName_);
max_ = dict.lookupOrDefault<scalar>("max", -GREAT);
min_ = dict.lookupOrDefault<scalar>("min", GREAT);
max_ = dict.getOrDefault<scalar>("max", -GREAT);
min_ = dict.getOrDefault<scalar>("min", GREAT);
dict.readEntry("nBins", nBins_);
const word format(dict.get<word>("setFormat"));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -427,20 +427,20 @@ bool Foam::functionObjects::momentum::read(const dictionary& dict)
Info<< type() << " " << name() << ":" << nl;
// Optional entries U and p
UName_ = dict.lookupOrDefault<word>("U", "U");
pName_ = dict.lookupOrDefault<word>("p", "p");
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
rhoRef_ = dict.lookupOrDefault<scalar>("rhoRef", 1.0);
hasCsys_ = dict.lookupOrDefault("cylindrical", false);
UName_ = dict.getOrDefault<word>("U", "U");
pName_ = dict.getOrDefault<word>("p", "p");
rhoName_ = dict.getOrDefault<word>("rho", "rho");
rhoRef_ = dict.getOrDefault<scalar>("rhoRef", 1);
hasCsys_ = dict.getOrDefault("cylindrical", false);
if (hasCsys_)
{
csys_ = coordSystem::cylindrical(dict);
}
writeMomentum_ = dict.lookupOrDefault("writeMomentum", false);
writeVelocity_ = dict.lookupOrDefault("writeVelocity", false);
writePosition_ = dict.lookupOrDefault("writePosition", false);
writeMomentum_ = dict.getOrDefault("writeMomentum", false);
writeVelocity_ = dict.getOrDefault("writeVelocity", false);
writePosition_ = dict.getOrDefault("writePosition", false);
Info<<"Integrating for selection: "
<< regionTypeNames_[regionType_]

View File

@ -378,8 +378,8 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
fieldExpression::read(dict);
UName_ = dict.lookupOrDefault<word>("U", "U");
rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
UName_ = dict.getOrDefault<word>("U", "U");
rhoName_ = dict.getOrDefault<word>("rho", "rho");
if (rhoName_ == "rhoInf")
{
@ -414,7 +414,7 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
Info<< " Operating mode: " << modeNames[mode_] << nl;
pRef_ = dict.lookupOrDefault<scalar>("pRef", 0);
pRef_ = dict.getOrDefault<scalar>("pRef", 0);
if
(
@ -460,7 +460,7 @@ bool Foam::functionObjects::pressure::read(const dictionary& dict)
rhoInfInitialised_ = true;
}
resultName_ = dict.lookupOrDefault<word>("result", resultName());
resultName_ = dict.getOrDefault<word>("result", resultName());
Info<< endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -127,7 +127,7 @@ bool Foam::functionObjects::reference::read(const dictionary& dict)
}
interpolationScheme_ =
dict.lookupOrDefault<word>("interpolationScheme", "cell");
dict.getOrDefault<word>("interpolationScheme", "cell");
}
Log << endl;

View File

@ -322,7 +322,7 @@ Foam::functionObjects::regionSizeDistribution::regionSizeDistribution
writeFile(obr_, name),
alphaName_(dict.get<word>("field")),
patchNames_(dict.get<wordRes>("patches")),
isoPlanes_(dict.lookupOrDefault("isoPlanes", false))
isoPlanes_(dict.getOrDefault("isoPlanes", false))
{
read(dict);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -445,50 +445,50 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
dimensionedScalar(dimless, Zero),
zeroGradientFvPatchScalarField::typeName
),
nonOrthogonality_(dict.lookupOrDefault<Switch>("switchNonOrtho", false)),
gradCc_(dict.lookupOrDefault<Switch>("switchGradCc", false)),
residuals_(dict.lookupOrDefault<Switch>("switchResiduals", false)),
faceWeight_(dict.lookupOrDefault<Switch>("switchFaceWeight", false)),
skewness_(dict.lookupOrDefault<Switch>("switchSkewness", false)),
Co_(dict.lookupOrDefault<Switch>("switchCo", false)),
nonOrthogonality_(dict.getOrDefault<Switch>("switchNonOrtho", false)),
gradCc_(dict.getOrDefault<Switch>("switchGradCc", false)),
residuals_(dict.getOrDefault<Switch>("switchResiduals", false)),
faceWeight_(dict.getOrDefault<Switch>("switchFaceWeight", false)),
skewness_(dict.getOrDefault<Switch>("switchSkewness", false)),
Co_(dict.getOrDefault<Switch>("switchCo", false)),
maxNonOrthogonality_
(
dict.lookupOrDefault<scalar>("maxNonOrthogonality", 20.0)
dict.getOrDefault<scalar>("maxNonOrthogonality", 20)
),
minNonOrthogonality_
(
dict.lookupOrDefault<scalar>("minNonOrthogonality", 60.0)
dict.getOrDefault<scalar>("minNonOrthogonality", 60)
),
maxGradCc_(dict.lookupOrDefault<scalar>("maxGradCc", 3.0)),
minGradCc_(dict.lookupOrDefault<scalar>("minGradCc", 4.0)),
maxResidual_(dict.lookupOrDefault<scalar>("maxResidual", 10.0)),
minFaceWeight_(dict.lookupOrDefault<scalar>("minFaceWeight", 0.3)),
maxFaceWeight_(dict.lookupOrDefault<scalar>("maxFaceWeight", 0.2)),
maxSkewness_(dict.lookupOrDefault<scalar>("maxSkewness", 2.0)),
minSkewness_(dict.lookupOrDefault<scalar>("minSkewness", 3.0)),
Co1_(dict.lookupOrDefault<scalar>("Co1", 1.0)),
Co2_(dict.lookupOrDefault<scalar>("Co2", 10.0)),
maxGradCc_(dict.getOrDefault<scalar>("maxGradCc", 3)),
minGradCc_(dict.getOrDefault<scalar>("minGradCc", 4)),
maxResidual_(dict.getOrDefault<scalar>("maxResidual", 10)),
minFaceWeight_(dict.getOrDefault<scalar>("minFaceWeight", 0.3)),
maxFaceWeight_(dict.getOrDefault<scalar>("maxFaceWeight", 0.2)),
maxSkewness_(dict.getOrDefault<scalar>("maxSkewness", 2)),
minSkewness_(dict.getOrDefault<scalar>("minSkewness", 3)),
Co1_(dict.getOrDefault<scalar>("Co1", 1)),
Co2_(dict.getOrDefault<scalar>("Co2", 10)),
nonOrthogonalityName_
(
dict.lookupOrDefault<word>("nonOrthogonality", "nonOrthoAngle")
dict.getOrDefault<word>("nonOrthogonality", "nonOrthoAngle")
),
faceWeightName_
(
dict.lookupOrDefault<word>("faceWeight", "faceWeight")
dict.getOrDefault<word>("faceWeight", "faceWeight")
),
skewnessName_
(
dict.lookupOrDefault<word>("skewness", "skewness")
dict.getOrDefault<word>("skewness", "skewness")
),
residualName_
(
dict.lookupOrDefault<word>("residual", "initialResidual:p")
dict.getOrDefault<word>("residual", "initialResidual:p")
),
UName_
(
dict.lookupOrDefault<word>("U", "U")
dict.getOrDefault<word>("U", "U")
),
tolerance_(0.001),
@ -496,9 +496,9 @@ Foam::functionObjects::stabilityBlendingFactor::stabilityBlendingFactor
errorIntegral_(mesh_.nCells(), Zero),
oldError_(mesh_.nCells(), Zero),
oldErrorIntegral_(mesh_.nCells(), Zero),
P_(dict.lookupOrDefault<scalar>("P", 3)),
I_(dict.lookupOrDefault<scalar>("I", 0.0)),
D_(dict.lookupOrDefault<scalar>("D", 0.25))
P_(dict.getOrDefault<scalar>("P", 3)),
I_(dict.getOrDefault<scalar>("I", 0)),
D_(dict.getOrDefault<scalar>("D", 0.25))
{
read(dict);
setResultName(typeName, "");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -882,7 +882,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
Info<< type() << " " << name() << ":" << nl;
UName_ = dict.lookupOrDefault<word>("U", "U");
UName_ = dict.getOrDefault<word>("U", "U");
if (fields_.empty())
{
@ -944,7 +944,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
}
interpolationScheme_ = dict.lookupOrDefault
interpolationScheme_ = dict.getOrDefault
(
"interpolationScheme",
interpolationCellPoint<scalar>::typeName
@ -952,7 +952,7 @@ bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
//Info<< " using interpolation " << interpolationScheme_ << endl;
cloudName_ = dict.lookupOrDefault<word>("cloud", type());
cloudName_ = dict.getOrDefault<word>("cloud", type());
sampledSetPtr_.clear();
sampledSetAxis_.clear();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,7 +95,7 @@ bool Foam::functionObjects::surfaceDistance::read
{
fvMeshFunctionObject::read(dict);
doCells_ = dict.lookupOrDefault("calculateCells", true);
doCells_ = dict.getOrDefault("calculateCells", true);
geomPtr_.clear();
geomPtr_.set

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -119,7 +119,7 @@ bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
Info<< type() << " fields: " << selectFields_ << nl;
resultName_ = dict.lookupOrDefault<word>("result", type() + "(@@)");
resultName_ = dict.getOrDefault<word>("result", type() + "(@@)");
// Require '@@' token for result, unless a single (non-regex) source field
return

View File

@ -811,7 +811,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
Info<< type() << " " << name() << ":" << nl;
directForceDensity_ = dict.lookupOrDefault("directForceDensity", false);
directForceDensity_ = dict.getOrDefault("directForceDensity", false);
patchSet_ =
mesh_.boundaryMesh().patchSet
@ -905,7 +905,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict)
}
}
writeFields_ = dict.lookupOrDefault("writeFields", false);
writeFields_ = dict.getOrDefault("writeFields", false);
if (writeFields_)
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -198,7 +198,7 @@ Foam::functionObjects::hydrostaticPressure::hydrostaticPressure
mesh_.objectRegistry::store(ph_rghPtr);
bool reInitialise = dict.lookupOrDefault<bool>("reInitialise", false);
bool reInitialise = dict.getOrDefault("reInitialise", false);
if (runTime.timeIndex() == 0 || reInitialise)
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -145,7 +145,7 @@ bool Foam::functionObjects::dataCloud::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
const int padWidth = dict.lookupOrDefault<int>("width", 8);
const int padWidth = dict.getOrDefault<int>("width", 8);
// Appropriate printf format - Enforce min/max sanity limits
if (padWidth < 1 || padWidth > 31)
@ -158,7 +158,7 @@ bool Foam::functionObjects::dataCloud::read(const dictionary& dict)
}
precision_ =
dict.lookupOrDefault("precision", IOstream::defaultPrecision());
dict.getOrDefault("precision", IOstream::defaultPrecision());
selectClouds_.clear();
@ -168,7 +168,7 @@ bool Foam::functionObjects::dataCloud::read(const dictionary& dict)
{
selectClouds_.resize(1);
selectClouds_.first() =
dict.lookupOrDefault<word>("cloud", cloud::defaultName);
dict.getOrDefault<word>("cloud", cloud::defaultName);
}
dict.readEntry("field", fieldName_);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -83,11 +83,11 @@ Foam::functionObjects::icoUncoupledKinematicCloud::icoUncoupledKinematicCloud
mu_("mu", rhoValue_*laminarTransport_.nu()),
U_
(
mesh_.lookupObject<volVectorField>(dict.lookupOrDefault<word>("U", "U"))
mesh_.lookupObject<volVectorField>(dict.getOrDefault<word>("U", "U"))
),
kinematicCloudName_
(
dict.lookupOrDefault<word>("kinematicCloud", "kinematicCloud")
dict.getOrDefault<word>("kinematicCloud", "kinematicCloud")
),
kinematicCloud_
(

View File

@ -396,7 +396,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
// Info<< type() << " " << name() << " output-format: "
// << writeOpts_.description() << nl;
const int padWidth = dict.lookupOrDefault<int>("width", 8);
const int padWidth = dict.getOrDefault<int>("width", 8);
// Appropriate printf format - Enforce min/max sanity limits
if (padWidth < 1 || padWidth > 31)
@ -408,10 +408,10 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
printf_ = "%0" + std::to_string(padWidth) + "d";
}
// useTimeName_ = dict.lookupOrDefault<bool>("useTimeName", false);
// useTimeName_ = dict.getOrDefault("useTimeName", false);
useVerts_ = dict.lookupOrDefault<bool>("cellData", false);
pruneEmpty_ = dict.lookupOrDefault<bool>("prune", false);
useVerts_ = dict.getOrDefault("cellData", false);
pruneEmpty_ = dict.getOrDefault("prune", false);
selectClouds_.clear();
dict.readIfPresent("clouds", selectClouds_);
@ -420,7 +420,7 @@ bool Foam::functionObjects::vtkCloud::read(const dictionary& dict)
{
selectClouds_.resize(1);
selectClouds_.first() =
dict.lookupOrDefault<word>("cloud", cloud::defaultName);
dict.getOrDefault<word>("cloud", cloud::defaultName);
}
selectFields_.clear();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -203,9 +203,9 @@ Foam::functionObjects::energyTransport::energyTransport
)
:
fvMeshFunctionObject(name, runTime, dict),
fieldName_(dict.lookupOrDefault<word>("field", "T")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
fieldName_(dict.getOrDefault<word>("field", "T")),
phiName_(dict.getOrDefault<word>("phi", "phi")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
nCorr_(0),
schemesField_("unknown-schemesField"),
fvOptions_(mesh_),
@ -332,7 +332,7 @@ bool Foam::functionObjects::energyTransport::read(const dictionary& dict)
dict.readIfPresent("phi", phiName_);
dict.readIfPresent("rho", rhoName_);
schemesField_ = dict.lookupOrDefault("schemesField", fieldName_);
schemesField_ = dict.getOrDefault("schemesField", fieldName_);
dict.readIfPresent("nCorr", nCorr_);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -181,14 +181,14 @@ Foam::functionObjects::scalarTransport::scalarTransport
)
:
fvMeshFunctionObject(name, runTime, dict),
fieldName_(dict.lookupOrDefault<word>("field", "s")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
nutName_(dict.lookupOrDefault<word>("nut", "none")),
phaseName_(dict.lookupOrDefault<word>("phase", "none")),
fieldName_(dict.getOrDefault<word>("field", "s")),
phiName_(dict.getOrDefault<word>("phi", "phi")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
nutName_(dict.getOrDefault<word>("nut", "none")),
phaseName_(dict.getOrDefault<word>("phase", "none")),
phasePhiCompressedName_
(
dict.lookupOrDefault<word>("phasePhiCompressed", "alphaPhiUn")
dict.getOrDefault<word>("phasePhiCompressed", "alphaPhiUn")
),
D_(0),
constantD_(false),
@ -196,7 +196,7 @@ Foam::functionObjects::scalarTransport::scalarTransport
resetOnStartUp_(false),
schemesField_("unknown-schemesField"),
fvOptions_(mesh_),
bounded01_(dict.lookupOrDefault("bounded01", true))
bounded01_(dict.getOrDefault("bounded01", true))
{
read(dict);
@ -229,10 +229,10 @@ bool Foam::functionObjects::scalarTransport::read(const dictionary& dict)
dict.readIfPresent("phase", phaseName_);
dict.readIfPresent("bounded01", bounded01_);
schemesField_ = dict.lookupOrDefault("schemesField", fieldName_);
schemesField_ = dict.getOrDefault("schemesField", fieldName_);
constantD_ = dict.readIfPresent("D", D_);
alphaD_ = dict.lookupOrDefault("alphaD", 1.0);
alphaDt_ = dict.lookupOrDefault("alphaDt", 1.0);
alphaD_ = dict.getOrDefault<scalar>("alphaD", 1);
alphaDt_ = dict.getOrDefault<scalar>("alphaDt", 1);
dict.readIfPresent("nCorr", nCorr_);
dict.readIfPresent("resetOnStartUp", resetOnStartUp_);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -184,7 +184,7 @@ bool Foam::functionObjects::abort::read(const dictionary& dict)
triggered_ = false;
defaultAction_ = Time::stopAtControlNames.lookupOrDefault
defaultAction_ = Time::stopAtControlNames.getOrDefault
(
"action",
dict,

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -139,7 +139,7 @@ bool Foam::areaWrite::read(const dictionary& dict)
)
);
verbose_ = dict.lookupOrDefault("verbose", false);
verbose_ = dict.getOrDefault("verbose", false);
// All possible area meshes for the given fvMesh region
meshes_ = obr().lookupClass<faMesh>();

View File

@ -116,17 +116,17 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
// Writer options
consecutive_ = dict.lookupOrDefault("consecutive", false);
consecutive_ = dict.getOrDefault("consecutive", false);
writeOpts_.useBoundaryMesh(dict.lookupOrDefault("boundary", true));
writeOpts_.useInternalMesh(dict.lookupOrDefault("internal", true));
writeOpts_.useBoundaryMesh(dict.getOrDefault("boundary", true));
writeOpts_.useInternalMesh(dict.getOrDefault("internal", true));
// Warn if noPatches keyword (1806) exists and contradicts our settings
// Cannot readily use Compat since the boolean has the opposite value.
if
(
dict.lookupOrDefault("noPatches", false)
dict.getOrDefault("noPatches", false)
&& writeOpts_.useBoundaryMesh()
)
{
@ -151,9 +151,9 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict)
// Case options
caseOpts_.nodeValues(dict.lookupOrDefault("nodeValues", false));
caseOpts_.width(dict.lookupOrDefault<label>("width", 8));
caseOpts_.overwrite(dict.lookupOrDefault("overwrite", false));
caseOpts_.nodeValues(dict.getOrDefault("nodeValues", false));
caseOpts_.width(dict.getOrDefault<label>("width", 8));
caseOpts_.overwrite(dict.getOrDefault("overwrite", false));
// Output directory

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -70,7 +70,7 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
functionObjectName_(dict.get<word>("functionObject")),
fieldNames_(dict.get<wordList>("fields")),
tolerance_(dict.get<scalar>("tolerance")),
window_(dict.lookupOrDefault<scalar>("window", -1)),
window_(dict.getOrDefault<scalar>("window", -1)),
windowType_
(
window_ > 0
@ -78,8 +78,8 @@ Foam::functionObjects::runTimeControls::averageCondition::averageCondition
: windowType::NONE
),
totalTime_(fieldNames_.size(), scalar(0)),
resetOnRestart_(dict.lookupOrDefault<bool>("resetOnRestart", false)),
nIterStartUp_(dict.lookupOrDefault<label>("nIterStartUp", 10)),
resetOnRestart_(dict.getOrDefault("resetOnRestart", false)),
nIterStartUp_(dict.getOrDefault<label>("nIterStartUp", 10)),
iter_(-1)
{
dictionary& conditionDict = this->conditionDict();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,7 +85,7 @@ equationInitialResidualCondition::equationInitialResidualCondition
runTimeCondition(name, obr, dict, state),
fieldSelection_(obr, true),
value_(dict.get<scalar>("value")),
timeStart_(dict.lookupOrDefault("timeStart", -GREAT)),
timeStart_(dict.getOrDefault("timeStart", -GREAT)),
mode_(operatingModeNames.get("mode", dict))
{
fieldSelection_.read(dict);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2016 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,7 +65,7 @@ equationMaxIterCondition
runTimeCondition(name, obr, dict, state),
fieldNames_(dict.get<wordList>("fields")),
threshold_(dict.get<label>("threshold")),
startIter_(dict.lookupOrDefault("startIter", 2))
startIter_(dict.getOrDefault("startIter", 2))
{
if (!fieldNames_.size())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -64,7 +64,7 @@ maxDurationCondition
duration_(dict.get<scalar>("duration")),
startTime_(-1),
initialised_(false),
resetOnRestart_(dict.lookupOrDefault("resetOnRestart", false))
resetOnRestart_(dict.getOrDefault("resetOnRestart", false))
{
if
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,10 +85,10 @@ Foam::functionObjects::runTimeControls::runTimeCondition::runTimeCondition
name_(name),
obr_(obr),
state_(state),
active_(dict.lookupOrDefault("active", true)),
active_(dict.getOrDefault("active", true)),
conditionDict_(setConditionDict()),
groupID_(dict.lookupOrDefault("groupID", -1)),
log(dict.lookupOrDefault("log", true))
groupID_(dict.getOrDefault("groupID", -1)),
log(dict.getOrDefault("log", true))
{}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -155,7 +155,7 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
// Set the action to perform when all conditions are satisfied
// - set to end for backwards compatibility with v1806
satisfiedAction_ =
satisfiedActionNames.lookupOrDefault
satisfiedActionNames.getOrDefault
(
"satisfiedAction",
dict,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,7 +95,7 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read
timeStepPtr_ = Function1<scalar>::New("deltaT", dict);
// Ensure that adjustTimeStep is active
if (!time_.controlDict().lookupOrDefault<bool>("adjustTimeStep", false))
if (!time_.controlDict().getOrDefault("adjustTimeStep", false))
{
FatalIOErrorInFunction(dict)
<< "Need to set 'adjustTimeStep' true to allow timestep control"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -148,7 +148,7 @@ bool Foam::functionObjects::solverInfo::read(const dictionary& dict)
fieldSet_.read(dict);
writeResidualFields_ =
dict.lookupOrDefault("writeResidualFields", false);
dict.getOrDefault("writeResidualFields", false);
residualFieldNames_.clear();

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.
@ -112,7 +112,7 @@ bool Foam::functionObjects::systemCall::read(const dictionary& dict)
dict.readIfPresent("executeCalls", executeCalls_);
dict.readIfPresent("writeCalls", writeCalls_);
dict.readIfPresent("endCalls", endCalls_);
masterOnly_ = dict.lookupOrDefault("master", false);
masterOnly_ = dict.getOrDefault("master", false);
if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +57,7 @@ Foam::functionObjects::thermoCoupleProbes::thermoCoupleProbes
:
probes(name, runTime, dict, loadFromFiles, false),
ODESystem(),
UName_(dict.lookupOrDefault<word>("U", "U")),
UName_(dict.getOrDefault<word>("U", "U")),
radiationFieldName_(dict.get<word>("radiationField")),
thermo_(mesh_.lookupObject<fluidThermo>(basicThermo::dictName)),
odeSolver_(nullptr),

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -88,7 +88,7 @@ bool Foam::functionObjects::timeInfo::read(const dictionary& dict)
timeFunctionObject::read(dict);
writeFile::read(dict);
perTimeStep_ = dict.lookupOrDefault("perTimeStep", false);
perTimeStep_ = dict.getOrDefault("perTimeStep", false);
return true;
}

View File

@ -170,11 +170,11 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
// We probably cannot trust old information after a reread
series_.clear();
// verbose_ = dict.lookupOrDefault<bool>("verbose", true);
doInternal_ = dict.lookupOrDefault<bool>("internal", true);
doBoundary_ = dict.lookupOrDefault<bool>("boundary", true);
oneBoundary_ = dict.lookupOrDefault<bool>("single", false);
interpolate_ = dict.lookupOrDefault<bool>("interpolate", false);
// verbose_ = dict.getOrDefault("verbose", true);
doInternal_ = dict.getOrDefault("internal", true);
doBoundary_ = dict.getOrDefault("boundary", true);
oneBoundary_ = dict.getOrDefault("single", false);
interpolate_ = dict.getOrDefault("interpolate", false);
//
// Writer options - default is xml base64
@ -197,7 +197,7 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
// Info<< type() << " " << name() << " output-format: "
// << writeOpts_.description() << nl;
const int padWidth = dict.lookupOrDefault<int>("width", 8);
const int padWidth = dict.getOrDefault<int>("width", 8);
// Appropriate printf format - Enforce min/max sanity limits
if (padWidth < 1 || padWidth > 31)
@ -213,8 +213,8 @@ bool Foam::functionObjects::vtkWrite::read(const dictionary& dict)
// Other options
//
decompose_ = dict.lookupOrDefault("decompose", false);
writeIds_ = dict.lookupOrDefault("writeIds", false);
decompose_ = dict.getOrDefault("decompose", false);
writeIds_ = dict.getOrDefault("writeIds", false);
// Output directory

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -241,7 +241,7 @@ bool Foam::functionObjects::vtkWrite::readSelection(const dictionary& dict)
{
selectRegions_.resize(1);
selectRegions_.first() =
dict.lookupOrDefault<word>("region", polyMesh::defaultRegion);
dict.getOrDefault<word>("region", polyMesh::defaultRegion);
}
// Restrict to specified meshes

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -75,7 +75,7 @@ Foam::functionObjects::writeObjects::writeObjects
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
dict.getOrDefault("region", polyMesh::defaultRegion)
)
),
writeOption_(ANY_WRITE),
@ -105,7 +105,7 @@ bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
dict.readEntry("objects", objectNames_);
}
writeOption_ = writeOptionNames_.lookupOrDefault
writeOption_ = writeOptionNames_.getOrDefault
(
"writeOption",
dict,