STYLE: reduced usage of Switch

- Since 'bool' and 'Switch' use the _identical_ input mechanism
  (ie, both accept true/false, on/off, yes/no, none, 1/0), the main
  reason to prefer one or the other is the output.

  The output for Switch is as text (eg, "true"), whereas for bool
  it is label (0 or 1). If the output is required for a dictionary,
  Switch may be appropriate. If the output is not required, or is only
  used for Pstream exchange, bool can be more appropriate.
This commit is contained in:
Mark Olesen 2018-06-01 20:51:48 +02:00
parent 0f60cc9263
commit 84b109219a
72 changed files with 227 additions and 319 deletions

View File

@ -78,7 +78,6 @@ Description
#include "XiModel.H"
#include "PDRDragModel.H"
#include "ignition.H"
#include "Switch.H"
#include "bound.H"
#include "pimpleControl.H"
#include "fvOptions.H"

View File

@ -63,7 +63,6 @@ Description
#include "XiModel.H"
#include "PDRDragModel.H"
#include "ignition.H"
#include "Switch.H"
#include "bound.H"
#include "dynamicRefineFvMesh.H"
#include "pimpleControl.H"

View File

@ -58,14 +58,14 @@ Foam::PDRDragModel::PDRDragModel
(
PDRProperties.subDict
(
word(PDRProperties.lookup("PDRDragModel")) + "Coeffs"
PDRProperties.get<word>("PDRDragModel") + "Coeffs"
)
),
turbulence_(turbulence),
rho_(rho),
U_(U),
phi_(phi),
on_(PDRDragModelCoeffs_.lookup("drag"))
on_(PDRDragModelCoeffs_.get<bool>("drag"))
{}
@ -81,7 +81,7 @@ bool Foam::PDRDragModel::read(const dictionary& PDRProperties)
{
PDRDragModelCoeffs_ = PDRProperties.optionalSubDict(type() + "Coeffs");
PDRDragModelCoeffs_.lookup("drag") >> on_;
PDRDragModelCoeffs_.read("drag", on_);
return true;
}

View File

@ -67,7 +67,7 @@ protected:
const volVectorField& U_;
const surfaceScalarField& phi_;
Switch on_;
bool on_;
private:

View File

@ -36,9 +36,9 @@ Foam::autoPtr<Foam::PDRDragModel> Foam::PDRDragModel::New
const surfaceScalarField& phi
)
{
const word modelType(PDRProperties.lookup("PDRDragModel"));
const word modelType(PDRProperties.get<word>("PDRDragModel"));
Info<< "Selecting flame-wrinkling model " << modelType << endl;
Info<< "Selecting drag model " << modelType << endl;
auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);

View File

@ -165,8 +165,8 @@ bool Foam::PDRDragModels::basic::read(const dictionary& PDRProperties)
{
PDRDragModel::read(PDRProperties);
PDRDragModelCoeffs_.lookup("Csu") >> Csu.value();
PDRDragModelCoeffs_.lookup("Csk") >> Csk.value();
PDRDragModelCoeffs_.read("Csu", Csu.value());
PDRDragModelCoeffs_.read("Csk", Csk.value());
return true;
}

View File

@ -1,2 +1,3 @@
Switch adjustTimeStep(runTime.controlDict().lookup("adjustTimeStep"));
scalar maxDeltaT(readScalar(runTime.controlDict().lookup("maxDeltaT")));
bool adjustTimeStep(runTime.controlDict().get<bool>("adjustTimeStep"));
scalar maxDeltaT(runTime.controlDict().get<scalar>("maxDeltaT"));

View File

@ -1,3 +1,3 @@
runTime.controlDict().lookup("adjustTimeStep") >> adjustTimeStep;
runTime.controlDict().read("adjustTimeStep", adjustTimeStep);
maxDeltaT = readScalar(runTime.controlDict().lookup("maxDeltaT"));
runTime.controlDict().read("maxDeltaT", maxDeltaT);

View File

@ -1,5 +1,5 @@
IOporosityModelList pZones(mesh);
Switch pressureImplicitPorosity(false);
bool pressureImplicitPorosity(false);
// nUCorrectors used for pressureImplicitPorosity
int nUCorr = 0;

View File

@ -13,9 +13,11 @@ IOdictionary gravitationalProperties
);
const dimensionedVector g(gravitationalProperties.lookup("g"));
const Switch rotating(gravitationalProperties.lookup("rotating"));
const bool rotating(gravitationalProperties.get<bool>("rotating"));
const dimensionedVector Omega =
(
rotating ? gravitationalProperties.lookup("Omega")
: dimensionedVector("Omega", -dimTime, vector(0,0,0));
: dimensionedVector("Omega", -dimTime, vector(0,0,0))
);
const dimensionedScalar magg = mag(g);
const dimensionedVector gHat = g/magg;

View File

@ -1,5 +1,5 @@
IOporosityModelList pZones(mesh);
Switch pressureImplicitPorosity(false);
bool pressureImplicitPorosity(false);
// nUCorrectors used for pressureImplicitPorosity
int nUCorr = 0;

View File

