mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: use readIfPresent instead of found/lookup combination
This commit is contained in:
@ -29,14 +29,9 @@ License
|
||||
#include "volFields.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
@ -52,7 +47,8 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
valueFraction() = 0.0;
|
||||
}
|
||||
|
||||
smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
|
||||
Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
(
|
||||
const smoluchowskiJumpTFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
@ -67,7 +63,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
{}
|
||||
|
||||
|
||||
smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
@ -118,7 +114,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
}
|
||||
|
||||
|
||||
smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
(
|
||||
const smoluchowskiJumpTFvPatchScalarField& ptpsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
@ -134,7 +130,7 @@ smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Map from self
|
||||
void smoluchowskiJumpTFvPatchScalarField::autoMap
|
||||
void Foam::smoluchowskiJumpTFvPatchScalarField::autoMap
|
||||
(
|
||||
const fvPatchFieldMapper& m
|
||||
)
|
||||
@ -144,7 +140,7 @@ void smoluchowskiJumpTFvPatchScalarField::autoMap
|
||||
|
||||
|
||||
// Reverse-map the given fvPatchField onto this fvPatchField
|
||||
void smoluchowskiJumpTFvPatchScalarField::rmap
|
||||
void Foam::smoluchowskiJumpTFvPatchScalarField::rmap
|
||||
(
|
||||
const fvPatchField<scalar>& ptf,
|
||||
const labelList& addr
|
||||
@ -155,7 +151,7 @@ void smoluchowskiJumpTFvPatchScalarField::rmap
|
||||
|
||||
|
||||
// Update the coefficients associated with the patch field
|
||||
void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
|
||||
void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
@ -174,11 +170,16 @@ void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
|
||||
// Prandtl number reading consistent with rhoCentralFoam
|
||||
const dictionary& thermophysicalProperties =
|
||||
db().lookupObject<IOdictionary>("thermophysicalProperties");
|
||||
dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
|
||||
if (thermophysicalProperties.found("Pr"))
|
||||
{
|
||||
Pr = thermophysicalProperties.lookup("Pr");
|
||||
}
|
||||
|
||||
dimensionedScalar Pr
|
||||
(
|
||||
dimensionedScalar::lookupOrDefault
|
||||
(
|
||||
"Pr",
|
||||
thermophysicalProperties,
|
||||
1.0
|
||||
)
|
||||
);
|
||||
|
||||
Field<scalar> C2 = pmu/prho
|
||||
*sqrt(ppsi*constant::mathematical::piByTwo)
|
||||
@ -197,7 +198,7 @@ void smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
|
||||
|
||||
|
||||
// Write
|
||||
void smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
|
||||
void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
os.writeKeyword("accommodationCoeff")
|
||||
@ -211,10 +212,12 @@ void smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
makePatchTypeField(fvPatchScalarField, smoluchowskiJumpTFvPatchScalarField);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
}
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
word fluxScheme("Kurganov");
|
||||
if (mesh.schemesDict().found("fluxScheme"))
|
||||
if (mesh.schemesDict().readIfPresent("fluxScheme", fluxScheme))
|
||||
{
|
||||
fluxScheme = word(mesh.schemesDict().lookup("fluxScheme"));
|
||||
if ((fluxScheme == "Tadmor") || (fluxScheme == "Kurganov"))
|
||||
{
|
||||
Info<< "fluxScheme: " << fluxScheme << endl;
|
||||
|
||||
@ -14,9 +14,13 @@ IOdictionary thermophysicalProperties
|
||||
)
|
||||
);
|
||||
|
||||
dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
|
||||
dimensionedScalar Pr
|
||||
(
|
||||
dimensionedScalar::lookupOrDefault
|
||||
(
|
||||
"Pr",
|
||||
thermophysicalProperties,
|
||||
1.0
|
||||
)
|
||||
);
|
||||
|
||||
if (thermophysicalProperties.found("Pr"))
|
||||
{
|
||||
Pr = thermophysicalProperties.lookup("Pr");
|
||||
}
|
||||
|
||||
@ -26,8 +26,13 @@
|
||||
|
||||
dimensionedScalar gamma = Cp/Cv;
|
||||
|
||||
dimensionedScalar Pr = dimensionedScalar("Pr", dimless, 1.0);
|
||||
if (thermodynamicProperties.found("Pr"))
|
||||
{
|
||||
Pr = thermodynamicProperties.lookup("Pr");
|
||||
}
|
||||
dimensionedScalar Pr
|
||||
(
|
||||
dimensionedScalar::lookupOrDefault
|
||||
(
|
||||
"Pr",
|
||||
thermodynamicProperties,
|
||||
1.0
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -175,10 +175,8 @@
|
||||
);
|
||||
|
||||
word dragPhase("blended");
|
||||
if (interfacialProperties.found("dragPhase"))
|
||||
if (interfacialProperties.readIfPresent("dragPhase", dragPhase))
|
||||
{
|
||||
dragPhase = word(interfacialProperties.lookup("dragPhase"));
|
||||
|
||||
bool validDrag =
|
||||
dragPhase == "a" || dragPhase == "b" || dragPhase == "blended";
|
||||
|
||||
|
||||
@ -110,11 +110,7 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
|
||||
procProcessorPatchStartIndex_(nProcs_),
|
||||
cyclicParallel_(false)
|
||||
{
|
||||
if (decompositionDict_.found("distributed"))
|
||||
{
|
||||
Switch distributed(decompositionDict_.lookup("distributed"));
|
||||
distributed_ = distributed;
|
||||
}
|
||||
decompositionDict_.readIfPresent("distributed", distributed_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,10 +43,10 @@ namespace Foam
|
||||
|
||||
addToRunTimeSelectionTable(polyPatch, cyclicPolyPatch, word);
|
||||
addToRunTimeSelectionTable(polyPatch, cyclicPolyPatch, dictionary);
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<cyclicPolyPatch::transformType, 4>::names[] =
|
||||
const char* Foam::NamedEnum<Foam::cyclicPolyPatch::transformType, 4>::names[] =
|
||||
{
|
||||
"unknown",
|
||||
"rotational",
|
||||
@ -54,9 +54,8 @@ const char* NamedEnum<cyclicPolyPatch::transformType, 4>::names[] =
|
||||
"noOrdering"
|
||||
};
|
||||
|
||||
const NamedEnum<cyclicPolyPatch::transformType, 4>
|
||||
cyclicPolyPatch::transformTypeNames;
|
||||
}
|
||||
const Foam::NamedEnum<Foam::cyclicPolyPatch::transformType, 4>
|
||||
Foam::cyclicPolyPatch::transformTypeNames;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -45,10 +45,7 @@ Foam::fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io)
|
||||
pistonLayers_("pistonLayers", dimLength, 0.0),
|
||||
motionSolver_(*this, engineDB_.engineDict().lookup("motionSolver"))
|
||||
{
|
||||
if (engineDB_.engineDict().found("pistonLayers"))
|
||||
{
|
||||
engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
|
||||
}
|
||||
engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,10 +44,7 @@ Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io)
|
||||
engineMesh(io),
|
||||
pistonLayers_("pistonLayers", dimLength, 0.0)
|
||||
{
|
||||
if (engineDB_.engineDict().found("pistonLayers"))
|
||||
{
|
||||
engineDB_.engineDict().lookup("pistonLayers") >> pistonLayers_;
|
||||
}
|
||||
engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -80,10 +80,7 @@ freestreamFvPatchField<Type>::freestreamFvPatchField
|
||||
fvPatchField<Type>::operator=(freestreamValue());
|
||||
}
|
||||
|
||||
if (dict.found("phi"))
|
||||
{
|
||||
dict.lookup("phi") >> this->phiName_;
|
||||
}
|
||||
dict.readIfPresent("phi", this->phiName_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -130,10 +130,7 @@ timeVaryingMappedFixedValueFvPatchField
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (dict.found("fieldTableName"))
|
||||
{
|
||||
dict.lookup("fieldTableName") >> fieldTableName_;
|
||||
}
|
||||
dict.readIfPresent("fieldTableName", fieldTableName_);
|
||||
|
||||
if (dict.found("value"))
|
||||
{
|
||||
|
||||
@ -229,18 +229,12 @@ void Foam::potential::potential::readPotentialDict()
|
||||
|
||||
if (potentialDict.found("external"))
|
||||
{
|
||||
|
||||
Info<< nl << "Reading external forces:" << endl;
|
||||
|
||||
const dictionary& externalDict = potentialDict.subDict("external");
|
||||
|
||||
// *********************************************************************
|
||||
// gravity
|
||||
|
||||
if (externalDict.found("gravity"))
|
||||
{
|
||||
gravity_ = externalDict.lookup("gravity");
|
||||
}
|
||||
externalDict.readIfPresent("gravity", gravity_);
|
||||
}
|
||||
|
||||
Info<< nl << tab << "gravity = " << gravity_ << endl;
|
||||
|
||||
@ -218,10 +218,7 @@ Foam::layerParameters::layerParameters
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (dict.found("nRelaxedIter"))
|
||||
{
|
||||
dict.lookup("nRelaxedIter") >> nRelaxedIter_;
|
||||
}
|
||||
dict.readIfPresent("nRelaxedIter", nRelaxedIter_);
|
||||
|
||||
if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
|
||||
{
|
||||
@ -303,10 +300,8 @@ Foam::layerParameters::layerParameters
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (dict.found("nRelaxedIter"))
|
||||
{
|
||||
dict.lookup("nRelaxedIter") >> nRelaxedIter_;
|
||||
}
|
||||
dict.readIfPresent("nRelaxedIter", nRelaxedIter_);
|
||||
|
||||
if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
|
||||
{
|
||||
FatalErrorIn("layerParameters::layerParameters(..)")
|
||||
|
||||
@ -522,11 +522,9 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// Collapse checking parameters
|
||||
scalar volFraction = -1;
|
||||
if (motionDict.found("minVolCollapseRatio"))
|
||||
{
|
||||
volFraction = readScalar(motionDict.lookup("minVolCollapseRatio"));
|
||||
}
|
||||
const scalar volFraction =
|
||||
motionDict.lookupOrDefault<scalar>("minVolCollapseRatio", -1);
|
||||
|
||||
const bool checkCollapse = (volFraction > 0);
|
||||
scalar minArea = -1;
|
||||
scalar maxNonOrtho = -1;
|
||||
|
||||
@ -151,17 +151,10 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
}
|
||||
|
||||
// Global perpendicular angle
|
||||
if (dict.found("perpendicularAngle"))
|
||||
{
|
||||
globalAngle[surfI] = readScalar(dict.lookup("perpendicularAngle"));
|
||||
}
|
||||
dict.readIfPresent("perpendicularAngle", globalAngle[surfI]);
|
||||
|
||||
//// Global patch name per surface
|
||||
//if (dict.found("patchType"))
|
||||
//{
|
||||
// dict.lookup("patchType") >> globalPatchType[surfI];
|
||||
//}
|
||||
|
||||
//dict.readIfPresent("patchType", globalPatchType[surfI]);
|
||||
|
||||
if (dict.found("regions"))
|
||||
{
|
||||
@ -446,13 +439,7 @@ Foam::refinementSurfaces::refinementSurfaces
|
||||
}
|
||||
|
||||
// Global perpendicular angle
|
||||
if (dict.found("perpendicularAngle"))
|
||||
{
|
||||
globalAngle[surfI] = readScalar
|
||||
(
|
||||
dict.lookup("perpendicularAngle")
|
||||
);
|
||||
}
|
||||
dict.readIfPresent("perpendicularAngle", globalAngle[surfI]);
|
||||
|
||||
if (dict.found("regions"))
|
||||
{
|
||||
|
||||
@ -178,11 +178,7 @@ Foam::label Foam::ptscotchDecomp::decompose
|
||||
// const dictionary& scotchCoeffs =
|
||||
// decompositionDict_.subDict("ptscotchCoeffs");
|
||||
//
|
||||
// if (scotchCoeffs.found("writeGraph"))
|
||||
// {
|
||||
// Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
|
||||
//
|
||||
// if (writeGraph)
|
||||
// if (scotchCoeffs.lookupOrDefault("writeGraph", false))
|
||||
// {
|
||||
// OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
|
||||
//
|
||||
@ -214,8 +210,6 @@ Foam::label Foam::ptscotchDecomp::decompose
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// Strategy
|
||||
// ~~~~~~~~
|
||||
|
||||
@ -178,11 +178,7 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
const dictionary& scotchCoeffs =
|
||||
decompositionDict_.subDict("scotchCoeffs");
|
||||
|
||||
if (scotchCoeffs.found("writeGraph"))
|
||||
{
|
||||
Switch writeGraph(scotchCoeffs.lookup("writeGraph"));
|
||||
|
||||
if (writeGraph)
|
||||
if (scotchCoeffs.lookupOrDefault("writeGraph", false))
|
||||
{
|
||||
OFstream str(mesh_.time().path() / mesh_.name() + ".grf");
|
||||
|
||||
@ -214,7 +210,6 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Strategy
|
||||
@ -229,7 +224,6 @@ Foam::label Foam::scotchDecomp::decompose
|
||||
const dictionary& scotchCoeffs =
|
||||
decompositionDict_.subDict("scotchCoeffs");
|
||||
|
||||
|
||||
string strategy;
|
||||
if (scotchCoeffs.readIfPresent("strategy", strategy))
|
||||
{
|
||||
|
||||
@ -76,11 +76,9 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
|
||||
rhoInf_ = readScalar(dict.lookup("rhoInf"));
|
||||
}
|
||||
|
||||
if (dict.found("g"))
|
||||
if (dict.readIfPresent("g", g_))
|
||||
{
|
||||
lookupGravity_ = -2;
|
||||
|
||||
g_ = dict.lookup("g");
|
||||
}
|
||||
|
||||
if (!dict.found("value"))
|
||||
|
||||
Reference in New Issue
Block a user