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

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

View File

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