@ -39,7 +39,7 @@ ThermalPhaseChangePhaseSystem
HeatAndMassTransferPhaseSystem<BasePhaseSystem>(mesh),
volatile_(this->lookup("volatile")),
saturationModel_(saturationModel::New(this->subDict("saturationModel"))),
massTransfer_(this->lookup("massTransfer"))
massTransfer_(this->template get<bool>("massTransfer"))
{
forAllConstIters(this->phasePairs_, phasePairIter)
@ -357,7 +357,7 @@ void Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::correctThermo()
volScalarField iDmdtNew(iDmdt);
if (massTransfer_ )
if (massTransfer_)
{
volScalarField H1
(

View File

@ -43,7 +43,6 @@ SourceFiles
#include "HeatAndMassTransferPhaseSystem.H"
#include "saturationModel.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,7 +70,7 @@ protected:
autoPtr<saturationModel> saturationModel_;
// Mass transfer enabled
Switch massTransfer_;
bool massTransfer_;
//- Interfacial Mass transfer rate
HashPtrTable<volScalarField, phasePairKey, phasePairKey::hash>

View File

@ -1,3 +1,3 @@
const dictionary& stressControl = mesh.solutionDict().subDict("stressAnalysis");
Switch compactNormalStress(stressControl.lookup("compactNormalStress"));
bool compactNormalStress(stressControl.get<bool>("compactNormalStress"));

View File

@ -2,4 +2,4 @@
int nCorr = stressControl.lookupOrDefault<int>("nCorrectors", 1);
scalar convergenceTolerance(readScalar(stressControl.lookup("D")));
scalar convergenceTolerance(stressControl.get<scalar>("D"));

View File

@ -184,9 +184,7 @@
volScalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
volScalarField threeK(E/(1.0 - 2.0*nu));
Switch planeStress(mechanicalProperties.lookup("planeStress"));
if (planeStress)
if (mechanicalProperties.get<bool>("planeStress"))
{
Info<< "Plane Stress\n" << endl;

View File

@ -1,3 +1,3 @@
nCorr = stressControl.lookupOrDefault<int>("nCorrectors", 1);
convergenceTolerance = readScalar(stressControl.lookup("D"));
stressControl.lookup("compactNormalStress") >> compactNormalStress;
convergenceTolerance = stressControl.get<scalar>("D");
compactNormalStress = stressControl.get<bool>("compactNormalStress");

View File

@ -12,7 +12,7 @@ IOdictionary thermalProperties
)
);
Switch thermalStress(thermalProperties.lookup("thermalStress"));
bool thermalStress(thermalProperties.get<bool>("thermalStress"));
volScalarField threeKalpha
(
@ -46,7 +46,6 @@ volScalarField DT
if (thermalStress)
{
autoPtr<volScalarField> CPtr;
IOobject CIO

View File

@ -39,7 +39,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -164,9 +164,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
scalarField threeK(E/(1.0 - 2.0*nu));
Switch planeStress(mechanicalProperties.lookup("planeStress"));
if (planeStress)
if (mechanicalProperties.get<bool>("planeStress"))
{
lambda = nu*E/((1.0 + nu)*(1.0 - nu));
threeK = E/(1.0 - nu);
@ -185,9 +183,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
+ twoMuLambda*fvPatchField<vector>::snGrad() - (n & sigmaD)
)/twoMuLambda;
Switch thermalStress(thermalProperties.lookup("thermalStress"));
if (thermalStress)
if (thermalProperties.get<bool>("thermalStress"))
{
const fvPatchField<scalar>& threeKalpha=
patch().lookupPatchField<volScalarField, scalar>("threeKalpha");

View File

@ -39,7 +39,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -163,9 +163,7 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
scalarField mu(E/(2.0*(1.0 + nu)));
scalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
Switch planeStress(mechanicalProperties.lookup("planeStress"));
if (planeStress)
if (mechanicalProperties.get<bool>("planeStress"))
{
lambda = nu*E/((1.0 + nu)*(1.0 - nu));
}

View File

@ -89,9 +89,7 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
IOdictionary motionProperties(motionObj);
Switch twoDMotion(motionProperties.lookup("twoDMotion"));
if (twoDMotion)
if (motionProperties.get<bool>("twoDMotion"))
{
Info<< "Correcting for 2D motion" << endl << endl;

View File

@ -658,9 +658,7 @@ int main(int argc, char *argv[])
IOdictionary motionProperties(motionObj);
Switch twoDMotion(motionProperties.lookup("twoDMotion"));
if (twoDMotion)
if (motionProperties.get<bool>("twoDMotion"))
{
Info<< "Correcting for 2D motion" << endl << endl;
correct2DPtr = new twoDPointCorrector(mesh);

View File

@ -297,7 +297,7 @@ int main(int argc, char *argv[])
autoPtr<extrudeModel> model(extrudeModel::New(dict));
// Whether to flip normals
const Switch flipNormals(dict.lookup("flipNormals"));
const bool flipNormals(dict.get<bool>("flipNormals"));
// What to extrude
const ExtrudeMode mode = ExtrudeModeNames.lookup
@ -983,8 +983,7 @@ int main(int argc, char *argv[])
// Merging front and back patch faces
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Switch mergeFaces(dict.lookup("mergeFaces"));
if (mergeFaces)
if (dict.get<bool>("mergeFaces"))
{
if (mode == MESH)
{
@ -1009,7 +1008,6 @@ int main(int argc, char *argv[])
}
polyTopoChanger stitcher(mesh);
stitcher.setSize(1);

View File

@ -1536,8 +1536,8 @@ int main(int argc, char *argv[])
mappedPatchBase::sampleMode sampleMode =
mappedPatchBase::sampleModeNames_[dict.lookup("sampleMode")];
const Switch oneD(dict.lookup("oneD"));
Switch oneDNonManifoldEdges(false);
const bool oneD(dict.get<bool>("oneD"));
bool oneDNonManifoldEdges(false);
word oneDPatchType(emptyPolyPatch::typeName);
if (oneD)
{
@ -1545,7 +1545,7 @@ int main(int argc, char *argv[])
dict.lookup("oneDPolyPatchType") >> oneDPatchType;
}
const Switch adaptMesh(dict.lookup("adaptMesh"));
const bool adaptMesh(dict.get<bool>("adaptMesh"));
if (hasZones)
{

View File

@ -97,7 +97,7 @@ Foam::automatic::automatic
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface,
const scalar& defaultCellSize
const scalar defaultCellSize
)
:
cellSizeCalculationType
@ -109,12 +109,15 @@ Foam::automatic::automatic
),
coeffsDict_(cellSizeCalcTypeDict.optionalSubDict(typeName + "Coeffs")),
surfaceName_(surface.searchableSurface::name()),
readCurvature_(Switch(coeffsDict_.lookup("curvature"))),
curvatureFile_(coeffsDict_.lookup("curvatureFile")),
readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))),
featureProximityFile_(coeffsDict_.lookup("featureProximityFile")),
readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))),
internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")),
readCurvature_(coeffsDict_.get<bool>("curvature")),
readFeatureProximity_(coeffsDict_.get<bool>("featureProximity")),
readInternalCloseness_(coeffsDict_.get<bool>("internalCloseness")),
curvatureFile_(coeffsDict_.get<word>("curvatureFile")),
featureProximityFile_(coeffsDict_.get<word>("featureProximityFile")),
internalClosenessFile_(coeffsDict_.get<word>("internalClosenessFile")),
curvatureCellSizeCoeff_
(
readScalar(coeffsDict_.lookup("curvatureCellSizeCoeff"))

View File

@ -37,7 +37,6 @@ SourceFiles
#include "cellSizeCalculationType.H"
#include "triSurfaceFields.H"
#include "PrimitivePatchInterpolation.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,9 +53,6 @@ class automatic
:
public cellSizeCalculationType
{
private:
// Private data
//- Dictionary of coefficients for automatic cell sizing
@ -65,13 +61,12 @@ private:
//- Name of the surface. Used to write the cell size field
const fileName surfaceName_;
const Switch readCurvature_;
const bool readCurvature_;
const bool readFeatureProximity_;
const bool readInternalCloseness_;
const word curvatureFile_;
const Switch readFeatureProximity_;
const word featureProximityFile_;
const Switch readInternalCloseness_;
const word internalClosenessFile_;
//- The curvature values are multiplied by the inverse of this value to
@ -100,13 +95,12 @@ public:
(
const dictionary& cellSizeCalcTypeDict,
const triSurfaceMesh& surface,
const scalar& defaultCellSize
const scalar defaultCellSize
);
//- Destructor
virtual ~automatic()
{}
virtual ~automatic() = default;
// Member Functions

View File

@ -42,43 +42,30 @@ Foam::cvControls::cvControls
foamyHexMeshDict_.subDict("surfaceConformation")
);
pointPairDistanceCoeff_ = readScalar
(
surfDict.lookup("pointPairDistanceCoeff")
);
pointPairDistanceCoeff_ =
surfDict.get<scalar>("pointPairDistanceCoeff");
mixedFeaturePointPPDistanceCoeff_ = readScalar
(
surfDict.lookup("mixedFeaturePointPPDistanceCoeff")
);
mixedFeaturePointPPDistanceCoeff_ =
surfDict.get<scalar>("mixedFeaturePointPPDistanceCoeff");
featurePointExclusionDistanceCoeff_ = readScalar
(
surfDict.lookup("featurePointExclusionDistanceCoeff")
);
featurePointExclusionDistanceCoeff_ =
surfDict.get<scalar>("featurePointExclusionDistanceCoeff");
featureEdgeExclusionDistanceCoeff_ = readScalar
(
surfDict.lookup("featureEdgeExclusionDistanceCoeff")
);
featureEdgeExclusionDistanceCoeff_ =
surfDict.get<scalar>("featureEdgeExclusionDistanceCoeff");
surfaceSearchDistanceCoeff_ =
surfDict.get<scalar>("surfaceSearchDistanceCoeff");
surfaceSearchDistanceCoeff_ = readScalar
(
surfDict.lookup("surfaceSearchDistanceCoeff")
);
maxSurfaceProtrusionCoeff_ =
surfDict.get<scalar>("maxSurfaceProtrusionCoeff");
maxSurfaceProtrusionCoeff_ = readScalar
(
surfDict.lookup("maxSurfaceProtrusionCoeff")
);
maxQuadAngle_ = readScalar(surfDict.lookup("maxQuadAngle"));
maxQuadAngle_ = surfDict.get<scalar>("maxQuadAngle");
surfaceConformationRebuildFrequency_ = max
(
1,
readLabel(surfDict.lookup("surfaceConformationRebuildFrequency"))
surfDict.get<label>("surfaceConformationRebuildFrequency")
);
@ -87,33 +74,23 @@ Foam::cvControls::cvControls
surfDict.subDict("featurePointControls")
);
specialiseFeaturePoints_ = Switch
(
featurePointControlsDict.lookup("specialiseFeaturePoints")
);
specialiseFeaturePoints_ =
featurePointControlsDict.get<Switch>("specialiseFeaturePoints");
guardFeaturePoints_ = Switch
(
featurePointControlsDict.lookup("guardFeaturePoints")
);
guardFeaturePoints_ =
featurePointControlsDict.get<Switch>("guardFeaturePoints");
edgeAiming_ = Switch
(
featurePointControlsDict.lookup("edgeAiming")
);
edgeAiming_ =
featurePointControlsDict.get<Switch>("edgeAiming");
if (!guardFeaturePoints_)
{
snapFeaturePoints_ = Switch
(
featurePointControlsDict.lookup("snapFeaturePoints")
);
snapFeaturePoints_ =
featurePointControlsDict.get<Switch>("snapFeaturePoints");
}
circulateEdges_ = Switch
(
featurePointControlsDict.lookup("circulateEdges")
);
circulateEdges_ =
featurePointControlsDict.get<Switch>("circulateEdges");
// Controls for coarse surface conformation
@ -122,62 +99,47 @@ Foam::cvControls::cvControls
surfDict.subDict("conformationControls")
);
surfacePtExclusionDistanceCoeff_ = readScalar
(
conformationControlsDict.lookup("surfacePtExclusionDistanceCoeff")
);
surfacePtExclusionDistanceCoeff_ =
conformationControlsDict.get<scalar>("surfacePtExclusionDistanceCoeff");
edgeSearchDistCoeffSqr_ = sqr
(
readScalar
(
conformationControlsDict.lookup("edgeSearchDistCoeff")
)
conformationControlsDict.get<scalar>("edgeSearchDistCoeff")
);
surfacePtReplaceDistCoeffSqr_ = sqr
(
readScalar
(
conformationControlsDict.lookup("surfacePtReplaceDistCoeff")
)
conformationControlsDict.get<scalar>("surfacePtReplaceDistCoeff")
);
maxConformationIterations_ = readLabel
(
conformationControlsDict.lookup("maxIterations")
);
maxConformationIterations_ =
conformationControlsDict.get<label>("maxIterations");
iterationToInitialHitRatioLimit_ = readScalar
(
conformationControlsDict.lookup("iterationToInitialHitRatioLimit")
);
iterationToInitialHitRatioLimit_ =
conformationControlsDict.get<scalar>("iterationToInitialHitRatioLimit");
// Motion control controls
const dictionary& motionDict(foamyHexMeshDict_.subDict("motionControl"));
defaultCellSize_ = readScalar(motionDict.lookup("defaultCellSize"));
defaultCellSize_ = motionDict.get<scalar>("defaultCellSize");
minimumCellSize_ =
readScalar(motionDict.lookup("minimumCellSizeCoeff"))*defaultCellSize_;
motionDict.get<scalar>("minimumCellSizeCoeff")*defaultCellSize_;
objOutput_ = Switch(motionDict.lookupOrDefault<Switch>("objOutput", false));
objOutput_ =
motionDict.lookupOrDefault<Switch>("objOutput", false);
timeChecks_ = Switch
(
motionDict.lookupOrDefault<Switch>("timeChecks", false)
);
timeChecks_ =
motionDict.lookupOrDefault<Switch>("timeChecks", false);
printVertexInfo_ = Switch
(
motionDict.lookupOrDefault<Switch>("printVertexInfo", false)
);
printVertexInfo_ =
motionDict.lookupOrDefault<Switch>("printVertexInfo", false);
if (Pstream::parRun())
{
maxLoadUnbalance_ = readScalar(motionDict.lookup("maxLoadUnbalance"));
maxLoadUnbalance_ = motionDict.get<scalar>("maxLoadUnbalance");
}
else
{
@ -186,7 +148,7 @@ Foam::cvControls::cvControls
cosAlignmentAcceptanceAngle_ = cos
(
degToRad(readScalar(motionDict.lookup("alignmentAcceptanceAngle")))
degToRad(motionDict.get<scalar>("alignmentAcceptanceAngle"))
);
@ -197,19 +159,15 @@ Foam::cvControls::cvControls
motionDict.subDict("pointInsertionCriteria")
);
insertionDistCoeff_ = readScalar
(
insertionDict.lookup("cellCentreDistCoeff")
);
insertionDistCoeff_ =
insertionDict.get<scalar>("cellCentreDistCoeff");
faceAreaRatioCoeff_ = readScalar
(
insertionDict.lookup("faceAreaRatioCoeff")
);
faceAreaRatioCoeff_ =
insertionDict.get<scalar>("faceAreaRatioCoeff");
cosInsertionAcceptanceAngle_ = cos
(
degToRad(readScalar(insertionDict.lookup("acceptanceAngle")))
degToRad(insertionDict.get<scalar>("acceptanceAngle"))
);
// Point removal criteria
@ -219,10 +177,8 @@ Foam::cvControls::cvControls
motionDict.subDict("pointRemovalCriteria")
);
removalDistCoeff_ = readScalar
(
removalDict.lookup("cellCentreDistCoeff")
);
removalDistCoeff_ =
removalDict.get<scalar>("cellCentreDistCoeff");
// polyMesh filtering controls
@ -231,34 +187,31 @@ Foam::cvControls::cvControls
foamyHexMeshDict_.subDict("polyMeshFiltering")
);
filterEdges_ = Switch
(
filteringDict.lookupOrDefault<Switch>("filterEdges", true)
);
filterEdges_ =
filteringDict.lookupOrDefault<Switch>("filterEdges", true);
filterFaces_ = Switch
(
filteringDict.lookupOrDefault<Switch>("filterFaces", false)
);
filterFaces_ =
filteringDict.lookupOrDefault<Switch>("filterFaces", false);
if (filterFaces_)
{
filterEdges_ = Switch::ON;
filterEdges_ = filterFaces_;
}
writeTetDualMesh_ = Switch(filteringDict.lookup("writeTetDualMesh"));
writeTetDualMesh_ =
filteringDict.get<Switch>("writeTetDualMesh");
writeCellShapeControlMesh_ =
Switch(filteringDict.lookup("writeCellShapeControlMesh"));
filteringDict.get<Switch>("writeCellShapeControlMesh");
if (Pstream::parRun())
{
writeBackgroundMeshDecomposition_ =
Switch(filteringDict.lookup("writeBackgroundMeshDecomposition"));
filteringDict.get<Switch>("writeBackgroundMeshDecomposition");
}
else
{
writeBackgroundMeshDecomposition_ = Switch(false);
writeBackgroundMeshDecomposition_ = Switch::FALSE;
}
}

