ENH: construct string types from Istream now explicit (#1033)

- this helps for trapping unguarded dictionary lookups.
This commit is contained in:
Mark Olesen 2018-11-03 20:24:34 +01:00
parent 552682ec03
commit 50baac3c45
65 changed files with 189 additions and 244 deletions

View File

@ -53,13 +53,7 @@ Foam::surfaceTensionModels::liquidProperties::liquidProperties
) )
: :
surfaceTensionModel(mesh), surfaceTensionModel(mesh),
phaseName_(dict.lookup("phase")) phaseName_(dict.get<word>("phase"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceTensionModels::liquidProperties::~liquidProperties()
{} {}

View File

@ -95,7 +95,7 @@ public:
//- Destructor //- Destructor
virtual ~liquidProperties(); virtual ~liquidProperties() = default;
// Member Functions // Member Functions

View File

@ -98,7 +98,7 @@ public:
autoPtr<phaseModel> operator()(Istream& is) const autoPtr<phaseModel> operator()(Istream& is) const
{ {
return autoPtr<phaseModel>::New(is, p_, T_); return autoPtr<phaseModel>::New(word(is), p_, T_);
} }
}; };

View File

@ -72,7 +72,7 @@ MultiComponentPhaseModel
species_ = thermoPtr_->composition().species(); species_ = thermoPtr_->composition().species();
inertIndex_ = species_[thermoPtr_().lookup("inertSpecie")]; inertIndex_ = species_[thermoPtr_->getWord("inertSpecie")];
X_.setSize(thermoPtr_->composition().species().size()); X_.setSize(thermoPtr_->composition().species().size());
@ -104,7 +104,6 @@ MultiComponentPhaseModel
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo> template<class BasePhaseModel, class phaseThermo>
void Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo> void Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>
::calculateVolumeFractions() ::calculateVolumeFractions()

View File

@ -53,7 +53,7 @@ Foam::phaseModel::phaseModel
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
fluid.mesh(), fluid.mesh(),
dimensionedScalar("alpha", dimless, 0) dimensionedScalar(dimless, Zero)
), ),
fluid_(fluid), fluid_(fluid),
name_(phaseName) name_(phaseName)

View File

