Commit 50baac3c authored by Mark Olesen's avatar Mark Olesen
Browse files

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

- this helps for trapping unguarded dictionary lookups.
parent 552682ec
......@@ -53,13 +53,7 @@ Foam::surfaceTensionModels::liquidProperties::liquidProperties
)
:
surfaceTensionModel(mesh),
phaseName_(dict.lookup("phase"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceTensionModels::liquidProperties::~liquidProperties()
phaseName_(dict.get<word>("phase"))
{}
......
......@@ -95,7 +95,7 @@ public:
//- Destructor
virtual ~liquidProperties();
virtual ~liquidProperties() = default;
// Member Functions
......
......@@ -98,7 +98,7 @@ public:
autoPtr<phaseModel> operator()(Istream& is) const
{
return autoPtr<phaseModel>::New(is, p_, T_);
return autoPtr<phaseModel>::New(word(is), p_, T_);
}
};
......
......@@ -72,7 +72,7 @@ MultiComponentPhaseModel
species_ = thermoPtr_->composition().species();
inertIndex_ = species_[thermoPtr_().lookup("inertSpecie")];
inertIndex_ = species_[thermoPtr_->getWord("inertSpecie")];
X_.setSize(thermoPtr_->composition().species().size());
......@@ -104,7 +104,6 @@ MultiComponentPhaseModel
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasePhaseModel, class phaseThermo>
void Foam::MultiComponentPhaseModel<BasePhaseModel, phaseThermo>
::calculateVolumeFractions()
......
......@@ -53,7 +53,7 @@ Foam::phaseModel::phaseModel
IOobject::AUTO_WRITE
),
fluid.mesh(),
dimensionedScalar("alpha", dimless, 0)
dimensionedScalar(dimless, Zero)
),
fluid_(fluid),
name_(phaseName)
......
......@@ -122,46 +122,29 @@ int main(int argc, char *argv[])
{
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")
{
vFields[i] =
new volVectorField
(
IOobject
(
nameMap.lookup(starFieldNames[i]),
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
vFields[i] = new volVectorField(io, mesh);
i += 3;
}
else
{
sFields[i] =
new volScalarField
(
IOobject
(
nameMap.lookup(starFieldNames[i]),
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
i++;
sFields[i] = new volScalarField(io, mesh);
++i;
}
}
else
{
i++;
++i;
}
}
......
......@@ -1297,6 +1297,7 @@ public:
defineDictionaryGetter(getBool, bool);
defineDictionaryGetter(getLabel, label);
defineDictionaryGetter(getScalar, scalar);
defineDictionaryGetter(getString, string);
defineDictionaryGetter(getWord, word);
defineDictionaryGetter(getFileName, fileName);
......
......@@ -48,7 +48,7 @@ Foam::fixedNormalSlipPointPatchField<Type>::fixedNormalSlipPointPatchField
)
:
slipPointPatchField<Type>(p, iF, dict),
n_(dict.lookup("n"))
n_(dict.get<vector>("n"))
{}
......
......@@ -53,7 +53,7 @@ Foam::PBiCCCG<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
SolverPerformance<Type> solverPerf
......
......@@ -50,7 +50,7 @@ template<class Type, class DType, class LUType>
Foam::SolverPerformance<Type>
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
SolverPerformance<Type> solverPerf
......
......@@ -50,7 +50,7 @@ template<class Type, class DType, class LUType>
typename Foam::SolverPerformance<Type>
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
SolverPerformance<Type> solverPerf
......
......@@ -248,7 +248,7 @@ Foam::GAMGAgglomeration::GAMGAgglomeration
)
? GAMGProcAgglomeration::New
(
controlDict.lookup("processorAgglomerator"),
controlDict.get<word>("processorAgglomerator"),
*this,
controlDict
)
......
......@@ -77,7 +77,7 @@ public:
inline Pair(const FixedList<T, 2>& lst, const bool doSort);
//- Construct from Istream
inline Pair(Istream& is);
inline explicit Pair(Istream& is);
// Member Functions
......
......@@ -44,7 +44,7 @@ See also
namespace Foam
{
// Forward declaration of friend functions and operators
// Forward declarations
template<class Type1, class Type2>
class Tuple2;
......@@ -93,7 +93,7 @@ public:
{}
//- Construct from Istream
inline Tuple2(Istream& is)
inline explicit Tuple2(Istream& is)
{
is >> *this;
}
......
......@@ -153,7 +153,7 @@ public:
{}
//- Construct from Istream
Switch(Istream& is);
explicit Switch(Istream& is);
// Helpers
......
......@@ -137,9 +137,8 @@ public:
//- Construct by concatenating words separated by '/'
explicit fileName(std::initializer_list<word> list);
//- Construct from Istream
fileName(Istream& is);
explicit fileName(Istream& is);
// Member Functions
......
......@@ -130,7 +130,7 @@ public:
//- Construct from Istream
// Treat as regular expression if surrounded by quotation marks.
keyType(Istream& is);
explicit keyType(Istream& is);
// Member Functions
......
......@@ -49,8 +49,6 @@ namespace Foam
namespace parsing
{
// Enumerations
//- Enumeration for possible parsing error
enum class errorType
{
......
......@@ -182,7 +182,7 @@ public:
inline string(const size_type len, const char c);
//- Construct from Istream
string(Istream& is);
explicit string(Istream& is);
// Member Functions
......
......@@ -109,7 +109,7 @@ public:
inline word(const char* s, size_type len, bool doStrip);
//- Construct from Istream
word(Istream& is);
explicit word(Istream& is);
// Member Functions
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment