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,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,