View File

@ -58,13 +58,10 @@ Foam::initialPointsMethod::initialPointsMethod
(
sqr
(
readScalar
(
initialPointsDict.lookup("minimumSurfaceDistanceCoeff")
)
initialPointsDict.get<scalar>("minimumSurfaceDistanceCoeff")
)
),
fixInitialPoints_(Switch(initialPointsDict.lookup("fixInitialPoints")))
fixInitialPoints_(initialPointsDict.get<bool>("fixInitialPoints"))
{}
@ -80,7 +77,7 @@ Foam::autoPtr<Foam::initialPointsMethod> Foam::initialPointsMethod::New
const autoPtr<backgroundMeshDecomposition>& decomposition
)
{
const word methodName(initialPointsDict.lookup("initialPointsMethod"));
const word methodName(initialPointsDict.get<word>("initialPointsMethod"));
Info<< nl << "Selecting initialPointsMethod "
<< methodName << endl;

View File

@ -40,7 +40,6 @@ SourceFiles
#include "backgroundMeshDecomposition.H"
#include "dictionary.H"
#include "Random.H"
#include "Switch.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
@ -80,7 +79,7 @@ protected:
// the local target cell size. Store square of value.
scalar minimumSurfaceDistanceCoeffSqr_;
Switch fixInitialPoints_;
bool fixInitialPoints_;
private:
@ -194,7 +193,7 @@ public:
return detailsDict_;
}
Switch fixInitialPoints() const
bool fixInitialPoints() const
{
return fixInitialPoints_;
}

