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
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
// (relative to previous value)
scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
Info<< "Time scales min/max:" << endl;
......
......@@ -5,52 +5,52 @@
scalar maxCo
(
pimpleDict.lookupOrDefault<scalar>("maxCo", 0.9)
pimpleDict.getOrDefault<scalar>("maxCo", 0.9)
);
scalar maxAlphaCo
(
pimpleDict.lookupOrDefault<scalar>("maxAlphaCo", 0.2)
pimpleDict.getOrDefault<scalar>("maxAlphaCo", 0.2)
);
scalar rDeltaTSmoothingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
pimpleDict.getOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
label nAlphaSpreadIter
(
pimpleDict.lookupOrDefault<label>("nAlphaSpreadIter", 1)
pimpleDict.getOrDefault<label>("nAlphaSpreadIter", 1)
);
scalar alphaSpreadDiff
(
pimpleDict.lookupOrDefault<scalar>("alphaSpreadDiff", 0.2)
pimpleDict.getOrDefault<scalar>("alphaSpreadDiff", 0.2)
);
scalar alphaSpreadMax
(
pimpleDict.lookupOrDefault<scalar>("alphaSpreadMax", 0.99)
pimpleDict.getOrDefault<scalar>("alphaSpreadMax", 0.99)
);
scalar alphaSpreadMin
(
pimpleDict.lookupOrDefault<scalar>("alphaSpreadMin", 0.01)
pimpleDict.getOrDefault<scalar>("alphaSpreadMin", 0.01)
);
label nAlphaSweepIter
(
pimpleDict.lookupOrDefault<label>("nAlphaSweepIter", 5)
pimpleDict.getOrDefault<label>("nAlphaSweepIter", 5)
);
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);
......
#include "readDyMControls.H"
correctPhi = pimple.dict().lookupOrDefault("correctPhi", true);
correctPhi = pimple.dict().getOrDefault("correctPhi", true);
maxAcousticCo = runTime.controlDict().get<scalar>("maxAcousticCo");
......@@ -55,23 +55,23 @@ VoFPatchTransfer::VoFPatchTransfer
transferModel(type(), film, dict),
deltaFactorToVoF_
(
coeffDict_.lookupOrDefault<scalar>("deltaFactorToVoF", 1.0)
coeffDict_.getOrDefault<scalar>("deltaFactorToVoF", 1.0)
),
deltaFactorToFilm_
(
coeffDict_.lookupOrDefault<scalar>("deltaFactorToFilm", 0.5)
coeffDict_.getOrDefault<scalar>("deltaFactorToFilm", 0.5)
),
alphaToVoF_
(
coeffDict_.lookupOrDefault<scalar>("alphaToVoF", 0.5)
coeffDict_.getOrDefault<scalar>("alphaToVoF", 0.5)
),
alphaToFilm_
(
coeffDict_.lookupOrDefault<scalar>("alphaToFilm", 0.1)
coeffDict_.getOrDefault<scalar>("alphaToFilm", 0.1)
),
transferRateCoeff_
(
coeffDict_.lookupOrDefault<scalar>("transferRateCoeff", 0.1)
coeffDict_.getOrDefault<scalar>("transferRateCoeff", 0.1)
),
patchIDs_(),
patchTransferredMasses_()
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -124,9 +125,9 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
cellSetOption(sourceName, modelType, dict, mesh),
alphaSolidT_(Function1<scalar>::New("alphaSolidT", coeffs_)),
L_("L", dimEnergy/dimMass, coeffs_),
relax_(coeffs_.lookupOrDefault("relax", 0.9)),
Cu_(coeffs_.lookupOrDefault<scalar>("Cu", 100000)),
q_(coeffs_.lookupOrDefault("q", 0.001)),
relax_(coeffs_.getOrDefault("relax", 0.9)),
Cu_(coeffs_.getOrDefault<scalar>("Cu", 100000)),
q_(coeffs_.getOrDefault<scalar>("q", 0.001)),
alphaSolid_
(
IOobject
......
......@@ -4,12 +4,12 @@ label nAlphaCorr(alphaControls.get<label>("nAlphaCorr"));
label nAlphaSubCycles(alphaControls.get<label>("nAlphaSubCycles"));
bool MULESCorr(alphaControls.lookupOrDefault("MULESCorr", false));
bool MULESCorr(alphaControls.getOrDefault("MULESCorr", false));
// Apply the compression correction from the previous iteration
// Improves efficiency for steady-simulations but can only be applied
// once the alpha field is reasonably steady, i.e. fully developed
bool alphaApplyPrevCorr
(
alphaControls.lookupOrDefault("alphaApplyPrevCorr", false)
alphaControls.getOrDefault("alphaApplyPrevCorr", false)
);
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -89,9 +89,9 @@ incompressibleTwoPhaseInteractingMixture
(
"d",
dimLength,
muModel_->viscosityProperties().lookupOrDefault("d", 0.0)
muModel_->viscosityProperties().getOrDefault("d", 0.0)
),
alphaMax_(muModel_->viscosityProperties().lookupOrDefault("alphaMax", 1.0)),
alphaMax_(muModel_->viscosityProperties().getOrDefault("alphaMax", 1.0)),
U_(U),
phi_(phi),
......@@ -132,11 +132,11 @@ bool Foam::incompressibleTwoPhaseInteractingMixture::read()
(
"d",
dimLength,
muModel_->viscosityProperties().lookupOrDefault("d", 0)
muModel_->viscosityProperties().getOrDefault("d", 0)
);
alphaMax_ =
muModel_->viscosityProperties().lookupOrDefault
muModel_->viscosityProperties().getOrDefault
(
"alphaMax",
1.0
......
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