Commit 6a448016 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: additional read guards for dimensionedType. input consistency (#762, #1148)

- provide a lookupOrDefault constructor form, since this is a fairly
  commonly used requirement and simplifies the calling sequence.

  Before

      dimensionedScalar rhoMax
      (
          dimensionedScalar::lookupOrDefault
          (
              "rhoMax",
              pimple.dict(),
              dimDensity,
              GREAT
          )
     );

  After

      dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());

- read, readIfPresent methods with alternative lookup names.

- Mark the Istream related constructors with compile-time deprecated
  warnings.

BUG: read, readIfPresent methods not handling optional dimensions (#1148)
parent af310075
......@@ -98,26 +98,7 @@ volScalarField Qdot
#include "createMRF.H"
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
#include "createFvOptions.H"
......@@ -180,7 +180,6 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
"Pr",
dimless,
thermophysicalProperties.subDict("mixture").subDict("transport")
.lookup("Pr")
);
Field<scalar> C2
......
......@@ -62,27 +62,7 @@ autoPtr<compressible::turbulenceModel> turbulence
#include "createMRF.H"
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
#include "createFvOptions.H"
......@@ -41,27 +41,8 @@ volVectorField U
pressureControl pressureControl(p, rho, pimple.dict(), false);
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
mesh.setFluxRequired(p.name());
......
......@@ -89,26 +89,7 @@ dimensionedScalar totalVolume = sum(mesh.V());
#include "createMRF.H"
#include "createRadiationModel.H"
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, simple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, simple.dict());
#include "createFvOptions.H"
......@@ -199,31 +199,13 @@ forAll(fluidRegions, i)
rhoMax.set
(
i,
new dimensionedScalar
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simpleDict,
dimDensity,
GREAT
)
)
new dimensionedScalar("rhoMax", dimDensity, GREAT, simpleDict)
);
rhoMin.set
(
i,
new dimensionedScalar
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simpleDict,
dimDensity,
0
)
)
new dimensionedScalar("rhoMin", dimDensity, Zero, simpleDict)
);
Info<< " Adding MRF\n" << endl;
......
......@@ -52,27 +52,8 @@ volVectorField U
mesh.setFluxRequired(p.name());
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, simple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, simple.dict());
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
......
......@@ -53,27 +53,8 @@ volVectorField U
mesh.setFluxRequired(p.name());
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, simple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, simple.dict());
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
......
......@@ -52,27 +52,8 @@ volVectorField U
mesh.setFluxRequired(p.name());
dimensionedScalar rhoMax
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
......
......@@ -12,41 +12,16 @@ IOdictionary thermodynamicProperties
)
);
dimensionedScalar psil
(
"psil",
dimCompressibility,
thermodynamicProperties
);
dimensionedScalar psil("psil", dimCompressibility, thermodynamicProperties);
dimensionedScalar rholSat
(
"rholSat",
dimDensity,
thermodynamicProperties
);
dimensionedScalar rholSat("rholSat", dimDensity, thermodynamicProperties);
dimensionedScalar psiv
(
"psiv",
dimCompressibility,
thermodynamicProperties
);
dimensionedScalar psiv("psiv", dimCompressibility, thermodynamicProperties);
dimensionedScalar pSat
(
"pSat",
dimPressure,
thermodynamicProperties
);
dimensionedScalar pSat("pSat", dimPressure, thermodynamicProperties);
dimensionedScalar rhovSat("rhovSat", psiv*pSat);
dimensionedScalar rhol0("rhol0", rholSat - pSat*psil);
dimensionedScalar rhoMin
(
"rhoMin",
dimDensity,
thermodynamicProperties
);
const dimensionedScalar rhoMin("rhoMin", dimDensity, thermodynamicProperties);
......@@ -57,24 +57,9 @@ Foam::mixtureViscosityModels::plastic::plastic
:
mixtureViscosityModel(name, viscosityProperties, U, phi),
plasticCoeffs_(viscosityProperties.optionalSubDict(modelName + "Coeffs")),
plasticViscosityCoeff_
(
"coeff",
dimensionSet(1, -1, -1, 0, 0),
plasticCoeffs_.lookup("coeff")
),
plasticViscosityExponent_
(
"exponent",
dimless,
plasticCoeffs_.lookup("exponent")
),
muMax_
(
"muMax",
dimensionSet(1, -1, -1, 0, 0),
plasticCoeffs_.lookup("muMax")
),
plasticViscosityCoeff_("coeff", dimDynamicViscosity, plasticCoeffs_),
plasticViscosityExponent_("exponent", dimless, plasticCoeffs_),
muMax_("muMax", dimDynamicViscosity, plasticCoeffs_),
alpha_
(
U.mesh().lookupObject<volScalarField>
......
......@@ -204,7 +204,7 @@ Foam::InterfaceCompositionModel<Thermo, OtherThermo>::InterfaceCompositionModel
)
)
),
Le_("Le", dimless, dict.lookupOrDefault<scalar>("Le", 1.0))
Le_("Le", dimless, 1.0, dict)
{}
......
......@@ -37,9 +37,9 @@ Foam::meltingEvaporationModels::Lee<Thermo, OtherThermo>::Lee
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", inv(dimTime), dict.lookup("C")),
Tactivate_("Tactivate", dimTemperature, dict.lookup("Tactivate")),
alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0.0))
C_("C", inv(dimTime), dict),
Tactivate_("Tactivate", dimTemperature, dict),
alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0))
{}
......
......@@ -46,19 +46,9 @@ Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
)
:
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", dimless, dict.lookup("C")),
Tactivate_
(
"Tactivate",
dimTemperature,
dict.lookup("Tactivate")
),
Mv_
(
"Mv",
dimMass/dimMoles,
dict.lookupOrDefault<scalar>("Mv", -1)
),
C_("C", dimless, dict),
Tactivate_("Tactivate", dimTemperature, dict),
Mv_("Mv", dimMass/dimMoles, -1, dict),
alphaMax_(dict.lookupOrDefault<scalar>("alphaMax", 1.0)),
alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0.5)),
alphaRestMax_(dict.lookupOrDefault<scalar>("alphaRestMax", 0.01))
......
......@@ -237,7 +237,7 @@ Foam::phaseSystem::phaseSystem
totalPhasePairs_(),
Prt_
(
dimensioned<scalar>::lookupOrAddToDict
dimensionedScalar::lookupOrAddToDict
(
"Prt", *this, 1.0
)
......
......@@ -48,54 +48,62 @@ Foam::thermoIncompressibleTwoPhaseMixture::thermoIncompressibleTwoPhaseMixture
(
"kappa1",
dimEnergy/dimTime/dimLength/dimTemperature,
subDict(phase1Name_).lookup("kappa")
subDict(phase1Name_),
"kappa"
),
kappa2_
(
"kappa2",
kappa1_.dimensions(),
subDict(phase2Name_).lookup("kappa")
subDict(phase2Name_),
"kappa"
),
Cp1_
(
"Cp1",
dimEnergy/dimTemperature/dimMass,
subDict(phase1Name_).lookup("Cp")
subDict(phase1Name_),
"Cp"
),
Cp2_
(
"Cp2",
dimEnergy/dimTemperature/dimMass,
subDict(phase2Name_).lookup("Cp")
subDict(phase2Name_),
"Cp"
),
Cv1_
(
"Cv1",
dimEnergy/dimTemperature/dimMass,
subDict(phase1Name_).lookup("Cv")
subDict(phase1Name_),
"Cv"
),
Cv2_
(
"Cv2",
dimEnergy/dimTemperature/dimMass,
subDict(phase2Name_).lookup("Cv")
subDict(phase2Name_),
"Cv"
),
Hf1_
(
"Hf1",
dimEnergy/dimMass,
subDict(phase1Name_).lookup("hf")
subDict(phase1Name_),
"hf"
),
Hf2_
(
"Hf2",
dimEnergy/dimMass,
subDict(phase2Name_).lookup("hf")
subDict(phase2Name_),
"hf"
)
{
......
......@@ -84,7 +84,7 @@ Foam::twoPhaseMixtureEThermo::twoPhaseMixtureEThermo
const surfaceScalarField& phi
)
:
basicThermo(U.mesh(), word::null),
basicThermo(U.mesh(), word::null),
thermoIncompressibleTwoPhaseMixture(U, phi),
e_
......@@ -105,12 +105,7 @@ Foam::twoPhaseMixtureEThermo::twoPhaseMixtureEThermo
)
),
TSat_
(
"TSat",
dimTemperature,
basicThermo::lookup("TSat")
),
TSat_("TSat", dimTemperature, static_cast<const basicThermo&>(*this)),
pDivU_(basicThermo::lookupOrDefault<Switch>("pDivU", true))
......
......@@ -44,7 +44,7 @@ Foam::phaseChangeTwoPhaseMixture::phaseChangeTwoPhaseMixture
:
incompressibleTwoPhaseMixture(U, phi),
phaseChangeTwoPhaseMixtureCoeffs_(optionalSubDict(type + "Coeffs")),
pSat_("pSat", dimPressure, lookup("pSat"))
pSat_("pSat", dimPressure, *this)
{}
......
......@@ -46,18 +46,8 @@ Foam::dragModel::dragModel
interfaceDict_(interfaceDict),
phase1_(phase1),
phase2_(phase2),
residualPhaseFraction_
(
"residualPhaseFraction",
dimless,
interfaceDict.lookup("residualPhaseFraction")
),
residualSlip_
(
"residualSlip",
dimVelocity,
interfaceDict.lookup("residualSlip")
)
residualPhaseFraction_("residualPhaseFraction", dimless, interfaceDict),
residualSlip_("residualSlip", dimVelocity, interfaceDict)
{}
......
......@@ -77,7 +77,8 @@ int main(int argc, char *argv[])
(
"maxSlamVelocity",
dimVelocity,
fluid.lookupOrDefault<scalar>("maxSlamVelocity", GREAT)
GREAT,
fluid
);
turbulence->validate();
......
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