View File

@ -81,7 +81,7 @@ int main(int argc, char *argv[])
);
const dictionary& extrusionDict(controlDict.subDict("extrusion"));
Switch extrude(extrusionDict.lookup("extrude"));
const bool extrude = extrusionDict.get<bool>("extrude");
const bool overwrite = args.found("overwrite");
// Read and triangulation

View File

@ -141,12 +141,13 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
// Invert surfaceCellSize to get the refinementLevel
const word scsFuncName =
shapeDict.lookup("surfaceCellSizeFunction");
shapeDict.get<word>("surfaceCellSizeFunction");
const dictionary& scsDict =
shapeDict.optionalSubDict(scsFuncName + "Coeffs");
const scalar surfaceCellSize =
readScalar(scsDict.lookup("surfaceCellSizeCoeff"));
scsDict.get<scalar>("surfaceCellSizeCoeff");
const label refLevel = sizeCoeffToRefinement
(
@ -222,7 +223,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
);
const word scsFuncName =
shapeControlRegionDict.lookup
shapeControlRegionDict.get<word>
(
"surfaceCellSizeFunction"
);
@ -233,10 +234,7 @@ autoPtr<refinementSurfaces> createRefinementSurfaces
);
const scalar surfaceCellSize =
readScalar
(
scsDict.lookup("surfaceCellSizeCoeff")
);
scsDict.get<scalar>("surfaceCellSizeCoeff");
const label refLevel = sizeCoeffToRefinement
(
@ -780,10 +778,10 @@ int main(int argc, char *argv[])
const scalar mergeDist = getMergeDistance
(
mesh,
readScalar(meshDict.lookup("mergeTolerance"))
meshDict.get<scalar>("mergeTolerance")
);
const Switch keepPatches(meshDict.lookupOrDefault("keepPatches", false));
const bool keepPatches(meshDict.lookupOrDefault("keepPatches", false));
// Read decomposePar dictionary
@ -958,7 +956,7 @@ int main(int argc, char *argv[])
// Calculate current ratio of hex cells v.s. wanted cell size
const scalar defaultCellSize =
readScalar(motionDict.lookup("defaultCellSize"));
motionDict.get<scalar>("defaultCellSize");
const scalar initialCellSize = ::pow(meshPtr().V()[0], 1.0/3.0);
@ -1020,7 +1018,7 @@ int main(int argc, char *argv[])
if (patchInfo.set(globalRegioni))
{
patchTypes[geomi][regioni] =
word(patchInfo[globalRegioni].lookup("type"));
patchInfo[globalRegioni].get<word>("type");
}
else
{
@ -1449,11 +1447,11 @@ int main(int argc, char *argv[])
// Now do the real work -refinement -snapping -layers
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const Switch wantRefine(meshDict.lookup("castellatedMesh"));
const Switch wantSnap(meshDict.lookup("snap"));
const Switch wantLayers(meshDict.lookup("addLayers"));
const bool wantRefine(meshDict.get<bool>("castellatedMesh"));
const bool wantSnap(meshDict.get<bool>("snap"));
const bool wantLayers(meshDict.get<bool>("addLayers"));
const Switch mergePatchFaces
const bool mergePatchFaces
(
meshDict.lookupOrDefault("mergePatchFaces", true)
);

View File

@ -444,16 +444,16 @@ int main(int argc, char *argv[])
const word dictName("createBafflesDict");
#include "setSystemMeshDictionaryIO.H"
Switch internalFacesOnly(false);
bool internalFacesOnly(false);
Switch noFields(false);
bool noFields(false);
PtrList<faceSelection> selectors;
{
Info<< "Reading baffle criteria from " << dictName << nl << endl;
IOdictionary dict(dictIO);
dict.lookup("internalFacesOnly") >> internalFacesOnly;
internalFacesOnly = dict.get<bool>("internalFacesOnly");
noFields = dict.lookupOrDefault("noFields", false);
const dictionary& selectionsDict = dict.subDict("baffles");
@ -717,10 +717,9 @@ int main(int argc, char *argv[])
// master and slave in different groupNames
// (ie 3D thermal baffles)
Switch sameGroup
(
patchSource.lookupOrDefault("sameGroup", true)
);
const bool sameGroup =
patchSource.lookupOrDefault("sameGroup", true);
if (!sameGroup)
{
groupNameMaster = groupName + "Group_master";
@ -800,7 +799,6 @@ int main(int argc, char *argv[])
}
createFaces
(
internalFacesOnly,
@ -897,10 +895,8 @@ int main(int argc, char *argv[])
{
const dictionary& patchSource = dict.subDict("patchPairs");
Switch sameGroup
(
patchSource.lookupOrDefault("sameGroup", true)
);
const bool sameGroup =
patchSource.lookupOrDefault("sameGroup", true);
const word& groupName = selectors[selectorI].name();

View File

@ -41,7 +41,6 @@ SourceFiles
#include "autoPtr.H"
#include "boolList.H"
#include "labelList.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,7 +70,7 @@ protected:
const dictionary dict_;
//- Switch direction?
const Switch flip_;
const bool flip_;
public:

View File

@ -540,8 +540,7 @@ int main(int argc, char *argv[])
IOdictionary dict(dictIO);
// Whether to synchronise points
const Switch pointSync(dict.lookup("pointSync"));
const bool pointSync(dict.get<bool>("pointSync"));
const polyBoundaryMesh& patches = mesh.boundaryMesh();

View File

@ -37,7 +37,6 @@ Description
#include "triSurfaceSearch.H"
#include "argList.H"
#include "Fstream.H"
#include "Switch.H"
#include "IOdictionary.H"
#include "boundBox.H"
#include "indexedOctree.H"
@ -102,10 +101,8 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
Switch addFaceNeighbours
(
meshSubsetDict.lookup("addFaceNeighbours")
);
const bool addFaceNeighbours =
meshSubsetDict.get<bool>("addFaceNeighbours");
const bool invertSelection =
meshSubsetDict.lookupOrDefault("invertSelection", false);
@ -231,7 +228,7 @@ int main(int argc, char *argv[])
fileName surfName(surfDict.lookup("name"));
Switch outside(surfDict.lookup("outside"));
const bool outside(surfDict.get<bool>("outside"));
if (outside)
{

View File

@ -203,7 +203,7 @@ void Foam::dynamicRefineFvMesh::readDict()
correctFluxes_.insert(fluxVelocities[i][0], fluxVelocities[i][1]);
}
dumpLevel_ = Switch(refineDict.lookup("dumpLevel"));
dumpLevel_ = refineDict.get<bool>("dumpLevel");
}

View File

@ -71,7 +71,6 @@ SourceFiles
#include "dynamicFvMesh.H"
#include "hexRef8.H"
#include "bitSet.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -92,7 +91,7 @@ protected:
hexRef8 meshCutter_;
//- Dump cellLevel for post-processing
Switch dumpLevel_;
bool dumpLevel_;
//- Fluxes to map
HashTable<word> correctFluxes_;

View File

@ -266,7 +266,7 @@ Foam::attachDetach::attachDetach
const polyTopoChanger& mme
)
:
polyMeshModifier(name, index, mme, Switch(dict.lookup("active"))),
polyMeshModifier(name, index, mme, dict.get<bool>("active")),
faceZoneID_
(
dict.lookup("faceZoneName"),

View File

@ -140,7 +140,7 @@ Foam::layerAdditionRemoval::layerAdditionRemoval
const word& zoneName,
const scalar minThickness,
const scalar maxThickness,
const Switch thicknessFromVolume
const bool thicknessFromVolume
)
:
polyMeshModifier(name, index, ptc, true),
@ -166,14 +166,11 @@ Foam::layerAdditionRemoval::layerAdditionRemoval
const polyTopoChanger& ptc
)
:
polyMeshModifier(name, index, ptc, Switch(dict.lookup("active"))),
polyMeshModifier(name, index, ptc, dict.get<bool>("active")),
faceZoneID_(dict.lookup("faceZoneName"), ptc.mesh().faceZones()),
minLayerThickness_(readScalar(dict.lookup("minLayerThickness"))),
maxLayerThickness_(readScalar(dict.lookup("maxLayerThickness"))),
thicknessFromVolume_
(
dict.lookupOrDefault<Switch>("thicknessFromVolume", true)
),
thicknessFromVolume_(dict.lookupOrDefault("thicknessFromVolume", true)),
oldLayerThickness_(readOldThickness(dict)),
pointsPairingPtr_(nullptr),
facesPairingPtr_(nullptr),

View File

@ -158,7 +158,7 @@ public:
const word& zoneName,
const scalar minThickness,
const scalar maxThickness,
const Switch thicknessFromVolume = true
const bool thicknessFromVolume = true
);
//- Construct from dictionary

View File

@ -31,7 +31,6 @@ License
#include "OFstream.H"
#include "meshTools.H"
#include "hexMatcher.H"
#include "Switch.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -371,7 +370,7 @@ Foam::directions::directions
<< tan1 << endl << endl;
}
Switch useTopo(dict.lookup("useHexTopology"));
const bool useTopo(dict.get<bool>("useHexTopology"));
vectorField normalDirs;
vectorField tan1Dirs;

