Commit 4f4d3638 authored by Andrew Heather's avatar Andrew Heather
Browse files

made coeffs dimensioned, and added new IO

parent 927de85f
......@@ -30,12 +30,26 @@ Description
#include "Switch.H"
#include "error.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Switch Switch::lookupOrAddToDict
(
const word& name,
dictionary& dict,
const Switch& defaultValue
)
{
return dict.lookupOrAddDefault<Switch>(name, defaultValue);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
word Switch::wordValue(const bool l) const
......@@ -74,6 +88,14 @@ bool Switch::boolValue(const word& w) const
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Switch::readIfPresent(const word& name, const dictionary& dict)
{
return dict.readIfPresent(name, logicalSwitch_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
......
......@@ -53,6 +53,7 @@ class Switch;
Istream& operator>>(Istream&, Switch&);
Ostream& operator<<(Ostream&, const Switch&);
class dictionary;
/*---------------------------------------------------------------------------*\
Class Switch Declaration
......@@ -92,6 +93,15 @@ public:
//- Construct from Istream
Switch(Istream& is);
//- Construct from dictionary, supplying default value so that if the
// value is not found, it is added into the dictionary.
static Switch lookupOrAddToDict
(
const word&,
dictionary&,
const Switch& defaultValue = false
);
// Member Operators
......@@ -114,6 +124,12 @@ public:
}
// Member fuctions
//- Update the value of the Switch if it is found in the dictionary
bool readIfPresent(const word&, const dictionary&);
// IOstream Operators
friend Istream& operator>>(Istream&, Switch&);
......
......@@ -26,13 +26,30 @@ License
#include "dimensionedType.H"
#include "pTraits.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template <class Type>
dimensioned<Type> dimensioned<Type>::lookupOrAddToDict
(
const word& name,
dictionary& dict,
const Type& defaultValue,
const dimensionSet& dims
)
{
Type value = dict.lookupOrAddDefault<Type>(name, defaultValue);
return dimensioned<Type>(name, dims, value);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template <class Type>
dimensioned<Type>::dimensioned
......@@ -168,6 +185,13 @@ void dimensioned<Type>::replace
}
template <class Type>
bool dimensioned<Type>::readIfPresent(const dictionary& dict)
{
return dict.readIfPresent(name_, value_);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template <class Type>
......
......@@ -56,6 +56,7 @@ Istream& operator>>(Istream&, dimensioned<Type>&);
template<class Type>
Ostream& operator<<(Ostream&, const dimensioned<Type>&);
class dictionary;
/*---------------------------------------------------------------------------*\
Class dimensioned Declaration
......@@ -107,6 +108,16 @@ public:
//- Construct from an Istream with a given name and dimensions
dimensioned(const word&, const dimensionSet&, Istream&);
//- Construct from dictionary, supplying default value so that if the
// value is not found, it is added into the dictionary.
static dimensioned<Type> lookupOrAddToDict
(
const word&,
dictionary&,
const Type& defaultValue = pTraits<Type>::zero,
const dimensionSet& dims = dimless
);
// Member functions
......@@ -137,6 +148,10 @@ public:
//- Return transpose.
dimensioned<Type> T() const;
//- Update the value of the dimensioned<Type> if it is found in the
// dictionary
bool readIfPresent(const dictionary&);
// Member operators
......
......@@ -55,8 +55,24 @@ DeardorffDiffStress::DeardorffDiffStress
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenSGSStress(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.094)),
cm_(LESmodelProperties().lookupOrAddDefault<scalar>("cm", 4.13))
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
LESmodelProperties(),
0.094
)
),
cm_
(
dimensioned<scalar>::lookupOrAddToDict
(
"cm",
LESmodelProperties(),
4.13
)
)
{
printCoeffs();
}
......@@ -113,8 +129,8 @@ bool DeardorffDiffStress::read()
{
if (GenSGSStress::read())
{
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
LESmodelProperties().readIfPresent<scalar>("cm", cm_);
ck_.readIfPresent(LESmodelProperties());
cm_.readIfPresent(LESmodelProperties());
return true;
}
......
......@@ -75,8 +75,8 @@ class DeardorffDiffStress
{
// Private data
scalar ck_;
scalar cm_;
dimensionedScalar ck_;
dimensionedScalar cm_;
// Private Member Functions
......
......@@ -51,7 +51,15 @@ GenEddyVisc::GenEddyVisc
word("GenEddyVisc"), rho, U, phi, thermoPhysicalModel
),
ce_(LESmodelProperties().lookupOrAddDefault<scalar>("ce", 1.048)),
ce_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ce",
LESmodelProperties(),
1.048
)
),
k_
(
......@@ -116,7 +124,7 @@ bool GenEddyVisc::read()
{
if (LESmodel::read())
{
LESmodelProperties().readIfPresent<scalar>("ce", ce_);
ce_.readIfPresent(LESmodelProperties());
return true;
}
......
......@@ -68,7 +68,7 @@ class GenEddyVisc
protected:
scalar ce_;
dimensionedScalar ce_;
volScalarField k_;
volScalarField muSgs_;
......
......@@ -55,7 +55,15 @@ GenSGSStress::GenSGSStress
thermoPhysicalModel
),
ce_(LESmodelProperties().lookupOrAddDefault<scalar>("ce" ,1.048)),
ce_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ce",
LESmodelProperties(),
1.048
)
),
B_
(
......@@ -131,7 +139,7 @@ bool GenSGSStress::read()
{
if (LESmodel::read())
{
LESmodelProperties().readIfPresent<scalar>("ce", ce_);
ce_.readIfPresent(LESmodelProperties());
return true;
}
......
......@@ -69,7 +69,7 @@ class GenSGSStress
protected:
scalar ce_;
dimensionedScalar ce_;
volSymmTensorField B_;
volScalarField muSgs_;
......
......@@ -55,7 +55,15 @@ Smagorinsky::Smagorinsky
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenEddyVisc(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.02))
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
LESmodelProperties(),
0.02
)
)
{
printCoeffs();
}
......@@ -84,7 +92,7 @@ bool Smagorinsky::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
ck_.readIfPresent(LESmodelProperties());
return true;
}
......
......@@ -71,7 +71,7 @@ class Smagorinsky
{
// Private data
scalar ck_;
dimensionedScalar ck_;
// Private Member Functions
......
......@@ -104,17 +104,98 @@ SpalartAllmaras::SpalartAllmaras
:
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
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)),
alphaNut_
(
dimensioned<scalar>::lookupOrAddToDict
(
"alphaNut",
LESmodelProperties(),
1.5
)
),
Cb1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cb1",
LESmodelProperties(),
0.1355
)
),
Cb2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cb2",
LESmodelProperties(),
0.622
)
),
Cv1_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cv1",
LESmodelProperties(),
7.1
)
),
Cv2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cv2",
LESmodelProperties(),
5.0
)
),
CDES_
(
dimensioned<scalar>::lookupOrAddToDict
(
"CDES",
LESmodelProperties(),
0.65
)
),
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
LESmodelProperties(),
0.07
)
),
kappa_
(
dimensioned<scalar>::lookupOrAddToDict
(
"kappa",
*this,
0.4187
)
),
Cw1_(Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_)),
Cw2_(LESmodelProperties().lookupOrAddDefault<scalar>("Cw2", 0.3)),
Cw3_(LESmodelProperties().lookupOrAddDefault<scalar>("Cw3", 2.0)),
Cw2_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cw2",
LESmodelProperties(),
0.3
)
),
Cw3_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cw3",
LESmodelProperties(),
2.0
)
),
nuTilda_
(
......@@ -218,17 +299,17 @@ bool SpalartAllmaras::read()
{
if (LESmodel::read())
{
LESmodelProperties().readIfPresent<scalar>("alphaNut", alphaNut_);
LESmodelProperties().readIfPresent<scalar>("Cb1", Cb1_);
LESmodelProperties().readIfPresent<scalar>("Cb2", Cb2_);
alphaNut_.readIfPresent(LESmodelProperties());
Cb1_.readIfPresent(LESmodelProperties());
Cb2_.readIfPresent(LESmodelProperties());
Cw1_ = Cb1_/sqr(kappa_) + alphaNut_*(1.0 + Cb2_);
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_);
Cw2_.readIfPresent(LESmodelProperties());
Cw3_.readIfPresent(LESmodelProperties());
Cv1_.readIfPresent(LESmodelProperties());
Cv2_.readIfPresent(LESmodelProperties());
CDES_.readIfPresent(LESmodelProperties());
ck_.readIfPresent(LESmodelProperties());
kappa_.readIfPresent(*this);
return true;
}
......
......@@ -58,18 +58,18 @@ class SpalartAllmaras
{
// Private data
scalar alphaNut_;
dimensionedScalar alphaNut_;
scalar Cb1_;
scalar Cb2_;
scalar Cv1_;
scalar Cv2_;
scalar CDES_;
scalar ck_;
scalar kappa_;
scalar Cw1_;
scalar Cw2_;
scalar Cw3_;
dimensionedScalar Cb1_;
dimensionedScalar Cb2_;
dimensionedScalar Cv1_;
dimensionedScalar Cv2_;
dimensionedScalar CDES_;
dimensionedScalar ck_;
dimensionedScalar kappa_;
dimensionedScalar Cw1_;
dimensionedScalar Cw2_;
dimensionedScalar Cw3_;
// Private member functions
......@@ -87,6 +87,7 @@ class SpalartAllmaras
volScalarField dTilda_;
volScalarField muSgs_;
public:
//- Runtime type information
......
......@@ -55,8 +55,24 @@ lowReOneEqEddy::lowReOneEqEddy
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenEddyVisc(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", ck_)),
beta_(LESmodelProperties().lookupOrAddDefault("beta", beta_))
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
LESmodelProperties(),
0.07
)
),
beta_
(
dimensioned<scalar>::lookupOrAddToDict
(
"beta",
LESmodelProperties(),
0.01
)
)
{
printCoeffs();
}
......@@ -100,8 +116,8 @@ bool lowReOneEqEddy::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().readIfPresent<scalar>("ck", ck_);
LESmodelProperties().readIfPresent<scalar>("beta", beta_);
ck_.readIfPresent(LESmodelProperties());
beta_.readIfPresent(LESmodelProperties());
return true;
}
......
......@@ -72,8 +72,8 @@ class lowReOneEqEddy
{
// Private data
scalar ck_;
scalar beta_;
dimensionedScalar ck_;
dimensionedScalar beta_;
// Private Member Functions
......
......@@ -54,7 +54,15 @@ oneEqEddy::oneEqEddy
LESmodel(typeName, rho, U, phi, thermoPhysicalModel),
GenEddyVisc(rho, U, phi, thermoPhysicalModel),
ck_(LESmodelProperties().lookupOrAddDefault("ck", 0.094))
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
LESmodelProperties(),
0.094
)
)
{
printCoeffs();
}
......@@ -96,7 +104,7 @@ bool oneEqEddy::read()
{
if (GenEddyVisc::read())
{
LESmodelProperties().readIfPresent("ck", ck_);
ck_.readIfPresent(LESmodelProperties());
return true;
}
......
......@@ -75,7 +75,7 @@ class oneEqEddy
{
// Private data
scalar ck_;
dimensionedScalar ck_;
// Private Member Functions
......
......@@ -54,8 +54,24 @@ DeardorffDiffStress::DeardorffDiffStress
LESmodel(typeName, U, phi, transport),
GenSGSStress(U, phi, transport),
ck_(LESmodelProperties().lookupOrAddDefault<scalar>("ck", 0.094)),
cm_(LESmodelProperties().lookupOrAddDefault<scalar>("cm", 4.13))
ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"ck",
LESmodelProperties(),
0.094
)
),