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)
This commit is contained in:
Mark Olesen
2019-01-03 13:34:11 +01:00
parent af310075a0
commit 6a448016aa
58 changed files with 443 additions and 688 deletions

View File

@ -98,26 +98,7 @@ volScalarField Qdot
#include "createMRF.H" #include "createMRF.H"
dimensionedScalar rhoMax const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
( const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
#include "createFvOptions.H" #include "createFvOptions.H"

View File

@ -180,7 +180,6 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
"Pr", "Pr",
dimless, dimless,
thermophysicalProperties.subDict("mixture").subDict("transport") thermophysicalProperties.subDict("mixture").subDict("transport")
.lookup("Pr")
); );
Field<scalar> C2 Field<scalar> C2

View File

@ -62,27 +62,7 @@ autoPtr<compressible::turbulenceModel> turbulence
#include "createMRF.H" #include "createMRF.H"
const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
dimensionedScalar rhoMax const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
#include "createFvOptions.H" #include "createFvOptions.H"

View File

@ -41,27 +41,8 @@ volVectorField U
pressureControl pressureControl(p, rho, pimple.dict(), false); pressureControl pressureControl(p, rho, pimple.dict(), false);
dimensionedScalar rhoMax const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
( const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
mesh.setFluxRequired(p.name()); mesh.setFluxRequired(p.name());

View File

@ -89,26 +89,7 @@ dimensionedScalar totalVolume = sum(mesh.V());
#include "createMRF.H" #include "createMRF.H"
#include "createRadiationModel.H" #include "createRadiationModel.H"
dimensionedScalar rhoMax const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, simple.dict());
( const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, simple.dict());
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simple.dict(),
dimDensity,
0
)
);
#include "createFvOptions.H" #include "createFvOptions.H"

View File

@ -199,31 +199,13 @@ forAll(fluidRegions, i)
rhoMax.set rhoMax.set
( (
i, i,
new dimensionedScalar new dimensionedScalar("rhoMax", dimDensity, GREAT, simpleDict)
(
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simpleDict,
dimDensity,
GREAT
)
)
); );
rhoMin.set rhoMin.set
( (
i, i,
new dimensionedScalar new dimensionedScalar("rhoMin", dimDensity, Zero, simpleDict)
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simpleDict,
dimDensity,
0
)
)
); );
Info<< " Adding MRF\n" << endl; Info<< " Adding MRF\n" << endl;

View File

@ -52,27 +52,8 @@ volVectorField U
mesh.setFluxRequired(p.name()); mesh.setFluxRequired(p.name());
dimensionedScalar rhoMax const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, simple.dict());
( const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, simple.dict());
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simple.dict(),
dimDensity,
0
)
);
Info<< "Creating turbulence model\n" << endl; Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence autoPtr<compressible::turbulenceModel> turbulence

View File

@ -53,27 +53,8 @@ volVectorField U
mesh.setFluxRequired(p.name()); mesh.setFluxRequired(p.name());
dimensionedScalar rhoMax const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, simple.dict());
( const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, simple.dict());
dimensionedScalar::lookupOrDefault
(
"rhoMax",
simple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
simple.dict(),
dimDensity,
0
)
);
Info<< "Creating turbulence model\n" << endl; Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence autoPtr<compressible::turbulenceModel> turbulence

View File

@ -52,27 +52,8 @@ volVectorField U
mesh.setFluxRequired(p.name()); mesh.setFluxRequired(p.name());
dimensionedScalar rhoMax const dimensionedScalar rhoMax("rhoMax", dimDensity, GREAT, pimple.dict());
( const dimensionedScalar rhoMin("rhoMin", dimDensity, Zero, pimple.dict());
dimensionedScalar::lookupOrDefault
(
"rhoMax",
pimple.dict(),
dimDensity,
GREAT
)
);
dimensionedScalar rhoMin
(
dimensionedScalar::lookupOrDefault
(
"rhoMin",
pimple.dict(),
dimDensity,
0
)
);
Info<< "Creating turbulence model\n" << endl; Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence autoPtr<compressible::turbulenceModel> turbulence

View File

@ -12,41 +12,16 @@ IOdictionary thermodynamicProperties
) )
); );
dimensionedScalar psil dimensionedScalar psil("psil", dimCompressibility, thermodynamicProperties);
(
"psil",
dimCompressibility,
thermodynamicProperties
);
dimensionedScalar rholSat dimensionedScalar rholSat("rholSat", dimDensity, thermodynamicProperties);
(
"rholSat",
dimDensity,
thermodynamicProperties
);
dimensionedScalar psiv dimensionedScalar psiv("psiv", dimCompressibility, thermodynamicProperties);
(
"psiv",
dimCompressibility,
thermodynamicProperties
);
dimensionedScalar pSat dimensionedScalar pSat("pSat", dimPressure, thermodynamicProperties);
(
"pSat",
dimPressure,
thermodynamicProperties
);
dimensionedScalar rhovSat("rhovSat", psiv*pSat); dimensionedScalar rhovSat("rhovSat", psiv*pSat);
dimensionedScalar rhol0("rhol0", rholSat - pSat*psil); dimensionedScalar rhol0("rhol0", rholSat - pSat*psil);
dimensionedScalar rhoMin const dimensionedScalar rhoMin("rhoMin", dimDensity, thermodynamicProperties);
(
"rhoMin",
dimDensity,
thermodynamicProperties
);

View File

@ -57,24 +57,9 @@ Foam::mixtureViscosityModels::plastic::plastic
: :
mixtureViscosityModel(name, viscosityProperties, U, phi), mixtureViscosityModel(name, viscosityProperties, U, phi),
plasticCoeffs_(viscosityProperties.optionalSubDict(modelName + "Coeffs")), plasticCoeffs_(viscosityProperties.optionalSubDict(modelName + "Coeffs")),
plasticViscosityCoeff_ plasticViscosityCoeff_("coeff", dimDynamicViscosity, plasticCoeffs_),
( plasticViscosityExponent_("exponent", dimless, plasticCoeffs_),
"coeff", muMax_("muMax", dimDynamicViscosity, plasticCoeffs_),
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")
),
alpha_ alpha_
( (
U.mesh().lookupObject<volScalarField> U.mesh().lookupObject<volScalarField>

View File

@ -204,7 +204,7 @@ Foam::InterfaceCompositionModel<Thermo, OtherThermo>::InterfaceCompositionModel
) )
) )
), ),
Le_("Le", dimless, dict.lookupOrDefault<scalar>("Le", 1.0)) Le_("Le", dimless, 1.0, dict)
{} {}

View File

@ -37,9 +37,9 @@ Foam::meltingEvaporationModels::Lee<Thermo, OtherThermo>::Lee
) )
: :
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair), InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", inv(dimTime), dict.lookup("C")), C_("C", inv(dimTime), dict),
Tactivate_("Tactivate", dimTemperature, dict.lookup("Tactivate")), Tactivate_("Tactivate", dimTemperature, dict),
alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0.0)) alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0))
{} {}

View File