@ -122,46 +122,29 @@ int main(int argc, char *argv[])
{ {
if (nameMap.found(starFieldNames[i])) if (nameMap.found(starFieldNames[i]))
{ {
IOobject io
(
nameMap.get<word>(starFieldNames[i]),
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
);
if (starFieldNames[i] == "SU") if (starFieldNames[i] == "SU")
{ {
vFields[i] = vFields[i] = new volVectorField(io, mesh);
new volVectorField
(
IOobject
(
nameMap.lookup(starFieldNames[i]),
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
i += 3; i += 3;
} }
else else
{ {
sFields[i] = sFields[i] = new volScalarField(io, mesh);
new volScalarField ++i;
(
IOobject
(
nameMap.lookup(starFieldNames[i]),
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
i++;
} }
} }
else else
{ {
i++; ++i;
} }
} }

View File

@ -1297,6 +1297,7 @@ public:
defineDictionaryGetter(getBool, bool); defineDictionaryGetter(getBool, bool);
defineDictionaryGetter(getLabel, label); defineDictionaryGetter(getLabel, label);
defineDictionaryGetter(getScalar, scalar); defineDictionaryGetter(getScalar, scalar);
defineDictionaryGetter(getString, string);
defineDictionaryGetter(getWord, word); defineDictionaryGetter(getWord, word);
defineDictionaryGetter(getFileName, fileName); defineDictionaryGetter(getFileName, fileName);

View File

@ -48,7 +48,7 @@ Foam::fixedNormalSlipPointPatchField<Type>::fixedNormalSlipPointPatchField
) )
: :
slipPointPatchField<Type>(p, iF, dict), slipPointPatchField<Type>(p, iF, dict),
n_(dict.lookup("n")) n_(dict.get<vector>("n"))
{} {}

View File

@ -53,7 +53,7 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
Field<Type>& psi Field<Type>& psi
) const ) const
{ {
word preconditionerName(this->controlDict_.lookup("preconditioner")); const word preconditionerName(this->controlDict_.getWord("preconditioner"));
// --- Setup class containing solver performance data // --- Setup class containing solver performance data
SolverPerformance<Type> solverPerf SolverPerformance<Type> solverPerf

View File

@ -50,7 +50,7 @@ template<class Type, class DType, class LUType>
Foam::SolverPerformance<Type> Foam::SolverPerformance<Type>
Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
{ {
word preconditionerName(this->controlDict_.lookup("preconditioner")); const word preconditionerName(this->controlDict_.getWord("preconditioner"));
// --- Setup class containing solver performance data // --- Setup class containing solver performance data
SolverPerformance<Type> solverPerf SolverPerformance<Type> solverPerf

View File

@ -50,7 +50,7 @@ template<class Type, class DType, class LUType>
typename Foam::SolverPerformance<Type> typename Foam::SolverPerformance<Type>
Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
{ {
word preconditionerName(this->controlDict_.lookup("preconditioner")); const word preconditionerName(this->controlDict_.getWord("preconditioner"));
// --- Setup class containing solver performance data // --- Setup class containing solver performance data
SolverPerformance<Type> solverPerf SolverPerformance<Type> solverPerf

View File

@ -248,7 +248,7 @@ Foam::GAMGAgglomeration::GAMGAgglomeration
) )
? GAMGProcAgglomeration::New ? GAMGProcAgglomeration::New
( (
controlDict.lookup("processorAgglomerator"), controlDict.get<word>("processorAgglomerator"),
*this, *this,
controlDict controlDict
) )

View File

@ -77,7 +77,7 @@ public:
inline Pair(const FixedList<T, 2>& lst, const bool doSort); inline Pair(const FixedList<T, 2>& lst, const bool doSort);
//- Construct from Istream //- Construct from Istream
inline Pair(Istream& is); inline explicit Pair(Istream& is);
// Member Functions // Member Functions

View File

@ -44,7 +44,7 @@ See also
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
template<class Type1, class Type2> template<class Type1, class Type2>
class Tuple2; class Tuple2;
@ -93,7 +93,7 @@ public:
{} {}
//- Construct from Istream //- Construct from Istream
inline Tuple2(Istream& is) inline explicit Tuple2(Istream& is)
{ {
is >> *this; is >> *this;
} }

View File

@ -153,7 +153,7 @@ public:
{} {}
//- Construct from Istream //- Construct from Istream
Switch(Istream& is); explicit Switch(Istream& is);
// Helpers // Helpers

View File

@ -137,9 +137,8 @@ public:
//- Construct by concatenating words separated by '/' //- Construct by concatenating words separated by '/'
explicit fileName(std::initializer_list<word> list); explicit fileName(std::initializer_list<word> list);
//- Construct from Istream //- Construct from Istream
fileName(Istream& is); explicit fileName(Istream& is);
// Member Functions // Member Functions

View File

@ -130,7 +130,7 @@ public:
//- Construct from Istream //- Construct from Istream
// Treat as regular expression if surrounded by quotation marks. // Treat as regular expression if surrounded by quotation marks.
keyType(Istream& is); explicit keyType(Istream& is);
// Member Functions // Member Functions

View File

@ -49,8 +49,6 @@ namespace Foam
namespace parsing namespace parsing
{ {
// Enumerations
//- Enumeration for possible parsing error //- Enumeration for possible parsing error
enum class errorType enum class errorType
{ {

View File

@ -182,7 +182,7 @@ public:
inline string(const size_type len, const char c); inline string(const size_type len, const char c);
//- Construct from Istream //- Construct from Istream
string(Istream& is); explicit string(Istream& is);
// Member Functions // Member Functions

View File

@ -109,7 +109,7 @@ public:
inline word(const char* s, size_type len, bool doStrip); inline word(const char* s, size_type len, bool doStrip);
//- Construct from Istream //- Construct from Istream
word(Istream& is); explicit word(Istream& is);
// Member Functions // Member Functions

View File

@ -162,7 +162,7 @@ public:
//- Construct from Istream //- Construct from Istream
// Words are treated as literals, strings with an auto-test // Words are treated as literals, strings with an auto-test
wordRe(Istream& is); explicit wordRe(Istream& is);
// Member Functions // Member Functions

View File

@ -69,7 +69,7 @@ outletMachNumberPressureFvPatchScalarField
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.lookupOrDefault<word>("U", "U")),
choked_(dict.lookup("choked")), choked_(dict.get<Switch>("choked")),
relax_(dict.lookupOrDefault<scalar>("relax", 0)) relax_(dict.lookupOrDefault<scalar>("relax", 0))
{} {}

View File

@ -74,7 +74,7 @@ outletMappedUniformInletHeatAdditionFvPatchField
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), fixedValueFvPatchScalarField(p, iF, dict),
outletPatchName_(dict.lookup("outletPatch")), outletPatchName_(dict.get<word>("outletPatch")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
Q_(dict.get<scalar>("Q")), Q_(dict.get<scalar>("Q")),
TMin_(dict.lookupOrDefault<scalar>("TMin", 0)), TMin_(dict.lookupOrDefault<scalar>("TMin", 0)),

View File

@ -86,7 +86,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), dict), temperatureCoupledBase(patch(), dict),
TnbrName_(dict.lookup("Tnbr")), TnbrName_(dict.get<word>("Tnbr")),
thicknessLayers_(0), thicknessLayers_(0),
kappaLayers_(0), kappaLayers_(0),
contactRes_(0.0) contactRes_(0.0)

View File

@ -65,7 +65,7 @@ Foam::LESModel<BasicTurbulenceModel>::LESModel
), ),
LESDict_(this->subOrEmptyDict("LES")), LESDict_(this->subOrEmptyDict("LES")),
turbulence_(LESDict_.lookup("turbulence")), turbulence_(LESDict_.get<Switch>("turbulence")),
printCoeffs_(LESDict_.lookupOrDefault<Switch>("printCoeffs", false)), printCoeffs_(LESDict_.lookupOrDefault<Switch>("printCoeffs", false)),
coeffDict_(LESDict_.optionalSubDict(type + "Coeffs")), coeffDict_(LESDict_.optionalSubDict(type + "Coeffs")),

View File

@ -93,11 +93,6 @@ protected:
//- Print model coefficients //- Print model coefficients
virtual void printCoeffs(const word& type); virtual void printCoeffs(const word& type);
private:
// Private Member Functions
//- No copy construct //- No copy construct
LESModel(const LESModel&) = delete; LESModel(const LESModel&) = delete;
@ -168,8 +163,7 @@ public:
//- Destructor //- Destructor
virtual ~LESModel() virtual ~LESModel() = default;
{}
// Member Functions // Member Functions

View File

@ -65,7 +65,7 @@ Foam::RASModel<BasicTurbulenceModel>::RASModel
), ),
RASDict_(this->subOrEmptyDict("RAS")), RASDict_(this->subOrEmptyDict("RAS")),
turbulence_(RASDict_.lookup("turbulence")), turbulence_(RASDict_.get<Switch>("turbulence")),
printCoeffs_(RASDict_.lookupOrDefault<Switch>("printCoeffs", false)), printCoeffs_(RASDict_.lookupOrDefault<Switch>("printCoeffs", false)),
coeffDict_(RASDict_.optionalSubDict(type + "Coeffs")), coeffDict_(RASDict_.optionalSubDict(type + "Coeffs")),

View File

@ -83,11 +83,6 @@ protected:
//- Print model coefficients //- Print model coefficients
virtual void printCoeffs(const word& type); virtual void printCoeffs(const word& type);
private:
// Private Member Functions
//- No copy construct //- No copy construct
RASModel(const RASModel&) = delete; RASModel(const RASModel&) = delete;
@ -158,8 +153,7 @@ public:
//- Destructor //- Destructor
virtual ~RASModel() virtual ~RASModel() = default;
{}
// Member Functions // Member Functions

View File

@ -100,7 +100,7 @@ Foam::TurbulenceModel<Alpha, Rho, BasicTurbulenceModel, TransportModel>::New
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
) )
).lookup("simulationType") ).get<word>("simulationType")
); );
Info<< "Selecting turbulence model type " << modelType << endl; Info<< "Selecting turbulence model type " << modelType << endl;

