From dd87c98393ee77d85a3499020b642d9b453a52f8 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Tue, 20 Nov 2018 15:14:10 +0100 Subject: [PATCH] ENH: add read guard for dimensionedType constructors (#762) - deprecate dimensionedType constructors using an Istream in favour of versions accepting a keyword and a dictionary. Dictionary entries are almost the exclusive means of read constructing a dimensionedType. By construct from the dictionary entry instead of doing a lookup() first, we can detect possible input errors such as too many tokens as a result of a input syntax error. Constructing a dimensionedType from a dictionary entry now has two forms. 1. dimensionedType(key, dims, dict); This is the constructor that will normally be used. It accepts entries with optional leading names and/or dimensions. If the entry contains dimensions, they are verified against the expected dimensions and an IOError is raised if they do not correspond. On conclusion, checks the token stream for any trailing rubbish. 2. dimensionedType(key, dict); This constructor is used less frequently. Similar to the previous description, except that it is initially dimensionless. If entry contains dimensions, they are used without further verification. The constructor also includes a token stream check. This constructor is useful when the dimensions are entirely defined from the dictionary input, but also when handling transition code where the input dimensions are not obvious from the source. This constructor can also be handy when obtaining values from a dictionary without needing to worry about the input dimensions. For example, Info<< "rho: " << dimensionedScalar("rho", dict).value() << nl; This will accept a large range of inputs without hassle. ENH: consistent handling of dimensionedType for inputs (#1083) BUG: incorrect Omega dimensions (fixes #2084) --- .../basic/laplacianFoam/createFields.H | 7 +- .../overLaplacianDyMFoam/createFields.H | 5 +- .../basic/scalarTransportFoam/createFields.H | 7 +- .../XiGModels/instabilityG/instabilityG.C | 4 +- .../SCOPE/SCOPELaminarFlameSpeed.C | 4 +- .../XiFoam/readCombustionProperties.H | 16 +-- .../electrostaticFoam/createFields.H | 8 +- .../financial/financialFoam/createFields.H | 6 +- .../liquidFilmFoam/readTransportProperties.H | 32 +---- .../sphereSurfactantFoam/createFaFields.H | 16 +-- .../surfactantFoam/createFaFields.H | 5 +- .../incompressible/icoFoam/createFields.H | 2 +- .../readGravitationalAcceleration.H | 7 +- .../solvers/lagrangian/DPMFoam/createFields.H | 5 +- .../constantSurfaceTensionCoefficient.C | 2 +- .../constant/constant.C | 19 +-- .../threePhaseInterfaceProperties.C | 4 +- .../test/parallelOverset/createFields.H | 5 +- .../applyBoundaryLayer/createFields.H | 2 +- .../preProcessing/engineSwirl/createFields.H | 30 +---- src/OpenFOAM/dimensionSet/dimensionSet.C | 20 ++- src/OpenFOAM/dimensionSet/dimensionSet.H | 35 ++--- src/OpenFOAM/dimensionSet/dimensionSets.H | 2 +- .../dimensionedType/dimensionedType.C | 126 +++++++++--------- .../dimensionedType/dimensionedType.H | 106 +++++++++++---- .../global/constants/dimensionedConstants.C | 33 +++-- .../engineTime/crankConRod/crankConRod.C | 16 +-- src/engine/include/StCorr.H | 6 +- ...ureCompressibleDensityFvPatchScalarField.C | 10 +- src/functionObjects/field/PecletNo/PecletNo.C | 2 +- .../ReynoldsAnalogy/ReynoldsAnalogy.C | 2 +- .../solidParticle/solidParticleCloud.C | 6 +- .../laminarFlameSpeed/Gulders/Gulders.C | 2 +- .../laminarFlameSpeed/GuldersEGR/GuldersEGR.C | 2 +- .../RaviPetersen/RaviPetersen.C | 2 +- .../laminarFlameSpeed/constant/constant.C | 2 +- .../laminarFlameSpeed/laminarFlameSpeed.C | 2 +- .../constantAbsorptionEmission.C | 12 +- .../constantAbsorptionEmission.H | 2 +- .../constantScatter/constantScatter.C | 10 +- .../constantScatter/constantScatter.H | 2 +- .../scatterModel/noScatter/noScatter.C | 6 - .../scatterModel/noScatter/noScatter.H | 2 +- .../mixtures/egrMixture/egrMixture.C | 4 +- .../mixtures/egrMixture/egrMixture.H | 3 +- .../inhomogeneousMixture.C | 4 +- .../inhomogeneousMixture.H | 3 +- .../singleStepReactingMixture.H | 3 +- .../veryInhomogeneousMixture.C | 2 +- .../veryInhomogeneousMixture.H | 3 +- .../constant/constantSurfaceTension.C | 2 +- .../validation/WatersKing/createFields.H | 2 +- 52 files changed, 292 insertions(+), 328 deletions(-) diff --git a/applications/solvers/basic/laplacianFoam/createFields.H b/applications/solvers/basic/laplacianFoam/createFields.H index 2c38779b3ae..dbddccb9049 100644 --- a/applications/solvers/basic/laplacianFoam/createFields.H +++ b/applications/solvers/basic/laplacianFoam/createFields.H @@ -31,11 +31,6 @@ IOdictionary transportProperties Info<< "Reading diffusivity DT\n" << endl; -dimensionedScalar DT -( - "DT", - dimArea/dimTime, - transportProperties -); +dimensionedScalar DT("DT", dimViscosity, transportProperties); #include "createFvOptions.H" diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H index d14935caab6..fc66a21b162 100644 --- a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H @@ -47,7 +47,4 @@ Info<< "Reading diffusivity DT\n" << endl; - dimensionedScalar DT - ( - transportProperties.lookup("DT") - ); + dimensionedScalar DT("DT", dimViscosity, transportProperties); diff --git a/applications/solvers/basic/scalarTransportFoam/createFields.H b/applications/solvers/basic/scalarTransportFoam/createFields.H index 390ac4e4730..ec2b2263c33 100644 --- a/applications/solvers/basic/scalarTransportFoam/createFields.H +++ b/applications/solvers/basic/scalarTransportFoam/createFields.H @@ -47,12 +47,7 @@ IOdictionary transportProperties Info<< "Reading diffusivity DT\n" << endl; -dimensionedScalar DT -( - "DT", - dimArea/dimTime, - transportProperties -); +dimensionedScalar DT("DT", dimViscosity, transportProperties); #include "createPhi.H" diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.C b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.C index a516bf0e46b..595f6887eff 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/instabilityG/instabilityG.C @@ -49,8 +49,8 @@ Foam::XiGModels::instabilityG::instabilityG ) : XiGModel(XiGProperties, thermo, turbulence, Su), - GIn_(XiGModelCoeffs_.lookup("GIn")), - lambdaIn_(XiGModelCoeffs_.lookup("lambdaIn")), + GIn_("GIn", dimless/dimTime, XiGModelCoeffs_), + lambdaIn_("lambdaIn", dimLength, XiGModelCoeffs_), XiGModel_(XiGModel::New(XiGModelCoeffs_, thermo, turbulence, Su)) {} diff --git a/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C b/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C index 97982841380..b56d31a2283 100644 --- a/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C +++ b/applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C @@ -408,7 +408,7 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const ( dimensionedScalar ( - psiuReactionThermo_.lookup("stoichiometricAirFuelMassRatio") + "stoichiometricAirFuelMassRatio", dimless, psiuReactionThermo_ )*ft/(scalar(1) - ft) ); } @@ -449,7 +449,7 @@ Foam::laminarFlameSpeedModels::SCOPE::operator()() const psiuReactionThermo_.Tu(), dimensionedScalar ( - psiuReactionThermo_.lookup("stoichiometricAirFuelMassRatio") + "stoichiometricAirFuelMassRatio", dimless, psiuReactionThermo_ )*ft/(scalar(1) - ft) ); } diff --git a/applications/solvers/combustion/XiFoam/readCombustionProperties.H b/applications/solvers/combustion/XiFoam/readCombustionProperties.H index 58b0626fb41..46c1d3ef522 100644 --- a/applications/solvers/combustion/XiFoam/readCombustionProperties.H +++ b/applications/solvers/combustion/XiFoam/readCombustionProperties.H @@ -12,34 +12,34 @@ ) ); - word SuModel + const word SuModel ( - combustionProperties.lookup("SuModel") + combustionProperties.get<word>("SuModel") ); dimensionedScalar sigmaExt ( - combustionProperties.lookup("sigmaExt") + "sigmaExt", dimless/dimTime, combustionProperties ); - word XiModel + const word XiModel ( - combustionProperties.lookup("XiModel") + combustionProperties.get<word>("XiModel") ); dimensionedScalar XiCoef ( - combustionProperties.lookup("XiCoef") + "XiCoef", dimless, combustionProperties ); dimensionedScalar XiShapeCoef ( - combustionProperties.lookup("XiShapeCoef") + "XiShapeCoef", dimless, combustionProperties ); dimensionedScalar uPrimeCoef ( - combustionProperties.lookup("uPrimeCoef") + "uPrimeCoef", dimless, combustionProperties ); ignition ign(combustionProperties, runTime, mesh); diff --git a/applications/solvers/electromagnetics/electrostaticFoam/createFields.H b/applications/solvers/electromagnetics/electrostaticFoam/createFields.H index 04c86c4edb5..e9c51b59a5b 100644 --- a/applications/solvers/electromagnetics/electrostaticFoam/createFields.H +++ b/applications/solvers/electromagnetics/electrostaticFoam/createFields.H @@ -14,12 +14,16 @@ dimensionedScalar epsilon0 ( - physicalProperties.lookup("epsilon0") + "epsilon0", + dimensionSet(-1, -3, 4, 0, 0, 2, 0), + physicalProperties ); dimensionedScalar k ( - physicalProperties.lookup("k") + "k", + dimensionSet(-1, 0, 2, 0, 0, 1, 0), + physicalProperties ); diff --git a/applications/solvers/financial/financialFoam/createFields.H b/applications/solvers/financial/financialFoam/createFields.H index a64337e794a..14bddd8adb6 100644 --- a/applications/solvers/financial/financialFoam/createFields.H +++ b/applications/solvers/financial/financialFoam/createFields.H @@ -16,21 +16,21 @@ dimensionedScalar strike ( "strike", dimLength, - financialProperties.lookup("strike") + financialProperties ); dimensionedScalar r ( "r", dimless/dimTime, - financialProperties.lookup("r") + financialProperties ); dimensionedScalar sigma ( "sigma", dimensionSet(0, 0, -0.5, 0, 0), - financialProperties.lookup("sigma") + financialProperties ); dimensionedScalar sigmaSqr = sqr(sigma); diff --git a/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H b/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H index 2f2c99ffda7..caa0fd34417 100644 --- a/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H +++ b/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H @@ -10,32 +10,12 @@ IOdictionary transportProperties ) ); -dimensionedScalar mug -( - transportProperties.lookup("mug") -); - -dimensionedScalar mul -( - transportProperties.lookup("mul") -); - -dimensionedScalar sigma -( - transportProperties.lookup("sigma") -); +dimensionedScalar mug("mug", dimViscosity, transportProperties); +dimensionedScalar mul("mul", dimViscosity, transportProperties); -dimensionedScalar rhol -( - transportProperties.lookup("rhol") -); +dimensionedScalar rhog("rhog", dimDensity, transportProperties); +dimensionedScalar rhol("rhol", dimDensity, transportProperties); -dimensionedScalar rhog -( - transportProperties.lookup("rhog") -); +dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties); -dimensionedScalar h0 -( - transportProperties.lookup("h0") -); +dimensionedScalar h0("h0", dimLength, transportProperties); diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H b/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H index b26d2888012..76ad60e90cd 100644 --- a/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H @@ -12,25 +12,13 @@ areaScalarField Cs aMesh ); -dimensioned<scalar> Cs0 -( - "Cs0", - dimensionSet(1, -2, 0, 0, 0, 0, 0), - 1.0 -); +dimensionedScalar Cs0("Cs0", dimMass/dimArea, 1.0); const areaVectorField& R = aMesh.areaCentres(); Cs = Cs0*(1.0 + R.component(vector::X)/mag(R)); - -dimensioned<scalar> Ds -( - "Ds", - dimensionSet(0, 2, -1, 0, 0, 0, 0), - 1.0 -); - +dimensionedScalar Ds("Ds", dimViscosity, 1.0); areaVectorField Us ( diff --git a/applications/solvers/finiteArea/surfactantFoam/createFaFields.H b/applications/solvers/finiteArea/surfactantFoam/createFaFields.H index a285b21cee0..2ad74fa266f 100644 --- a/applications/solvers/finiteArea/surfactantFoam/createFaFields.H +++ b/applications/solvers/finiteArea/surfactantFoam/createFaFields.H @@ -29,10 +29,7 @@ IOdictionary transportProperties Info<< "Reading diffusivity D\n" << endl; -dimensionedScalar Ds -( - transportProperties.lookup("Ds") -); +dimensionedScalar Ds("Ds", dimViscosity, transportProperties); areaVectorField Us ( diff --git a/applications/solvers/incompressible/icoFoam/createFields.H b/applications/solvers/incompressible/icoFoam/createFields.H index bdaef3a7bf6..02d916bcba9 100644 --- a/applications/solvers/incompressible/icoFoam/createFields.H +++ b/applications/solvers/incompressible/icoFoam/createFields.H @@ -16,7 +16,7 @@ dimensionedScalar nu ( "nu", dimViscosity, - transportProperties.lookup("nu") + transportProperties ); Info<< "Reading field p\n" << endl; diff --git a/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H b/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H index b960a2f6406..6443bf967e4 100644 --- a/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H +++ b/applications/solvers/incompressible/shallowWaterFoam/readGravitationalAcceleration.H @@ -12,12 +12,13 @@ IOdictionary gravitationalProperties ) ); -const dimensionedVector g(gravitationalProperties.lookup("g")); +const dimensionedVector g("g", dimAcceleration, gravitationalProperties); const bool rotating(gravitationalProperties.get<bool>("rotating")); const dimensionedVector Omega = ( - rotating ? gravitationalProperties.lookup("Omega") - : dimensionedVector("Omega", -dimTime, vector(0,0,0)) + rotating + ? dimensionedVector("Omega", dimless/dimTime, gravitationalProperties) + : dimensionedVector("Omega", dimless/dimTime, Zero) ); const dimensionedScalar magg = mag(g); const dimensionedVector gHat = g/magg; diff --git a/applications/solvers/lagrangian/DPMFoam/createFields.H b/applications/solvers/lagrangian/DPMFoam/createFields.H index 55c3608ac92..527e4651773 100644 --- a/applications/solvers/lagrangian/DPMFoam/createFields.H +++ b/applications/solvers/lagrangian/DPMFoam/createFields.H @@ -72,10 +72,7 @@ dimensionedScalar rhocValue ( IOobject::groupName("rho", continuousPhaseName), dimDensity, - continuousPhaseTransport.lookup - ( - IOobject::groupName("rho", continuousPhaseName) - ) + continuousPhaseTransport ); volScalarField rhoc diff --git a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C index 37af91206b7..31a741ef9b4 100644 --- a/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C +++ b/applications/solvers/multiphase/icoReactingMultiphaseInterFoam/phasesSystem/interfaceModels/surfaceTensionModels/constantSurfaceTensionCoefficient/constantSurfaceTensionCoefficient.C @@ -55,7 +55,7 @@ constantSurfaceTensionCoefficient ) : surfaceTensionModel(dict, pair, registerObject), - sigma_("sigma", dimensionSet(1, 0, -2, 0, 0), dict.lookup("sigma")) + sigma_("sigma", dimMass/sqr(dimTime), dict) {} diff --git a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C index f82f1f197c9..6da1c099726 100644 --- a/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C +++ b/applications/solvers/multiphase/interCondensatingEvaporatingFoam/temperaturePhaseChangeTwoPhaseMixtures/constant/constant.C @@ -53,10 +53,15 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::constant ) : temperaturePhaseChangeTwoPhaseMixture(mixture, mesh), - coeffC_(subDict(type() + "Coeffs").lookup("coeffC")), - coeffE_(subDict(type() + "Coeffs").lookup("coeffE")) -{ -} + coeffC_ + ( + "coeffC", dimless/dimTime/dimTemperature, subDict(type() + "Coeffs") + ), + coeffE_ + ( + "coeffE", dimless/dimTime/dimTemperature, subDict(type() + "Coeffs") + ) +{} // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // @@ -163,10 +168,8 @@ bool Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::read() return true; } - else - { - return false; - } + + return false; } diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C b/applications/solvers/multiphase/interFoam/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C index 03b8bc9aad4..9de37d62b82 100644 --- a/applications/solvers/multiphase/interFoam/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C +++ b/applications/solvers/multiphase/interFoam/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C @@ -160,8 +160,8 @@ Foam::threePhaseInterfaceProperties::threePhaseInterfaceProperties mixture_.alpha1().name() ).get<scalar>("cAlpha") ), - sigma12_("sigma12", dimensionSet(1, 0, -2, 0, 0), mixture), - sigma13_("sigma13", dimensionSet(1, 0, -2, 0, 0), mixture), + sigma12_("sigma12", dimMass/sqr(dimTime), mixture), + sigma13_("sigma13", dimMass/sqr(dimTime), mixture), deltaN_ ( diff --git a/applications/test/parallelOverset/createFields.H b/applications/test/parallelOverset/createFields.H index d14935caab6..fc66a21b162 100644 --- a/applications/test/parallelOverset/createFields.H +++ b/applications/test/parallelOverset/createFields.H @@ -47,7 +47,4 @@ Info<< "Reading diffusivity DT\n" << endl; - dimensionedScalar DT - ( - transportProperties.lookup("DT") - ); + dimensionedScalar DT("DT", dimViscosity, transportProperties); diff --git a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H index d82d9ffbf59..629d2746730 100644 --- a/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H +++ b/applications/utilities/preProcessing/applyBoundaryLayer/createFields.H @@ -57,7 +57,7 @@ y.correctBoundaryConditions(); // Set the mean boundary-layer thickness -dimensionedScalar ybl("ybl", dimLength, 0); +dimensionedScalar ybl("ybl", dimLength, Zero); if (args.found("ybl")) { diff --git a/applications/utilities/preProcessing/engineSwirl/createFields.H b/applications/utilities/preProcessing/engineSwirl/createFields.H index bb8b2b0d23a..5cfe5cb2fbd 100644 --- a/applications/utilities/preProcessing/engineSwirl/createFields.H +++ b/applications/utilities/preProcessing/engineSwirl/createFields.H @@ -12,35 +12,17 @@ IOdictionary engineGeometry ) ); -vector swirlAxis -( - engineGeometry.lookup("swirlAxis") -); +vector swirlAxis(engineGeometry.get<vector>("swirlAxis")); -vector swirlCenter -( - engineGeometry.lookup("swirlCenter") -); +vector swirlCenter(engineGeometry.get<vector>("swirlCenter")); -dimensionedScalar swirlRPMRatio -( - engineGeometry.lookup("swirlRPMRatio") -); +dimensionedScalar swirlRPMRatio("swirlRPMRatio", engineGeometry); -dimensionedScalar swirlProfile -( - engineGeometry.lookup("swirlProfile") -); +dimensionedScalar swirlProfile("swirlProfile", engineGeometry); -dimensionedScalar bore -( - engineGeometry.lookup("bore") -); +dimensionedScalar bore("bore", dimLength, engineGeometry); -dimensionedScalar rpm -( - engineGeometry.lookup("rpm") -); +dimensionedScalar rpm("rpm", dimless/dimTime, engineGeometry); Info<< "Reading field U\n" << endl; diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.C b/src/OpenFOAM/dimensionSet/dimensionSet.C index b9c9be7b39d..d2ec48e3f89 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSet.C +++ b/src/OpenFOAM/dimensionSet/dimensionSet.C @@ -25,19 +25,25 @@ License #include "dimensionSet.H" #include "dimensionedScalar.H" -#include "StringStream.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { -defineTypeNameAndDebug(dimensionSet, 1); -const scalar dimensionSet::smallExponent = SMALL; + defineTypeNameAndDebug(dimensionSet, 1); } +const Foam::scalar Foam::dimensionSet::smallExponent = SMALL; + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::dimensionSet::dimensionSet() +: + exponents_(Zero) +{} + + Foam::dimensionSet::dimensionSet ( const scalar mass, @@ -48,6 +54,8 @@ Foam::dimensionSet::dimensionSet const scalar current, const scalar luminousIntensity ) +: + exponents_() { exponents_[MASS] = mass; exponents_[LENGTH] = length; @@ -66,9 +74,9 @@ Foam::dimensionSet::dimensionSet(const FixedList<scalar,7>& dims) Foam::dimensionSet::dimensionSet(const dimensionSet& ds) -{ - reset(ds); -} +: + exponents_(ds.exponents_) +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/dimensionSet/dimensionSet.H b/src/OpenFOAM/dimensionSet/dimensionSet.H index c84e8c68309..7c102b852c6 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSet.H +++ b/src/OpenFOAM/dimensionSet/dimensionSet.H @@ -229,6 +229,9 @@ public: // Constructors + //- Construct null (dimensionless). + dimensionSet(); + //- Construct from exponents for the first five or all seven dimensions dimensionSet ( @@ -254,7 +257,7 @@ public: } //- Construct from Istream - dimensionSet(Istream& is); + explicit dimensionSet(Istream& is); // Member functions @@ -377,48 +380,48 @@ public: // Friend operators - friend dimensionSet operator-(const dimensionSet&); + friend dimensionSet operator-(const dimensionSet& ds); friend dimensionSet operator+ ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); friend dimensionSet operator- ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); friend dimensionSet operator* ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); friend dimensionSet operator/ ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); friend dimensionSet operator& ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); friend dimensionSet operator^ ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); friend dimensionSet operator&& ( - const dimensionSet&, - const dimensionSet& + const dimensionSet& ds1, + const dimensionSet& ds2 ); diff --git a/src/OpenFOAM/dimensionSet/dimensionSets.H b/src/OpenFOAM/dimensionSet/dimensionSets.H index cf74ae85b40..ecaa3cf8d55 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSets.H +++ b/src/OpenFOAM/dimensionSet/dimensionSets.H @@ -119,7 +119,7 @@ public: } //- (if valid) obtain set of coefficients of unitNames - void coefficients(scalarField&) const; + void coefficients(scalarField& exponents) const; }; diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index 5cf0a09c637..822113e3aa9 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -30,13 +30,12 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -void Foam::dimensioned<Type>::initialize(Istream& is) +void Foam::dimensioned<Type>::initialize(Istream& is, bool checkDims) { token nextToken(is); is.putBack(nextToken); - // Check if the original format is used in which the name is provided - // and reset the name to that read + // Optional name found - use it if (nextToken.isWord()) { is >> name_; @@ -44,26 +43,27 @@ void Foam::dimensioned<Type>::initialize(Istream& is) is.putBack(nextToken); } - // If the dimensions are provided compare with the argument - scalar multiplier = 1.0; + scalar mult(1.0); if (nextToken == token::BEGIN_SQR) { - dimensionSet dims(dimless); - dims.read(is, multiplier); + // Optional dimensions found - use them + const dimensionSet curr(dimensions_); + dimensions_.read(is, mult); - if (dims != dimensions_) + if (checkDims && curr != dimensions_) { FatalIOErrorInFunction(is) - << "The dimensions " << dims - << " provided do not match the required dimensions " - << dimensions_ + << "The dimensions " << dimensions_ + << " provided do not match the expected dimensions " + << curr << endl << abort(FatalIOError); } } + // Read value is >> value_; - value_ *= multiplier; + value_ *= mult; } @@ -124,10 +124,7 @@ Foam::dimensioned<Type>::dimensioned template<class Type> -Foam::dimensioned<Type>::dimensioned -( - Istream& is -) +Foam::dimensioned<Type>::dimensioned(Istream& is) : dimensions_(dimless) { @@ -145,10 +142,13 @@ Foam::dimensioned<Type>::dimensioned name_(name), dimensions_(dimless) { - scalar multiplier; - dimensions_.read(is, multiplier); + // Read dimensionSet + multiplier + scalar mult(1.0); + dimensions_.read(is, mult); + + // Read value is >> value_; - value_ *= multiplier; + value_ *= mult; } @@ -164,7 +164,7 @@ Foam::dimensioned<Type>::dimensioned dimensions_(dims), value_(Zero) { - initialize(is); + initialize(is, true); // checkDims } @@ -172,15 +172,32 @@ template<class Type> Foam::dimensioned<Type>::dimensioned ( const word& name, - const dimensionSet& dims, 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) { - initialize(dict.lookup(name)); + // 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); } @@ -195,12 +212,13 @@ Foam::dimensioned<Type> Foam::dimensioned<Type>::lookupOrDefault const Type& defaultValue ) { - if (dict.found(name)) - { - return dimensioned<Type>(name, dims, dict.get<Type>(name)); - } - - return dimensioned<Type>(name, dims, defaultValue); + return + dimensioned<Type> + ( + name, + dims, + dict.lookupOrDefault<Type>(name, defaultValue) + ); } @@ -326,15 +344,14 @@ bool Foam::dimensioned<Type>::readIfPresent(const dictionary& dict) template<class Type> -Foam::Istream& -Foam::dimensioned<Type>::read(Istream& is, const dictionary& readSet) +Foam::Istream& Foam::dimensioned<Type>::read(Istream& is) { // Read name is >> name_; // Read dimensionSet + multiplier - scalar mult; - dimensions_.read(is, mult, readSet); + scalar mult(1.0); + dimensions_.read(is, mult); // Read value is >> value_; @@ -346,17 +363,14 @@ Foam::dimensioned<Type>::read(Istream& is, const dictionary& readSet) template<class Type> -Foam::Istream& Foam::dimensioned<Type>::read -( - Istream& is, - const HashTable<dimensionedScalar>& readSet -) +Foam::Istream& +Foam::dimensioned<Type>::read(Istream& is, const dictionary& readSet) { // Read name is >> name_; // Read dimensionSet + multiplier - scalar mult; + scalar mult(1.0); dimensions_.read(is, mult, readSet); // Read value @@ -369,14 +383,18 @@ Foam::Istream& Foam::dimensioned<Type>::read template<class Type> -Foam::Istream& Foam::dimensioned<Type>::read(Istream& is) +Foam::Istream& Foam::dimensioned<Type>::read +( + Istream& is, + const HashTable<dimensionedScalar>& readSet +) { // Read name is >> name_; // Read dimensionSet + multiplier - scalar mult; - dimensions_.read(is, mult); + scalar mult(1.0); + dimensions_.read(is, mult, readSet); // Read value is >> value_; @@ -574,29 +592,7 @@ Foam::dimensioned<Type> Foam::min template<class Type> Foam::Istream& Foam::operator>>(Istream& is, dimensioned<Type>& dt) { - token nextToken(is); - is.putBack(nextToken); - - // Check if the original format is used in which the name is provided - // and reset the name to that read - if (nextToken.isWord()) - { - is >> dt.name_; - is >> nextToken; - is.putBack(nextToken); - } - - // If the dimensions are provided reset the dimensions to those read - scalar multiplier = 1.0; - if (nextToken == token::BEGIN_SQR) - { - dt.dimensions_.read(is, multiplier); - } - - // Read the value - is >> dt.value_; - dt.value_ *= multiplier; - + dt.initialize(is, false); // no checkDims is.check(FUNCTION_NAME); return is; } @@ -609,7 +605,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const dimensioned<Type>& dt) os << dt.name() << token::SPACE; // Write the dimensions - scalar mult; + scalar mult(1.0); dt.dimensions().write(os, mult); os << token::SPACE; diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H index b761462ab31..0b84e6cc62b 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,9 +79,16 @@ class dimensioned // Private member functions - //- Initialize from Istream - // Helper-function for constructors - void initialize(Istream& is); + //- Constructor helper. + // 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. + void initialize(Istream& is, bool checkDims); public: @@ -92,7 +99,7 @@ public: // Constructors - //- Null constructor: a dimensionless Zero, named "0" + //- Construct null: a dimensionless Zero, named "0" dimensioned(); //- A dimensioned Zero, named "0" @@ -101,7 +108,7 @@ public: //- A dimensioned Zero, named "0" explicit dimensioned(const dimensionSet& dims, const zero); - //- Construct dimensionless from given value. + //- Implicit construct dimensionless from given value. dimensioned(const Type& val) : name_(::Foam::name(val)), @@ -109,7 +116,7 @@ public: value_(val) {} - //- Copy construct a dimensioned Type with a new name + //- Copy construct dimensioned Type with a new name dimensioned(const word& name, const dimensioned<Type>& dt); //- Construct from components: name, dimensionSet and a value. @@ -120,21 +127,31 @@ public: const Type& val ); - //- Construct from Istream. - dimensioned(Istream& is); - - //- Construct from Istream with a given name - dimensioned(const word& name, Istream& is); - - //- Construct from Istream with a given name and dimensions - dimensioned(const word& name, const dimensionSet& dims, Istream& is); - - //- Construct from dictionary lookup with a given name and dimensions + //- Construct from dictionary lookup with a given name. + // 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 + // used without further verification. + // If no dimensions are found, the quantity is dimensionless. + dimensioned(const word& name, 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 + // normally verified against the expected dimensions. dimensioned ( const word& name, const dimensionSet& dims, - const dictionary& dict + const dictionary& dict, + const bool checkDims = true //!< verify dimensions read ); @@ -181,7 +198,7 @@ public: ); - // Member functions + // Member Functions //- Return const reference to name. const word& name() const; @@ -210,26 +227,29 @@ public: //- Return transpose. dimensioned<Type> T() const; - //- Update the value of dimensioned<Type> + //- Update the value of dimensioned\<Type\> void 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. bool readIfPresent(const dictionary& dict); - // I/O + // IO + + //- Read name, dimensions, value from stream, + //- using units from system table + Istream& read(Istream& is); - //- Read value from stream and units from dictionary + //- Read name, dimensions, value from stream, + //- using units from dictionary Istream& read(Istream& is, const dictionary& readSet); - //- Read value from stream and units from table + //- Read name, dimensions, value from stream, + //- using units from table Istream& read(Istream& is, const HashTable<dimensionedScalar>& readSet); - //- Read value from stream and units from system table - Istream& read(Istream& is); - - // Member operators + // Member Operators //- Return a component as a dimensioned<cmptType> dimensioned<cmptType> operator[](const direction d) const; @@ -242,6 +262,9 @@ public: // IOstream operators + //- Read from stream. The name and dimensions are optional. + // If the optional dimensions are present, they are used + // used without further verification. friend Istream& operator>> <Type> ( Istream& is, @@ -253,6 +276,33 @@ public: Ostream& os, const dimensioned<Type>& dt ); + + + // Housekeeping + + //- Deprecated(2018-11) Construct from Istream + //- (expects name, dimensions, value) + // \deprecated(2018-11) - should generally use one of the construct + // from dictionary constructors instead. They provide additional + // checks on the input stream. + explicit dimensioned(Istream& is); + + //- Deprecated(2018-11) Construct from Istream with given name + //- (expects dimensions, value) + // \deprecated(2018-11) - should generally use one of the construct + // from dictionary constructors instead. They provide additional + // checks on the input stream. + dimensioned(const word& name, Istream& is); + + //- Deprecated(2018-11) Construct from Istream with given name + //- and expected dimensions. + // Expects value, but supports optional name and dimensions. + // If the optional dimensions are present, they are read and + // verified against the expected dimensions. + // \deprecated(2018-11) - should generally use one of the construct + // from dictionary constructors instead. They provide additional + // checks on the input stream. + dimensioned(const word& name, const dimensionSet& dims, Istream& is); }; diff --git a/src/OpenFOAM/global/constants/dimensionedConstants.C b/src/OpenFOAM/global/constants/dimensionedConstants.C index 56527dbfd68..3f0e9d1c5c5 100644 --- a/src/OpenFOAM/global/constants/dimensionedConstants.C +++ b/src/OpenFOAM/global/constants/dimensionedConstants.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,16 +25,17 @@ License #include "dimensionedConstants.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { + dictionary* dimensionedConstantsPtr_(nullptr); +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -dictionary* dimensionedConstantsPtr_(nullptr); +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -dictionary& dimensionedConstants() +Foam::dictionary& Foam::dimensionedConstants() { return debug::switchSet ( @@ -44,7 +45,7 @@ dictionary& dimensionedConstants() } -dimensionedScalar dimensionedConstant +Foam::dimensionedScalar Foam::dimensionedConstant ( const word& group, const word& varName @@ -57,28 +58,24 @@ dimensionedScalar dimensionedConstant if (!dict.found("unitSet")) { - std::cerr<< "Cannot find unitSet in dictionary " << dict.name() + std::cerr + << "Cannot find unitSet in dictionary " << dict.name() << std::endl; } const word unitSetCoeffs(dict.get<word>("unitSet") + "Coeffs"); - if (!dict.found(unitSetCoeffs)) + const dictionary* unitDictPtr = dict.findDict(unitSetCoeffs); + + if (!unitDictPtr) { - std::cerr<< "Cannot find " << unitSetCoeffs << " in dictionary " + std::cerr + << "Cannot find " << unitSetCoeffs << " in dictionary " << dict.name() << std::endl; } - dictionary& unitDict = dict.subDict(unitSetCoeffs); - - dictionary& groupDict = unitDict.subDict(group); - - return dimensionedScalar(groupDict.lookup(varName)); + return dimensionedScalar(varName, unitDictPtr->subDict(group)); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/engine/engineTime/crankConRod/crankConRod.C b/src/engine/engineTime/crankConRod/crankConRod.C index ca8bb64147e..243269767ab 100644 --- a/src/engine/engineTime/crankConRod/crankConRod.C +++ b/src/engine/engineTime/crankConRod/crankConRod.C @@ -74,11 +74,11 @@ Foam::crankConRod::crankConRod systemName, constantName ), - rpm_(dict_.lookup("rpm")), - conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)), - bore_(dimensionedScalar("bore", dimLength, 0)), - stroke_(dimensionedScalar("stroke", dimLength, 0)), - clearance_(dimensionedScalar("clearance", dimLength, 0)) + rpm_("rpm", dimless/dimTime, dict_), + conRodLength_("conRodLength", dimLength, Zero), + bore_("bore", dimLength, Zero), + stroke_("stroke", dimLength, Zero), + clearance_("clearance", dimLength, Zero) { // geometric parameters are not strictly required for Time dict_.readIfPresent("conRodLength", conRodLength_); @@ -112,10 +112,8 @@ bool Foam::crankConRod::read() timeAdjustment(); return true; } - else - { - return false; - } + + return false; } diff --git a/src/engine/include/StCorr.H b/src/engine/include/StCorr.H index b49fee32627..735bd090f24 100644 --- a/src/engine/include/StCorr.H +++ b/src/engine/include/StCorr.H @@ -4,7 +4,7 @@ { // Calculate volume of ignition kernel dimensionedScalar Vk("Vk", dimVolume, gSum(c*mesh.V().field())); - dimensionedScalar Ak("Ak", dimArea, 0.0); + dimensionedScalar Ak("Ak", dimArea, Zero); if (Vk.value() > SMALL) { @@ -39,7 +39,7 @@ // Assume it is part-circular dimensionedScalar thickness ( - combustionProperties.lookup("ignitionThickness") + "ignitionThickness", dimLength, combustionProperties ); scalar circleFraction @@ -67,7 +67,7 @@ // Assume it is plane or two planes Ak = dimensionedScalar ( - combustionProperties.lookup("ignitionKernelArea") + "ignitionKernelArea", dimArea, combustionProperties ); break; } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C index cc1b0f4ff93..529c6f1aaf5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedPressureCompressibleDensity/fixedPressureCompressibleDensityFvPatchScalarField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -108,13 +108,11 @@ void Foam::fixedPressureCompressibleDensityFvPatchScalarField::updateCoeffs() const dictionary& thermoProps = db().lookupObject<IOdictionary>("thermodynamicProperties"); - const scalar rholSat = - dimensionedScalar(thermoProps.lookup("rholSat")).value(); + const scalar rholSat = dimensionedScalar("rholSat", thermoProps).value(); - const scalar pSat = - dimensionedScalar(thermoProps.lookup("pSat")).value(); + const scalar pSat = dimensionedScalar("pSat", thermoProps).value(); - const scalar psil = dimensionedScalar(thermoProps.lookup("psil")).value(); + const scalar psil = dimensionedScalar("psil", thermoProps).value(); operator==(rholSat + psil*(pp - pSat)); diff --git a/src/functionObjects/field/PecletNo/PecletNo.C b/src/functionObjects/field/PecletNo/PecletNo.C index c63524651c0..084733fe6a4 100644 --- a/src/functionObjects/field/PecletNo/PecletNo.C +++ b/src/functionObjects/field/PecletNo/PecletNo.C @@ -93,7 +93,7 @@ bool Foam::functionObjects::PecletNo::calc() IOobject::NO_WRITE ), mesh_, - dimensionedScalar(model.lookup("nu")) + dimensionedScalar("nu", dimViscosity, model) ); } else diff --git a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C index a7df02d563d..2c5de30fbe4 100644 --- a/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C +++ b/src/functionObjects/field/heatTransferCoeff/heatTransferCoeffModels/ReynoldsAnalogy/ReynoldsAnalogy.C @@ -141,7 +141,7 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::devReff() const const dictionary& transportProperties = mesh_.lookupObject<dictionary>("transportProperties"); - dimensionedScalar nu(transportProperties.lookup("nu")); + dimensionedScalar nu("nu", dimViscosity, transportProperties); const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_); diff --git a/src/lagrangian/solidParticle/solidParticleCloud.C b/src/lagrangian/solidParticle/solidParticleCloud.C index 8e1727b2391..91bd1bae090 100644 --- a/src/lagrangian/solidParticle/solidParticleCloud.C +++ b/src/lagrangian/solidParticle/solidParticleCloud.C @@ -50,9 +50,9 @@ Foam::solidParticleCloud::solidParticleCloud IOobject::NO_WRITE ) ), - rhop_(dimensionedScalar(particleProperties_.lookup("rhop")).value()), - e_(dimensionedScalar(particleProperties_.lookup("e")).value()), - mu_(dimensionedScalar(particleProperties_.lookup("mu")).value()) + rhop_(dimensionedScalar("rhop", particleProperties_).value()), + e_(dimensionedScalar("e", particleProperties_).value()), + mu_(dimensionedScalar("mu", particleProperties_).value()) { if (readFields) { diff --git a/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C b/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C index c1dbfacc4d2..445b5f893c7 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C +++ b/src/thermophysicalModels/laminarFlameSpeed/Gulders/Gulders.C @@ -222,7 +222,7 @@ Foam::laminarFlameSpeedModels::Gulders::operator()() const psiuReactionThermo_.Tu(), dimensionedScalar ( - psiuReactionThermo_.lookup("stoichiometricAirFuelMassRatio") + "stoichiometricAirFuelMassRatio", dimless, psiuReactionThermo_ )*ft/max(1 - ft, SMALL) ); } diff --git a/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C b/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C index 97c10ebb277..4b035b71935 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C +++ b/src/thermophysicalModels/laminarFlameSpeed/GuldersEGR/GuldersEGR.C @@ -226,7 +226,7 @@ Foam::laminarFlameSpeedModels::GuldersEGR::operator()() const psiuReactionThermo_.Tu(), dimensionedScalar ( - psiuReactionThermo_.lookup("stoichiometricAirFuelMassRatio") + "stoichiometricAirFuelMassRatio", dimless, psiuReactionThermo_ )/ ( scalar(1)/psiuReactionThermo_.composition().Y("ft") diff --git a/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C b/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C index 7bca4b04595..d775e1b7ae2 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C +++ b/src/thermophysicalModels/laminarFlameSpeed/RaviPetersen/RaviPetersen.C @@ -313,7 +313,7 @@ Foam::laminarFlameSpeedModels::RaviPetersen::operator()() const EqR = dimensionedScalar ( - psiuReactionThermo_.lookup("stoichiometricAirFuelMassRatio") + "stoichiometricAirFuelMassRatio", dimless, psiuReactionThermo_ )*ft/max(1 - ft, SMALL); } else diff --git a/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C b/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C index 37ba46fbb19..406a455c744 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C +++ b/src/thermophysicalModels/laminarFlameSpeed/constant/constant.C @@ -54,7 +54,7 @@ Foam::laminarFlameSpeedModels::constant::constant : laminarFlameSpeed(dict, ct), - Su_(dict.lookup("Su")) + Su_("Su", dimVelocity, dict) {} diff --git a/src/thermophysicalModels/laminarFlameSpeed/laminarFlameSpeed/laminarFlameSpeed.C b/src/thermophysicalModels/laminarFlameSpeed/laminarFlameSpeed/laminarFlameSpeed.C index 9f097c96f8a..a8267d78c1d 100644 --- a/src/thermophysicalModels/laminarFlameSpeed/laminarFlameSpeed/laminarFlameSpeed.C +++ b/src/thermophysicalModels/laminarFlameSpeed/laminarFlameSpeed/laminarFlameSpeed.C @@ -50,7 +50,7 @@ Foam::laminarFlameSpeed::laminarFlameSpeed if (!psiuReactionThermo_.composition().contains("ft")) { equivalenceRatio_ = - dimensionedScalar(dict.lookup("equivalenceRatio")).value(); + dimensionedScalar("equivalenceRatio", dimless, dict).value(); } } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C index 6fd866c6d97..df44b6a83eb 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.C @@ -54,15 +54,9 @@ Foam::radiation::constantAbsorptionEmission::constantAbsorptionEmission : absorptionEmissionModel(dict, mesh), coeffsDict_(dict.optionalSubDict(typeName + "Coeffs")), - a_(coeffsDict_.lookup("absorptivity")), - e_(coeffsDict_.lookup("emissivity")), - E_(coeffsDict_.lookup("E")) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::radiation::constantAbsorptionEmission::~constantAbsorptionEmission() + a_("absorptivity", coeffsDict_), + e_("emissivity", coeffsDict_), + E_("E", coeffsDict_) {} diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H index 18fc7f349e1..537a22bd37b 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/constantAbsorptionEmission/constantAbsorptionEmission.H @@ -84,7 +84,7 @@ public: //- Destructor - virtual ~constantAbsorptionEmission(); + virtual ~constantAbsorptionEmission() = default; // Member Functions diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C index dd552d0a668..fc99cb0189a 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.C @@ -54,14 +54,8 @@ Foam::radiation::constantScatter::constantScatter : scatterModel(dict, mesh), coeffsDict_(dict.optionalSubDict(typeName + "Coeffs")), - sigma_(coeffsDict_.lookup("sigma")), - C_(coeffsDict_.lookup("C")) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::radiation::constantScatter::~constantScatter() + sigma_("sigma", dimless/dimLength, coeffsDict_), + C_("C", dimless, coeffsDict_) {} diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H index ccf024e6b22..c7253fd884e 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/constantScatter/constantScatter.H @@ -85,7 +85,7 @@ public: //- Destructor - virtual ~constantScatter(); + virtual ~constantScatter() = default; // Member Functions diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C index 999b09866bf..b412b52bd19 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.C @@ -50,12 +50,6 @@ Foam::radiation::noScatter::noScatter {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::radiation::noScatter::~noScatter() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::tmp<Foam::volScalarField> Foam::radiation::noScatter::sigmaEff() const diff --git a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H index 2fb19569df2..b01eb9e0daa 100644 --- a/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H +++ b/src/thermophysicalModels/radiation/submodels/scatterModel/noScatter/noScatter.H @@ -69,7 +69,7 @@ public: //- Destructor - virtual ~noScatter(); + virtual ~noScatter() = default; // Member Functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.C index d5e368ca9f1..2a36c957fc8 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.C @@ -50,7 +50,7 @@ Foam::egrMixture<ThermoType>::egrMixture phaseName ), - stoicRatio_(thermoDict.lookup("stoichiometricAirFuelMassRatio")), + stoicRatio_("stoichiometricAirFuelMassRatio", dimless, thermoDict), fuel_(thermoDict.subDict("fuel")), oxidant_(thermoDict.subDict("oxidant")), @@ -101,7 +101,7 @@ const ThermoType& Foam::egrMixture<ThermoType>::mixture template<class ThermoType> void Foam::egrMixture<ThermoType>::read(const dictionary& thermoDict) { - stoicRatio_ = thermoDict.lookup("stoichiometricAirFuelMassRatio"); + thermoDict.readEntry("stoichiometricAirFuelMassRatio", stoicRatio_); fuel_ = ThermoType(thermoDict.subDict("fuel")); oxidant_ = ThermoType(thermoDict.subDict("oxidant")); diff --git a/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H index 43425d5116e..d3f64ce2748 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/egrMixture/egrMixture.H @@ -93,8 +93,7 @@ public: //- Destructor - virtual ~egrMixture() - {} + virtual ~egrMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.C index ef7d739f51a..53346cbbe16 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.C @@ -54,7 +54,7 @@ Foam::inhomogeneousMixture<ThermoType>::inhomogeneousMixture phaseName ), - stoicRatio_(thermoDict.lookup("stoichiometricAirFuelMassRatio")), + stoicRatio_("stoichiometricAirFuelMassRatio", dimless, thermoDict), fuel_(thermoDict.subDict("fuel")), oxidant_(thermoDict.subDict("oxidant")), @@ -98,7 +98,7 @@ const ThermoType& Foam::inhomogeneousMixture<ThermoType>::mixture template<class ThermoType> void Foam::inhomogeneousMixture<ThermoType>::read(const dictionary& thermoDict) { - stoicRatio_ = thermoDict.lookup("stoichiometricAirFuelMassRatio"); + thermoDict.readEntry("stoichiometricAirFuelMassRatio", stoicRatio_); fuel_ = ThermoType(thermoDict.subDict("fuel")); oxidant_ = ThermoType(thermoDict.subDict("oxidant")); diff --git a/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H index 55be584e702..28078850599 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/inhomogeneousMixture/inhomogeneousMixture.H @@ -90,8 +90,7 @@ public: //- Destructor - virtual ~inhomogeneousMixture() - {} + virtual ~inhomogeneousMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H index 22ef714a89d..0c541925add 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H @@ -129,8 +129,7 @@ public: //- Destructor - virtual ~singleStepReactingMixture() - {} + virtual ~singleStepReactingMixture() = default; // Member functions diff --git a/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.C index 28d71d5f86a..a745c41d3ac 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.C @@ -55,7 +55,7 @@ Foam::veryInhomogeneousMixture<ThermoType>::veryInhomogeneousMixture phaseName ), - stoicRatio_(thermoDict.lookup("stoichiometricAirFuelMassRatio")), + stoicRatio_("stoichiometricAirFuelMassRatio", dimless, thermoDict), fuel_(thermoDict.subDict("fuel")), oxidant_(thermoDict.subDict("oxidant")), diff --git a/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H index 390f6390add..fe662be3529 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H +++ b/src/thermophysicalModels/reactionThermo/mixtures/veryInhomogeneousMixture/veryInhomogeneousMixture.H @@ -98,8 +98,7 @@ public: //- Destructor - virtual ~veryInhomogeneousMixture() - {} + virtual ~veryInhomogeneousMixture() = default; // Member functions diff --git a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C index 82470fdba76..6277ca6153b 100644 --- a/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C +++ b/src/transportModels/interfaceProperties/surfaceTensionModels/constant/constantSurfaceTension.C @@ -48,7 +48,7 @@ Foam::surfaceTensionModels::constant::constant ) : surfaceTensionModel(mesh), - sigma_("sigma", dimensionSet(1, 0, -2, 0, 0), dict) + sigma_("sigma", dimMass/sqr(dimTime), dict) {} diff --git a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/WatersKing/createFields.H b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/WatersKing/createFields.H index 6ad317ff9be..dcc9f526564 100644 --- a/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/WatersKing/createFields.H +++ b/tutorials/incompressible/pimpleFoam/laminar/planarPoiseuille/validation/WatersKing/createFields.H @@ -15,7 +15,7 @@ const scalar nu2 = ( "nu", dimViscosity, - transportProperties.lookup("nu") + transportProperties ).value(); Info<< "Reading viscoelastic properties\n" << endl; -- GitLab