@ -46,19 +46,9 @@ Foam::meltingEvaporationModels::kineticGasEvaporation<Thermo, OtherThermo>
) )
: :
InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair), InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
C_("C", dimless, dict.lookup("C")), C_("C", dimless, dict),
Tactivate_ Tactivate_("Tactivate", dimTemperature, dict),
( Mv_("Mv", dimMass/dimMoles, -1, dict),
"Tactivate",
dimTemperature,
dict.lookup("Tactivate")
),
Mv_
(
"Mv",
dimMass/dimMoles,
dict.lookupOrDefault<scalar>("Mv", -1)
),
alphaMax_(dict.lookupOrDefault<scalar>("alphaMax", 1.0)), alphaMax_(dict.lookupOrDefault<scalar>("alphaMax", 1.0)),
alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0.5)), alphaMin_(dict.lookupOrDefault<scalar>("alphaMin", 0.5)),
alphaRestMax_(dict.lookupOrDefault<scalar>("alphaRestMax", 0.01)) alphaRestMax_(dict.lookupOrDefault<scalar>("alphaRestMax", 0.01))

View File

@ -237,7 +237,7 @@ Foam::phaseSystem::phaseSystem
totalPhasePairs_(), totalPhasePairs_(),
Prt_ Prt_
( (
dimensioned<scalar>::lookupOrAddToDict dimensionedScalar::lookupOrAddToDict
( (
"Prt", *this, 1.0 "Prt", *this, 1.0
) )

View File

@ -48,54 +48,62 @@ Foam::thermoIncompressibleTwoPhaseMixture::thermoIncompressibleTwoPhaseMixture
( (
"kappa1", "kappa1",
dimEnergy/dimTime/dimLength/dimTemperature, dimEnergy/dimTime/dimLength/dimTemperature,
subDict(phase1Name_).lookup("kappa") subDict(phase1Name_),
"kappa"
), ),
kappa2_ kappa2_
( (
"kappa2", "kappa2",
kappa1_.dimensions(), kappa1_.dimensions(),
subDict(phase2Name_).lookup("kappa") subDict(phase2Name_),
"kappa"
), ),
Cp1_ Cp1_
( (
"Cp1", "Cp1",
dimEnergy/dimTemperature/dimMass, dimEnergy/dimTemperature/dimMass,
subDict(phase1Name_).lookup("Cp") subDict(phase1Name_),
"Cp"
), ),
Cp2_ Cp2_
( (
"Cp2", "Cp2",
dimEnergy/dimTemperature/dimMass, dimEnergy/dimTemperature/dimMass,
subDict(phase2Name_).lookup("Cp") subDict(phase2Name_),
"Cp"
), ),
Cv1_ Cv1_
( (
"Cv1", "Cv1",
dimEnergy/dimTemperature/dimMass, dimEnergy/dimTemperature/dimMass,
subDict(phase1Name_).lookup("Cv") subDict(phase1Name_),
"Cv"
), ),
Cv2_ Cv2_
( (
"Cv2", "Cv2",
dimEnergy/dimTemperature/dimMass, dimEnergy/dimTemperature/dimMass,
subDict(phase2Name_).lookup("Cv") subDict(phase2Name_),
"Cv"
), ),
Hf1_ Hf1_
( (
"Hf1", "Hf1",
dimEnergy/dimMass, dimEnergy/dimMass,
subDict(phase1Name_).lookup("hf") subDict(phase1Name_),
"hf"
), ),
Hf2_ Hf2_
( (
"Hf2", "Hf2",
dimEnergy/dimMass, dimEnergy/dimMass,
subDict(phase2Name_).lookup("hf") subDict(phase2Name_),
"hf"
) )
{ {

View File

@ -84,7 +84,7 @@ Foam::twoPhaseMixtureEThermo::twoPhaseMixtureEThermo
const surfaceScalarField& phi const surfaceScalarField& phi
) )
: :
basicThermo(U.mesh(), word::null), basicThermo(U.mesh(), word::null),
thermoIncompressibleTwoPhaseMixture(U, phi), thermoIncompressibleTwoPhaseMixture(U, phi),
e_ e_
@ -105,12 +105,7 @@ Foam::twoPhaseMixtureEThermo::twoPhaseMixtureEThermo
) )
), ),
TSat_ TSat_("TSat", dimTemperature, static_cast<const basicThermo&>(*this)),
(
"TSat",
dimTemperature,
basicThermo::lookup("TSat")
),
pDivU_(basicThermo::lookupOrDefault<Switch>("pDivU", true)) pDivU_(basicThermo::lookupOrDefault<Switch>("pDivU", true))

View File

@ -44,7 +44,7 @@ Foam::phaseChangeTwoPhaseMixture::phaseChangeTwoPhaseMixture
: :
incompressibleTwoPhaseMixture(U, phi), incompressibleTwoPhaseMixture(U, phi),
phaseChangeTwoPhaseMixtureCoeffs_(optionalSubDict(type + "Coeffs")), phaseChangeTwoPhaseMixtureCoeffs_(optionalSubDict(type + "Coeffs")),
pSat_("pSat", dimPressure, lookup("pSat")) pSat_("pSat", dimPressure, *this)
{} {}

View File

@ -46,18 +46,8 @@ Foam::dragModel::dragModel
interfaceDict_(interfaceDict), interfaceDict_(interfaceDict),
phase1_(phase1), phase1_(phase1),
phase2_(phase2), phase2_(phase2),
residualPhaseFraction_ residualPhaseFraction_("residualPhaseFraction", dimless, interfaceDict),
( residualSlip_("residualSlip", dimVelocity, interfaceDict)
"residualPhaseFraction",
dimless,
interfaceDict.lookup("residualPhaseFraction")
),
residualSlip_
(
"residualSlip",
dimVelocity,
interfaceDict.lookup("residualSlip")
)
{} {}

View File

@ -77,7 +77,8 @@ int main(int argc, char *argv[])
( (
"maxSlamVelocity", "maxSlamVelocity",
dimVelocity, dimVelocity,
fluid.lookupOrDefault<scalar>("maxSlamVelocity", GREAT) GREAT,
fluid
); );
turbulence->validate(); turbulence->validate();

View File

@ -57,7 +57,7 @@ Foam::phaseModel::phaseModel
nu_ nu_
( (
"nu", "nu",
dimensionSet(0, 2, -1, 0, 0), dimViscosity,
phaseDict_ phaseDict_
), ),
kappa_ kappa_
@ -69,7 +69,7 @@ Foam::phaseModel::phaseModel
Cp_ Cp_
( (
"Cp", "Cp",
dimensionSet(0, 2, -2, -1, 0), dimSpecificHeatCapacity,
phaseDict_ phaseDict_
), ),
rho_ rho_

View File

