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

@ -143,7 +143,7 @@ Foam::layerAdditionRemoval::layerAdditionRemoval
minLayerThickness_(dict.get<scalar>("minLayerThickness")),
maxLayerThickness_(dict.get<scalar>("maxLayerThickness")),
thicknessFromVolume_(dict.getOrDefault("thicknessFromVolume", true)),
oldLayerThickness_(dict.getOrDefault<scalar>("oldLayerThickness", -1.0)),
oldLayerThickness_(dict.getOrDefault<scalar>("oldLayerThickness", -1)),
pointsPairingPtr_(nullptr),
facesPairingPtr_(nullptr),
triggerRemoval_(-1),

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -117,7 +118,7 @@ bool Foam::motionSmootherAlgo::checkMesh
);
const scalar minFaceFlatness
(
dict.lookupOrDefault<scalar>
dict.getOrDefault<scalar>
(
"minFaceFlatness", -1, keyType::REGEX_RECURSIVE
)

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,10 +44,10 @@ Foam::zoneMotion::zoneMotion
moveAllCells_(false)
{
word cellZoneName =
dict.lookupOrDefault<word>("cellZone", "none");
dict.getOrDefault<word>("cellZone", "none");
word cellSetName =
dict.lookupOrDefault<word>("cellSet", "none");
dict.getOrDefault<word>("cellSet", "none");
if ((cellZoneName != "none") && (cellSetName != "none"))
{

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.
@ -56,7 +56,7 @@ Foam::solidBodyMotionFunctions::drivenLinearMotion::drivenLinearMotion
:
solidBodyMotionFunction(SBMFCoeffs, runTime),
CofGvelocity_(SBMFCoeffs.get<word>("CofGvelocity")),
normal_(SBMFCoeffs.lookupOrDefault<vector>("normal", Zero)),
normal_(SBMFCoeffs.getOrDefault<vector>("normal", Zero)),
CofGvel_
(
IOobject

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,10 +62,10 @@ Foam::solidBodyMotionSolver::solidBodyMotionSolver
moveAllCells_(false)
{
word cellZoneName =
coeffDict().lookupOrDefault<word>("cellZone", "none");
coeffDict().getOrDefault<word>("cellZone", "none");
word cellSetName =
coeffDict().lookupOrDefault<word>("cellSet", "none");
coeffDict().getOrDefault<word>("cellSet", "none");
if ((cellZoneName != "none") && (cellSetName != "none"))
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +36,7 @@ Foam::polyMeshFilterSettings::polyMeshFilterSettings(const dictionary& dict)
dict_(dict),
controlMeshQuality_
(
dict_.lookupOrDefault<Switch>("controlMeshQuality", false)
dict_.getOrDefault<Switch>("controlMeshQuality", false)
),
collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
@ -53,39 +54,27 @@ Foam::polyMeshFilterSettings::polyMeshFilterSettings(const dictionary& dict)
),
edgeReductionFactor_
(
meshQualityCoeffDict_.lookupOrDefault<scalar>("edgeReductionFactor", -1)
meshQualityCoeffDict_.getOrDefault<scalar>("edgeReductionFactor", -1)
),
maxIterations_
(
meshQualityCoeffDict_.lookupOrAddDefault<label>("maximumIterations", 1)
meshQualityCoeffDict_.getOrAdd<label>("maximumIterations", 1)
),
maxSmoothIters_
(
meshQualityCoeffDict_.lookupOrAddDefault<label>
(
"maximumSmoothingIterations",
0
)
meshQualityCoeffDict_.getOrAdd<label>("maximumSmoothingIterations", 0)
),
initialFaceLengthFactor_
(
collapseFacesCoeffDict_.lookupOrAddDefault<scalar>
(
"initialFaceLengthFactor",
-1
)
collapseFacesCoeffDict_.getOrAdd<scalar>("initialFaceLengthFactor", -1)
),
faceReductionFactor_
(
meshQualityCoeffDict_.lookupOrAddDefault<scalar>
(
"faceReductionFactor",
-1
)
meshQualityCoeffDict_.getOrAdd<scalar>("faceReductionFactor", -1)
),
maxPointErrorCount_
(
meshQualityCoeffDict_.lookupOrAddDefault<label>("maxPointErrorCount", 0)
meshQualityCoeffDict_.getOrAdd<label>("maxPointErrorCount", 0)
)
{}

View File

@ -1212,19 +1212,19 @@ Foam::edgeCollapser::edgeCollapser
mesh_(mesh),
guardFraction_
(
dict.lookupOrDefault<scalar>("guardFraction", 0)
dict.getOrDefault<scalar>("guardFraction", 0)
),
maxCollapseFaceToPointSideLengthCoeff_
(
dict.lookupOrDefault<scalar>("maxCollapseFaceToPointSideLengthCoeff", 0)
dict.getOrDefault<scalar>("maxCollapseFaceToPointSideLengthCoeff", 0)
),
allowEarlyCollapseToPoint_
(
dict.lookupOrDefault("allowEarlyCollapseToPoint", true)
dict.getOrDefault("allowEarlyCollapseToPoint", true)
),
allowEarlyCollapseCoeff_
(
dict.lookupOrDefault<scalar>("allowEarlyCollapseCoeff", 0)
dict.getOrDefault<scalar>("allowEarlyCollapseCoeff", 0)
)
{
if (debug)

View File

@ -676,42 +676,42 @@ const Foam::pointField& Foam::slidingInterface::pointProjection() const
void Foam::slidingInterface::setTolerances(const dictionary&dict, bool report)
{
pointMergeTol_ = dict.lookupOrDefault<scalar>
pointMergeTol_ = dict.getOrDefault<scalar>
(
"pointMergeTol",
pointMergeTol_
);
edgeMergeTol_ = dict.lookupOrDefault<scalar>
edgeMergeTol_ = dict.getOrDefault<scalar>
(
"edgeMergeTol",
edgeMergeTol_
);
nFacesPerSlaveEdge_ = dict.lookupOrDefault<label>
nFacesPerSlaveEdge_ = dict.getOrDefault<label>
(
"nFacesPerSlaveEdge",
nFacesPerSlaveEdge_
);
edgeFaceEscapeLimit_ = dict.lookupOrDefault<label>
edgeFaceEscapeLimit_ = dict.getOrDefault<label>
(
"edgeFaceEscapeLimit",
edgeFaceEscapeLimit_
);
integralAdjTol_ = dict.lookupOrDefault<scalar>
integralAdjTol_ = dict.getOrDefault<scalar>
(
"integralAdjTol",
integralAdjTol_
);
edgeMasterCatchFraction_ = dict.lookupOrDefault<scalar>
edgeMasterCatchFraction_ = dict.getOrDefault<scalar>
(
"edgeMasterCatchFraction",
edgeMasterCatchFraction_
);
edgeCoPlanarTol_ = dict.lookupOrDefault<scalar>
edgeCoPlanarTol_ = dict.getOrDefault<scalar>
(
"edgeCoPlanarTol",
edgeCoPlanarTol_
);
edgeEndCutoffTol_ = dict.lookupOrDefault<scalar>
edgeEndCutoffTol_ = dict.getOrDefault<scalar>
(
"edgeEndCutoffTol",
edgeEndCutoffTol_