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) 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")
]
)
{
......
......@@ -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")
]
)
{
......
......@@ -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
......
......@@ -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());
......
......@@ -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 = "
......
......@@ -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 = "
......
......@@ -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_
(
......
......@@ -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()),
......
......@@ -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)
......
......@@ -472,7 +472,7 @@ int main(int argc, char *argv[])
IOdictionary dict(dictIO);
internalFacesOnly = dict.get<bool>("internalFacesOnly");
noFields = dict.lookupOrDefault("noFields", false);
noFields = dict.getOrDefault("noFields", false);
const dictionary& selectionsDict = dict.subDict("baffles");
......@@ -735,7 +735,7 @@ int main(int argc, char *argv[])
// (ie 3D thermal baffles)
const bool sameGroup =
patchSource.lookupOrDefault("sameGroup", true);
patchSource.getOrDefault("sameGroup", true);
if (!sameGroup)
{
......@@ -915,7 +915,7 @@ int main(int argc, char *argv[])
const dictionary& patchSource = dict.subDict("patchPairs");
const bool sameGroup =
patchSource.lookupOrDefault("sameGroup", true);
patchSource.getOrDefault("sameGroup", true);
const word& groupName = selectors[selectorI].name();
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -50,7 +50,7 @@ Foam::faceSelection::faceSelection
name_(name),
mesh_(mesh),
dict_(dict),
flip_(dict.lookupOrDefault("flip", false))
flip_(dict.getOrDefault("flip", false))
{}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,7 +67,7 @@ Foam::faceSelections::searchableSurfaceSelection::searchableSurfaceSelection
dict.get<word>("surface"),
IOobject
(
dict.lookupOrDefault("name", mesh.objectRegistry::db().name()),
dict.getOrDefault("name", mesh.objectRegistry::db().name()),
mesh.time().constant(),
"triSurface",
mesh.objectRegistry::db(),
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
bool moveMeshOuterCorrectors
(
pimple.dict().lookupOrDefault("moveMeshOuterCorrectors", false)
pimple.dict().getOrDefault("moveMeshOuterCorrectors", false)
);
while (runTime.loop())
......
......@@ -714,7 +714,7 @@ int main(int argc, char *argv[])
renumberPtr = renumberMethod::New(renumberDict);
sortCoupledFaceCells = renumberDict.lookupOrDefault
sortCoupledFaceCells = renumberDict.getOrDefault
(
"sortCoupledFaceCells",
false
......@@ -725,7 +725,7 @@ int main(int argc, char *argv[])
<< endl;
}
blockSize = renumberDict.lookupOrDefault("blockSize", 0);
blockSize = renumberDict.getOrDefault("blockSize", 0);
if (blockSize > 0)
{
Info<< "Ordering cells into regions of size " << blockSize
......@@ -743,7 +743,7 @@ int main(int argc, char *argv[])
}
}
orderPoints = renumberDict.lookupOrDefault("orderPoints", false);
orderPoints = renumberDict.getOrDefault("orderPoints", false);
if (orderPoints)
{
Info<< "Ordering points into internal and boundary points." << nl
......
......@@ -15,4 +15,4 @@ const label sampleFrequency(propsDict.get<label>("sampleFrequency"));
const label maxPositions(propsDict.get<label>("maxPositions"));
const word setFormat(propsDict.lookupOrDefault<word>("setFormat", "vtk"));
const word setFormat(propsDict.getOrDefault<word>("setFormat", "vtk"));
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 DHI
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
isoCutCell icc(mesh, f);
icc.volumeOfFluid(alpha1, f0);
if (dict.lookupOrDefault("invertAlpha", false))
if (dict.getOrDefault("invertAlpha", false))
{
alpha1 = 1 - alpha1;
}
......
......@@ -4,7 +4,7 @@
// Maximum length for dynamicList
const label maxDynListLength
(
viewFactorDict.lookupOrDefault<label>("maxDynListLength", 100000)
viewFactorDict.getOrDefault<label>("maxDynListLength", 100000)
);
for (label proci = 0; proci < Pstream::nProcs(); proci++)
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -281,12 +281,12 @@ int main(int argc, char *argv[])
const word viewFactorWall("viewFactorWall");
const bool writeViewFactors =
viewFactorDict.lookupOrDefault("writeViewFactorMatrix", false);
viewFactorDict.getOrDefault("writeViewFactorMatrix", false);
const bool dumpRays =
viewFactorDict.lookupOrDefault("dumpRays", false);
viewFactorDict.getOrDefault("dumpRays", false);
const label debug = viewFactorDict.lookupOrDefault<label>("debug", 0);
const label debug = viewFactorDict.getOrDefault<label>("debug", 0);
// Read agglomeration map
labelListIOList finalAgglom
......
......@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
// We don't needs the intersectionMethod yet, but can use it
// for setting a reasonable loading option
const surfaceIntersection::intersectionType selfIntersect =
surfaceIntersection::selfIntersectionNames.lookupOrDefault
surfaceIntersection::selfIntersectionNames.getOrDefault
(
"intersectionMethod",
surfaceDict,
......@@ -320,7 +320,7 @@ int main(int argc, char *argv[])
// Loading option - default depends on context
triSurfaceLoader::loadingOption loadingOption =
triSurfaceLoader::loadingOptionNames.lookupOrDefault
triSurfaceLoader::loadingOptionNames.getOrDefault
(
"loadingOption",
surfaceDict,
......@@ -384,9 +384,9 @@ int main(int argc, char *argv[])
const dictionary& trimDict = surfaceDict.subDict("trimFeatures");
const scalar minLen =
trimDict.lookupOrDefault<scalar>("minLen", 0);
trimDict.getOrDefault<scalar>("minLen", 0);
const label minElem =
trimDict.lookupOrDefault<label>("minElem", 0);
trimDict.getOrDefault<label>("minElem", 0);
// Trim away small groups of features
if (minLen > 0 || minElem > 0)
......@@ -461,7 +461,7 @@ int main(int argc, char *argv[])
}
// Suboption: "nonManifoldEdges" (false: remove non-manifold edges)
if (!subsetDict.lookupOrDefault("nonManifoldEdges", true))
if (!subsetDict.getOrDefault("nonManifoldEdges", true))
{
Info<< "Removing all non-manifold edges"
<< " (edges with > 2 connected faces) unless they"
......@@ -476,7 +476,7 @@ int main(int argc, char *argv[])
}
// Suboption: "openEdges" (false: remove open edges)
if (!subsetDict.lookupOrDefault("openEdges", true))
if (!subsetDict.getOrDefault("openEdges", true))
{
Info<< "Removing all open edges"
<< " (edges with 1 connected face)" << endl;
......@@ -656,13 +656,13 @@ int main(int argc, char *argv[])
// Output information
const bool optCloseness =
surfaceDict.lookupOrDefault("closeness", false);
surfaceDict.getOrDefault("closeness", false);
const bool optProximity =
surfaceDict.lookupOrDefault("featureProximity", false);
surfaceDict.getOrDefault("featureProximity", false);
const bool optCurvature =
surfaceDict.lookupOrDefault("curvature", false);
surfaceDict.getOrDefault("curvature", false);
// For VTK legacy format, we would need an a priori count of
......@@ -723,7 +723,7 @@ int main(int argc, char *argv[])
if (optCloseness)
{
const scalar maxProximity =
surfaceDict.lookupOrDefault<scalar>("maxFeatureProximity", 1);
surfaceDict.getOrDefault<scalar>("maxFeatureProximity", 1);
tmp<scalarField> tproximity =
edgeMeshTools::writeFeatureProximity
......
......@@ -85,7 +85,7 @@ int main(int argc, char *argv[])
IOobject::NO_WRITE
),
meshDict.subDict("geometry"),
meshDict.lookupOrDefault("singleRegionName", true)
meshDict.getOrDefault("singleRegionName", 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