@ -58,8 +58,10 @@ NonRandomTwoLiquid
pair.phase1().mesh(), pair.phase1().mesh(),
dimensionedScalar("one", dimless, 1) dimensionedScalar("one", dimless, 1)
), ),
beta12_("", dimless/dimTemperature, 0), alpha12_("alpha12", dimless, Zero),
beta21_("", dimless/dimTemperature, 0) alpha21_("alpha21", dimless, Zero),
beta12_("beta12", dimless/dimTemperature, Zero),
beta21_("beta21", dimless/dimTemperature, Zero)
{ {
if (this->speciesNames_.size() != 2) if (this->speciesNames_.size() != 2)
{ {
@ -74,31 +76,10 @@ NonRandomTwoLiquid
species1Index_ = this->thermo_.composition().species()[species1Name_]; species1Index_ = this->thermo_.composition().species()[species1Name_];
species2Index_ = this->thermo_.composition().species()[species2Name_]; species2Index_ = this->thermo_.composition().species()[species2Name_];
alpha12_ = dimensionedScalar alpha12_.read("alpha", dict.subDict(species1Name_));
( alpha21_.read("alpha", dict.subDict(species2Name_));
"alpha12", beta12_.read("beta", dict.subDict(species1Name_));
dimless, beta21_.read("beta", dict.subDict(species2Name_));
dict.subDict(species1Name_).lookup("alpha")
);
alpha21_ = dimensionedScalar
(
"alpha21",
dimless,
dict.subDict(species2Name_).lookup("alpha")
);
beta12_ = dimensionedScalar
(
"beta12",
dimless/dimTemperature,
dict.subDict(species1Name_).lookup("beta")
);
beta21_ = dimensionedScalar
(
"beta21",
dimless/dimTemperature,
dict.subDict(species2Name_).lookup("beta")
);
saturationModel12_.reset saturationModel12_.reset
( (

View File

@ -49,7 +49,7 @@ Foam::dragModels::Beetstra::Beetstra
) )
: :
dragModel(dict, pair, registerObject), dragModel(dict, pair, registerObject),
residualRe_("residualRe", dimless, dict.lookup("residualRe")) residualRe_("residualRe", dimless, dict)
{} {}

View File

@ -50,7 +50,7 @@ Foam::dragModels::Tenneti::Tenneti
) )
: :
dragModel(dict, pair, registerObject), dragModel(dict, pair, registerObject),
residualRe_("residualRe", dimless, dict.lookup("residualRe")) residualRe_("residualRe", dimless, dict)
{} {}

View File

@ -50,11 +50,8 @@ Foam::heatTransferModel::heatTransferModel
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
dict.lookupOrDefault<scalar> pair_.dispersed().residualAlpha().value(),
( dict
"residualAlpha",
pair_.dispersed().residualAlpha().value()
)
) )
{} {}

View File

@ -57,11 +57,8 @@ Foam::swarmCorrections::TomiyamaSwarm::TomiyamaSwarm
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
dict.lookupOrDefault<scalar> pair_.dispersed().residualAlpha().value(),
( dict
"residualAlpha",
pair_.dispersed().residualAlpha().value()
)
), ),
l_("l", dimless, dict) l_("l", dimless, dict)
{} {}

View File

@ -61,11 +61,8 @@ Foam::turbulentDispersionModels::Burns::Burns
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
dict.lookupOrDefault<scalar> pair_.dispersed().residualAlpha().value(),
( dict
"residualAlpha",
pair_.dispersed().residualAlpha().value()
)
) )
{} {}

View File

@ -52,12 +52,7 @@ Foam::blendingMethods::hyperbolic::hyperbolic
) )
: :
blendingMethod(dict), blendingMethod(dict),
transitionAlphaScale_ transitionAlphaScale_("transitionAlphaScale", dimless, dict)
(
"transitionAlphaScale",
dimless,
dict.lookup("transitionAlphaScale")
)
{ {
forAllConstIter(wordList, phaseNames, iter) forAllConstIter(wordList, phaseNames, iter)
{ {
@ -66,12 +61,7 @@ Foam::blendingMethods::hyperbolic::hyperbolic
minContinuousAlpha_.insert minContinuousAlpha_.insert
( (
*iter, *iter,
dimensionedScalar dimensionedScalar(name, dimless, dict)
(
name,
dimless,
dict.lookup(name)
)
); );
} }
} }

View File

@ -63,12 +63,7 @@ Foam::blendingMethods::linear::linear
minFullyContinuousAlpha_.insert minFullyContinuousAlpha_.insert
( (
*iter, *iter,
dimensionedScalar dimensionedScalar(nameFull, dimless, dict)
(
nameFull,
dimless,
dict.lookup(nameFull)
)
); );
const word namePart const word namePart
@ -79,12 +74,7 @@ Foam::blendingMethods::linear::linear
minPartlyContinuousAlpha_.insert minPartlyContinuousAlpha_.insert
( (
*iter, *iter,
dimensionedScalar dimensionedScalar(namePart, dimless, dict)
(
namePart,
dimless,
dict.lookup(namePart)
)
); );
if if

View File

@ -66,9 +66,9 @@ Foam::phaseModel::phaseModel
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
fluid.subDict(phaseName).lookup("residualAlpha") fluid.subDict(phaseName)
), ),
alphaMax_(fluid.subDict(phaseName).lookupOrDefault("alphaMax", 1.0)) alphaMax_(fluid.subDict(phaseName).lookupOrDefault<scalar>("alphaMax", 1))
{ {
diameterModel_ = diameterModel::New(fluid.subDict(phaseName), *this); diameterModel_ = diameterModel::New(fluid.subDict(phaseName), *this);
} }

View File

@ -68,7 +68,7 @@ class phaseModel
//- Index of phase //- Index of phase
label index_; label index_;
//- Return the residual phase-fraction for given phase //- The residual phase-fraction for given phase
// Used to stabilize the phase momentum as the phase-fraction -> 0 // Used to stabilize the phase momentum as the phase-fraction -> 0
dimensionedScalar residualAlpha_; dimensionedScalar residualAlpha_;

View File

@ -49,7 +49,7 @@ JohnsonJacksonParticleSlipFvPatchVectorField
) )
: :
partialSlipFvPatchVectorField(p, iF), partialSlipFvPatchVectorField(p, iF),
specularityCoefficient_("specularityCoefficient", dimless, 0) specularityCoefficient_("specularityCoefficient", dimless, Zero)
{} {}
@ -76,12 +76,7 @@ JohnsonJacksonParticleSlipFvPatchVectorField
) )
: :
partialSlipFvPatchVectorField(p, iF), partialSlipFvPatchVectorField(p, iF),
specularityCoefficient_ specularityCoefficient_("specularityCoefficient", dimless, dict)
(
"specularityCoefficient",
dimless,
dict.lookup("specularityCoefficient")
)
{ {
if if
( (
@ -219,7 +214,6 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::updateCoeffs()
) )
.subDict("RAS") .subDict("RAS")
.subDict("kineticTheoryCoeffs") .subDict("kineticTheoryCoeffs")
.lookup("alphaMax")
); );
// calculate the slip value fraction // calculate the slip value fraction

View File

@ -48,8 +48,8 @@ JohnsonJacksonParticleThetaFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
restitutionCoefficient_("restitutionCoefficient", dimless, 0), restitutionCoefficient_("restitutionCoefficient", dimless, Zero),
specularityCoefficient_("specularityCoefficient", dimless, 0) specularityCoefficient_("specularityCoefficient", dimless, Zero)
{} {}
@ -78,18 +78,8 @@ JohnsonJacksonParticleThetaFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
restitutionCoefficient_ restitutionCoefficient_("restitutionCoefficient", dimless, dict),
( specularityCoefficient_("specularityCoefficient", dimless, dict)
"restitutionCoefficient",
dimless,
dict.lookup("restitutionCoefficient")
),
specularityCoefficient_
(
"specularityCoefficient",
dimless,
dict.lookup("specularityCoefficient")
)
{ {
if if
( (
@ -233,7 +223,6 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::updateCoeffs()
) )
.subDict("RAS") .subDict("RAS")
.subDict("kineticTheoryCoeffs") .subDict("kineticTheoryCoeffs")
.lookup("alphaMax")
); );
// calculate the reference value and the value fraction // calculate the reference value and the value fraction

View File

