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

@ -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;

View File

@ -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");
}

View File

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

View File

@ -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_

View File

@ -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")),

View File

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

View File

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

View File

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

View File

@ -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)
)
{}

View File

@ -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)
)
{}

View File

@ -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_
(

View File

@ -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];

View File

@ -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::

View File

@ -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_)
{

View File

@ -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)

View File

@ -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")
]
)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -87,7 +88,7 @@ Foam::searchablePlateFeatures::searchablePlateFeatures
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>("meshableSide", "inside")
dict.getOrDefault<word>("meshableSide", "inside")
]
)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2015 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ Foam::triSurfaceMeshFeatures::triSurfaceMeshFeatures
(
extendedFeatureEdgeMesh::sideVolumeTypeNames_
[
dict.lookupOrDefault<word>("meshableSide", "inside")
dict.getOrDefault<word>("meshableSide", "inside")
]
)
{

View File

@ -103,7 +103,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
foamyHexMeshDict.subDict("geometry"),
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
foamyHexMeshDict.getOrDefault("singleRegionName", true)
);
// Write some stats

View File

@ -438,7 +438,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
foamyHexMeshDict.subDict("geometry"),
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
foamyHexMeshDict.getOrDefault("singleRegionName", true)
);
Random rndGen(64293*Pstream::myProcNo());

View File

@ -411,7 +411,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
foamyHexMeshDict.subDict("geometry"),
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
foamyHexMeshDict.getOrDefault("singleRegionName", true)
);
Info<< "Geometry read in = "

View File

@ -98,7 +98,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
foamyHexMeshDict.subDict("geometry"),
foamyHexMeshDict.lookupOrDefault("singleRegionName", true)
foamyHexMeshDict.getOrDefault("singleRegionName", true)
);
Info<< "Geometry read in = "

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -125,7 +126,7 @@ Foam::CV2D::CV2D
IOobject::NO_WRITE
),
cvMeshDict.subDict("geometry"),
cvMeshDict.lookupOrDefault("singleRegionName", true)
cvMeshDict.getOrDefault("singleRegionName", true)
),
qSurf_
(

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -157,7 +158,7 @@ Foam::shortEdgeFilter2D::shortEdgeFilter2D
shortEdgeFilterFactor_(dict.get<scalar>("shortEdgeFilterFactor")),
edgeAttachedToBoundaryFactor_
(
dict.lookupOrDefault<scalar>("edgeAttachedToBoundaryFactor", 2.0)
dict.getOrDefault<scalar>("edgeAttachedToBoundaryFactor", 2.0)
),
patchNames_(wordList()),
patchSizes_(labelList()),

View File

@ -853,12 +853,12 @@ int main(int argc, char *argv[])
dryRun
);
const bool keepPatches(meshDict.lookupOrDefault("keepPatches", false));
const bool keepPatches(meshDict.getOrDefault("keepPatches", false));
// format to be used for writing lines
const word setFormat
(
meshDict.lookupOrDefault
meshDict.getOrDefault<word>
(
"setFormat",
vtkSetWriter<scalar>::typeName
@ -871,7 +871,7 @@ int main(int argc, char *argv[])
const scalar maxSizeRatio
(
meshDict.lookupOrDefault<scalar>("maxSizeRatio", 100.0)
meshDict.getOrDefault<scalar>("maxSizeRatio", 100)
);
@ -919,7 +919,7 @@ int main(int argc, char *argv[])
// Set debug level
meshRefinement::debugType debugLevel = meshRefinement::debugType
(
meshDict.lookupOrDefault<label>
meshDict.getOrDefault<label>
(
"debug",
0
@ -1004,7 +1004,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
geometryDict,
meshDict.lookupOrDefault("singleRegionName", true)
meshDict.getOrDefault("singleRegionName", true)
);
@ -1059,7 +1059,7 @@ int main(int argc, char *argv[])
allGeometry,
conformationDict,
shapeControlDict,
refineDict.lookupOrDefault("gapLevelIncrement", 0),
refineDict.getOrDefault("gapLevelIncrement", 0),
initialCellSize/defaultCellSize
);
@ -1078,7 +1078,7 @@ int main(int argc, char *argv[])
"refinementSurfaces",
dryRun
),
refineDict.lookupOrDefault("gapLevelIncrement", 0),
refineDict.getOrDefault("gapLevelIncrement", 0),
dryRun
)
);
@ -1714,7 +1714,7 @@ int main(int argc, char *argv[])
{
const bool mergePatchFaces
(
meshDict.lookupOrDefault("mergePatchFaces", true)
meshDict.getOrDefault("mergePatchFaces", true)
);
if (!mergePatchFaces)
@ -1728,7 +1728,7 @@ int main(int argc, char *argv[])
{
const bool mergeAcrossPatches
(
meshDict.lookupOrDefault("mergeAcrossPatches", false)
meshDict.getOrDefault("mergeAcrossPatches", false)
);
if (mergeAcrossPatches)