Commit 3e43edf0 authored by Mark Olesen's avatar Mark Olesen
Browse files

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).
parent f721b534
......@@ -5,5 +5,5 @@ const dictionary& potentialFlow
const int nNonOrthCorr
(
potentialFlow.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0)
potentialFlow.getOrDefault<int>("nNonOrthogonalCorrectors", 0)
);
......@@ -5,5 +5,5 @@ const dictionary& potentialFlow
const int nNonOrthCorr
(
potentialFlow.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0)
potentialFlow.getOrDefault<int>("nNonOrthogonalCorrectors", 0)
);
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -72,7 +72,7 @@ PDRkEpsilon::PDRkEpsilon
C4_
(
dimensioned<scalar>::lookupOrAddToDict
dimensioned<scalar>::getOrAddToDict
(
"C4",
coeffDict_,
......
......@@ -2,10 +2,10 @@
bool correctPhi
(
pimple.dict().lookupOrDefault("correctPhi", true)
pimple.dict().getOrDefault("correctPhi", true)
);
bool checkMeshCourantNo
(
pimple.dict().lookupOrDefault("checkMeshCourantNo", false)
pimple.dict().getOrDefault("checkMeshCourantNo", false)
);
#include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", true);
correctPhi = pimple.dict().getOrDefault("correctPhi", true);
checkMeshCourantNo =
pimple.dict().lookupOrDefault("checkMeshCourantNo", false);
pimple.dict().getOrDefault("checkMeshCourantNo", false);
......@@ -12,12 +12,12 @@ IOdictionary additionalControlsDict
bool solvePrimaryRegion
(
additionalControlsDict.lookupOrDefault("solvePrimaryRegion", true)
additionalControlsDict.getOrDefault("solvePrimaryRegion", true)
);
bool solvePyrolysisRegion
(
additionalControlsDict.lookupOrDefault("solvePyrolysisRegion", true)
additionalControlsDict.getOrDefault("solvePyrolysisRegion", true)
);
scalar maxDi = pyrolysis.maxDiff();
if (pimple.dict().lookupOrDefault("hydrostaticInitialization", false))
if (pimple.dict().getOrDefault("hydrostaticInitialization", false))
{
volScalarField& ph_rgh = regIOobject::store
(
......@@ -24,7 +24,7 @@ if (pimple.dict().lookupOrDefault("hydrostaticInitialization", false))
label nCorr
(
pimple.dict().lookupOrDefault<label>("nHydrostaticCorrectors", 5)
pimple.dict().getOrDefault<label>("nHydrostaticCorrectors", 5)
);
for (label i=0; i<nCorr; i++)
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -34,27 +35,27 @@ License
scalar maxCo(pimpleDict.get<scalar>("maxCo"));
// Maximum time scale
scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
scalar maxDeltaT(pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT));
// Smoothing parameter (0-1) when smoothing iterations > 0
scalar rDeltaTSmoothingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
// Damping coefficient (1-0)
scalar rDeltaTDampingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
);
// Maximum change in cell temperature per iteration
// (relative to previous value)
scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
scalar alphaTemp(pimpleDict.getOrDefault<scalar>("alphaTemp", 0.05));
// Maximum change in cell concentration per iteration
// (relative to reference value)
scalar alphaY(pimpleDict.lookupOrDefault("alphaY", 1.0));
scalar alphaY(pimpleDict.getOrDefault<scalar>("alphaY", 1.0));
Info<< "Time scales min/max:" << endl;
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -82,13 +83,13 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")),
UName_(dict.getOrDefault<word>("U", "U")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
Twall_("Twall", dict, p.size()),
gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4))
gamma_(dict.getOrDefault<scalar>("gamma", 1.4))
{
if
(
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -82,15 +83,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
)
:
partialSlipFvPatchVectorField(p, iF),
TName_(dict.lookupOrDefault<word>("T", "T")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")),
tauMCName_(dict.lookupOrDefault<word>("tauMC", "tauMC")),
TName_(dict.getOrDefault<word>("T", "T")),
rhoName_(dict.getOrDefault<word>("rho", "rho")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
tauMCName_(dict.getOrDefault<word>("tauMC", "tauMC")),
accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
Uwall_("Uwall", dict, p.size()),
thermalCreep_(dict.lookupOrDefault("thermalCreep", true)),
curvature_(dict.lookupOrDefault("curvature", true))
thermalCreep_(dict.getOrDefault("thermalCreep", true)),
curvature_(dict.getOrDefault("curvature", true))
{
if
(
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,8 +67,8 @@ Foam::fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF, dict),
pName_(dict.lookupOrDefault<word>("p", "p")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi"))
pName_(dict.getOrDefault<word>("p", "p")),
psiName_(dict.getOrDefault<word>("psi", "thermo:psi"))
{}
......
......@@ -3,7 +3,7 @@
scalar rDeltaTSmoothingCoeff
(
runTime.controlDict().lookupOrDefault<scalar>
runTime.controlDict().getOrDefault<scalar>
(
"rDeltaTSmoothingCoeff",
0.02
......
......@@ -17,7 +17,7 @@
const dictionary& eosDict = thermoDict.subDict("equationOfState");
bool local = eosDict.lookupOrDefault("local", false);
bool local = eosDict.getOrDefault("local", false);
// Evolve T as:
//
......
bool ddtCorr
(
pimple.dict().lookupOrDefault("ddtCorr", true)
pimple.dict().getOrDefault("ddtCorr", true)
);
#include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", false);
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
checkMeshCourantNo =
pimple.dict().lookupOrDefault("checkMeshCourantNo", false);
pimple.dict().getOrDefault("checkMeshCourantNo", false);
ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true);
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
......@@ -5,22 +5,22 @@
scalar maxCo
(
pimpleDict.lookupOrDefault<scalar>("maxCo", 0.8)
pimpleDict.getOrDefault<scalar>("maxCo", 0.8)
);
scalar rDeltaTSmoothingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.02)
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.02)
);
scalar rDeltaTDampingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
);
scalar maxDeltaT
(
pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT)
pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
);
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
......
......@@ -82,5 +82,5 @@ dimensionedScalar initialMass = fvc::domainIntegrate(rho);
bool adjustFringe
(
simple.dict().lookupOrDefault("oversetAdjustPhi", false)
simple.dict().getOrDefault("oversetAdjustPhi", false)
);
const dictionary& Bpiso = mesh.solutionDict().subDict("BPISO");
const int nBcorr = Bpiso.lookupOrDefault<int>("nCorrectors", 1);
const int nBcorr = Bpiso.getOrDefault<int>("nCorrectors", 1);
#include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", false);
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
checkMeshCourantNo =
pimple.dict().lookupOrDefault("checkMeshCourantNo", false);
pimple.dict().getOrDefault("checkMeshCourantNo", false);
ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true);
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
const dictionary& simple = fluidRegions[i].solutionDict().subDict("SIMPLE");
const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
simple.getOrDefault<int>("nNonOrthogonalCorrectors", 0);
const bool momentumPredictor =
simple.lookupOrDefault("momentumPredictor", true);
simple.getOrDefault("momentumPredictor", true);
const dictionary& simple = mesh.solutionDict().subDict("SIMPLE");
const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
simple.getOrDefault<int>("nNonOrthogonalCorrectors", 0);
......@@ -227,11 +227,11 @@ turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
mixedFvPatchScalarField(p, iF),
regionType_(regionTypeNames_.get("region", dict)),
method_(KMethodTypeNames_.get("kappaMethod", dict)),
kappaName_(dict.lookupOrDefault<word>("kappa", "none")),
kappaName_(dict.getOrDefault<word>("kappa", "none")),
otherPhaseName_(dict.get<word>("otherPhase")),
TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")),
qrNbrName_(dict.lookupOrDefault<word>("qrNbr", "none")),
qrName_(dict.lookupOrDefault<word>("qr", "none"))
TnbrName_(dict.getOrDefault<word>("Tnbr", "T")),
qrNbrName_(dict.getOrDefault<word>("qrNbr", "none")),
qrName_(dict.getOrDefault<word>("qr", "none"))
{
if (!isA<mappedPatchBase>(this->patch().patch()))
{
......
......@@ -2,10 +2,10 @@
Switch faceMomentum
(
pimpleDict.lookupOrDefault<Switch>("faceMomentum", false)
pimpleDict.getOrDefault<Switch>("faceMomentum", false)
);
int nEnergyCorrectors
(
pimpleDict.lookupOrDefault<int>("nEnergyCorrectors", 1)
pimpleDict.getOrDefault<int>("nEnergyCorrectors", 1)
);
const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE");
const int nCorr =
pimple.lookupOrDefault<int>("nCorrectors", 1);
pimple.getOrDefault<int>("nCorrectors", 1);
const int nNonOrthCorr =
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
pimple.getOrDefault<int>("nNonOrthogonalCorrectors", 0);
const bool momentumPredictor =
pimple.lookupOrDefault("momentumPredictor", true);
pimple.getOrDefault("momentumPredictor", true);
......@@ -5,4 +5,4 @@
const dictionary& pimple = solutionDict.subDict("PIMPLE");
const int nOuterCorr =
pimple.lookupOrDefault<int>("nOuterCorrectors", 1);
pimple.getOrDefault<int>("nOuterCorrectors", 1);
const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE");
int nNonOrthCorr =
pimple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0);
pimple.getOrDefault<int>("nNonOrthogonalCorrectors", 0);
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,6 +32,6 @@ Description
\*---------------------------------------------------------------------------*/
scalar maxDi = runTime.controlDict().lookupOrDefault<scalar>("maxDi", 10.0);
scalar maxDi = runTime.controlDict().getOrDefault<scalar>("maxDi", 10);
// ************************************************************************* //
......@@ -2,25 +2,25 @@
bool correctPhi
(
pimple.dict().lookupOrDefault("correctPhi", false)
pimple.dict().getOrDefault("correctPhi", false)
);
bool checkMeshCourantNo
(
pimple.dict().lookupOrDefault("checkMeshCourantNo", false)
pimple.dict().getOrDefault("checkMeshCourantNo", false)
);
bool massFluxInterpolation
(
pimple.dict().lookupOrDefault("massFluxInterpolation", false)
pimple.dict().getOrDefault("massFluxInterpolation", false)
);
bool adjustFringe
(
pimple.dict().lookupOrDefault("oversetAdjustPhi", false)
pimple.dict().getOrDefault("oversetAdjustPhi", false)
);
bool ddtCorr
(
pimple.dict().lookupOrDefault("ddtCorr", true)
pimple.dict().getOrDefault("ddtCorr", true)
);
#include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", false);
correctPhi = pimple.dict().getOrDefault("correctPhi", false);
checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false);
checkMeshCourantNo = pimple.dict().getOrDefault("checkMeshCourantNo", false);
massFluxInterpolation =
pimple.dict().lookupOrDefault("massFluxInterpolation", false);
pimple.dict().getOrDefault("massFluxInterpolation", false);
ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true);
ddtCorr = pimple.dict().getOrDefault("ddtCorr", true);
......@@ -22,9 +22,9 @@
bool adjustFringe
(
simple.dict().lookupOrDefault("oversetAdjustPhi", false)
simple.dict().getOrDefault("oversetAdjustPhi", false)
);
bool massFluxInterpolation
(
simple.dict().lookupOrDefault("massFluxInterpolation", false)
simple.dict().getOrDefault("massFluxInterpolation", false)
);
......@@ -5,7 +5,7 @@ int nUCorr = 0;
if (pZones.active())
{
// nUCorrectors for pressureImplicitPorosity
nUCorr = simple.dict().lookupOrDefault<int>("nUCorrectors", 0);
nUCorr = simple.dict().getOrDefault<int>("nUCorrectors", 0);
if (nUCorr > 0)
{
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -34,23 +35,23 @@ License
scalar maxCo(pimpleDict.get<scalar>("maxCo"));
// Maximum time scale
scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
scalar maxDeltaT(pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT));
// Smoothing parameter (0-1) when smoothing iterations > 0
scalar rDeltaTSmoothingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
// Damping coefficient (1-0)
scalar rDeltaTDampingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
);
// Maximum change in cell temperature per iteration
// (relative to previous value)
scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
Info<< "Time scales min/max:" << endl;
......
bool solvePrimaryRegion
(
pimple.dict().lookupOrDefault("solvePrimaryRegion", true)
pimple.dict().getOrDefault("solvePrimaryRegion", true)
);
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -34,23 +35,23 @@ License
scalar maxCo(pimpleDict.get<scalar>("maxCo"));
// Maximum time scale
scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
scalar maxDeltaT(pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT));
// Smoothing parameter (0-1) when smoothing iterations > 0
scalar rDeltaTSmoothingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
// Damping coefficient (1-0)
scalar rDeltaTDampingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
);
// Maximum change in cell temperature per iteration