View File

@ -75,9 +75,7 @@ protected:
const transportModel& transport_; const transportModel& transport_;
private: // Protected Member Functions
// Private Member Functions
//- No copy construct //- No copy construct
TurbulenceModel(const TurbulenceModel&) = delete; TurbulenceModel(const TurbulenceModel&) = delete;
@ -139,8 +137,7 @@ public:
//- Destructor //- Destructor
virtual ~TurbulenceModel() virtual ~TurbulenceModel() = default;
{}
// Member Functions // Member Functions

View File

@ -134,7 +134,7 @@ nutUTabulatedWallFunctionFvPatchScalarField
) )
: :
nutWallFunctionFvPatchScalarField(p, iF, dict), nutWallFunctionFvPatchScalarField(p, iF, dict),
uPlusTableName_(dict.lookup("uPlusTable")), uPlusTableName_(dict.get<word>("uPlusTable")),
uPlusTable_ uPlusTable_
( (
IOobject IOobject

View File

@ -109,7 +109,7 @@ Foam::laminarModel<BasicTurbulenceModel>::New
// otherwise it is registered in the database twice // otherwise it is registered in the database twice
const word modelType const word modelType
( (
modelDict.subDict("laminar").lookup("laminarModel") modelDict.subDict("laminar").get<word>("laminarModel")
); );
Info<< "Selecting laminar stress model " << modelType << endl; Info<< "Selecting laminar stress model " << modelType << endl;

View File

@ -71,11 +71,6 @@ protected:
//- Print model coefficients //- Print model coefficients
virtual void printCoeffs(const word& type); virtual void printCoeffs(const word& type);
private:
// Private Member Functions
//- No copy construct //- No copy construct
laminarModel(const laminarModel&) = delete; laminarModel(const laminarModel&) = delete;
@ -146,8 +141,7 @@ public:
//- Destructor //- Destructor
virtual ~laminarModel() virtual ~laminarModel() = default;
{}
// Member Functions // Member Functions

View File

@ -98,7 +98,7 @@ Foam::velocityDisplacementMotionSolver::velocityDisplacementMotionSolver
( (
displacementMotionSolver::New displacementMotionSolver::New
( (
coeffDict().lookup("solver"), coeffDict().get<word>("solver"),
mesh, mesh,
IOdictionary IOdictionary
( (

View File

@ -50,6 +50,7 @@ namespace functionObjects
} }
} }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::functionObjects::codedFunctionObject::prepare void Foam::functionObjects::codedFunctionObject::prepare
@ -194,9 +195,10 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
dict.readCompat<word>("name", {{"redirectType", 1706}}, name_); dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
const entry* dataPtr = dict.findEntry("codeData", keyType::LITERAL); const entry* dataPtr = dict.findEntry("codeData", keyType::LITERAL);
if (dataPtr) if (dataPtr)
{ {
codeData_ = stringOps::trim(dataPtr->stream()); dataPtr->readEntry(codeData_);
stringOps::inplaceExpand(codeData_, dict); stringOps::inplaceExpand(codeData_, dict);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -207,9 +209,10 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
} }
const entry* readPtr = dict.findEntry("codeRead", keyType::LITERAL); const entry* readPtr = dict.findEntry("codeRead", keyType::LITERAL);
if (readPtr) if (readPtr)
{ {
codeRead_ = stringOps::trim(readPtr->stream()); readPtr->readEntry(codeRead_);
stringOps::inplaceExpand(codeRead_, dict); stringOps::inplaceExpand(codeRead_, dict);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -220,9 +223,10 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
} }
const entry* execPtr = dict.findEntry("codeExecute", keyType::LITERAL); const entry* execPtr = dict.findEntry("codeExecute", keyType::LITERAL);
if (execPtr) if (execPtr)
{ {
codeExecute_ = stringOps::trim(execPtr->stream()); execPtr->readEntry(codeExecute_);
stringOps::inplaceExpand(codeExecute_, dict); stringOps::inplaceExpand(codeExecute_, dict);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -233,9 +237,10 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
} }
const entry* writePtr = dict.findEntry("codeWrite", keyType::LITERAL); const entry* writePtr = dict.findEntry("codeWrite", keyType::LITERAL);
if (writePtr) if (writePtr)
{ {
codeWrite_ = stringOps::trim(writePtr->stream()); writePtr->readEntry(codeWrite_);
stringOps::inplaceExpand(codeWrite_, dict); stringOps::inplaceExpand(codeWrite_, dict);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -246,9 +251,10 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
} }
const entry* endPtr = dict.findEntry("codeEnd", keyType::LITERAL); const entry* endPtr = dict.findEntry("codeEnd", keyType::LITERAL);
if (endPtr) if (endPtr)
{ {
codeEnd_ = stringOps::trim(endPtr->stream()); endPtr->readEntry(codeEnd_);
stringOps::inplaceExpand(codeEnd_, dict); stringOps::inplaceExpand(codeEnd_, dict);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -260,10 +266,8 @@ bool Foam::functionObjects::codedFunctionObject::read(const dictionary& dict)
if (!dataPtr && !readPtr && !execPtr && !writePtr && !endPtr) if (!dataPtr && !readPtr && !execPtr && !writePtr && !endPtr)
{ {
IOWarningInFunction IOWarningInFunction(dict)
( << "No critical \"code\" prefixed keywords were found."
dict
) << "No critical \"code\" prefixed keywords were found."
<< " Please check the code documentation for more details." << " Please check the code documentation for more details."
<< nl << endl; << nl << endl;
} }

View File

@ -134,8 +134,6 @@ protected:
virtual const dictionary& codeDict() const; virtual const dictionary& codeDict() const;
private:
//- No copy construct //- No copy construct
codedFunctionObject(const codedFunctionObject&) = delete; codedFunctionObject(const codedFunctionObject&) = delete;

View File

@ -85,20 +85,14 @@ displacementComponentLaplacianFvMotionSolver
frozenPointsZone_ frozenPointsZone_
( (
coeffDict().found("frozenPointsZone") coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) ? fvMesh_.pointZones().findZoneID
(
coeffDict().get<word>("frozenPointsZone")
)
: -1 : -1
) )
{ {
Switch applyPointLocation if (coeffDict().lookupOrDefault("applyPointLocation", true))
(
coeffDict().lookupOrDefault
(
"applyPointLocation",
true
)
);
if (applyPointLocation)
{ {
pointLocation_.reset pointLocation_.reset
( (

View File

@ -93,7 +93,10 @@ Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver
frozenPointsZone_ frozenPointsZone_
( (
coeffDict().found("frozenPointsZone") coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) ? fvMesh_.pointZones().findZoneID
(
coeffDict().get<word>("frozenPointsZone")
)
: -1 : -1
) )
{ {
@ -178,7 +181,10 @@ displacementLaplacianFvMotionSolver
frozenPointsZone_ frozenPointsZone_
( (
coeffDict().found("frozenPointsZone") coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) ? fvMesh_.pointZones().findZoneID
(
coeffDict().get<word>("frozenPointsZone")
)
: -1 : -1
) )
{ {

View File

@ -97,7 +97,10 @@ solidBodyDisplacementLaplacianFvMotionSolver
frozenPointsZone_ frozenPointsZone_
( (
coeffDict().found("frozenPointsZone") coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) ? fvMesh_.pointZones().findZoneID
(
coeffDict().get<word>("frozenPointsZone")
)
: -1 : -1
) )
{ {
@ -183,7 +186,10 @@ solidBodyDisplacementLaplacianFvMotionSolver
frozenPointsZone_ frozenPointsZone_
( (
coeffDict().found("frozenPointsZone") coeffDict().found("frozenPointsZone")
? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone")) ? fvMesh_.pointZones().findZoneID
(
coeffDict().get<word>("frozenPointsZone")
)
: -1 : -1
) )
{ {

View File

@ -316,10 +316,10 @@ surfaceDisplacementPointPatchVectorField
) )
: :
fixedValuePointPatchVectorField(p, iF, dict), fixedValuePointPatchVectorField(p, iF, dict),
velocity_(dict.lookup("velocity")), velocity_(dict.get<vector>("velocity")),
surfacesDict_(dict.subDict("geometry")), surfacesDict_(dict.subDict("geometry")),
projectMode_(projectModeNames_.get("projectMode", dict)), projectMode_(projectModeNames_.get("projectMode", dict)),
projectDir_(dict.lookup("projectDirection")), projectDir_(dict.get<vector>("projectDirection")),
wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)), wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)),
frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null)) frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null))
{ {

View File

@ -110,7 +110,7 @@ private:
//- Plane for 2D wedge case or -1. //- Plane for 2D wedge case or -1.
const label wedgePlane_; const label wedgePlane_;
//- pointZone with frozen points //- Name of pointZone with frozen points
const word frozenPointsZone_; const word frozenPointsZone_;
//- Demand driven: surface to project //- Demand driven: surface to project

View File

@ -317,7 +317,7 @@ surfaceSlipDisplacementPointPatchVectorField
pointPatchVectorField(p, iF, dict), pointPatchVectorField(p, iF, dict),
surfacesDict_(dict.subDict("geometry")), surfacesDict_(dict.subDict("geometry")),
projectMode_(projectModeNames_.get("projectMode", dict)), projectMode_(projectModeNames_.get("projectMode", dict)),
projectDir_(dict.lookup("projectDirection")), projectDir_(dict.get<vector>("projectDirection")),
wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)), wedgePlane_(dict.lookupOrDefault("wedgePlane", -1)),
frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null)) frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null))
{} {}

View File

@ -153,11 +153,9 @@ void Foam::fv::CodedSource<Type>::correct
GeometricField<Type, fvPatchField, volMesh>& field GeometricField<Type, fvPatchField, volMesh>& field
) )
{ {
if (debug) DebugInfo
{ << "CodedSource<" << pTraits<Type>::typeName
Info<< "CodedSource<"<< pTraits<Type>::typeName << ">::correct for source " << name_ << endl;
<< ">::correct for source " << name_ << endl;
}
updateLibrary(name_); updateLibrary(name_);
redirectFvOption().correct(field); redirectFvOption().correct(field);
@ -171,11 +169,9 @@ void Foam::fv::CodedSource<Type>::addSup
const label fieldi const label fieldi
) )
{ {
if (debug) DebugInfo
{ << "CodedSource<" << pTraits<Type>::typeName
Info<< "CodedSource<"<< pTraits<Type>::typeName << ">::addSup for source " << name_ << endl;
<< ">::addSup for source " << name_ << endl;
}
updateLibrary(name_); updateLibrary(name_);
redirectFvOption().addSup(eqn, fieldi); redirectFvOption().addSup(eqn, fieldi);
@ -190,11 +186,9 @@ void Foam::fv::CodedSource<Type>::addSup
const label fieldi const label fieldi
) )
{ {
if (debug) DebugInfo
{ << "CodedSource<" << pTraits<Type>::typeName
Info<< "CodedSource<"<< pTraits<Type>::typeName << ">::addSup for source " << name_ << endl;
<< ">::addSup for source " << name_ << endl;
}
updateLibrary(name_); updateLibrary(name_);
redirectFvOption().addSup(rho, eqn, fieldi); redirectFvOption().addSup(rho, eqn, fieldi);
@ -208,11 +202,9 @@ void Foam::fv::CodedSource<Type>::constrain
const label fieldi const label fieldi
) )
{ {
if (debug) DebugInfo
{ << "CodedSource<" << pTraits<Type>::typeName
Info<< "CodedSource<"<< pTraits<Type>::typeName << ">::constrain for source " << name_ << endl;
<< ">::constrain for source " << name_ << endl;
}
updateLibrary(name_); updateLibrary(name_);
redirectFvOption().constrain(eqn, fieldi); redirectFvOption().constrain(eqn, fieldi);

View File

@ -43,7 +43,8 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
const entry& e = const entry& e =
coeffs_.lookupEntry("codeCorrect", keyType::LITERAL); coeffs_.lookupEntry("codeCorrect", keyType::LITERAL);
codeCorrect_ = stringOps::trim(e.stream()); e.readEntry(codeCorrect_);
stringOps::inplaceTrim(codeCorrect_);
stringOps::inplaceExpand(codeCorrect_, coeffs_); stringOps::inplaceExpand(codeCorrect_, coeffs_);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -57,7 +58,8 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
const entry& e = const entry& e =
coeffs_.lookupEntry("codeAddSup", keyType::LITERAL); coeffs_.lookupEntry("codeAddSup", keyType::LITERAL);
codeAddSup_ = stringOps::trim(e.stream()); e.readEntry(codeAddSup_);
stringOps::inplaceTrim(codeAddSup_);
stringOps::inplaceExpand(codeAddSup_, coeffs_); stringOps::inplaceExpand(codeAddSup_, coeffs_);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (
@ -71,7 +73,8 @@ bool Foam::fv::CodedSource<Type>::read(const dictionary& dict)
const entry& e = const entry& e =
coeffs_.lookupEntry("codeSetValue", keyType::LITERAL); coeffs_.lookupEntry("codeSetValue", keyType::LITERAL);
codeSetValue_ = stringOps::trim(e.stream()); e.readEntry(codeSetValue_);
stringOps::inplaceTrim(codeSetValue_);
stringOps::inplaceExpand(codeSetValue_, coeffs_); stringOps::inplaceExpand(codeSetValue_, coeffs_);
dynamicCodeContext::addLineDirective dynamicCodeContext::addLineDirective
( (

View File

@ -45,17 +45,17 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
( (
owner.db().objectRegistry::template lookupObject<volScalarField> owner.db().objectRegistry::template lookupObject<volScalarField>
( (
this->coeffDict().lookup("referenceField") this->coeffDict().getWord("referenceField")
) )
), ),
thresholdField_ thresholdField_
( (
owner.db().objectRegistry::template lookupObject<volScalarField> owner.db().objectRegistry::template lookupObject<volScalarField>
( (
this->coeffDict().lookup("thresholdField") this->coeffDict().getWord("thresholdField")
) )
), ),
positionsFile_(this->coeffDict().lookup("positionsFile")), positionsFile_(this->coeffDict().getWord("positionsFile")),
positions_ positions_
( (
IOobject IOobject
@ -74,8 +74,11 @@ Foam::FieldActivatedInjection<CloudType>::FieldActivatedInjection
( (
this->coeffDict().getLabel("parcelsPerInjector") this->coeffDict().getLabel("parcelsPerInjector")
), ),
nParcelsInjected_(positions_.size(), 0), nParcelsInjected_(positions_.size(), Zero),
U0_(this->coeffDict().lookup("U0")), U0_
(
this->coeffDict().template get<vector>("U0")
),
diameters_(positions_.size()), diameters_(positions_.size()),
sizeDistribution_ sizeDistribution_
( (

View File

@ -40,7 +40,7 @@ Foam::PatchFlowRateInjection<CloudType>::PatchFlowRateInjection
) )
: :
InjectionModel<CloudType>(dict, owner, modelName,typeName), InjectionModel<CloudType>(dict, owner, modelName,typeName),
patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patch")), patchInjectionBase(owner.mesh(), this->coeffDict().getWord("patch")),
phiName_(this->coeffDict().template lookupOrDefault<word>("phi", "phi")), phiName_(this->coeffDict().template lookupOrDefault<word>("phi", "phi")),
rhoName_(this->coeffDict().template lookupOrDefault<word>("rho", "rho")), rhoName_(this->coeffDict().template lookupOrDefault<word>("rho", "rho")),
duration_(this->coeffDict().getScalar("duration")), duration_(this->coeffDict().getScalar("duration")),

View File

@ -38,7 +38,7 @@ Foam::PatchInjection<CloudType>::PatchInjection
) )
: :
InjectionModel<CloudType>(dict, owner, modelName, typeName), InjectionModel<CloudType>(dict, owner, modelName, typeName),
patchInjectionBase(owner.mesh(), this->coeffDict().lookup("patch")), patchInjectionBase(owner.mesh(), this->coeffDict().getWord("patch")),
duration_(this->coeffDict().getScalar("duration")), duration_(this->coeffDict().getScalar("duration")),
parcelsPerSecond_ parcelsPerSecond_
( (

View File

@ -75,12 +75,6 @@ Foam::patchInjectionBase::patchInjectionBase(const patchInjectionBase& pib)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchInjectionBase::~patchInjectionBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh) void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh)

View File

@ -51,7 +51,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward class declarations // Forward declarations
class polyMesh; class polyMesh;
class fvMesh; class fvMesh;
class Random; class Random;
@ -106,7 +106,7 @@ public:
//- Destructor //- Destructor
virtual ~patchInjectionBase(); virtual ~patchInjectionBase() = default;
// Member Functions // Member Functions

View File

@ -60,7 +60,7 @@ Foam::ErgunWenYuDragForce<CloudType>::ErgunWenYuDragForce
( (
this->mesh().template lookupObject<volScalarField> this->mesh().template lookupObject<volScalarField>
( (
this->coeffs().lookup("alphac") this->coeffs().getWord("alphac")
) )
) )
{} {}
@ -77,7 +77,7 @@ Foam::ErgunWenYuDragForce<CloudType>::ErgunWenYuDragForce
( (
this->mesh().template lookupObject<volScalarField> this->mesh().template lookupObject<volScalarField>
( (
this->coeffs().lookup("alphac") this->coeffs().getWord("alphac")
) )
) )
{} {}

View File

@ -60,7 +60,7 @@ Foam::PlessisMasliyahDragForce<CloudType>::PlessisMasliyahDragForce
( (
this->mesh().template lookupObject<volScalarField> this->mesh().template lookupObject<volScalarField>
( (
this->coeffs().lookup("alphac") this->coeffs().getWord("alphac")
) )
) )
{} {}
@ -77,7 +77,7 @@ Foam::PlessisMasliyahDragForce<CloudType>::PlessisMasliyahDragForce
( (
this->mesh().template lookupObject<volScalarField> this->mesh().template lookupObject<volScalarField>
( (
this->coeffs().lookup("alphac") this->coeffs().getWord("alphac")
) )
) )
{} {}

View File

@ -57,7 +57,7 @@ Foam::WenYuDragForce<CloudType>::WenYuDragForce
( (
this->mesh().template lookupObject<volScalarField> this->mesh().template lookupObject<volScalarField>
( (
this->coeffs().lookup("alphac") this->coeffs().getWord("alphac")
) )
) )
{} {}
@ -74,7 +74,7 @@ Foam::WenYuDragForce<CloudType>::WenYuDragForce
( (
this->mesh().template lookupObject<volScalarField> this->mesh().template lookupObject<volScalarField>
( (
this->coeffs().lookup("alphac") this->coeffs().getWord("alphac")
) )
) )
{} {}

View File

@ -95,19 +95,12 @@ Foam::PhaseChangeModel<CloudType>::PhaseChangeModel
CloudSubModelBase<CloudType>(owner, dict, typeName, type), CloudSubModelBase<CloudType>(owner, dict, typeName, type),
enthalpyTransfer_ enthalpyTransfer_
( (
wordToEnthalpyTransfer(this->coeffDict().lookup("enthalpyTransfer")) wordToEnthalpyTransfer(this->coeffDict().getWord("enthalpyTransfer"))
), ),
dMass_(0.0) dMass_(0.0)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::PhaseChangeModel<CloudType>::~PhaseChangeModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType> template<class CloudType>

View File

@ -60,7 +60,7 @@ class PhaseChangeModel
{ {
public: public:
// Public enumerations // Public Enumerations
//- Enthalpy transfer type //- Enthalpy transfer type
enum enthalpyTransferType enum enthalpyTransferType
@ -70,7 +70,7 @@ public:
}; };
//- Name representations of enthalpy transfer types //- Name representations of enthalpy transfer types
static const Foam::wordList enthalpyTransferTypeNames; static const wordList enthalpyTransferTypeNames;
protected: protected:
@ -136,7 +136,7 @@ public:
//- Destructor //- Destructor
virtual ~PhaseChangeModel(); virtual ~PhaseChangeModel() = default;
//- Selector //- Selector

View File

@ -489,7 +489,7 @@ Foam::ThermoSurfaceFilm<CloudType>::ThermoSurfaceFilm
CpFilmPatch_(0), CpFilmPatch_(0),
interactionType_ interactionType_
( (
interactionTypeEnum(this->coeffDict().lookup("interactionType")) interactionTypeEnum(this->coeffDict().getWord("interactionType"))
), ),
deltaWet_(0.0), deltaWet_(0.0),
splashParcelType_(0), splashParcelType_(0),

View File

@ -118,7 +118,7 @@ Foam::displacementMotionSolverMeshMover::displacementMotionSolverMeshMover
( (
displacementMotionSolver::New displacementMotionSolver::New
( (
dict.lookup("solver"), dict.get<word>("solver"),
pointDisplacement.mesh()(), pointDisplacement.mesh()(),
IOdictionary IOdictionary
( (

View File

@ -48,7 +48,7 @@ Foam::RBD::restraint::restraint
) )
: :
name_(name), name_(name),
bodyID_(model.bodyID(dict.lookup("body"))), bodyID_(model.bodyID(dict.get<word>("body"))),
bodyIndex_(model.master(bodyID_)), bodyIndex_(model.master(bodyID_)),
coeffs_(dict), coeffs_(dict),
model_(model) model_(model)

View File

@ -60,7 +60,7 @@ namespace RBD
class rigidBodyModel; class rigidBodyModel;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class restraint Declaration Class restraint Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class restraint class restraint

View File

@ -194,7 +194,7 @@ Foam::RBD::rigidBodyModel::rigidBodyModel
{ {
merge merge
( (
bodyID(bodyDict.lookup("mergeWith")), bodyID(bodyDict.get<word>("mergeWith")),
bodyDict.lookup("transform"), bodyDict.lookup("transform"),
rigidBody::New(key, bodyDict) rigidBody::New(key, bodyDict)
); );
@ -203,7 +203,7 @@ Foam::RBD::rigidBodyModel::rigidBodyModel
{ {
join join
( (
bodyID(bodyDict.lookup("parent")), bodyID(bodyDict.get<word>("parent")),
bodyDict.lookup("transform"), bodyDict.lookup("transform"),
joint::New(bodyDict.subDict("joint")), joint::New(bodyDict.subDict("joint")),
rigidBody::New(key, bodyDict) rigidBody::New(key, bodyDict)

View File

@ -64,16 +64,16 @@ Foam::autoPtr<ChemistryModel> Foam::basicChemistryModel::New
const dictionary& chemistryTypeDict = const dictionary& chemistryTypeDict =
chemistryDict.subDict("chemistryType"); chemistryDict.subDict("chemistryType");
const word& solverName const word solverName
( (
chemistryTypeDict.found("solver") chemistryTypeDict.getCompat<word>
? chemistryTypeDict.lookup("solver") (
: chemistryTypeDict.found("chemistrySolver") "solver",
? chemistryTypeDict.lookup("chemistrySolver") {{"chemistrySolver", -1712}}
: chemistryTypeDict.lookup("solver") // error if neither entry is found )
); );
const word& methodName const word methodName
( (
chemistryTypeDict.lookupOrDefault<word> chemistryTypeDict.lookupOrDefault<word>
( (
@ -90,8 +90,7 @@ Foam::autoPtr<ChemistryModel> Foam::basicChemistryModel::New
Info<< "Selecting chemistry solver " << chemistryTypeDictNew << endl; Info<< "Selecting chemistry solver " << chemistryTypeDictNew << endl;
typedef typename ChemistryModel::thermoConstructorTable cstrTableType; auto* cstrTable = ChemistryModel::thermoConstructorTablePtr_;
cstrTableType* cstrTable = ChemistryModel::thermoConstructorTablePtr_;
const word chemSolverCompThermoName = const word chemSolverCompThermoName =
solverName + '<' + methodName + '<' solverName + '<' + methodName + '<'
@ -106,7 +105,7 @@ Foam::autoPtr<ChemistryModel> Foam::basicChemistryModel::New
<< "Unknown " << typeName_() << " type " << solverName << endl << "Unknown " << typeName_() << " type " << solverName << endl
<< endl; << endl;
const wordList names(cstrTable->toc()); const wordList names(cstrTable->sortedToc());
wordList thisCmpts; wordList thisCmpts;
thisCmpts.append(word::null); thisCmpts.append(word::null);
@ -123,7 +122,7 @@ Foam::autoPtr<ChemistryModel> Foam::basicChemistryModel::New
const wordList cmpts(basicThermo::splitThermoName(names[i], 8)); const wordList cmpts(basicThermo::splitThermoName(names[i], 8));
bool isValid = true; bool isValid = true;
for (label i = 2; i < cmpts.size() && isValid; ++ i) for (label i = 2; i < cmpts.size() && isValid; ++i)
{ {
isValid = isValid && cmpts[i] == thisCmpts[i]; isValid = isValid && cmpts[i] == thisCmpts[i];
} }

View File

@ -91,28 +91,28 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
nFunc++; nFunc++;
} }
if (coeffsDict_.found("lookUpTableFileName")) if
(
coeffsDict_.found("lookUpTableFileName")
&& "none" != coeffsDict_.get<word>("lookUpTableFileName")
)
{ {
const word name = coeffsDict_.lookup("lookUpTableFileName"); lookUpTablePtr_.reset
if (name != "none") (
{ new interpolationLookUpTable<scalar>
lookUpTablePtr_.reset
( (
new interpolationLookUpTable<scalar> coeffsDict_.get<fileName>("lookUpTableFileName"),
( mesh.time().constant(),
fileName(coeffsDict_.lookup("lookUpTableFileName")), mesh
mesh.time().constant(), )
mesh );
)
);
if (!mesh.foundObject<volScalarField>("ft")) if (!mesh.foundObject<volScalarField>("ft"))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "specie ft is not present to use with " << "specie ft is not present to use with "
<< "lookUpTableFileName " << nl << "lookUpTableFileName " << nl
<< exit(FatalError); << exit(FatalError);
}
} }
} }
@ -213,7 +213,7 @@ Foam::radiation::greyMeanAbsorptionEmission::aCont(const label bandI) const
forAll(a, celli) forAll(a, celli)
{ {
forAllConstIter(HashTable<label>, speciesNames_, iter) forAllConstIters(speciesNames_, iter)
{ {
label n = iter(); label n = iter();
scalar Xipi = 0.0; scalar Xipi = 0.0;

View File

@ -102,28 +102,28 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
} }
nBands_ = nBand; nBands_ = nBand;
if (coeffsDict_.found("lookUpTableFileName")) if
(
coeffsDict_.found("lookUpTableFileName")
&& "none" != coeffsDict_.get<word>("lookUpTableFileName")
)
{ {
const word name = coeffsDict_.lookup("lookUpTableFileName"); lookUpTablePtr_.set
if (name != "none") (
{ new interpolationLookUpTable<scalar>
lookUpTablePtr_.set
( (
new interpolationLookUpTable<scalar> coeffsDict_.get<fileName>("lookUpTableFileName"),
( mesh.time().constant(),
fileName(coeffsDict_.lookup("lookUpTableFileName")), mesh
mesh.time().constant(), )
mesh );
)
);
if (!mesh.foundObject<volScalarField>("ft")) if (!mesh.foundObject<volScalarField>("ft"))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "specie ft is not present to use with " << "specie ft is not present to use with "
<< "lookUpTableFileName " << nl << "lookUpTableFileName " << nl
<< exit(FatalError); << exit(FatalError);
}
} }
} }
@ -224,7 +224,7 @@ Foam::radiation::wideBandAbsorptionEmission::aCont(const label bandi) const
forAll(a, celli) forAll(a, celli)
{ {
forAllConstIter(HashTable<label>, speciesNames_, iter) forAllConstIters(speciesNames_, iter)
{ {
const label n = iter(); const label n = iter();
scalar Xipi = 0; scalar Xipi = 0;

View File

@ -51,7 +51,7 @@ void Foam::singleStepReactingMixture<ThermoType>::calculateqFuel()
specieProd_[speciei] = -1; specieProd_[speciei] = -1;
} }
Info << "Fuel heat of combustion :" << qFuel_.value() << endl; Info<< "Fuel heat of combustion :" << qFuel_.value() << endl;
} }
@ -73,9 +73,9 @@ void Foam::singleStepReactingMixture<ThermoType>::massAndAirStoichRatios()
* mag(specieStoichCoeffs_[O2Index])) * mag(specieStoichCoeffs_[O2Index]))
/ (Wu*mag(specieStoichCoeffs_[fuelIndex_])); / (Wu*mag(specieStoichCoeffs_[fuelIndex_]));
Info << "stoichiometric air-fuel ratio :" << stoicRatio_.value() << endl; Info<< "stoichiometric air-fuel ratio :" << stoicRatio_.value() << endl;
Info << "stoichiometric oxygen-fuel ratio :" << s_.value() << endl; Info<< "stoichiometric oxygen-fuel ratio :" << s_.value() << endl;
} }
@ -108,7 +108,7 @@ void Foam::singleStepReactingMixture<ThermoType>::calculateMaxProducts()
Yprod0_[speciei] = this->speciesData()[speciei].W()/Wm*Xi[i]; Yprod0_[speciei] = this->speciesData()[speciei].W()/Wm*Xi[i];
} }
Info << "Maximum products mass concentrations:" << nl; Info<< "Maximum products mass concentrations:" << nl;
forAll(Yprod0_, i) forAll(Yprod0_, i)
{ {
if (Yprod0_[i] > 0) if (Yprod0_[i] > 0)
@ -202,8 +202,8 @@ Foam::singleStepReactingMixture<ThermoType>::singleStepReactingMixture
specieStoichCoeffs_(this->species_.size(), Zero), specieStoichCoeffs_(this->species_.size(), Zero),
Yprod0_(this->species_.size(), Zero), Yprod0_(this->species_.size(), Zero),
fres_(Yprod0_.size()), fres_(Yprod0_.size()),
inertIndex_(this->species()[thermoDict.lookup("inertSpecie")]), inertIndex_(this->species()[thermoDict.get<word>("inertSpecie")]),
fuelIndex_(this->species()[thermoDict.lookup("fuel")]), fuelIndex_(this->species()[thermoDict.get<word>("fuel")]),
specieProd_(Yprod0_.size(), 1) specieProd_(Yprod0_.size(), 1)
{ {
if (this->size() == 1) if (this->size() == 1)

View File

@ -74,7 +74,7 @@ Foam::solidReaction<ReactionThermo>::solidReaction
{ {
this->setLRhs this->setLRhs
( (
IStringStream(dict.lookup("reaction"))(), IStringStream(dict.getString("reaction"))(),
pyrolisisGases_, pyrolisisGases_,
glhs_, glhs_,
grhs_ grhs_

View File

@ -335,7 +335,7 @@ Foam::Reaction<ReactionThermo>::Reaction
{ {
setLRhs setLRhs
( (
IStringStream(dict.lookup("reaction"))(), IStringStream(dict.getString("reaction"))(),
species_, species_,
lhs_, lhs_,
rhs_ rhs_