View File

@ -450,7 +450,7 @@ void Foam::multiDirRefinement::refineFromDict
)
{
// How to walk cell circumference.
Switch pureGeomCut(dict.lookup("geometricCut"));
const bool pureGeomCut(dict.get<bool>("geometricCut"));
autoPtr<cellLooper> cellWalker;
if (pureGeomCut)
@ -486,9 +486,9 @@ Foam::multiDirRefinement::multiDirRefinement
cellLabels_(cellLabels),
addedCells_(mesh.nCells())
{
Switch useHex(dict.lookup("useHexTopology"));
const bool useHex(dict.get<bool>("useHexTopology"));
Switch writeMesh(dict.lookup("writeMesh"));
const bool writeMesh(dict.get<bool>("writeMesh"));
wordList dirNames(dict.lookup("directions"));
@ -529,9 +529,9 @@ Foam::multiDirRefinement::multiDirRefinement
cellLabels_(cellLabels),
addedCells_(mesh.nCells())
{
Switch useHex(dict.lookup("useHexTopology"));
const bool useHex(dict.get<bool>("useHexTopology"));
Switch writeMesh(dict.lookup("writeMesh"));
const bool writeMesh(dict.get<bool>("writeMesh"));
wordList dirNames(dict.lookup("directions"));

View File

@ -56,7 +56,7 @@ Foam::setUpdater::setUpdater
const polyTopoChanger& mme
)
:
polyMeshModifier(name, index, mme, Switch(dict.lookup("active")))
polyMeshModifier(name, index, mme, dict.get<bool>("active"))
{}

View File

@ -210,7 +210,7 @@ Foam::slidingInterface::slidingInterface
const polyTopoChanger& mme
)
:
polyMeshModifier(name, index, mme, Switch(dict.lookup("active"))),
polyMeshModifier(name, index, mme, dict.get<bool>("active")),
masterFaceZoneID_
(
dict.lookup("masterFaceZoneName"),

View File

@ -179,10 +179,10 @@ void Foam::faSchemes::read(const dictionary& dict)
if
(
fluxRequired_.found("default")
&& word(fluxRequired_.lookup("default")) != "none"
&& fluxRequired_.get<word>("default") != "none"
)
{
defaultFluxRequired_ = Switch(fluxRequired_.lookup("default"));
defaultFluxRequired_ = fluxRequired_.get<bool>("default");
}
}
}

