Commit 2251d431 authored by Andrew Heather's avatar Andrew Heather
Browse files

added lookupOrAddDefault and readIfPresent functions

parent 98735abb
......@@ -55,9 +55,11 @@ DeardorffDiffStress::DeardorffDiffStress
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenSGSStress(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookup("ck")),
cm_(LESmodelProperties().lookup("cm"))
{}
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.094)),
cm_(LESmodelProperties().lookupOrAddDefault<scalar>("cm", 4.13))
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -111,8 +113,8 @@ bool DeardorffDiffStress::read()
{
if (GenSGSStress::read())
{
LESmodelProperties().lookup("ck") >> ck_;
LESmodelProperties().lookup("cm") >> cm_;
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
LESmodelProperties().readIfPresent<scalar>("cm", cm_);
return true;
}
......
......@@ -75,8 +75,8 @@ class DeardorffDiffStress
{
// Private data
dimensionedScalar ck_;
dimensionedScalar cm_;
scalar ck_;
scalar cm_;
// Private Member Functions
......@@ -114,7 +114,7 @@ public:
//- Return the effective diffusivity for B
tmp<volScalarField> DBEff() const
{
return tmp<volScalarField>
return tmp<volScalarField>
(
new volScalarField("DBEff", muSgs_ + mu())
);
......
......@@ -51,7 +51,7 @@ GenEddyVisc::GenEddyVisc
word("GenEddyVisc"), rho, U, phi, thermoPhysicalModel
),
ce_(LESmodelProperties().lookup("ce")),
ce_(LESmodelProperties().lookupOrAddDefault<scalar>("ce", 1.048)),
k_
(
......@@ -78,7 +78,9 @@ GenEddyVisc::GenEddyVisc
),
mesh_
)
{}
{
// printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -114,7 +116,7 @@ bool GenEddyVisc::read()
{
if (LESmodel::read())
{
LESmodelProperties().lookup("ce") >> ce_;
LESmodelProperties().readIfPresent<scalar>("ce", ce_);
return true;
}
......
......@@ -68,7 +68,7 @@ class GenEddyVisc
protected:
dimensionedScalar ce_;
scalar ce_;
volScalarField k_;
volScalarField muSgs_;
......
......@@ -55,7 +55,7 @@ GenSGSStress::GenSGSStress
thermoPhysicalModel
),
ce_(LESmodelProperties().lookup("ce")),
ce_(LESmodelProperties().lookupOrAddDefault<scalar>("ce" ,1.048)),
B_
(
......@@ -82,7 +82,9 @@ GenSGSStress::GenSGSStress
),
mesh_
)
{}
{
// printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -129,7 +131,7 @@ bool GenSGSStress::read()
{
if (LESmodel::read())
{
LESmodelProperties().lookup("ce") >> ce_;
LESmodelProperties().readIfPresent<scalar>("ce", ce_);
return true;
}
......
......@@ -69,7 +69,7 @@ class GenSGSStress
protected:
dimensionedScalar ce_;
scalar ce_;
volSymmTensorField B_;
volScalarField muSgs_;
......
......@@ -39,7 +39,18 @@ namespace compressible
defineTypeNameAndDebug(LESmodel, 0);
defineRunTimeSelectionTable(LESmodel, dictionary);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void LESmodel::printCoeffs()
{
if (printCoeffs_)
{
Info<< LESmodelProperties_;
}
}
// * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * * //
LESmodel::LESmodel
(
......@@ -70,6 +81,7 @@ LESmodel::LESmodel
phi_(phi),
thermoPhysicalModel_(thermoPhysicalModel),
printCoeffs_(lookupOrDefault<Switch>("printCoeffs", false)),
LESmodelProperties_(subDict(type + "Coeffs")),
k0_("k0", dimVelocity*dimVelocity, SMALL),
......
......@@ -93,6 +93,7 @@ private:
const basicThermo& thermoPhysicalModel_;
Switch printCoeffs_;
dictionary LESmodelProperties_;
dimensionedScalar k0_;
......@@ -107,6 +108,14 @@ private:
LESmodel& operator=(const LESmodel&);
protected:
// Protected Member Functions
//- Print model coefficients
virtual void printCoeffs();
public:
//- Runtime type information
......@@ -191,7 +200,7 @@ public:
//- Access the dictionary which provides info. about choice of
// models, and all related data (particularly model coefficients).
inline const dictionary& LESmodelProperties()
inline dictionary& LESmodelProperties()
{
return LESmodelProperties_;
}
......
......@@ -55,8 +55,10 @@ Smagorinsky::Smagorinsky
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenEddyVisc(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookup("ck"))
{}
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.02))
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -82,7 +84,7 @@ bool Smagorinsky::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().lookup("ck") >> ck_;
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
return true;
}
......
......@@ -71,7 +71,7 @@ class Smagorinsky
{
// Private data
dimensionedScalar ck_;
scalar ck_;
// Private Member Functions
......
......@@ -104,17 +104,17 @@ SpalartAllmaras::SpalartAllmaras
:
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
alphaNut_(LESmodelProperties().lookup("alphaNut")),
Cb1_(LESmodelProperties().lookup("Cb1")),
Cb2_(LESmodelProperties().lookup("Cb2")),
Cv1_(LESmodelProperties().lookup("Cv1")),
Cv2_(LESmodelProperties().lookup("Cv2")),
CDES_(LESmodelProperties().lookup("CDES")),
ck_(LESmodelProperties().lookup("ck")),
kappa_(lookup("kappa")),
alphaNut_(LESmodelProperties().lookupOrAddDefault<scalar>("alphaNut", 1.5)),
Cb1_(LESmodelProperties().lookupOrAddDefault<scalar>("Cb1", 0.1355)),
Cb2_(LESmodelProperties().lookupOrAddDefault<scalar>("Cb2", 0.622)),
Cv1_(LESmodelProperties().lookupOrAddDefault<scalar>("Cv1", 7.1)),
Cv2_(LESmodelProperties().lookupOrAddDefault<scalar>("Cv2", 5.0)),
CDES_(LESmodelProperties().lookupOrAddDefault<scalar>("CDES", 0.65)),
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.07)),
kappa_(lookupOrAddDefault<scalar>("kappa", 0.4187)),
Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)),
Cw2_(LESmodelProperties().lookup("Cw2")),
Cw3_(LESmodelProperties().lookup("Cw3")),
Cw2_(LESmodelProperties().lookupOrAddDefault<scalar>("Cw2", 0.3)),
Cw3_(LESmodelProperties().lookupOrAddDefault<scalar>("Cw3", 2.0)),
nuTilda_
(
......@@ -143,7 +143,9 @@ SpalartAllmaras::SpalartAllmaras
mesh_
)
{}
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -216,18 +218,18 @@ bool SpalartAllmaras::read()
{
if (LESmodel::read())
{
LESmodelProperties().lookup("alphaNut") >> alphaNut_;
LESmodelProperties().lookup("Cb1") >> Cb1_;
LESmodelProperties().lookup("Cb2") >> Cb2_;
LESmodelProperties().readIfPresent<scalar>("alphaNut", alphaNut_);
LESmodelProperties().readIfPresent<scalar>("Cb1", Cb1_);
LESmodelProperties().readIfPresent<scalar>("Cb2", Cb2_);
Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_);
LESmodelProperties().lookup("Cw2") >> Cw2_;
LESmodelProperties().lookup("Cw3") >> Cw3_;
LESmodelProperties().lookup("Cv1") >> Cv1_;
LESmodelProperties().lookup("Cv2") >> Cv2_;
LESmodelProperties().lookup("CDES") >> CDES_;
LESmodelProperties().lookup("ck") >> ck_;
lookup("kappa") >> kappa_;
LESmodelProperties().readIfPresent<scalar>("Cw2", Cw2_);
LESmodelProperties().readIfPresent<scalar>("Cw3", Cw3_);
LESmodelProperties().readIfPresent<scalar>("Cv1", Cv1_);
LESmodelProperties().readIfPresent<scalar>("Cv2", Cv2_);
LESmodelProperties().readIfPresent<scalar>("CDES", CDES_);
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
readIfPresent<scalar>("kappa", kappa_);
return true;
}
else
......
......@@ -58,18 +58,18 @@ class SpalartAllmaras
{
// Private data
dimensionedScalar alphaNut_;
scalar alphaNut_;
dimensionedScalar Cb1_;
dimensionedScalar Cb2_;
dimensionedScalar Cv1_;
dimensionedScalar Cv2_;
dimensionedScalar CDES_;
dimensionedScalar ck_;
dimensionedScalar kappa_;
dimensionedScalar Cw1_;
dimensionedScalar Cw2_;
dimensionedScalar Cw3_;
scalar Cb1_;
scalar Cb2_;
scalar Cv1_;
scalar Cv2_;
scalar CDES_;
scalar ck_;
scalar kappa_;
scalar Cw1_;
scalar Cw2_;
scalar Cw3_;
// Private member functions
......@@ -81,7 +81,7 @@ class SpalartAllmaras
// Disallow default bitwise copy construct and assignment
SpalartAllmaras(const SpalartAllmaras&);
SpalartAllmaras& operator=(const SpalartAllmaras&);
SpalartAllmaras& operator=(const SpalartAllmaras&);
volScalarField nuTilda_;
volScalarField dTilda_;
......@@ -112,7 +112,7 @@ public:
// Member Functions
//- Return SGS kinetic energy
tmp<volScalarField> k() const
{
......@@ -131,7 +131,7 @@ public:
tmp<volScalarField> muSgs() const
{
return muSgs_;
}
}
//- Return thermal conductivity
tmp<volScalarField> alphaEff() const
......
......@@ -90,7 +90,9 @@ dynOneEqEddy::dynOneEqEddy
filterPtr_(LESfilter::New(U.mesh(), LESmodelProperties())),
filter_(filterPtr_())
{}
{
printCoeffs();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......
......@@ -55,9 +55,11 @@ lowReOneEqEddy::lowReOneEqEddy
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenEddyVisc(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookup("ck")),
beta_(LESmodelProperties().lookup("beta"))
{}
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", ck_)),
beta_(LESmodelProperties().lookupOrAddDefault("beta", beta_))
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -98,8 +100,8 @@ bool lowReOneEqEddy::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().lookup("ck") >> ck_;
LESmodelProperties().lookup("beta") >> beta_;
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
LESmodelProperties().readIfPresent<scalar>("beta", beta_);
return true;
}
......
......@@ -72,8 +72,8 @@ class lowReOneEqEddy
{
// Private data
dimensionedScalar ck_;
dimensionedScalar beta_;
scalar ck_;
scalar beta_;
// Private Member Functions
......@@ -111,7 +111,7 @@ public:
//- Return the effective diffusivity for k
tmp<volScalarField> DkEff() const
{
return tmp<volScalarField>
return tmp<volScalarField>
(
new volScalarField("DkEff", muSgs_ + mu())
);
......
......@@ -54,8 +54,10 @@ oneEqEddy::oneEqEddy
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenEddyVisc(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookup("ck"))
{}
ck_(LESmodelProperties().lookupOrAddDefault("ck", 0.094))
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -94,7 +96,7 @@ bool oneEqEddy::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().lookup("ck") >> ck_;
LESmodelProperties().readIfPresent("ck", ck_);
return true;
}
......
......@@ -75,7 +75,7 @@ class oneEqEddy
{
// Private data
dimensionedScalar ck_;
scalar ck_;
// Private Member Functions
......
......@@ -52,9 +52,11 @@ DeardorffDiffStress::DeardorffDiffStress
LESmodel(typeName, U, phi, transport),
GenSGSStress(U, phi, transport),
ck_(LESmodelProperties().lookup("ck")),
cm_(LESmodelProperties().lookup("cm"))
{}
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.094)),
cm_(LESmodelProperties().lookupOrAddDefault<scalar>("cm", 4.13))
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -109,8 +111,8 @@ bool DeardorffDiffStress::read()
{
if (GenSGSStress::read())
{
LESmodelProperties().lookup("ck") >> ck_;
LESmodelProperties().lookup("cm") >> cm_;
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
LESmodelProperties().readIfPresent<scalar>("cm", cm_);
return true;
}
......
......@@ -73,8 +73,8 @@ class DeardorffDiffStress
{
// Private data
dimensionedScalar ck_;
dimensionedScalar cm_;
scalar ck_;
scalar cm_;
// Private Member Functions
......
......@@ -44,7 +44,7 @@ GenEddyVisc::GenEddyVisc
:
LESmodel(word("GenEddyVisc"), U, phi, transport),
ce_(LESmodelProperties().lookup("ce")),
ce_(LESmodelProperties().lookupOrAddDefault<scalar>("ce", 1.048)),
nuSgs_
(
......@@ -58,7 +58,9 @@ GenEddyVisc::GenEddyVisc
),
mesh_
)
{}
{
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -94,7 +96,7 @@ bool GenEddyVisc::read()
{
if (LESmodel::read())
{
LESmodelProperties().lookup("ce") >> ce_;
LESmodelProperties().readIfPresent<scalar>("ce", ce_);
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment