Commit 13778f76 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: use dictionary::readEntry for detection of input errors (#762, #1033)

- instead of   dict.lookup(name) >> val;
  can use      dict.readEntry(name, val);

  for checking of input token sizes.
  This helps catch certain types of input errors:

  {

      key1 ;                // <- Missing value
      key2 1234             // <- Missing ';' terminator
      key3 val;
  }

STYLE: readIfPresent() instead of 'if found ...' in a few more places.
parent 7d880758
......@@ -104,7 +104,7 @@ bool Foam::XiGModels::basicSubGrid::read(const dictionary& XiGProperties)
{
XiGModel::read(XiGProperties);
XiGModelCoeffs_.lookup("k1") >> k1;
XiGModelCoeffs_.readEntry("k1", k1);
return true;
}
......
......@@ -96,9 +96,9 @@ bool Foam::XiEqModels::Gulder::read(const dictionary& XiEqProperties)
{
XiEqModel::read(XiEqProperties);
XiEqModelCoeffs_.lookup("XiEqCoef") >> XiEqCoef_;
XiEqModelCoeffs_.lookup("uPrimeCoef") >> uPrimeCoef_;
XiEqModelCoeffs_.lookup("subGridSchelkin") >> subGridSchelkin_;
XiEqModelCoeffs_.readEntry("XiEqCoef", XiEqCoef_);
XiEqModelCoeffs_.readEntry("uPrimeCoef", uPrimeCoef_);
XiEqModelCoeffs_.readEntry("subGridSchelkin", subGridSchelkin_);
return true;
}
......
......@@ -147,11 +147,11 @@ bool Foam::XiEqModels::SCOPEXiEq::read(const dictionary& XiEqProperties)
{
XiEqModel::read(XiEqProperties);
XiEqModelCoeffs_.lookup("XiEqCoef") >> XiEqCoef_;
XiEqModelCoeffs_.lookup("XiEqExp") >> XiEqExp_;
XiEqModelCoeffs_.lookup("lCoef") >> lCoef_;
XiEqModelCoeffs_.lookup("uPrimeCoef") >> uPrimeCoef_;
XiEqModelCoeffs_.lookup("subGridSchelkin") >> subGridSchelkin_;
XiEqModelCoeffs_.readEntry("XiEqCoef", XiEqCoef_);
XiEqModelCoeffs_.readEntry("XiEqExp", XiEqExp_);
XiEqModelCoeffs_.readEntry("lCoef", lCoef_);
XiEqModelCoeffs_.readEntry("uPrimeCoef", uPrimeCoef_);
XiEqModelCoeffs_.readEntry("subGridSchelkin", subGridSchelkin_);
return true;
}
......
......@@ -73,7 +73,7 @@ bool Foam::XiEqModels::instability::read(const dictionary& XiEqProperties)
{
XiEqModel::read(XiEqProperties);
XiEqModelCoeffs_.lookup("XiEqIn") >> XiEqIn;
XiEqModelCoeffs_.readEntry("XiEqIn", XiEqIn);
return XiEqModel_->read(XiEqModelCoeffs_);
}
......
......@@ -76,7 +76,7 @@ bool Foam::XiGModels::KTS::read(const dictionary& XiGProperties)
{
XiGModel::read(XiGProperties);
XiGModelCoeffs_.lookup("GEtaCoef") >> GEtaCoef_;
XiGModelCoeffs_.readEntry("GEtaCoef", GEtaCoef_);
return true;
}
......
......@@ -86,8 +86,8 @@ bool Foam::XiGModels::instabilityG::read(const dictionary& XiGProperties)
{
XiGModel::read(XiGProperties);
XiGModelCoeffs_.lookup("GIn") >> GIn_;
XiGModelCoeffs_.lookup("lambdaIn") >> lambdaIn_;
XiGModelCoeffs_.readEntry("GIn", GIn_);
XiGModelCoeffs_.readEntry("lambdaIn", lambdaIn_);
return true;
}
......
......@@ -89,7 +89,7 @@ bool Foam::XiModels::algebraic::read(const dictionary& XiProperties)
{
XiModel::read(XiProperties);
XiModelCoeffs_.lookup("XiShapeCoef") >> XiShapeCoef;
XiModelCoeffs_.readEntry("XiShapeCoef", XiShapeCoef);
return true;
}
......
......@@ -136,7 +136,7 @@ bool Foam::XiModels::transport::read(const dictionary& XiProperties)
{
XiModel::read(XiProperties);
XiModelCoeffs_.lookup("XiShapeCoef") >> XiShapeCoef;
XiModelCoeffs_.readEntry("XiShapeCoef", XiShapeCoef);
return true;
}
......
......@@ -32,7 +32,7 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict)
if (cellSetOption::read(dict))
{
alphaSolidT_ = Function1<scalar>::New("alphaSolidT", coeffs_);
coeffs_.lookup("L") >> L_;
coeffs_.readEntry("L", L_);
coeffs_.readIfPresent("relax", relax_);
coeffs_.readIfPresent("Cu", Cu_);
coeffs_.readIfPresent("q", q_);
......
......@@ -122,8 +122,8 @@ bool Foam::incompressibleTwoPhaseInteractingMixture::read()
&& nucModel_().read(subDict(phase2Name_))
)
{
muModel_->viscosityProperties().lookup("rho") >> rhod_;
nucModel_->viscosityProperties().lookup("rho") >> rhoc_;
muModel_->viscosityProperties().readEntry("rho", rhod_);
nucModel_->viscosityProperties().readEntry("rho", rhoc_);
dd_ = dimensionedScalar
(
......
......@@ -128,9 +128,9 @@ bool Foam::mixtureViscosityModels::BinghamPlastic::read
{
plastic::read(viscosityProperties);
plasticCoeffs_.lookup("yieldStressCoeff") >> yieldStressCoeff_;
plasticCoeffs_.lookup("yieldStressExponent") >> yieldStressExponent_;
plasticCoeffs_.lookup("yieldStressOffset") >> yieldStressOffset_;
plasticCoeffs_.readEntry("yieldStressCoeff", yieldStressCoeff_);
plasticCoeffs_.readEntry("yieldStressExponent", yieldStressExponent_);
plasticCoeffs_.readEntry("yieldStressOffset", yieldStressOffset_);
return true;
}
......
......@@ -119,9 +119,9 @@ bool Foam::mixtureViscosityModels::plastic::read
plasticCoeffs_ = viscosityProperties.optionalSubDict(typeName + "Coeffs");
plasticCoeffs_.lookup("k") >> plasticViscosityCoeff_;
plasticCoeffs_.lookup("n") >> plasticViscosityExponent_;
plasticCoeffs_.lookup("muMax") >> muMax_;
plasticCoeffs_.readEntry("k", plasticViscosityCoeff_);
plasticCoeffs_.readEntry("n", plasticViscosityExponent_);
plasticCoeffs_.readEntry("muMax", muMax_);
return true;
}
......
......@@ -271,7 +271,7 @@ void Foam::multiphaseSystem::solve()
const dictionary& alphaControls = mesh.solverDict("alpha");
label nAlphaSubCycles(readLabel(alphaControls.lookup("nAlphaSubCycles")));
label nAlphaCorr(readLabel(alphaControls.lookup("nAlphaCorr")));
mesh.solverDict("alpha").lookup("cAlphas") >> cAlphas_;
mesh.solverDict("alpha").readEntry("cAlphas", cAlphas_);
// Reset ddtAlphaMax
ddtAlphaMax_ = dimensionedScalar(dimless, Zero);
......
......@@ -158,8 +158,8 @@ bool Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::read()
{
if (temperaturePhaseChangeTwoPhaseMixture::read())
{
subDict(type() + "Coeffs").lookup("coeffC") >> coeffC_;
subDict(type() + "Coeffs").lookup("coeffE") >> coeffE_;
subDict(type() + "Coeffs").readEntry("coeffC", coeffC_);
subDict(type() + "Coeffs").readEntry("coeffE", coeffE_);
return true;
}
......
......@@ -109,17 +109,17 @@ bool Foam::thermoIncompressibleTwoPhaseMixture::read()
{
if (incompressibleTwoPhaseMixture::read())
{
subDict(phase1Name_).lookup("kappa") >> kappa1_;
subDict(phase2Name_).lookup("kappa") >> kappa2_;
subDict(phase1Name_).readEntry("kappa", kappa1_);
subDict(phase2Name_).readEntry("kappa", kappa2_);
subDict(phase1Name_).lookup("Cp") >> Cp1_;
subDict(phase2Name_).lookup("Cp") >> Cp2_;
subDict(phase1Name_).readEntry("Cp", Cp1_);
subDict(phase2Name_).readEntry("Cp", Cp2_);
subDict(phase1Name_).lookup("Cv") >> Cv1_;
subDict(phase2Name_).lookup("Cv") >> Cv2_;
subDict(phase1Name_).readEntry("Cv", Cv1_);
subDict(phase2Name_).readEntry("Cv", Cv2_);
subDict(phase1Name_).lookup("hf") >> Hf1_;
subDict(phase2Name_).lookup("hf") >> Hf2_;
subDict(phase1Name_).readEntry("hf", Hf1_);
subDict(phase2Name_).readEntry("hf", Hf2_);
return true;
}
......
......@@ -581,14 +581,12 @@ bool Foam::twoPhaseMixtureEThermo::read()
{
if (basicThermo::read() && thermoIncompressibleTwoPhaseMixture::read())
{
basicThermo::lookup("pDivU") >> pDivU_;
basicThermo::lookup("TSat") >> TSat_;
basicThermo::readEntry("pDivU", pDivU_);
basicThermo::readEntry("TSat", TSat_);
return true;
}
else
{
return false;
}
return false;
}
......
......@@ -231,9 +231,9 @@ bool Foam::incompressibleThreePhaseMixture::read()
&& nuModel3_().read(*this)
)
{
nuModel1_->viscosityProperties().lookup("rho") >> rho1_;
nuModel2_->viscosityProperties().lookup("rho") >> rho2_;
nuModel3_->viscosityProperties().lookup("rho") >> rho3_;
nuModel1_->viscosityProperties().readEntry("rho", rho1_);
nuModel2_->viscosityProperties().readEntry("rho", rho2_);
nuModel3_->viscosityProperties().readEntry("rho", rho3_);
return true;
}
......
......@@ -104,10 +104,10 @@ bool Foam::phaseChangeTwoPhaseMixtures::Kunz::read()
{
phaseChangeTwoPhaseMixtureCoeffs_ = optionalSubDict(type() + "Coeffs");
phaseChangeTwoPhaseMixtureCoeffs_.lookup("UInf") >> UInf_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("tInf") >> tInf_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cc") >> Cc_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cv") >> Cv_;
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("UInf", UInf_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("tInf", tInf_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("Cc", Cc_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("Cv", Cv_);
mcCoeff_ = Cc_*rho2()/tInf_;
mvCoeff_ = Cv_*rho2()/(0.5*rho1()*sqr(UInf_)*tInf_);
......
......@@ -99,10 +99,10 @@ bool Foam::phaseChangeTwoPhaseMixtures::Merkle::read()
{
phaseChangeTwoPhaseMixtureCoeffs_ = optionalSubDict(type() + "Coeffs");
phaseChangeTwoPhaseMixtureCoeffs_.lookup("UInf") >> UInf_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("tInf") >> tInf_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cc") >> Cc_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cv") >> Cv_;
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("UInf", UInf_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("tInf", tInf_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("Cc", Cc_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("Cv", Cv_);
mcCoeff_ = Cc_/(0.5*sqr(UInf_)*tInf_);
mvCoeff_ = Cv_*rho1()/(0.5*sqr(UInf_)*tInf_*rho2());
......
......@@ -153,10 +153,10 @@ bool Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::read()
{
phaseChangeTwoPhaseMixtureCoeffs_ = optionalSubDict(type() + "Coeffs");
phaseChangeTwoPhaseMixtureCoeffs_.lookup("n") >> n_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("dNuc") >> dNuc_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cc") >> Cc_;
phaseChangeTwoPhaseMixtureCoeffs_.lookup("Cv") >> Cv_;
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("n", n_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("dNuc", dNuc_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("Cc", Cc_);
phaseChangeTwoPhaseMixtureCoeffs_.readEntry("Cv", Cv_);
return true;
}
......
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