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 ...@@ -5,5 +5,5 @@ const dictionary& potentialFlow
const int nNonOrthCorr const int nNonOrthCorr
( (
potentialFlow.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0) potentialFlow.getOrDefault<int>("nNonOrthogonalCorrectors", 0)
); );
...@@ -5,5 +5,5 @@ const dictionary& potentialFlow ...@@ -5,5 +5,5 @@ const dictionary& potentialFlow
const int nNonOrthCorr const int nNonOrthCorr
( (
potentialFlow.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0) potentialFlow.getOrDefault<int>("nNonOrthogonalCorrectors", 0)
); );
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -72,7 +72,7 @@ PDRkEpsilon::PDRkEpsilon ...@@ -72,7 +72,7 @@ PDRkEpsilon::PDRkEpsilon
C4_ C4_
( (
dimensioned<scalar>::lookupOrAddToDict dimensioned<scalar>::getOrAddToDict
( (
"C4", "C4",
coeffDict_, coeffDict_,
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
bool correctPhi bool correctPhi
( (
pimple.dict().lookupOrDefault("correctPhi", true) pimple.dict().getOrDefault("correctPhi", true)
); );
bool checkMeshCourantNo bool checkMeshCourantNo
( (
pimple.dict().lookupOrDefault("checkMeshCourantNo", false) pimple.dict().getOrDefault("checkMeshCourantNo", false)
); );
#include "readTimeControls.H" #include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); correctPhi = pimple.dict().getOrDefault("correctPhi", true);
checkMeshCourantNo = checkMeshCourantNo =
pimple.dict().lookupOrDefault("checkMeshCourantNo", false); pimple.dict().getOrDefault("checkMeshCourantNo", false);
...@@ -12,12 +12,12 @@ IOdictionary additionalControlsDict ...@@ -12,12 +12,12 @@ IOdictionary additionalControlsDict
bool solvePrimaryRegion bool solvePrimaryRegion
( (
additionalControlsDict.lookupOrDefault("solvePrimaryRegion", true) additionalControlsDict.getOrDefault("solvePrimaryRegion", true)
); );
bool solvePyrolysisRegion bool solvePyrolysisRegion
( (
additionalControlsDict.lookupOrDefault("solvePyrolysisRegion", true) additionalControlsDict.getOrDefault("solvePyrolysisRegion", true)
); );
scalar maxDi = pyrolysis.maxDiff(); scalar maxDi = pyrolysis.maxDiff();
if (pimple.dict().lookupOrDefault("hydrostaticInitialization", false)) if (pimple.dict().getOrDefault("hydrostaticInitialization", false))
{ {
volScalarField& ph_rgh = regIOobject::store volScalarField& ph_rgh = regIOobject::store
( (
...@@ -24,7 +24,7 @@ if (pimple.dict().lookupOrDefault("hydrostaticInitialization", false)) ...@@ -24,7 +24,7 @@ if (pimple.dict().lookupOrDefault("hydrostaticInitialization", false))
label nCorr label nCorr
( (
pimple.dict().lookupOrDefault<label>("nHydrostaticCorrectors", 5) pimple.dict().getOrDefault<label>("nHydrostaticCorrectors", 5)
); );
for (label i=0; i<nCorr; i++) for (label i=0; i<nCorr; i++)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -34,27 +35,27 @@ License ...@@ -34,27 +35,27 @@ License
scalar maxCo(pimpleDict.get<scalar>("maxCo")); scalar maxCo(pimpleDict.get<scalar>("maxCo"));
// Maximum time scale // 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 // Smoothing parameter (0-1) when smoothing iterations > 0
scalar rDeltaTSmoothingCoeff scalar rDeltaTSmoothingCoeff
( (
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1) pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
); );
// Damping coefficient (1-0) // Damping coefficient (1-0)
scalar rDeltaTDampingCoeff scalar rDeltaTDampingCoeff
( (
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1.0) pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
); );
// Maximum change in cell temperature per iteration // Maximum change in cell temperature per iteration
// (relative to previous value) // (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 // Maximum change in cell concentration per iteration
// (relative to reference value) // (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; Info<< "Time scales min/max:" << endl;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -82,13 +83,13 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField ...@@ -82,13 +83,13 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.getOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.getOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")), psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")), muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
accommodationCoeff_(dict.get<scalar>("accommodationCoeff")), accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
Twall_("Twall", dict, p.size()), Twall_("Twall", dict, p.size()),
gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4)) gamma_(dict.getOrDefault<scalar>("gamma", 1.4))
{ {
if if
( (
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -82,15 +83,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField ...@@ -82,15 +83,15 @@ Foam::maxwellSlipUFvPatchVectorField::maxwellSlipUFvPatchVectorField
) )
: :
partialSlipFvPatchVectorField(p, iF), partialSlipFvPatchVectorField(p, iF),
TName_(dict.lookupOrDefault<word>("T", "T")), TName_(dict.getOrDefault<word>("T", "T")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.getOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")), psiName_(dict.getOrDefault<word>("psi", "thermo:psi")),
muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")), muName_(dict.getOrDefault<word>("mu", "thermo:mu")),
tauMCName_(dict.lookupOrDefault<word>("tauMC", "tauMC")), tauMCName_(dict.getOrDefault<word>("tauMC", "tauMC")),
accommodationCoeff_(dict.get<scalar>("accommodationCoeff")), accommodationCoeff_(dict.get<scalar>("accommodationCoeff")),
Uwall_("Uwall", dict, p.size()), Uwall_("Uwall", dict, p.size()),
thermalCreep_(dict.lookupOrDefault("thermalCreep", true)), thermalCreep_(dict.getOrDefault("thermalCreep", true)),
curvature_(dict.lookupOrDefault("curvature", true)) curvature_(dict.getOrDefault("curvature", true))
{ {
if if
( (
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -66,8 +67,8 @@ Foam::fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField ...@@ -66,8 +67,8 @@ Foam::fixedRhoFvPatchScalarField::fixedRhoFvPatchScalarField
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), fixedValueFvPatchScalarField(p, iF, dict),
pName_(dict.lookupOrDefault<word>("p", "p")), pName_(dict.getOrDefault<word>("p", "p")),
psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")) psiName_(dict.getOrDefault<word>("psi", "thermo:psi"))
{} {}
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
scalar rDeltaTSmoothingCoeff scalar rDeltaTSmoothingCoeff
( (
runTime.controlDict().lookupOrDefault<scalar> runTime.controlDict().getOrDefault<scalar>
( (
"rDeltaTSmoothingCoeff", "rDeltaTSmoothingCoeff",
0.02 0.02
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
const dictionary& eosDict = thermoDict.subDict("equationOfState"); const dictionary& eosDict = thermoDict.subDict("equationOfState");
bool local = eosDict.lookupOrDefault("local", false); bool local = eosDict.getOrDefault("local", false);
// Evolve T as: // Evolve T as:
// //
......
bool ddtCorr bool ddtCorr
( (
pimple.dict().lookupOrDefault("ddtCorr", true) pimple.dict().getOrDefault("ddtCorr", true)
); );
#include "readTimeControls.H" #include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); correctPhi = pimple.dict().getOrDefault("correctPhi", false);
checkMeshCourantNo = 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 @@ ...@@ -5,22 +5,22 @@
scalar maxCo scalar maxCo
( (
pimpleDict.lookupOrDefault<scalar>("maxCo", 0.8) pimpleDict.getOrDefault<scalar>("maxCo", 0.8)
); );
scalar rDeltaTSmoothingCoeff scalar rDeltaTSmoothingCoeff
( (
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.02) pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.02)
); );
scalar rDeltaTDampingCoeff scalar rDeltaTDampingCoeff
( (
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1.0) pimpleDict.getOrDefault<scalar>("rDeltaTDampingCoeff", 1.0)
); );
scalar maxDeltaT scalar maxDeltaT
( (
pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT) pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
); );
volScalarField rDeltaT0("rDeltaT0", rDeltaT); volScalarField rDeltaT0("rDeltaT0", rDeltaT);
......
...@@ -82,5 +82,5 @@ dimensionedScalar initialMass = fvc::domainIntegrate(rho); ...@@ -82,5 +82,5 @@ dimensionedScalar initialMass = fvc::domainIntegrate(rho);
bool adjustFringe bool adjustFringe
( (
simple.dict().lookupOrDefault("oversetAdjustPhi", false) simple.dict().getOrDefault("oversetAdjustPhi", false)
); );
const dictionary& Bpiso = mesh.solutionDict().subDict("BPISO"); 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" #include "readTimeControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); correctPhi = pimple.dict().getOrDefault("correctPhi", false);
checkMeshCourantNo = 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 dictionary& simple = fluidRegions[i].solutionDict().subDict("SIMPLE");
const int nNonOrthCorr = const int nNonOrthCorr =
simple.lookupOrDefault<int>("nNonOrthogonalCorrectors", 0); simple.getOrDefault<int>("nNonOrthogonalCorrectors", 0);
const bool momentumPredictor = const bool momentumPredictor =
simple.lookupOrDefault("momentumPredictor", true); simple.getOrDefault("momentumPredictor", true);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment