Input of dimensionedScalars: update read-construction of dimensionedScalar in applications

so that the specification of the name and dimensions are optional in property dictionaries.

Update tutorials so that the name of the dimensionedScalar property is
no longer duplicated but optional dimensions are still provided and are
checked on read.
This commit is contained in:
Henry Weller
2015-07-20 22:52:53 +01:00
parent 491d82363b
commit ecee2d275e
321 changed files with 895 additions and 1486 deletions

View File

@ -1,95 +1,99 @@
Info<< "Reading financial properties\n" << endl;
Info<< "Reading financial properties\n" << endl;
IOdictionary financialProperties
IOdictionary financialProperties
(
IOobject
(
IOobject
(
"financialProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
"financialProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
dimensionedScalar strike
dimensionedScalar strike
(
"strike",
dimLength,
financialProperties.lookup("strike")
);
dimensionedScalar r
(
"r",
dimless/dimTime,
financialProperties.lookup("r")
);
dimensionedScalar sigma
(
"sigma",
dimensionSet(0, 0, -0.5, 0, 0),
financialProperties.lookup("sigma")
);
dimensionedScalar sigmaSqr = sqr(sigma);
Info<< nl << "Reading field V" << endl;
volScalarField V
(
IOobject
(
financialProperties.lookup("strike")
);
"V",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
dimensionedScalar r
surfaceVectorField Pf
(
IOobject
(
financialProperties.lookup("r")
);
"Pf",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh.Cf()
);
dimensionedScalar sigma
volVectorField P
(
IOobject
(
financialProperties.lookup("sigma")
);
"P",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh.C()
);
dimensionedScalar sigmaSqr = sqr(sigma);
V == max
(
P.component(Foam::vector::X) - strike,
dimensionedScalar("0", V.dimensions(), 0.0)
);
Info<< nl << "Reading field V" << endl;
volScalarField V
volScalarField delta
(
IOobject
(
IOobject
(
"V",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
surfaceVectorField Pf
(
IOobject
(
"Pf",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh.Cf()
);
volVectorField P
(
IOobject
(
"P",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh.C()
);
//- V == max(strike - P.x(), dimensionedScalar("0", V.dimensions(), 0.0));
V == max
(
P.component(Foam::vector::X) - strike,
dimensionedScalar("0", V.dimensions(), 0.0)
);
volScalarField delta
(
IOobject
(
"delta",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
fvc::grad(V)().component(Foam::vector::X)
);
"delta",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
fvc::grad(V)().component(Foam::vector::X)
);

View File

@ -1,13 +1,18 @@
singlePhaseTransportModel laminarTransport(U, phi);
singlePhaseTransportModel laminarTransport(U, phi);
// Thermal expansion coefficient [1/K]
dimensionedScalar beta(laminarTransport.lookup("beta"));
// Thermal expansion coefficient [1/K]
dimensionedScalar beta
(
"beta",
dimless/dimTemperature,
laminarTransport.lookup("beta")
);
// Reference temperature [K]
dimensionedScalar TRef(laminarTransport.lookup("TRef"));
// Reference temperature [K]
dimensionedScalar TRef("TRef", dimTemperature, laminarTransport.lookup("TRef"));
// Laminar Prandtl number
dimensionedScalar Pr(laminarTransport.lookup("Pr"));
// Laminar Prandtl number
dimensionedScalar Pr("Pr", dimless, laminarTransport.lookup("Pr"));
// Turbulent Prandtl number
dimensionedScalar Prt(laminarTransport.lookup("Prt"));
// Turbulent Prandtl number
dimensionedScalar Prt("Prt", dimless, laminarTransport.lookup("Prt"));

View File

@ -1,49 +1,49 @@
Info<< "Reading field U\n" << endl;
volVectorField U
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Creating face flux\n" << endl;
surfaceScalarField phi
(
IOobject
(
"phi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
"U",
runTime.timeName(),
mesh,
dimensionedScalar("zero", mesh.Sf().dimensions()*U.dimensions(), 0.0)
);
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::RASModel> turbulence
Info<< "Creating face flux\n" << endl;
surfaceScalarField phi
(
IOobject
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
"phi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero", mesh.Sf().dimensions()*U.dimensions(), 0.0)
);
dimensionedVector Ubar(laminarTransport.lookup("Ubar"));
vector flowDirection = (Ubar/mag(Ubar)).value();
tensor flowMask = sqr(flowDirection);
singlePhaseTransportModel laminarTransport(U, phi);
dimensionedVector gradP
(
"gradP",
dimensionSet(0, 1, -2, 0, 0),
vector::zero
);
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
dimensionedVector Ubar("Ubar", dimVelocity, laminarTransport.lookup("Ubar"));
vector flowDirection = (Ubar/mag(Ubar)).value();
tensor flowMask = sqr(flowDirection);
dimensionedVector gradP
(
"gradP",
dimensionSet(0, 1, -2, 0, 0),
vector::zero
);

View File

@ -18,6 +18,8 @@
dimensionedScalar rhoInfValue
(
"rhoInf",
dimDensity,
laminarTransport.lookup("rhoInf")
);

View File

@ -1,27 +1,52 @@
Info<< "Reading thermodynamicProperties\n" << endl;
Info<< "Reading thermodynamicProperties\n" << endl;
IOdictionary thermodynamicProperties
IOdictionary thermodynamicProperties
(
IOobject
(
IOobject
(
"thermodynamicProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
"thermodynamicProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
dimensionedScalar psil(thermodynamicProperties.lookup("psil"));
dimensionedScalar psil
(
"psil",
dimCompressibility,
thermodynamicProperties.lookup("psil")
);
dimensionedScalar rholSat(thermodynamicProperties.lookup("rholSat"));
dimensionedScalar rholSat
(
"rholSat",
dimDensity,
thermodynamicProperties.lookup("rholSat")
);
dimensionedScalar psiv(thermodynamicProperties.lookup("psiv"));
dimensionedScalar psiv
(
"psiv",
dimCompressibility,
thermodynamicProperties.lookup("psiv")
);
dimensionedScalar pSat(thermodynamicProperties.lookup("pSat"));
dimensionedScalar pSat
(
"pSat",
dimPressure,
thermodynamicProperties.lookup("pSat")
);
dimensionedScalar rhovSat("rhovSat", psiv*pSat);
dimensionedScalar rhovSat("rhovSat", psiv*pSat);
dimensionedScalar rhol0("rhol0", rholSat - pSat*psil);
dimensionedScalar rhol0("rhol0", rholSat - pSat*psil);
dimensionedScalar rhoMin(thermodynamicProperties.lookup("rhoMin"));
dimensionedScalar rhoMin
(
"rhoMin",
dimDensity,
thermodynamicProperties.lookup("rhoMin")
);

View File

@ -46,7 +46,7 @@ volScalarField rho
mixture.rho()
);
dimensionedScalar pMin(mixture.lookup("pMin"));
dimensionedScalar pMin("pMin", dimPressure, mixture.lookup("pMin"));
mesh.setFluxRequired(p_rgh.name());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -152,9 +152,9 @@ Foam::incompressibleThreePhaseMixture::incompressibleThreePhaseMixture
)
),
rho1_(nuModel1_->viscosityProperties().lookup("rho")),
rho2_(nuModel2_->viscosityProperties().lookup("rho")),
rho3_(nuModel3_->viscosityProperties().lookup("rho"))
rho1_("rho", dimDensity, nuModel1_->viscosityProperties().lookup("rho")),
rho2_("rho", dimDensity, nuModel2_->viscosityProperties().lookup("rho")),
rho3_("rho", dimDensity, nuModel3_->viscosityProperties().lookup("rho"))
{
alpha3_ == 1.0 - alpha1_ - alpha2_;
calcNu();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,7 +44,7 @@ Foam::phaseChangeTwoPhaseMixture::phaseChangeTwoPhaseMixture
:
incompressibleTwoPhaseMixture(U, phi),
phaseChangeTwoPhaseMixtureCoeffs_(subDict(type + "Coeffs")),
pSat_(lookup("pSat"))
pSat_("pSat", dimPressure, lookup("pSat"))
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,7 +59,7 @@ Foam::phase::phase
phi
)
),
rho_(phaseDict_.lookup("rho"))
rho_("rho", dimDensity, phaseDict_.lookup("rho"))
{}

View File

@ -37,10 +37,10 @@ volScalarField& alpha2(mixture.alpha2());
const dimensionedScalar& rho1 = mixture.rho1();
const dimensionedScalar& rho2 = mixture.rho2();
dimensionedScalar Dab(mixture.lookup("Dab"));
dimensionedScalar Dab("Dab", dimViscosity, mixture.lookup("Dab"));
// Read the reciprocal of the turbulent Schmidt number
dimensionedScalar alphatab(mixture.lookup("alphatab"));
dimensionedScalar alphatab("alphatab", dimless, mixture.lookup("alphatab"));
// Need to store rho for ddt(rho, U)
volScalarField rho("rho", alpha1*rho1 + alpha2*rho2);