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
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -74,7 +75,7 @@ Foam::phaseModel::phaseModel
dimless,
fluid.subDict(phaseName)
),
alphaMax_(phaseDict_.lookupOrDefault<scalar>("alphaMax", 1)),
alphaMax_(phaseDict_.getOrDefault<scalar>("alphaMax", 1)),
thermo_(rhoThermo::New(fluid.mesh(), name_)),
U_
(
......
#include "createControl.H"
int nCorr = stressControl.lookupOrDefault<int>("nCorrectors", 1);
int nCorr = stressControl.getOrDefault<int>("nCorrectors", 1);
scalar convergenceTolerance(stressControl.get<scalar>("D"));
nCorr = stressControl.lookupOrDefault<int>("nCorrectors", 1);
nCorr = stressControl.getOrDefault<int>("nCorrectors", 1);
convergenceTolerance = stressControl.get<scalar>("D");
compactNormalStress = stressControl.get<bool>("compactNormalStress");
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -41,12 +41,12 @@ Foam::PatchFunction1Types::MappedField<Type>::MappedField
:
PatchFunction1<Type>(pp, entryName, dict),
fieldTableName_(entryName),
setAverage_(dict.lookupOrDefault("setAverage", false)),
perturb_(dict.lookupOrDefault("perturb", 1e-5)),
pointsName_(dict.lookupOrDefault<word>("points", "points")),
setAverage_(dict.getOrDefault("setAverage", false)),
perturb_(dict.getOrDefault<scalar>("perturb", 1e-5)),
pointsName_(dict.getOrDefault<word>("points", "points")),
mapMethod_
(
dict.lookupOrDefault<word>
dict.getOrDefault<word>
(
"mapMethod",
"planarInterpolation"
......
......@@ -264,7 +264,7 @@ int main(int argc, char *argv[])
const ExtrudeMode mode = ExtrudeModeNames.get("constructFrom", dict);
// Any merging of small edges
const scalar mergeTol(dict.lookupOrDefault<scalar>("mergeTol", 1e-4));
const scalar mergeTol(dict.getOrDefault<scalar>("mergeTol", 1e-4));
Info<< "Extruding from " << ExtrudeModeNames[mode]
<< " using model " << model().type() << endl;
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -1498,7 +1498,7 @@ int main(int argc, char *argv[])
word oneDPatchType(emptyPolyPatch::typeName);
if (oneD)
{
oneDNonManifoldEdges = dict.lookupOrDefault("nonManifold", false);
oneDNonManifoldEdges = dict.getOrDefault("nonManifold", false);
oneDPatchType = dict.get<word>("oneDPolyPatchType");
}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -310,7 +311,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
foamyHexMeshDict.subDict("geometry"),
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
foamyHexMeshDict.getOrDefault("singleRegionName", true)
);
conformationSurfaces geometryToConformTo
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -75,12 +76,12 @@ Foam::cv2DControls::cv2DControls
objOutput_
(
motionControl_.lookupOrDefault<Switch>("objOutput", false)
motionControl_.getOrDefault<Switch>("objOutput", false)
),
meshedSurfaceOutput_
(
motionControl_.lookupOrDefault<Switch>("meshedSurfaceOutput", false)
motionControl_.getOrDefault<Switch>("meshedSurfaceOutput", false)
),
randomiseInitialGrid_
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2018 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -806,7 +806,7 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition
spanScale_(coeffsDict.get<scalar>("spanScale")),
minCellSizeLimit_
(
coeffsDict.lookupOrDefault<scalar>("minCellSizeLimit", 0.0)
coeffsDict.getOrDefault<scalar>("minCellSizeLimit", 0)
),
minLevels_(coeffsDict.get<label>("minLevels")),
volRes_(coeffsDict.get<label>("sampleResolution")),
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -36,10 +37,10 @@ Foam::cellAspectRatioControl::cellAspectRatioControl
)
:
aspectRatioDict_(motionDict.subOrEmptyDict("cellAspectRatioControl")),
aspectRatio_(aspectRatioDict_.lookupOrDefault<scalar>("aspectRatio", 1.0)),
aspectRatio_(aspectRatioDict_.getOrDefault<scalar>("aspectRatio", 1)),
aspectRatioDirection_
(
aspectRatioDict_.lookupOrDefault<vector>
aspectRatioDict_.getOrDefault<vector>
(
"aspectRatioDirection",
Zero
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -53,7 +53,7 @@ Foam::cellSizeAndAlignmentControl::cellSizeAndAlignmentControl
defaultCellSize_(defaultCellSize),
forceInitialPointInsertion_
(
dict.lookupOrDefault<Switch>
dict.getOrDefault<Switch>
(
"forceInitialPointInsertion",
Switch::OFF
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -169,7 +170,7 @@ Foam::searchableSurfaceControl::searchableSurfaceControl
geometryToConformTo,
defaultCellSize
),
surfaceName_(controlFunctionDict.lookupOrDefault<word>("surface", name)),
surfaceName_(controlFunctionDict.getOrDefault<word>("surface", name)),
searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
geometryToConformTo_(geometryToConformTo),
cellSizeFunctions_(1),
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -70,7 +71,7 @@ Foam::fieldFromFile::fieldFromFile
),
cellSizeMultipleCoeff_
(
coeffsDict_.lookupOrDefault<scalar>("cellSizeMultipleCoeff", 1)
coeffsDict_.getOrDefault<scalar>("cellSizeMultipleCoeff", 1)
)
{}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -54,7 +54,7 @@ Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
defaultCellSize_(defaultCellSize),
refinementFactor_
(
lookupOrDefault<scalar>("refinementFactor", 1.0)
getOrDefault<scalar>("refinementFactor", 1)
)
{}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -840,7 +841,7 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
IOobject::NO_WRITE
),
foamyHexMeshDict.subDict("geometry"),
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
foamyHexMeshDict.getOrDefault("singleRegionName", true)
),
geometryToConformTo_
(
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -1716,7 +1716,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
forAll(procNeighbours, patchi)
{
procNeighbours[patchi] =
patchDicts[patchi].lookupOrDefault<label>("neighbProcNo", -1);
patchDicts[patchi].getOrDefault<label>("neighbProcNo", -1);
}
List<DynamicList<face>> patchFaces(nPatches, DynamicList<face>(0));
......@@ -2338,7 +2338,7 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches
if (patchFaces[nbI].size() > 0)
{
const label neighbour =
patchDicts[nbI].lookupOrDefault<label>("neighbProcNo", -1);
patchDicts[nbI].getOrDefault<label>("neighbProcNo", -1);
faceList procPatchFaces = patchFaces[nbI];
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -134,7 +135,7 @@ void Foam::conformationSurfaces::readFeatures
)
{
const word featureMethod =
featureDict.lookupOrDefault<word>("featureMethod", "none");
featureDict.getOrDefault<word>("featureMethod", "none");
if (featureMethod == "extendedFeatureEdgeMesh")
{
......@@ -217,7 +218,7 @@ void Foam::conformationSurfaces::readFeatures
)
{
const word featureMethod =
featureDict.lookupOrDefault<word>("featureMethod", "none");
featureDict.getOrDefault<word>("featureMethod", "none");
if (featureMethod == "extendedFeatureEdgeMesh")
{
......@@ -380,7 +381,7 @@ Foam::conformationSurfaces::conformationSurfaces
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>
dict.getOrDefault<word>
(
"meshableSide",
"inside"
......@@ -452,7 +453,7 @@ Foam::conformationSurfaces::conformationSurfaces
regionI,
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
regionDict.lookupOrDefault<word>
regionDict.getOrDefault<word>
(
"meshableSide",
extendedFeatureEdgeMesh::
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -131,13 +132,13 @@ Foam::cvControls::cvControls
motionDict.get<scalar>("minimumCellSizeCoeff")*defaultCellSize_;
objOutput_ =
motionDict.lookupOrDefault<Switch>("objOutput", false);
motionDict.getOrDefault<Switch>("objOutput", false);
timeChecks_ =
motionDict.lookupOrDefault<Switch>("timeChecks", false);
motionDict.getOrDefault<Switch>("timeChecks", false);
printVertexInfo_ =
motionDict.lookupOrDefault<Switch>("printVertexInfo", false);
motionDict.getOrDefault<Switch>("printVertexInfo", false);
if (Pstream::parRun())
{
......@@ -190,10 +191,10 @@ Foam::cvControls::cvControls
);
filterEdges_ =
filteringDict.lookupOrDefault<Switch>("filterEdges", true);
filteringDict.getOrDefault<Switch>("filterEdges", true);
filterFaces_ =
filteringDict.lookupOrDefault<Switch>("filterFaces", false);
filteringDict.getOrDefault<Switch>("filterFaces", false);
if (filterFaces_)
{
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -884,14 +884,14 @@ autoDensity::autoDensity
globalTrialPoints_(0),
minCellSizeLimit_
(
detailsDict().lookupOrDefault<scalar>("minCellSizeLimit", 0.0)
detailsDict().getOrDefault<scalar>("minCellSizeLimit", 0)
),
minLevels_(detailsDict().get<label>("minLevels")),
maxSizeRatio_(detailsDict().get<scalar>("maxSizeRatio")),
volRes_(detailsDict().get<label>("sampleResolution")),
surfRes_
(
detailsDict().lookupOrDefault<label>("surfaceSampleResolution", volRes_)
detailsDict().getOrDefault<label>("surfaceSampleResolution", volRes_)
)
{
if (maxSizeRatio_ <= 1.0)
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -58,7 +59,7 @@ Foam::searchableBoxFeatures::searchableBoxFeatures
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>("meshableSide", "inside")
dict.getOrDefault<word>("meshableSide", "inside")
]
)
{
......
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