Commit d58c1424 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: use restricted dictionary lookup for utilities (issue #762)

- get<label>, get<scalar> instead of readLabel, readScalar, etc.
parent d362c223
......@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
wordList polyMeshPatches
(
faMeshDefinition.lookup("polyMeshPatches")
faMeshDefinition.get<wordList>("polyMeshPatches")
);
const dictionary& bndDict = faMeshDefinition.subDict("boundary");
......@@ -107,9 +107,9 @@ int main(int argc, char *argv[])
faPatches[patchI].name_ = faPatchNames[patchI];
faPatches[patchI].type_ = word(curPatchDict.lookup("type"));
faPatches[patchI].type_ = curPatchDict.get<word>("type");
const word ownName = curPatchDict.lookup("ownerPolyPatch");
const word ownName(curPatchDict.get<word>("ownerPolyPatch"));
faPatches[patchI].ownPolyPatchID_ =
mesh.boundaryMesh().findPatchID(ownName);
......@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
const word neiName = curPatchDict.lookup("neighbourPolyPatch");
const word neiName(curPatchDict.get<word>("neighbourPolyPatch"));
faPatches[patchI].ngbPolyPatchID_ =
mesh.boundaryMesh().findPatchID(neiName);
......
......@@ -357,13 +357,13 @@ int main(int argc, char *argv[])
)
);
fileName surfName(refineDict.lookup("surface"));
fileName surfName(refineDict.get<fileName>("surface"));
pointField outsidePts(refineDict.lookup("outsidePoints"));
bool useSurface(readBool(refineDict.lookup("useSurface")));
bool selectCut(readBool(refineDict.lookup("selectCut")));
bool selectInside(readBool(refineDict.lookup("selectInside")));
bool selectOutside(readBool(refineDict.lookup("selectOutside")));
scalar nearDist(readScalar(refineDict.lookup("nearDistance")));
const bool useSurface(refineDict.get<bool>("useSurface"));
const bool selectCut(refineDict.get<bool>("selectCut"));
const bool selectInside(refineDict.get<bool>("selectInside"));
const bool selectOutside(refineDict.get<bool>("selectOutside"));
const scalar nearDist(refineDict.get<scalar>("nearDistance"));
if (useSurface)
......
......@@ -677,22 +677,22 @@ int main(int argc, char *argv[])
)
);
fileName surfName(refineDict.lookup("surface"));
fileName surfName(refineDict.get<fileName>("surface"));
surfName.expand();
label nCutLayers(readLabel(refineDict.lookup("nCutLayers")));
label cellLimit(readLabel(refineDict.lookup("cellLimit")));
bool selectCut(readBool(refineDict.lookup("selectCut")));
bool selectInside(readBool(refineDict.lookup("selectInside")));
bool selectOutside(readBool(refineDict.lookup("selectOutside")));
bool selectHanging(readBool(refineDict.lookup("selectHanging")));
scalar minEdgeLen(readScalar(refineDict.lookup("minEdgeLen")));
scalar maxEdgeLen(readScalar(refineDict.lookup("maxEdgeLen")));
scalar curvature(readScalar(refineDict.lookup("curvature")));
scalar curvDist(readScalar(refineDict.lookup("curvatureDistance")));
const label nCutLayers(refineDict.get<label>("nCutLayers"));
const label cellLimit(refineDict.get<label>("cellLimit"));
const bool selectCut(refineDict.get<bool>("selectCut"));
const bool selectInside(refineDict.get<bool>("selectInside"));
const bool selectOutside(refineDict.get<bool>("selectOutside"));
const bool selectHanging(refineDict.get<bool>("selectHanging"));
const scalar minEdgeLen(refineDict.get<scalar>("minEdgeLen"));
const scalar maxEdgeLen(refineDict.get<scalar>("maxEdgeLen"));
const scalar curvature(refineDict.get<scalar>("curvature"));
const scalar curvDist(refineDict.get<scalar>("curvatureDistance"));
pointField outsidePts(refineDict.lookup("outsidePoints"));
label refinementLimit(readLabel(refineDict.lookup("splitLevel")));
bool writeMesh(readBool(refineDict.lookup("writeMesh")));
const label refinementLimit(refineDict.get<label>("splitLevel"));
const bool writeMesh(refineDict.get<bool>("writeMesh"));
Info<< "Cells to be used for meshing (0=false, 1=true):" << nl
<< " cells cut by surface : " << selectCut << nl
......
......@@ -1505,7 +1505,7 @@ int main(int argc, char *argv[])
autoPtr<extrudeModel> model(extrudeModel::New(dict));
// Region
const word shellRegionName(dict.lookup("region"));
const word shellRegionName(dict.get<word>("region"));
// Faces to extrude - either faceZones or faceSets (boundary faces only)
wordList zoneNames;
......@@ -1534,7 +1534,7 @@ int main(int argc, char *argv[])
mappedPatchBase::sampleMode sampleMode =
mappedPatchBase::sampleModeNames_[dict.lookup("sampleMode")];
mappedPatchBase::sampleModeNames_.lookup("sampleMode", dict);
const bool oneD(dict.get<bool>("oneD"));
bool oneDNonManifoldEdges(false);
......@@ -1542,7 +1542,7 @@ int main(int argc, char *argv[])
if (oneD)
{
oneDNonManifoldEdges = dict.lookupOrDefault("nonManifold", false);
dict.lookup("oneDPolyPatchType") >> oneDPatchType;
oneDPatchType = dict.get<word>("oneDPolyPatchType");
}
const bool adaptMesh(dict.get<bool>("adaptMesh"));
......
......@@ -90,8 +90,8 @@ Foam::extrude2DMesh::extrude2DMesh
dict_(dict),
//patchDict_(dict.subDict("patchInfo")),
model_(model),
modelType_(dict.lookup("extrudeModel")),
patchType_(dict.lookup("patchType")),
modelType_(dict.get<word>("extrudeModel")),
patchType_(dict.get<word>("patchType")),
frontPatchi_(-1),
backPatchi_(-1)
{
......@@ -99,12 +99,6 @@ Foam::extrude2DMesh::extrude2DMesh
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::extrude2DMesh::~extrude2DMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::extrude2DMesh::addFrontBackPatches()
......
......@@ -77,6 +77,7 @@ class extrude2DMesh
const word patchType_;
label frontPatchi_;
label backPatchi_;
// Private Member Functions
......@@ -109,7 +110,7 @@ public:
//- Destructor
~extrude2DMesh();
~extrude2DMesh() = default;
// Member Functions
......
......@@ -27,7 +27,6 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cv2DControls::cv2DControls
(
const dictionary& controlDict,
......@@ -39,43 +38,61 @@ Foam::cv2DControls::cv2DControls
motionControl_(controlDict.subDict("motionControl")),
conformationControl_(controlDict.subDict("surfaceConformation")),
minCellSize_(readScalar(motionControl_.lookup("minCellSize"))),
minCellSize_(motionControl_.get<scalar>("minCellSize")),
minCellSize2_(Foam::sqr(minCellSize_)),
maxQuadAngle_(readScalar(conformationControl_.lookup("maxQuadAngle"))),
maxQuadAngle_(conformationControl_.get<scalar>("maxQuadAngle")),
nearWallAlignedDist_
(
readScalar(motionControl_.lookup("nearWallAlignedDist"))*minCellSize_
motionControl_.get<scalar>("nearWallAlignedDist") * minCellSize_
),
nearWallAlignedDist2_(Foam::sqr(nearWallAlignedDist_)),
insertSurfaceNearestPointPairs_
(
conformationControl_.lookup("insertSurfaceNearestPointPairs")
conformationControl_.get<Switch>
(
"insertSurfaceNearestPointPairs"
)
),
mirrorPoints_
(
conformationControl_.get<Switch>
(
"mirrorPoints"
)
),
mirrorPoints_(conformationControl_.lookup("mirrorPoints")),
insertSurfaceNearPointPairs_
(
conformationControl_.lookup("insertSurfaceNearPointPairs")
conformationControl_.get<Switch>
(
"insertSurfaceNearPointPairs"
)
),
objOutput_(motionControl_.lookupOrDefault<Switch>("objOutput", false)),
objOutput_
(
motionControl_.lookupOrDefault<Switch>("objOutput", false)
),
meshedSurfaceOutput_
(
motionControl_.lookupOrDefault<Switch>("meshedSurfaceOutput", false)
),
randomiseInitialGrid_(conformationControl_.lookup("randomiseInitialGrid")),
randomiseInitialGrid_
(
conformationControl_.get<Switch>("randomiseInitialGrid")
),
randomPerturbation_
(
readScalar(conformationControl_.lookup("randomPerturbation"))
conformationControl_.get<scalar>("randomPerturbation")
),
maxBoundaryConformingIter_
(
readLabel(conformationControl_.lookup("maxBoundaryConformingIter"))
conformationControl_.get<label>("maxBoundaryConformingIter")
),
span_
......@@ -87,39 +104,29 @@ Foam::cv2DControls::cv2DControls
minEdgeLen_
(
readScalar(conformationControl_.lookup("minEdgeLenCoeff"))
*minCellSize_
conformationControl_.get<scalar>("minEdgeLenCoeff") * minCellSize_
),
minEdgeLen2_(Foam::sqr(minEdgeLen_)),
maxNotchLen_
(
readScalar(conformationControl_.lookup("maxNotchLenCoeff"))
*minCellSize_
conformationControl_.get<scalar>("maxNotchLenCoeff") * minCellSize_
),
maxNotchLen2_(Foam::sqr(maxNotchLen_)),
minNearPointDist_
(
readScalar(conformationControl_.lookup("minNearPointDistCoeff"))
*minCellSize_
conformationControl_.get<scalar>("minNearPointDistCoeff")*minCellSize_
),
minNearPointDist2_(Foam::sqr(minNearPointDist_)),
ppDist_
(
readScalar(conformationControl_.lookup("pointPairDistanceCoeff"))
*minCellSize_
conformationControl_.get<scalar>("pointPairDistanceCoeff")*minCellSize_
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cv2DControls::~cv2DControls()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::cv2DControls::write(Ostream& os) const
......
......@@ -164,7 +164,7 @@ public:
//- Destructor
~cv2DControls();
~cv2DControls() = default;
// Member Functions
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -801,14 +801,14 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition
allBackgroundMeshBounds_(Pstream::nProcs()),
globalBackgroundBounds_(),
mergeDist_(1e-6*mesh_.bounds().mag()),
spanScale_(readScalar(coeffsDict.lookup("spanScale"))),
spanScale_(coeffsDict.get<scalar>("spanScale")),
minCellSizeLimit_
(
coeffsDict.lookupOrDefault<scalar>("minCellSizeLimit", 0.0)
),
minLevels_(readLabel(coeffsDict.lookup("minLevels"))),
volRes_(readLabel(coeffsDict.lookup("sampleResolution"))),
maxCellWeightCoeff_(readScalar(coeffsDict.lookup("maxCellWeightCoeff")))
minLevels_(coeffsDict.get<label>("minLevels")),
volRes_(coeffsDict.get<label>("sampleResolution")),
maxCellWeightCoeff_(coeffsDict.get<scalar>("maxCellWeightCoeff"))
{
if (!Pstream::parRun())
{
......
......@@ -72,7 +72,7 @@ Foam::cellSizeAndAlignmentControl::New
const scalar& defaultCellSize
)
{
const word controlType(controlFunctionDict.lookup("type"));
const word controlType(controlFunctionDict.get<word>("type"));
Info<< indent << "Selecting cellSizeAndAlignmentControl "
<< controlType << endl;
......@@ -103,10 +103,4 @@ Foam::cellSizeAndAlignmentControl::New
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cellSizeAndAlignmentControl::~cellSizeAndAlignmentControl()
{}
// ************************************************************************* //
......@@ -139,7 +139,7 @@ public:
//- Destructor
virtual ~cellSizeAndAlignmentControl();
virtual ~cellSizeAndAlignmentControl() = default;
// Member Functions
......
......@@ -70,10 +70,10 @@ Foam::fileControl::fileControl
geometryToConformTo,
defaultCellSize
),
pointsFile_(controlFunctionDict.lookup("pointsFile")),
sizesFile_(controlFunctionDict.lookup("sizesFile")),
alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")),
maxPriority_(readLabel(controlFunctionDict.lookup("priority")))
pointsFile_(controlFunctionDict.get<fileName>("pointsFile")),
sizesFile_(controlFunctionDict.get<fileName>("sizesFile")),
alignmentsFile_(controlFunctionDict.get<fileName>("alignmentsFile")),
maxPriority_(controlFunctionDict.get<label>("priority"))
{
Info<< indent << "Loading " << name << " from file:" << nl
<< indent << " priority : " << maxPriority_ << nl
......@@ -84,12 +84,6 @@ Foam::fileControl::fileControl
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileControl::~fileControl()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
//
//Foam::scalar Foam::fileControl::cellSize(const point& pt) const
......
......@@ -90,7 +90,7 @@ public:
);
//- Destructor
~fileControl();
~fileControl() = default;
// Member Functions
......
......@@ -63,9 +63,9 @@ Foam::cellSizeFunction::cellSizeFunction
defaultCellSize_(defaultCellSize),
regionIndices_(regionIndices),
sideMode_(),
priority_(readLabel(cellSizeFunctionDict.lookup("priority", true)))
priority_(cellSizeFunctionDict.get<label>("priority", true))
{
word mode = cellSizeFunctionDict.lookup("mode", true);
const word mode = cellSizeFunctionDict.get<word>("mode", true);
if (surface_.hasVolumeType())
{
......@@ -125,7 +125,7 @@ Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
{
const word functionName
(
cellSizeFunctionDict.lookup("cellSizeFunction")
cellSizeFunctionDict.get<word>("cellSizeFunction")
);
Info<< indent << "Selecting cellSizeFunction "
......
......@@ -106,9 +106,7 @@ protected:
label priority_;
private:
// Private Member Functions
// Protected Member Functions
//- No copy construct
cellSizeFunction(const cellSizeFunction&) = delete;
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -29,20 +29,18 @@ License
#include "triSurfaceFields.H"
#include "volumeType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearDistance, 0);
addToRunTimeSelectionTable(cellSizeFunction, linearDistance, dictionary);
defineTypeNameAndDebug(linearDistance, 0);
addToRunTimeSelectionTable(cellSizeFunction, linearDistance, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
linearDistance::linearDistance
Foam::linearDistance::linearDistance
(
const dictionary& initialPointsDict,
const searchableSurface& surface,
......@@ -60,12 +58,11 @@ linearDistance::linearDistance
),
distanceCellSize_
(
readScalar(coeffsDict().lookup("distanceCellSizeCoeff"))
*defaultCellSize
coeffsDict().get<scalar>("distanceCellSizeCoeff") * defaultCellSize
),
distance_
(
readScalar(coeffsDict().lookup("distanceCoeff"))*defaultCellSize
coeffsDict().get<scalar>("distanceCoeff") * defaultCellSize
),
distanceSqr_(sqr(distance_))
{}
......@@ -73,7 +70,7 @@ linearDistance::linearDistance
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
scalar linearDistance::sizeFunction
Foam::scalar Foam::linearDistance::sizeFunction
(
const point& pt,
scalar d,
......@@ -83,7 +80,7 @@ scalar linearDistance::sizeFunction
const scalar interpolatedSize
= surfaceCellSizeFunction_().interpolate(pt, index);
scalar gradient
const scalar gradient
= (distanceCellSize_ - interpolatedSize)
/distance_;
......@@ -95,7 +92,7 @@ scalar linearDistance::sizeFunction
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool linearDistance::sizeLocations
bool Foam::linearDistance::sizeLocations
(
const pointIndexHit& hitPt,
const vector& n,
......@@ -111,9 +108,9 @@ bool linearDistance::sizeLocations
shapeSizes.resize(2);
shapePts[0] = pt - n*distance_;
shapeSizes[0] = distanceCellSize_;
shapePts[1] = pt + n*distance_;
shapeSizes[0] = distanceCellSize_;
shapeSizes[1] = distanceCellSize_;
}
else if (sideMode_ == smInside)
......@@ -137,7 +134,7 @@ bool linearDistance::sizeLocations
}
bool linearDistance::cellSize(const point& pt, scalar& size) const
bool Foam::linearDistance::cellSize(const point& pt, scalar& size) const
{
size = 0;
......@@ -211,7 +208,7 @@ bool linearDistance::cellSize(const point& pt, scalar& size) const
}
bool linearDistance::setCellSize(const pointField& pts)
bool Foam::linearDistance::setCellSize(const pointField& pts)
{
// labelHashSet surfaceAlreadyHit(surfaceCellSize_.size());
......@@ -249,8 +246,4 @@ bool linearDistance::setCellSize(const pointField& pts)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -88,8 +88,7 @@ public:
//- Destructor
virtual ~linearDistance()
{}
virtual ~linearDistance() = default;