ENH: avoid readScalar, readLabel etc from dictionary (#762, #1033)

- use the dictionary 'get' methods instead of readScalar for
  additional checking

     Unchecked:  readScalar(dict.lookup("key"));
     Checked:    dict.get<scalar>("key");

- In templated classes that also inherit from a dictionary, an additional
  'template' keyword will be required. Eg,

     this->coeffsDict().template get<scalar>("key");

  For this common use case, the predefined getXXX shortcuts may be
  useful. Eg,

     this->coeffsDict().getScalar("key");
This commit is contained in:
Mark Olesen
2018-10-12 08:14:47 +02:00
parent 990d00d40d
commit 8eddcc072a
335 changed files with 1007 additions and 1127 deletions

View File

@ -76,12 +76,12 @@ FSD<ReactionThermo, ThermoType>::FSD
),
YFuelFuelStream_(dimensionedScalar("YFuelStream", dimless, 1.0)),
YO2OxiStream_(dimensionedScalar("YOxiStream", dimless, 0.23)),
Cv_(readScalar(this->coeffs().lookup("Cv"))),
Cv_(this->coeffs().getScalar("Cv")),
C_(5.0),
ftMin_(0.0),
ftMax_(1.0),
ftDim_(300),
ftVarMin_(readScalar(this->coeffs().lookup("ftVarMin")))
ftVarMin_(this->coeffs().getScalar("ftVarMin"))
{}

View File

@ -39,10 +39,10 @@ Foam::consumptionSpeed::consumptionSpeed
(
const dictionary& dict
)
: omega0_(readScalar(dict.lookup("omega0"))),
eta_(readScalar(dict.lookup("eta"))),
sigmaExt_(readScalar(dict.lookup("sigmaExt"))),
omegaMin_(readScalar(dict.lookup("omegaMin")))
: omega0_(dict.get<scalar>("omega0")),
eta_(dict.get<scalar>("eta")),
sigmaExt_(dict.get<scalar>("sigmaExt")),
omegaMin_(dict.get<scalar>("omegaMin"))
{}

View File

@ -57,11 +57,8 @@ Foam::reactionRateFlameAreaModels::relaxation::relaxation
:
reactionRateFlameArea(modelType, dict, mesh, combModel),
correlation_(dict.optionalSubDict(typeName + "Coeffs").subDict(fuel_)),
C_(readScalar(dict.optionalSubDict(typeName + "Coeffs").lookup("C"))),
alpha_
(
readScalar(dict.optionalSubDict(typeName + "Coeffs").lookup("alpha"))
)
C_(dict.optionalSubDict(typeName + "Coeffs").get<scalar>("C")),
alpha_(dict.optionalSubDict(typeName + "Coeffs").get<scalar>("alpha"))
{}

View File

@ -37,7 +37,7 @@ Foam::combustionModels::PaSR<ReactionThermo>::PaSR
)
:
laminar<ReactionThermo>(modelType, thermo, turb, combustionProperties),
Cmix_(readScalar(this->coeffs().lookup("Cmix"))),
Cmix_(this->coeffs().getScalar("Cmix")),
kappa_
(
IOobject

View File

@ -49,7 +49,7 @@ diffusion<ReactionThermo, ThermoType>::diffusion
turb,
combustionProperties
),
C_(readScalar(this->coeffs().lookup("C"))),
C_(this->coeffs().getScalar("C")),
oxidantName_(this->coeffs().template lookupOrDefault<word>("oxidant", "O2"))
{}

View File

@ -48,7 +48,7 @@ eddyDissipationDiffusionModel
turb,
combustionProperties
),
Cd_(readScalar(this->coeffs().lookup("Cd")))
Cd_(this->coeffs().getScalar("Cd"))
{}

View File

@ -48,7 +48,7 @@ eddyDissipationModelBase<ReactionThermo, ThermoType>::eddyDissipationModelBase
turb,
combustionProperties
),
CEDC_(readScalar(this->coeffs().lookup("CEDC")))
CEDC_(this->coeffs().getScalar("CEDC"))
{}

View File

@ -48,7 +48,7 @@ infinitelyFastChemistry<ReactionThermo, ThermoType>::infinitelyFastChemistry
turb,
combustionProperties
),
C_(readScalar(this->coeffs().lookup("C")))
C_(this->coeffs().getScalar("C"))
{}

View File

@ -57,7 +57,7 @@ singleStepCombustion<ReactionThermo, ThermoType>::singleStepCombustion
this->mesh(),
dimensionedScalar(dimMass/dimVolume/dimTime, Zero)
),
semiImplicit_(readBool(this->coeffs_.lookup("semiImplicit")))
semiImplicit_(this->coeffs_.getBool("semiImplicit"))
{
if (isA<singleStepReactingMixture<ThermoType>>(this->thermo()))
{