Commit 55c48861 authored by henry's avatar henry
Browse files
parents 3be01b9e 8ccd361f
......@@ -244,6 +244,23 @@ void Foam::fvPatchField<Type>::write(Ostream& os) const
}
template<class Type>
template<class EntryType>
void Foam::fvPatchField<Type>::writeEntryIfDifferent
(
Ostream& os,
const word& entryName,
const EntryType& value1,
const EntryType& value2
) const
{
if (value1 != value2)
{
os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl;
}
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type>
......
......@@ -414,8 +414,21 @@ public:
virtual void manipulateMatrix(fvMatrix<Type>& matrix);
//- Write
virtual void write(Ostream&) const;
// I-O
//- Write
virtual void write(Ostream&) const;
//- Helper function to write the keyword and entry only if the
// values are not equal. The value is then output as value2
template<class EntryType>
void writeEntryIfDifferent
(
Ostream& os,
const word& entryName,
const EntryType& value1,
const EntryType& value2
) const;
// Check
......
......@@ -125,6 +125,8 @@ RASModel::RASModel
k0_("k0", dimVelocity*dimVelocity, SMALL),
epsilon0_("epsilon", k0_.dimensions()/dimTime, SMALL),
epsilonSmall_("epsilonSmall", epsilon0_.dimensions(), SMALL),
omega0_("omega", dimless/dimTime, SMALL),
omegaSmall_("omegaSmall", omega0_.dimensions(), SMALL),
y_(mesh_)
{}
......@@ -204,6 +206,8 @@ bool RASModel::read()
k0_.readIfPresent(*this);
epsilon0_.readIfPresent(*this);
epsilonSmall_.readIfPresent(*this);
omega0_.readIfPresent(*this);
omegaSmall_.readIfPresent(*this);
return true;
}
......
......@@ -80,22 +80,47 @@ protected:
// Protected data
//- Turbulence on/off flag
Switch turbulence_;
//- Flag to print the model coeffs at run-time
Switch printCoeffs_;
//- Model coefficients dictionary
dictionary coeffDict_;
dictionary wallFunctionDict_;
dimensionedScalar kappa_;
dimensionedScalar E_;
dimensionedScalar Cmu_;
dimensionedScalar Prt_;
// Wall function properties
//- Wall function dictionary
dictionary wallFunctionDict_;
dimensionedScalar kappa_;
dimensionedScalar E_;
dimensionedScalar Cmu_;
dimensionedScalar Prt_;
//- Value of y+ at the edge of the laminar sublayer
scalar yPlusLam_;
//- Lower limit of k
dimensionedScalar k0_;
//- Lower limit of epsilon
dimensionedScalar epsilon0_;
//- Small epsilon value used to avoid divide by zero
dimensionedScalar epsilonSmall_;
//- Lower limit for omega
dimensionedScalar omega0_;
//- Small omega value used to avoid divide by zero
dimensionedScalar omegaSmall_;
//- Near wall distance boundary field
nearWallDist y_;
......@@ -193,6 +218,19 @@ public:
return epsilonSmall_;
}
//- Return the value of omega0 which epsilon is not allowed to be
// less than
const dimensionedScalar& omega0() const
{
return omega0_;
}
//- Return the value of omegaSmall which is added to epsilon when
// calculating nut
const dimensionedScalar& omegaSmall() const
{
return omegaSmall_;
}
//- Allow k0 to be changed
dimensionedScalar& k0()
......@@ -212,6 +250,17 @@ public:
return epsilonSmall_;
}
//- Allow omega0 to be changed
dimensionedScalar& omega0()
{
return omega0_;
}
//- Allow omegaSmall to be changed
dimensionedScalar& omegaSmall()
{
return omegaSmall_;
}
//- Return kappa for use in wall-functions
dimensionedScalar kappa() const
......
......@@ -48,7 +48,8 @@ alphatWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF)
fixedValueFvPatchScalarField(p, iF),
mutName_("mut")
{}
......@@ -61,7 +62,8 @@ alphatWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
mutName_(ptf.mutName_)
{}
......@@ -73,7 +75,8 @@ alphatWallFunctionFvPatchScalarField
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict)
fixedValueFvPatchScalarField(p, iF, dict),
mutName_(dict.lookupOrDefault<word>("mut", "mut"))
{}
......@@ -83,7 +86,8 @@ alphatWallFunctionFvPatchScalarField
const alphatWallFunctionFvPatchScalarField& awfpsf
)
:
fixedValueFvPatchScalarField(awfpsf)
fixedValueFvPatchScalarField(awfpsf),
mutName_(awfpsf.mutName_)
{}
......@@ -94,7 +98,8 @@ alphatWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(awfpsf, iF)
fixedValueFvPatchScalarField(awfpsf, iF),
mutName_(awfpsf.mutName_)
{}
......@@ -106,7 +111,7 @@ void alphatWallFunctionFvPatchScalarField::updateCoeffs()
const scalar Prt = ras.Prt().value();
const scalarField& mutw =
patch().lookupPatchField<volScalarField, scalar>("mut");
patch().lookupPatchField<volScalarField, scalar>(mutName_);
operator==(mutw/Prt);
}
......@@ -115,6 +120,7 @@ void alphatWallFunctionFvPatchScalarField::updateCoeffs()
void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
writeEntry("value", os);
}
......
......@@ -57,6 +57,11 @@ class alphatWallFunctionFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
// Private data
//- Name of turbulent viscosity field
word mutName_;
public:
......
......@@ -64,7 +64,13 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedInternalValueFvPatchField<scalar>(p, iF)
fixedInternalValueFvPatchField<scalar>(p, iF),
UName_("U"),
kName_("k"),
GName_("G"),
rhoName_("rho"),
muName_("mu"),
mutName_("mut")
{
checkType();
}
......@@ -78,7 +84,13 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper
)
:
fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper)
fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
UName_(ptf.UName_),
kName_(ptf.kName_),
GName_(ptf.GName_),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
mutName_(ptf.mutName_)
{
checkType();
}
......@@ -91,7 +103,13 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
const dictionary& dict
)
:
fixedInternalValueFvPatchField<scalar>(p, iF, dict)
fixedInternalValueFvPatchField<scalar>(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
kName_(dict.lookupOrDefault<word>("k", "k")),
GName_(dict.lookupOrDefault<word>("G", "G")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
mutName_(dict.lookupOrDefault<word>("mut", "mut"))
{
checkType();
}
......@@ -102,7 +120,13 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
const epsilonWallFunctionFvPatchScalarField& ewfpsf
)
:
fixedInternalValueFvPatchField<scalar>(ewfpsf)
fixedInternalValueFvPatchField<scalar>(ewfpsf),
UName_(ewfpsf.UName_),
kName_(ewfpsf.kName_),
GName_(ewfpsf.GName_),
rhoName_(ewfpsf.rhoName_),
muName_(ewfpsf.muName_),
mutName_(ewfpsf.mutName_)
{
checkType();
}
......@@ -114,7 +138,13 @@ epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF
)
:
fixedInternalValueFvPatchField<scalar>(ewfpsf, iF)
fixedInternalValueFvPatchField<scalar>(ewfpsf, iF),
UName_(ewfpsf.UName_),
kName_(ewfpsf.kName_),
GName_(ewfpsf.GName_),
rhoName_(ewfpsf.rhoName_),
muName_(ewfpsf.muName_),
mutName_(ewfpsf.mutName_)
{
checkType();
}
......@@ -135,24 +165,24 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
const scalarField& y = ras.y()[patch().index()];
volScalarField& G = const_cast<volScalarField&>
(db().lookupObject<volScalarField>("G"));
(db().lookupObject<volScalarField>(GName_));
volScalarField& epsilon = const_cast<volScalarField&>
(db().lookupObject<volScalarField>("epsilon"));
(db().lookupObject<volScalarField>(dimensionedInternalField().name()));
const volScalarField& k = db().lookupObject<volScalarField>("k");
const volScalarField& k = db().lookupObject<volScalarField>(kName_);
const scalarField& rhow =
patch().lookupPatchField<volScalarField, scalar>("rho");
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const scalarField& muw =
patch().lookupPatchField<volScalarField, scalar>("mu");
patch().lookupPatchField<volScalarField, scalar>(muName_);
const scalarField& mutw =
patch().lookupPatchField<volScalarField, scalar>("mut");
patch().lookupPatchField<volScalarField, scalar>(mutName_);
const fvPatchVectorField& Uw =
patch().lookupPatchField<volVectorField, vector>("U");
patch().lookupPatchField<volVectorField, vector>(UName_);
const scalarField magGradUw = mag(Uw.snGrad());
......@@ -197,6 +227,12 @@ void epsilonWallFunctionFvPatchScalarField::evaluate
void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fixedInternalValueFvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
writeEntryIfDifferent<word>(os, "G", "G", GName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
writeEntryIfDifferent<word>(os, "mut", "mut", mutName_);
writeEntry("value", os);
}
......
......@@ -57,6 +57,26 @@ class epsilonWallFunctionFvPatchScalarField
:
public fixedInternalValueFvPatchField<scalar>
{
// Private data
//- Name of velocity field
word UName_;
//- Name of turbulence kinetic energy field
word kName_;
//- Name of turbulence generation field
word GName_;
//- Name of density field
word rhoName_;
//- Name of laminar viscosity field
word muName_;
//- Name of turbulent viscosity field
word mutName_;
// Private member functions
......
......@@ -77,6 +77,9 @@ mutRoughWallFunctionFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF),
rhoName_("rho"),
muName_("mu"),
kName_("k"),
Ks_(p.size(), 0.0),
Cs_(p.size(), 0.0)
{}
......@@ -92,6 +95,9 @@ mutRoughWallFunctionFvPatchScalarField
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kName_(ptf.kName_),
Ks_(ptf.Ks_, mapper),
Cs_(ptf.Cs_, mapper)
{}
......@@ -106,6 +112,9 @@ mutRoughWallFunctionFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF, dict),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kName_(dict.lookupOrDefault<word>("k", "k")),
Ks_("Ks", dict, p.size()),
Cs_("Cs", dict, p.size())
{}
......@@ -114,25 +123,31 @@ mutRoughWallFunctionFvPatchScalarField
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
const mutRoughWallFunctionFvPatchScalarField& nrwfpsf
const mutRoughWallFunctionFvPatchScalarField& rwfpsf
)
:
fixedValueFvPatchScalarField(nrwfpsf),
Ks_(nrwfpsf.Ks_),
Cs_(nrwfpsf.Cs_)
fixedValueFvPatchScalarField(rwfpsf),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kName_(rwfpsf.kName_),
Ks_(rwfpsf.Ks_),
Cs_(rwfpsf.Cs_)
{}
mutRoughWallFunctionFvPatchScalarField::
mutRoughWallFunctionFvPatchScalarField
(
const mutRoughWallFunctionFvPatchScalarField& nrwfpsf,
const mutRoughWallFunctionFvPatchScalarField& rwfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(nrwfpsf, iF),
Ks_(nrwfpsf.Ks_),
Cs_(nrwfpsf.Cs_)
fixedValueFvPatchScalarField(rwfpsf, iF),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kName_(rwfpsf.kName_),
Ks_(rwfpsf.Ks_),
Cs_(rwfpsf.Cs_)
{}
......@@ -178,12 +193,12 @@ void mutRoughWallFunctionFvPatchScalarField::updateCoeffs()
const scalarField& y = ras.y()[patch().index()];
const scalarField& rhow =
patch().lookupPatchField<volScalarField, scalar>("rho");
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const scalarField& k = db().lookupObject<volScalarField>("k");
const scalarField& k = db().lookupObject<volScalarField>(kName_);
const scalarField& muw =
patch().lookupPatchField<volScalarField, scalar>("mu");
patch().lookupPatchField<volScalarField, scalar>(muName_);
scalarField& mutw = *this;
......@@ -229,6 +244,9 @@ void mutRoughWallFunctionFvPatchScalarField::updateCoeffs()
void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
Cs_.writeEntry("Cs", os);
Ks_.writeEntry("Ks", os);
writeEntry("value", os);
......
......@@ -64,6 +64,15 @@ class mutRoughWallFunctionFvPatchScalarField
{
// Private data
//- Name of density field
word rhoName_;
//- Name of laminar viscosity field
word muName_;
//- Name of turbulence kinetic energy field
word kName_;
//- Roughness height
scalarField Ks_;
......
......@@ -49,6 +49,9 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF),
UName_("U"),
rhoName_("rho"),
muName_("mu"),
roughnessHeight_(pTraits<scalar>::zero),
roughnessConstant_(pTraits<scalar>::zero),
roughnessFudgeFactor_(pTraits<scalar>::zero)
......@@ -65,6 +68,9 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
UName_(ptf.UName_),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
roughnessHeight_(ptf.roughnessHeight_),
roughnessConstant_(ptf.roughnessConstant_),
roughnessFudgeFactor_(ptf.roughnessFudgeFactor_)
......@@ -80,6 +86,9 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
)
:
fixedValueFvPatchScalarField(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))),
roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))),
roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor")))
......@@ -89,27 +98,33 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
(
const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf
const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& rwfpsf
)
:
fixedValueFvPatchScalarField(tppsf),
roughnessHeight_(tppsf.roughnessHeight_),
roughnessConstant_(tppsf.roughnessConstant_),
roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_)
fixedValueFvPatchScalarField(rwfpsf),
UName_(rwfpsf.UName_),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
roughnessHeight_(rwfpsf.roughnessHeight_),
roughnessConstant_(rwfpsf.roughnessConstant_),
roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_)
{}
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
(
const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf,
const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& rwfpsf,
const DimensionedField<scalar, volMesh>& iF