View File

@ -181,10 +181,10 @@ void Foam::fvSchemes::read(const dictionary& dict)
if
(
fluxRequired_.found("default")
&& word(fluxRequired_.lookup("default")) != "none"
&& fluxRequired_.get<word>("default") != "none"
)
{
defaultFluxRequired_ = Switch(fluxRequired_.lookup("default"));
defaultFluxRequired_ = fluxRequired_.get<bool>("default");
}
}
}

View File

@ -1114,7 +1114,7 @@ Foam::InteractionLists<ParticleType>::InteractionLists
(
const polyMesh& mesh,
scalar maxDistance,
Switch writeCloud,
bool writeCloud,
const word& UName
)
:

View File

@ -89,7 +89,7 @@ class InteractionLists
//- Switch controlling whether or not the cloud gets populated
// with the referred particles, hence gets written out
const Switch writeCloud_;
const bool writeCloud_;
//- mapDistribute to exchange referred particles into referred cells
autoPtr<mapDistribute> cellMapPtr_;
@ -218,7 +218,7 @@ public:
(
const polyMesh& mesh,
scalar maxDistance,
Switch writeCloud = false,
bool writeCloud = false,
const word& UName = "U"
);

View File

@ -553,13 +553,10 @@ Foam::PairCollision<CloudType>::PairCollision
(
owner.mesh(),
readScalar(this->coeffDict().lookup("maxInteractionDistance")),
Switch
this->coeffDict().lookupOrDefault
(
this->coeffDict().lookupOrDefault
(
"writeReferredParticleCloud",
false
)
"writeReferredParticleCloud",
false
),
this->coeffDict().lookupOrDefault("U", word("U"))
)