@ -98,25 +98,9 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel
equilibrium_(coeffDict_.lookup("equilibrium")), equilibrium_(coeffDict_.lookup("equilibrium")),
e_("e", dimless, coeffDict_), e_("e", dimless, coeffDict_),
alphaMax_("alphaMax", dimless, coeffDict_), alphaMax_("alphaMax", dimless, coeffDict_),
alphaMinFriction_ alphaMinFriction_("alphaMinFriction", dimless, coeffDict_),
( residualAlpha_("residualAlpha", dimless, coeffDict_),
"alphaMinFriction", maxNut_("maxNut", dimViscosity, 1000, coeffDict_),
dimless,
coeffDict_
),
residualAlpha_
(
"residualAlpha",
dimless,
coeffDict_
),
maxNut_
(
"maxNut",
dimensionSet(0,2,-1,0,0),
coeffDict_.lookupOrDefault<scalar>("maxNut",1000)
),
Theta_ Theta_
( (
@ -142,7 +126,7 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
U.mesh(), U.mesh(),
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) dimensionedScalar(dimViscosity, Zero)
), ),
gs0_ gs0_
@ -156,7 +140,7 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
U.mesh(), U.mesh(),
dimensionedScalar(dimensionSet(0, 0, 0, 0, 0), Zero) dimensionedScalar(dimless, Zero)
), ),
kappa_ kappa_
@ -170,7 +154,7 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
U.mesh(), U.mesh(),
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero) dimensionedScalar(dimDynamicViscosity, Zero)
), ),
nuFric_ nuFric_
@ -184,7 +168,7 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
U.mesh(), U.mesh(),
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) dimensionedScalar(dimViscosity, Zero)
) )
{ {
if (type == typeName) if (type == typeName)

View File

@ -77,12 +77,7 @@ Foam::diameterModels::IATE::IATE
), ),
dMax_("dMax", dimLength, diameterProperties_), dMax_("dMax", dimLength, diameterProperties_),
dMin_("dMin", dimLength, diameterProperties_), dMin_("dMin", dimLength, diameterProperties_),
residualAlpha_ residualAlpha_("residualAlpha", dimless, diameterProperties_),
(
"residualAlpha",
dimless,
diameterProperties_
),
d_ d_
( (
IOobject IOobject

View File

@ -50,11 +50,8 @@ Foam::heatTransferModel::heatTransferModel
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
dict.lookupOrDefault<scalar> pair_.dispersed().residualAlpha().value(),
( dict
"residualAlpha",
pair_.dispersed().residualAlpha().value()
)
) )
{} {}

View File

@ -57,11 +57,8 @@ Foam::swarmCorrections::TomiyamaSwarm::TomiyamaSwarm
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
dict.lookupOrDefault<scalar> pair_.dispersed().residualAlpha().value(),
( dict
"residualAlpha",
pair_.dispersed().residualAlpha().value()
)
), ),
l_("l", dimless, dict) l_("l", dimless, dict)
{} {}

View File

@ -61,11 +61,8 @@ Foam::turbulentDispersionModels::Burns::Burns
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
dict.lookupOrDefault<scalar> pair_.dispersed().residualAlpha().value(),
( dict
"residualAlpha",
pair_.dispersed().residualAlpha().value()
)
) )
{} {}

View File

@ -76,12 +76,7 @@ JohnsonJacksonParticleSlipFvPatchVectorField
) )
: :
partialSlipFvPatchVectorField(p, iF), partialSlipFvPatchVectorField(p, iF),
specularityCoefficient_ specularityCoefficient_("specularityCoefficient", dimless, dict)
(
"specularityCoefficient",
dimless,
dict.lookup("specularityCoefficient")
)
{ {
if if
( (
@ -219,7 +214,6 @@ void Foam::JohnsonJacksonParticleSlipFvPatchVectorField::updateCoeffs()
) )
.subDict("RAS") .subDict("RAS")
.subDict("kineticTheoryCoeffs") .subDict("kineticTheoryCoeffs")
.lookup("alphaMax")
); );
// calculate the slip value fraction // calculate the slip value fraction

View File

@ -48,8 +48,8 @@ JohnsonJacksonParticleThetaFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
restitutionCoefficient_("restitutionCoefficient", dimless, 0), restitutionCoefficient_("restitutionCoefficient", dimless, Zero),
specularityCoefficient_("specularityCoefficient", dimless, 0) specularityCoefficient_("specularityCoefficient", dimless, Zero)
{} {}
@ -78,18 +78,8 @@ JohnsonJacksonParticleThetaFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
restitutionCoefficient_ restitutionCoefficient_("restitutionCoefficient", dimless, dict),
( specularityCoefficient_("specularityCoefficient", dimless, dict)
"restitutionCoefficient",
dimless,
dict.lookup("restitutionCoefficient")
),
specularityCoefficient_
(
"specularityCoefficient",
dimless,
dict.lookup("specularityCoefficient")
)
{ {
if if
( (
@ -233,7 +223,6 @@ void Foam::JohnsonJacksonParticleThetaFvPatchScalarField::updateCoeffs()
) )
.subDict("RAS") .subDict("RAS")
.subDict("kineticTheoryCoeffs") .subDict("kineticTheoryCoeffs")
.lookup("alphaMax")
); );
// calculate the reference value and the value fraction // calculate the reference value and the value fraction

View File

@ -98,25 +98,9 @@ Foam::RASModels::kineticTheoryModel::kineticTheoryModel
equilibrium_(coeffDict_.lookup("equilibrium")), equilibrium_(coeffDict_.lookup("equilibrium")),
e_("e", dimless, coeffDict_), e_("e", dimless, coeffDict_),
alphaMax_("alphaMax", dimless, coeffDict_), alphaMax_("alphaMax", dimless, coeffDict_),
alphaMinFriction_ alphaMinFriction_("alphaMinFriction", dimless, coeffDict_),
( residualAlpha_("residualAlpha", dimless, coeffDict_),
"alphaMinFriction", maxNut_("maxNut", dimViscosity, 1000, coeffDict_),
dimless,
coeffDict_
),
residualAlpha_
(
"residualAlpha",
dimless,
coeffDict_
),
maxNut_
(
"maxNut",
dimViscosity,
coeffDict_.lookupOrDefault<scalar>("maxNut",1000)
),
Theta_ Theta_
( (

View File

@ -52,12 +52,7 @@ Foam::blendingMethods::hyperbolic::hyperbolic
) )
: :
blendingMethod(dict), blendingMethod(dict),
transitionAlphaScale_ transitionAlphaScale_("transitionAlphaScale", dimless, dict)
(
"transitionAlphaScale",
dimless,
dict.lookup("transitionAlphaScale")
)
{ {
forAllConstIter(wordList, phaseNames, iter) forAllConstIter(wordList, phaseNames, iter)
{ {
@ -66,12 +61,7 @@ Foam::blendingMethods::hyperbolic::hyperbolic
maxDispersedAlpha_.insert maxDispersedAlpha_.insert
( (
*iter, *iter,
dimensionedScalar dimensionedScalar(name, dimless, dict)
(
name,
dimless,
dict.lookup(name)
)
); );
} }
} }

View File

@ -63,12 +63,7 @@ Foam::blendingMethods::linear::linear
maxFullyDispersedAlpha_.insert maxFullyDispersedAlpha_.insert
( (
*iter, *iter,
dimensionedScalar dimensionedScalar(nameFull, dimless, dict)
(
nameFull,
dimless,
dict.lookup(nameFull)
)
); );
const word namePart const word namePart
@ -79,12 +74,7 @@ Foam::blendingMethods::linear::linear
maxPartlyDispersedAlpha_.insert maxPartlyDispersedAlpha_.insert
( (
*iter, *iter,
dimensionedScalar dimensionedScalar(namePart, dimless, dict)
(
namePart,
dimless,
dict.lookup(namePart)
)
); );
if if