View File

@ -64,7 +64,7 @@ bool Foam::MultiInteraction<CloudType>::read(const dictionary& dict)
}
}
oneInteractionOnly_ = Switch(dict.lookup("oneInteractionOnly"));
oneInteractionOnly_ = dict.get<bool>("oneInteractionOnly");
if (oneInteractionOnly_)
{

View File

@ -94,7 +94,7 @@ class MultiInteraction
{
// Private data
Switch oneInteractionOnly_;
bool oneInteractionOnly_;
//- Submodels
PtrList<PatchInteractionModel<CloudType>> models_;

View File

@ -59,7 +59,7 @@ correlationFunction<vector> vacf
molecules.size()
);
bool writeVacf(Switch(velocityACFDict.lookup("writeFile")));
bool writeVacf(velocityACFDict.get<bool>("writeFile"));
//- Pressure autocorrelation function
@ -77,7 +77,7 @@ correlationFunction<vector> pacf
1
);
bool writePacf(Switch(pressureACFDict.lookup("writeFile")));
bool writePacf(pressureACFDict.get<bool>("writeFile"));
//- Heat flux autocorrelation function
@ -95,4 +95,4 @@ correlationFunction<vector> hfacf
1
);
bool writeHFacf(Switch(heatFluxACFDict.lookup("writeFile")));
bool writeHFacf(heatFluxACFDict.get<bool>("writeFile"));

View File

@ -68,7 +68,7 @@ Foam::pairPotential::pairPotential
forceLookup_(0),
energyLookup_(0),
esfPtr_(nullptr),
writeTables_(Switch(pairPotentialProperties_.lookup("writeTables")))
writeTables_(pairPotentialProperties_.get<bool>("writeTables"))
{}

View File

@ -54,4 +54,5 @@ inline bool Foam::pairPotential::writeTables() const
return writeTables_;
}
// ************************************************************************* //

View File

@ -301,7 +301,10 @@ Foam::ORourkeCollision<CloudType>::ORourkeCollision
(
owner.db().template lookupObject<SLGThermo>("SLGThermo").liquids()
),
coalescence_(this->coeffDict().lookup("coalescence"))
coalescence_
(
this->coeffDict().template get<bool>("coalescence")
)
{}

View File

@ -58,8 +58,8 @@ protected:
const liquidMixtureProperties& liquids_;
//- Coalescence activation switch
Switch coalescence_;
//- Coalescence activated?
bool coalescence_;
// Protected Member Functions

View File

@ -36,7 +36,6 @@ Description
#include "point.H"
#include "extrudeModel.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +72,7 @@ class offsetSurface
autoPtr<triSurfaceSearch> offsetSearchPtr_;
// Whether to re-project onto offsetted surface
const Switch project_;
const bool project_;
public:

View File

@ -398,7 +398,7 @@ Foam::regionModels::regionModel::regionModel
),
primaryMesh_(mesh),
time_(mesh.time()),
active_(lookup("active")),
active_(get<Switch>("active")),
infoOutput_(true),
modelName_(modelName),
regionMeshPtr_(nullptr),
@ -446,7 +446,7 @@ Foam::regionModels::regionModel::regionModel
),
primaryMesh_(mesh),
time_(mesh.time()),
active_(dict.lookup("active")),
active_(dict.get<Switch>("active")),
infoOutput_(false),
modelName_(modelName),
regionMeshPtr_(nullptr),

View File

@ -55,8 +55,8 @@ Foam::structuredRenumber::structuredRenumber
methodDict_(renumberDict.optionalSubDict(typeName + "Coeffs")),
patches_(methodDict_.lookup("patches")),
nLayers_(methodDict_.lookupOrDefault<label>("nLayers", labelMax)),
depthFirst_(methodDict_.lookup("depthFirst")),
reverse_(methodDict_.lookup("reverse")),
depthFirst_(methodDict_.get<bool>("depthFirst")),
reverse_(methodDict_.get<bool>("reverse")),
method_(renumberMethod::New(methodDict_))
{}

View File

@ -42,7 +42,6 @@ SourceFiles
#include "renumberMethod.H"
#include "topoDistanceData.H"
#include "Switch.H"
namespace Foam
{
@ -63,7 +62,7 @@ public:
// column and layer
class layerLess
{
const Switch depthFirst_;
const bool depthFirst_;
const labelList& order_;
const List<topoDistanceData>& distance_;
@ -71,7 +70,7 @@ public:
layerLess
(
const Switch depthFirst,
const bool depthFirst,
const labelList& order,
const List<topoDistanceData>& distance
)
@ -93,9 +92,9 @@ public:
const label nLayers_;
const Switch depthFirst_;
const bool depthFirst_;
const Switch reverse_;
const bool reverse_;
const autoPtr<renumberMethod> method_;

View File

@ -85,7 +85,7 @@ class sampledDistanceSurface
// Private data
//- Whether to recalculate cell values as average of point values
const Switch average_;
const bool average_;
//- Track if the surface needs an update
mutable bool needsUpdate_;

View File

@ -98,11 +98,11 @@ class sampledIsoSurface
//- Merge tolerance
const scalar mergeTol_;
//- Whether to coarse
const Switch regularise_;
//- Whether to coarsen
const bool regularise_;
//- Whether to recalculate cell values as average of point values
const Switch average_;
const bool average_;
//- Zone name/index (if restricted to zones)
mutable cellZoneID zoneID_;

View File

@ -97,10 +97,10 @@ class sampledIsoSurfaceCell
const boundBox bounds_;
//- Whether to coarse
const Switch regularise_;
const bool regularise_;
//- Whether to recalculate cell values as average of point values
const Switch average_;
const bool average_;
//- If restricted to zones, name of this zone or a regular expression
keyType zoneKey_;

View File

@ -102,10 +102,10 @@ class sampledCuttingPlane
const scalar mergeTol_;
//- Whether to coarsen
const Switch regularise_;
const bool regularise_;
//- Whether to recalculate cell values as average of point values
const Switch average_;
const bool average_;
//- Zone name/index (if restricted to zones)
mutable cellZoneID zoneID_;

View File

@ -66,7 +66,7 @@ Foam::distanceSurface::distanceSurface
)
),
distance_(readScalar(dict.lookup("distance"))),
signed_(readBool(dict.lookup("signed"))),
signed_(dict.get<bool>("signed")),
cell_(dict.lookupOrDefault("cell", true)),
regularise_(dict.lookupOrDefault("regularise", true)),
bounds_(dict.lookupOrDefault("bounds", boundBox::invertedBox)),
@ -85,7 +85,7 @@ Foam::distanceSurface::distanceSurface
const scalar distance,
const bool signedDistance,
const bool cell,
const Switch regularise,
const bool regularise,
const boundBox& bounds
)
:

View File

@ -84,7 +84,7 @@ class distanceSurface
const bool cell_;
//- Whether to coarsen
const Switch regularise_;
const bool regularise_;
//- Optional bounding box to trim triangles against
const boundBox bounds_;
@ -131,7 +131,7 @@ public:
const scalar distance,
const bool signedDistance,
const bool cell,
const Switch regularise,
const bool regularise,
const boundBox& bounds = boundBox::invertedBox
);

View File

@ -122,7 +122,7 @@ class isoSurface
const scalar iso_;
//- Regularise?
const Switch regularise_;
const bool regularise_;
//- Optional bounds
const boundBox bounds_;

View File

@ -42,7 +42,6 @@ SourceFiles
#include "chemistryReader.H"
#include "fileName.H"
#include "typeInfo.H"
#include "Switch.H"
#include "HashPtrTable.H"
#include "ReactionList.H"
#include "DynamicList.H"
@ -187,7 +186,7 @@ private:
dictionary transportDict_;
//- Flag to indicate that file is in new format
Switch newFormat_;
bool newFormat_;
//- Tolerance for element imbalance in a reaction
scalar imbalanceTol_;

View File

@ -25,7 +25,6 @@ License
#include "liquidProperties.H"
#include "HashTable.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -121,38 +120,36 @@ Foam::autoPtr<Foam::liquidProperties> Foam::liquidProperties::New
InfoInFunction << "Constructing liquidProperties" << endl;
}
const word& liquidType = dict.dictName();
const word liquidType(dict.dictName());
if (dict.found("defaultCoeffs"))
{
// Backward-compatibility
if (Switch(dict.lookup("defaultCoeffs")))
if (dict.get<bool>("defaultCoeffs"))
{
return New(liquidType);
}
else
auto cstrIter = dictionaryConstructorTablePtr_->cfind(liquidType);
if (!cstrIter.found())
{
auto cstrIter = dictionaryConstructorTablePtr_->cfind(liquidType);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown liquidProperties type "
<< liquidType << nl << nl
<< "Valid liquidProperties types :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<liquidProperties>
(
cstrIter()
(
dict.optionalSubDict(liquidType + "Coeffs")
)
);
FatalErrorInFunction
<< "Unknown liquidProperties type "
<< liquidType << nl << nl
<< "Valid liquidProperties types :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<liquidProperties>
(
cstrIter()
(
dict.optionalSubDict(liquidType + "Coeffs")
)
);
}
auto cstrIter = dictionaryConstructorTablePtr_->cfind(liquidType);

View File

@ -70,7 +70,7 @@ Foam::autoPtr<Foam::solidProperties> Foam::solidProperties::New
{
// Backward-compatibility
if (Switch(dict.lookup("defaultCoeffs")))
if (dict.get<bool>("defaultCoeffs"))
{
return New(solidType);
}