View File

@ -78,12 +78,7 @@ Foam::diameterModels::IATE::IATE
), ),
dMax_("dMax", dimLength, diameterProperties_), dMax_("dMax", dimLength, diameterProperties_),
dMin_("dMin", dimLength, diameterProperties_), dMin_("dMin", dimLength, diameterProperties_),
residualAlpha_ residualAlpha_("residualAlpha", dimless, diameterProperties_),
(
"residualAlpha",
dimless,
diameterProperties_
),
d_ d_
( (
IOobject IOobject

View File

@ -70,9 +70,9 @@ Foam::phaseModel::phaseModel
( (
"residualAlpha", "residualAlpha",
dimless, dimless,
fluid.subDict(phaseName).lookup("residualAlpha") fluid.subDict(phaseName)
), ),
alphaMax_(phaseDict_.lookupOrDefault("alphaMax", 1.0)), alphaMax_(phaseDict_.lookupOrDefault<scalar>("alphaMax", 1)),
thermo_(rhoThermo::New(fluid.mesh(), name_)), thermo_(rhoThermo::New(fluid.mesh(), name_)),
U_ U_
( (

View File

@ -108,6 +108,7 @@ int main(int argc, char *argv[])
dict.add("test1", scalar(10)); dict.add("test1", scalar(10));
dict.add("test2a", scalar(21)); dict.add("test2a", scalar(21));
dict.add("test5", dimensionedScalar("", 50)); dict.add("test5", dimensionedScalar("", 50));
dict.add("carp1", dimensionedScalar("test1", 11));
// This will fail to tokenize: // This will fail to tokenize:
// dict.add("test5", dimensionedScalar(50)); // dict.add("test5", dimensionedScalar(50));
} }
@ -126,6 +127,36 @@ int main(int argc, char *argv[])
Info<< "test5 : " Info<< "test5 : "
<< dimensionedScalar::lookupOrAddToDict("test5", dict, -50) << nl; << dimensionedScalar::lookupOrAddToDict("test5", dict, -50) << nl;
// Deprecated
Info<< "Deprecated constructors" << nl;
Info<< "carp : "
<< dimensionedScalar(dict.lookup("carp1")) << nl;
Info<< "carp : "
<< dimensionedScalar("other", dict.lookup("test5")) << nl;
Info<< "carp : "
<< dimensionedScalar("carp", dimless, dict.lookup("carp1")) << nl;
Info<< "alt : "
<< dimensionedScalar("myName", dimless, dict, "carp1") << nl;
Info<< "alt : "
<< dimensionedScalar("myName", dimless, dict, "test5") << nl;
{
dimensionedScalar scalar1("myName", dimless, Zero);
scalar1.read("test5", dict);
Info<< "read in : " << scalar1 << nl;
scalar1.readIfPresent("test4", dict);
Info<< "read in : " << scalar1 << nl;
scalar1.readIfPresent("test5", dict);
Info<< "read in : " << scalar1 << nl;
}
Info<< nl << "Dictionary is now: " << dict << nl; Info<< nl << "Dictionary is now: " << dict << nl;
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,10 +27,10 @@ License
#include "pTraits.H" #include "pTraits.H"
#include "dictionary.H" #include "dictionary.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::dimensioned<Type>::initialize(Istream& is, bool checkDims) void Foam::dimensioned<Type>::initialize(Istream& is, const bool checkDims)
{ {
token nextToken(is); token nextToken(is);
is.putBack(nextToken); is.putBack(nextToken);
@ -67,13 +67,50 @@ void Foam::dimensioned<Type>::initialize(Istream& is, bool checkDims)
} }
template<class Type>
bool Foam::dimensioned<Type>::readEntry
(
const word& key,
const dictionary& dict,
const bool mandatory,
const bool checkDims,
enum keyType::option matchOpt
)
{
// Largely identical to dictionary::readEntry(),
// but with optional handling of checkDims
const auto finder(dict.csearch(key, matchOpt));
if (finder.found())
{
ITstream& is = finder.ptr()->stream();
initialize(is, checkDims);
dict.checkITstream(is, key);
return true;
}
else if (mandatory)
{
FatalIOErrorInFunction(dict)
<< "Entry '" << key << "' not found in dictionary "
<< dict.name()
<< exit(FatalIOError);
}
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::dimensioned<Type>::dimensioned() Foam::dimensioned<Type>::dimensioned()
: :
name_("0"), name_("0"),
dimensions_(dimless), dimensions_(),
value_(Zero) value_(Zero)
{} {}
@ -123,10 +160,79 @@ Foam::dimensioned<Type>::dimensioned
{} {}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const word& name,
const dictionary& dict
)
:
name_(name),
dimensions_(),
value_(Zero)
{
// mandatory, no checkDims
readEntry(name, dict, true, false);
}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const word& name,
const dimensionSet& dims,
const dictionary& dict
)
:
name_(name),
dimensions_(dims),
value_(Zero)
{
// mandatory, checkDims
readEntry(name, dict);
}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const word& name,
const dimensionSet& dims,
const dictionary& dict,
const word& entryName
)
:
name_(name),
dimensions_(dims),
value_(Zero)
{
// mandatory, checkDims
readEntry(entryName, dict);
}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const word& name,
const dimensionSet& dims,
const Type& val,
const dictionary& dict
)
:
name_(name),
dimensions_(dims),
value_(val)
{
// non-mandatory, checkDims
readEntry(name, dict, false);
}
template<class Type> template<class Type>
Foam::dimensioned<Type>::dimensioned(Istream& is) Foam::dimensioned<Type>::dimensioned(Istream& is)
: :
dimensions_(dimless) dimensions_()
{ {
read(is); read(is);
} }
@ -140,15 +246,9 @@ Foam::dimensioned<Type>::dimensioned
) )
: :
name_(name), name_(name),
dimensions_(dimless) dimensions_()
{ {
// Read dimensionSet + multiplier read(is, false); // Don't read name. Read dimensionSet + multiplier only.
scalar mult(1.0);
dimensions_.read(is, mult);
// Read value
is >> value_;
value_ *= mult;
} }
@ -164,40 +264,8 @@ Foam::dimensioned<Type>::dimensioned
dimensions_(dims), dimensions_(dims),
value_(Zero) value_(Zero)
{ {
initialize(is, true); // checkDims // checkDims
} initialize(is, true);
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const word& name,
const dictionary& dict
)
:
dimensioned<Type>(name, dimless, dict, false) // no checkDims
{}
template<class Type>
Foam::dimensioned<Type>::dimensioned
(
const word& name,
const dimensionSet& dims,
const dictionary& dict,
const bool checkDims
)
:
name_(name),
dimensions_(dims),
value_(Zero)
{
// Like dictionary::lookup(), but in two stages to detect input errors
const entry& e = dict.lookupEntry(name, keyType::REGEX);
ITstream& is = e.stream();
initialize(is, checkDims);
e.checkITstream(is);
} }
@ -212,14 +280,8 @@ Foam::dimensioned<Type> Foam::dimensioned<Type>::lookupOrDefault
const Type& defaultValue const Type& defaultValue
) )
{ {
if (dict.found(name)) // checkDims = true
{ return dimensioned<Type>(name, dims, defaultValue, dict);
return dimensioned<Type>(name, dims, dict);
}
else
{
return dimensioned<Type>(name, dims, defaultValue);
}
} }
@ -231,7 +293,7 @@ Foam::dimensioned<Type> Foam::dimensioned<Type>::lookupOrDefault
const Type& defaultValue const Type& defaultValue
) )
{ {
return lookupOrDefault(name, dict, dimless, defaultValue); return dimensioned<Type>(name, dimless, defaultValue, dict);
} }
@ -244,12 +306,13 @@ Foam::dimensioned<Type> Foam::dimensioned<Type>::lookupOrAddToDict
const Type& defaultValue const Type& defaultValue
) )
{ {
if (!dict.found(name)) if (dict.found(name))
{ {
(void) dict.add(name, defaultValue); return dimensioned<Type>(name, dims, dict);
} }
return dimensioned<Type>(name, dims, dict); (void) dict.add(name, defaultValue);
return dimensioned<Type>(name, dims, defaultValue);
} }
@ -273,6 +336,7 @@ const Foam::word& Foam::dimensioned<Type>::name() const
return name_; return name_;
} }
template<class Type> template<class Type>
Foam::word& Foam::dimensioned<Type>::name() Foam::word& Foam::dimensioned<Type>::name()
{ {
@ -286,6 +350,7 @@ const Foam::dimensionSet& Foam::dimensioned<Type>::dimensions() const
return dimensions_; return dimensions_;
} }
template<class Type> template<class Type>
Foam::dimensionSet& Foam::dimensioned<Type>::dimensions() Foam::dimensionSet& Foam::dimensioned<Type>::dimensions()
{ {
@ -299,6 +364,7 @@ const Type& Foam::dimensioned<Type>::value() const
return value_; return value_;
} }
template<class Type> template<class Type>
Type& Foam::dimensioned<Type>::value() Type& Foam::dimensioned<Type>::value()
{ {
@ -335,24 +401,51 @@ void Foam::dimensioned<Type>::replace
template<class Type> template<class Type>
void Foam::dimensioned<Type>::read(const dictionary& dict) bool Foam::dimensioned<Type>::read(const dictionary& dict)
{ {
dict.readEntry(name_, value_); return read(name_, dict);
} }
template<class Type> template<class Type>
bool Foam::dimensioned<Type>::readIfPresent(const dictionary& dict) bool Foam::dimensioned<Type>::readIfPresent(const dictionary& dict)
{ {
return dict.readIfPresent(name_, value_); return readIfPresent(name_, dict);
} }
template<class Type> template<class Type>
Foam::Istream& Foam::dimensioned<Type>::read(Istream& is) bool Foam::dimensioned<Type>::read
(
const word& entryName,
const dictionary& dict
)
{ {
// Read name // mandatory, checkDims
is >> name_; return readEntry(entryName, dict);
}
template<class Type>
bool Foam::dimensioned<Type>::readIfPresent
(
const word& entryName,
const dictionary& dict
)
{
// non-mandatory, checkDims
return readEntry(entryName, dict, false);
}
template<class Type>
Foam::Istream& Foam::dimensioned<Type>::read(Istream& is, const bool readName)
{
if (readName)
{
// Read name
is >> name_;
}
// Read dimensionSet + multiplier // Read dimensionSet + multiplier
scalar mult(1.0); scalar mult(1.0);
@ -632,17 +725,15 @@ Foam::Istream& Foam::operator>>(Istream& is, dimensioned<Type>& dt)
template<class Type> template<class Type>
Foam::Ostream& Foam::operator<<(Ostream& os, const dimensioned<Type>& dt) Foam::Ostream& Foam::operator<<(Ostream& os, const dimensioned<Type>& dt)
{ {
// Write the name // The name
os << dt.name() << token::SPACE; os << dt.name() << token::SPACE;
// Write the dimensions // The dimensions
scalar mult(1.0); scalar mult(1.0);
dt.dimensions().write(os, mult); dt.dimensions().write(os, mult);
os << token::SPACE; // The value
os << token::SPACE << dt.value()/mult;
// Write the value
os << dt.value()/mult;
os.check(FUNCTION_NAME); os.check(FUNCTION_NAME);
return os; return os;
@ -743,8 +834,8 @@ Foam::dimensioned<Type> Foam::operator/
return dimensioned<Type> return dimensioned<Type>
( (
'(' + dt.name() + '|' + ds.name() + ')', '(' + dt.name() + '|' + ds.name() + ')',
dt.dimensions()/ds.dimensions(), dt.dimensions() / ds.dimensions(),
dt.value()/ds.value() dt.value() / ds.value()
); );
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -52,10 +52,7 @@ class dictionary;
template<class Type> class dimensioned; template<class Type> class dimensioned;
template<class Type> template<class Type>
Istream& operator>>(Istream&, dimensioned<Type>&); Istream& operator>>(Istream& is, dimensioned<Type>& dt);
template<class Type>
Ostream& operator<<(Ostream&, const dimensioned<Type>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -65,9 +62,9 @@ Ostream& operator<<(Ostream&, const dimensioned<Type>&);
template<class Type> template<class Type>
class dimensioned class dimensioned
{ {
// Private data // Private Data
//- Variable name //- The variable name
word name_; word name_;
//- The dimension set //- The dimension set
@ -77,9 +74,9 @@ class dimensioned
Type value_; Type value_;
// Private member functions // Private Member Functions
//- Constructor helper. //- Read helper.
// Requires a value, optional preceded with name and/or dimensions. // Requires a value, optional preceded with name and/or dimensions.
// \verbatim // \verbatim
// [name] [dims] value // [name] [dims] value
@ -88,8 +85,28 @@ class dimensioned
// If dimensions are present, they are read. // If dimensions are present, they are read.
// With checkDims = true, the dimensions read are verified // With checkDims = true, the dimensions read are verified
// against the current (expected) dimensions. // against the current (expected) dimensions.
void initialize(Istream& is, bool checkDims); void initialize(Istream& is, const bool checkDims);
//- Find entry and assign to dimensioned Type
//- FatalIOError if it is found and the number of tokens is incorrect,
//- or it is mandatory and not found.
//
// Requires a value, optional preceded with name and/or dimensions.
// \verbatim
// [name] [dims] value
// \endverbatim
// If the name is present, it is used to rename.
// If dimensions are present, they are read.
// With checkDims = true, the dimensions read are verified
// against the current (expected) dimensions.
bool readEntry
(
const word& key,
const dictionary& dict,
const bool mandatory = true, //!< entry is mandatory
const bool checkDims = true, //!< verify dimensions read
enum keyType::option matchOpt = keyType::REGEX
);
public: public:
@ -99,7 +116,7 @@ public:
// Constructors // Constructors
//- Construct null: a dimensionless Zero, named "0" //- A dimensionless Zero, named "0"
dimensioned(); dimensioned();
//- A dimensioned Zero, named "0" //- A dimensioned Zero, named "0"
@ -119,7 +136,7 @@ public:
//- Copy construct dimensioned Type with a new name //- Copy construct dimensioned Type with a new name
dimensioned(const word& name, const dimensioned<Type>& dt); dimensioned(const word& name, const dimensioned<Type>& dt);
//- Construct from components: name, dimensionSet and a value. //- Construct from components (name, dimensions, value).
dimensioned dimensioned
( (
const word& name, const word& name,
@ -145,19 +162,48 @@ public:
// \endverbatim // \endverbatim
// If the optional name is found, it is used for renaming. // If the optional name is found, it is used for renaming.
// If the optional dimensions are present, they are read and // If the optional dimensions are present, they are read and
// normally verified against the expected dimensions. // verified against the expected dimensions.
dimensioned
(
const word& name,
const dimensionSet& dims,
const dictionary& dict
);
//- Construct from dictionary lookup with a given name and dimensions.
// The dictionary entry may contain optional name and dimensions.
// \verbatim
// [name] [dims] value
// \endverbatim
// If the optional name is found, it is used for renaming.
// If the optional dimensions are present, they are read and
// verified against the expected dimensions.
dimensioned dimensioned
( (
const word& name, const word& name,
const dimensionSet& dims, const dimensionSet& dims,
const dictionary& dict, const dictionary& dict,
const bool checkDims = true //!< verify dimensions read const word& entryName //!< dictionary lookup name
);
//- Construct from components (name, dimensions, value) with
//- optional dictionary override.
// The dictionary entry may contain optional name and dimensions.
// \verbatim
// [name] [dims] value
// \endverbatim
dimensioned
(
const word& name,
const dimensionSet& dims,
const Type& val,
const dictionary& dict
); );
// Static member functions // Static Member Functions
//- Construct from dictionary, with default dimensions and value. //- Construct dimensioned from dictionary, with default value.
//- FatalIOError if there are excess tokens. //- FatalIOError if there are excess tokens.
static dimensioned<Type> lookupOrDefault static dimensioned<Type> lookupOrDefault
( (
@ -167,7 +213,7 @@ public:
const Type& defaultValue = Type(Zero) const Type& defaultValue = Type(Zero)
); );
//- Construct from dictionary, dimensionless and with a value. //- Construct dimensionless from dictionary, with default value.
// FatalIOError if it is found and there are excess tokens. // FatalIOError if it is found and there are excess tokens.
static dimensioned<Type> lookupOrDefault static dimensioned<Type> lookupOrDefault
( (
@ -176,7 +222,7 @@ public:
const Type& defaultValue = Type(Zero) const Type& defaultValue = Type(Zero)
); );
//- Construct from dictionary, with default value. //- Construct dimensioned from dictionary, with default value.
// If the value is not found, it is added into the dictionary. // If the value is not found, it is added into the dictionary.
// FatalIOError if it is found and there are excess tokens. // FatalIOError if it is found and there are excess tokens.
static dimensioned<Type> lookupOrAddToDict static dimensioned<Type> lookupOrAddToDict
@ -187,7 +233,7 @@ public:
const Type& defaultValue = Type(Zero) const Type& defaultValue = Type(Zero)
); );
//- Construct from dictionary, dimensionless with default value. //- Construct dimensionless from dictionary, with default value.
// If the value is not found, it is added into the dictionary. // If the value is not found, it is added into the dictionary.
// FatalIOError if it is found and there are excess tokens. // FatalIOError if it is found and there are excess tokens.
static dimensioned<Type> lookupOrAddToDict static dimensioned<Type> lookupOrAddToDict
@ -227,24 +273,35 @@ public:
//- Return transpose. //- Return transpose.
dimensioned<Type> T() const; dimensioned<Type> T() const;
//- Update the value of dimensioned\<Type\> //- Update the value of dimensioned\<Type\>,
void read(const dictionary& dict); //- lookup in dictionary with the name().
bool read(const dictionary& dict);
//- Update the value of dimensioned\<Type\> if found in the dictionary. //- Update the value of dimensioned\<Type\> if found in the dictionary,
//- lookup in dictionary with the name().
bool readIfPresent(const dictionary& dict); bool readIfPresent(const dictionary& dict);
//- Update the value of dimensioned\<Type\>,
//- using an alternative entry name
bool read(const word& entryName, const dictionary& dict);
//- Update the value of dimensioned\<Type\> if found in the dictionary,
//- using an alternative entry name
bool readIfPresent(const word& entryName, const dictionary& dict);
// IO // IO
//- Read name, dimensions, value from stream, //- Read (name, dimensions, value) from stream,
//- using units from system table //- using units from system table.
Istream& read(Istream& is); // Optionally skip reading the name
Istream& read(Istream& is, const bool readName = true);
//- Read name, dimensions, value from stream, //- Read (name, dimensions, value) from stream,
//- using units from dictionary //- using units from dictionary
Istream& read(Istream& is, const dictionary& readSet); Istream& read(Istream& is, const dictionary& readSet);
//- Read name, dimensions, value from stream, //- Read (name, dimensions, value) from stream,
//- using units from table //- using units from table
Istream& read(Istream& is, const HashTable<dimensionedScalar>& readSet); Istream& read(Istream& is, const HashTable<dimensionedScalar>& readSet);
@ -265,54 +322,52 @@ public:
void operator/=(const scalar s); void operator/=(const scalar s);
// IOstream operators // IOstream Operators
//- Read from stream. The name and dimensions are optional. //- Read from stream. The name and dimensions are optional.
// If the optional dimensions are present, they are used // If the optional dimensions are present,
// used without further verification. // they are used without further verification.
friend Istream& operator>> <Type> friend Istream& operator>> <Type>
( (
Istream& is, Istream& is,
dimensioned<Type>& dt dimensioned<Type>& dt
); );
friend Ostream& operator<< <Type>
(
Ostream& os,
const dimensioned<Type>& dt
);
// Housekeeping // Housekeeping
//- Deprecated(2018-11) Construct from Istream //- Deprecated(2018-11) Construct from Istream
//- (expects name, dimensions, value) //- (expects name, dimensions, value)
// \deprecated(2018-11) - should generally use one of the construct // \deprecated(2018-11) - should generally use construct from
// from dictionary constructors instead. They provide additional // dictionary instead (additional checks on the input stream).
// checks on the input stream. explicit dimensioned(Istream& is)
explicit dimensioned(Istream& is); FOAM_DEPRECATED(2018-11);
//- Deprecated(2018-11) Construct from Istream with given name //- Deprecated(2018-11) Construct from Istream with given name
//- (expects dimensions, value) //- (expects dimensions, value)
// \deprecated(2018-11) - should generally use one of the construct // \deprecated(2018-11) - should generally use construct from
// from dictionary constructors instead. They provide additional // dictionary instead (additional checks on the input stream).
// checks on the input stream. dimensioned(const word& name, Istream& is)
dimensioned(const word& name, Istream& is); FOAM_DEPRECATED(2018-11);
//- Deprecated(2018-11) Construct from Istream with given name //- Deprecated(2018-11) Construct from Istream with given name
//- and expected dimensions. //- and expected dimensions.
// Expects value, but supports optional name and dimensions. // Expects value, but supports optional name and dimensions.
// If the optional dimensions are present, they are read and // If the optional dimensions are present, they are read and
// verified against the expected dimensions. // verified against the expected dimensions.
// \deprecated(2018-11) - should generally use one of the construct // \deprecated(2018-11) - should generally use construct from
// from dictionary constructors instead. They provide additional // dictionary instead (additional checks on the input stream).
// checks on the input stream. dimensioned(const word& name, const dimensionSet& dims, Istream& is)
dimensioned(const word& name, const dimensionSet& dims, Istream& is); FOAM_DEPRECATED(2018-11);
}; };
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
//- Output operator
template<class Type>
Ostream& operator<<(Ostream& os, const dimensioned<Type>& dt);
template<class Type, direction r> template<class Type, direction r>
dimensioned<typename powProduct<Type, r>::type> dimensioned<typename powProduct<Type, r>::type>
pow pow

View File

@ -31,13 +31,7 @@ template<class BasicTurbulenceModel>
void Foam::EddyDiffusivity<BasicTurbulenceModel>::correctNut() void Foam::EddyDiffusivity<BasicTurbulenceModel>::correctNut()
{ {
// Read Prt if provided // Read Prt if provided
Prt_ = dimensioned<scalar>::lookupOrDefault Prt_ = dimensionedScalar("Prt", dimless, 1.0, this->coeffDict());
(
"Prt",
this->coeffDict(),
1.0
);
alphat_ = this->rho_*this->nut()/Prt_; alphat_ = this->rho_*this->nut()/Prt_;
alphat_.correctBoundaryConditions(); alphat_.correctBoundaryConditions();
} }

View File

@ -248,12 +248,7 @@ void alphatJayatillekeWallFunctionFvPatchScalarField::updateCoeffs()
// Molecular Prandtl number // Molecular Prandtl number
const scalar Pr const scalar Pr
( (
dimensionedScalar dimensionedScalar("Pr", dimless, transportProperties).value()
(
"Pr",
dimless,
transportProperties.lookup("Pr")
).value()
); );
// Populate boundary values // Populate boundary values

View File

@ -61,25 +61,9 @@ Maxwell<BasicTurbulenceModel>::Maxwell
propertiesName propertiesName
), ),
nuM_ nuM_("nuM", dimViscosity, this->coeffDict_),
(
dimensioned<scalar>
(
"nuM",
dimViscosity,
this->coeffDict_.lookup("nuM")
)
),
lambda_ lambda_("lambda", dimTime, this->coeffDict_),
(
dimensioned<scalar>
(
"lambda",
dimTime,
this->coeffDict_.lookup("lambda")
)
),
sigma_ sigma_
( (

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,16 +36,7 @@ bool Foam::functionObjects::reference::calcType()
{ {
const VolFieldType& vf = *vfPtr; const VolFieldType& vf = *vfPtr;
dimensioned<Type> offset dimensioned<Type> offset("offset", vf.dimensions(), Zero, localDict_);
(
dimensioned<Type>::lookupOrDefault
(
"offset",
localDict_,
vf.dimensions(),
Zero
)
);
dimensioned<Type> cellValue("value", vf.dimensions(), Zero); dimensioned<Type> cellValue("value", vf.dimensions(), Zero);

View File

@ -385,12 +385,7 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::forces::mu() const
const dictionary& transportProperties = const dictionary& transportProperties =
lookupObject<dictionary>("transportProperties"); lookupObject<dictionary>("transportProperties");
dimensionedScalar nu dimensionedScalar nu("nu", dimViscosity, transportProperties);
(
"nu",
dimViscosity,
transportProperties.lookup("nu")
);
return rho()*nu; return rho()*nu;
} }

View File

@ -208,32 +208,16 @@ Foam::functionObjects::energyTransport::energyTransport
schemesField_("unknown-schemesField"), schemesField_("unknown-schemesField"),
fvOptions_(mesh_), fvOptions_(mesh_),
multiphaseThermo_(dict.subOrEmptyDict("phaseThermos")), multiphaseThermo_(dict.subOrEmptyDict("phaseThermos")),
Cp_ Cp_("Cp", dimEnergy/dimMass/dimTemperature, 0, dict),
(
dict.lookupOrDefault
(
"Cp",
dimensionedScalar("Cp", dimEnergy/dimMass/dimTemperature, 0)
)
),
kappa_ kappa_
( (
dict.lookupOrDefault "kappa",
( dimEnergy/dimTime/dimLength/dimTemperature,
"kappa", 0,
dimensionedScalar dict
(
"kappa",
dimEnergy/dimTime/dimLength/dimTemperature,
0
)
)
), ),
rho_ rho_("rhoInf", dimDensity, 0, dict),
( Prt_("Prt", dimless, 1, dict),
dict.lookupOrDefault("rhoInf", dimensionedScalar("rho", dimDensity, 0))
),
Prt_(dict.lookupOrDefault("Prt", dimensionedScalar("Prt", dimless, 1))),
rhoCp_ rhoCp_
( (
IOobject IOobject
@ -281,7 +265,7 @@ Foam::functionObjects::energyTransport::energyTransport
( (
"Cp", "Cp",
dimEnergy/dimMass/dimTemperature, dimEnergy/dimMass/dimTemperature,
dict.lookup("Cp") dict
) )
); );
@ -292,7 +276,7 @@ Foam::functionObjects::energyTransport::energyTransport
( (
"kappa", "kappa",
dimEnergy/dimTime/dimLength/dimTemperature, dimEnergy/dimTime/dimLength/dimTemperature,
dict.lookup("kappa") dict
) )
); );

View File

@ -63,13 +63,10 @@ solidification::solidification
), ),
maxSolidificationRate_ maxSolidificationRate_
( (
dimensioned<scalar>::lookupOrDefault "maxSolidificationRate",
( dimless/dimTime,
"maxSolidificationRate", GREAT,
coeffDict_, coeffDict_
dimless/dimTime,
GREAT
)
), ),
mass_ mass_
( (

View File

@ -56,25 +56,25 @@ Foam::compressibilityModels::Chung::Chung
( (
"psiv", "psiv",
dimCompressibility, dimCompressibility,
compressibilityProperties_.lookup("psiv") compressibilityProperties_
), ),
psil_ psil_
( (
"psil", "psil",
dimCompressibility, dimCompressibility,
compressibilityProperties_.lookup("psil") compressibilityProperties_
), ),
rhovSat_ rhovSat_
( (
"rhovSat", "rhovSat",
dimDensity, dimDensity,
compressibilityProperties_.lookup("rhovSat") compressibilityProperties_
), ),
rholSat_ rholSat_
( (
"rholSat", "rholSat",
dimDensity, dimDensity,
compressibilityProperties_.lookup("rholSat") compressibilityProperties_
) )
{ {
correct(); correct();

View File

@ -56,25 +56,25 @@ Foam::compressibilityModels::Wallis::Wallis
( (
"psiv", "psiv",
dimCompressibility, dimCompressibility,
compressibilityProperties_.lookup("psiv") compressibilityProperties_
), ),
psil_ psil_
( (
"psil", "psil",
dimCompressibility, dimCompressibility,
compressibilityProperties_.lookup("psil") compressibilityProperties_
), ),
rhovSat_ rhovSat_
( (
"rhovSat", "rhovSat",
dimDensity, dimDensity,
compressibilityProperties_.lookup("rhovSat") compressibilityProperties_
), ),
rholSat_ rholSat_
( (
"rholSat", "rholSat",
dimDensity, dimDensity,
compressibilityProperties_.lookup("rholSat") compressibilityProperties_
) )
{ {
correct(); correct();

View File

@ -56,13 +56,13 @@ Foam::compressibilityModels::linear::linear
( (
"psiv", "psiv",
dimCompressibility, dimCompressibility,
compressibilityProperties_.lookup("psiv") compressibilityProperties_
), ),
psil_ psil_
( (
"psil", "psil",
dimCompressibility, dimCompressibility,
compressibilityProperties_.lookup("psil") compressibilityProperties_
) )
{ {
correct(); correct();