updates to compressible wall functions

This commit is contained in:
andy
2009-07-23 11:17:28 +01:00
parent 3ee3750f99
commit a98fe1c74f
10 changed files with 312 additions and 417 deletions

View File

@ -74,13 +74,7 @@ mutRoughWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(p, iF), mutWallFunctionFvPatchScalarField(p, iF),
rhoName_("rho"),
muName_("mu"),
kName_("k"),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
Ks_(p.size(), 0.0), Ks_(p.size(), 0.0),
Cs_(p.size(), 0.0) Cs_(p.size(), 0.0)
{} {}
@ -95,13 +89,7 @@ mutRoughWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchScalarField(ptf, p, iF, mapper), mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kName_(ptf.kName_),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
Ks_(ptf.Ks_, mapper), Ks_(ptf.Ks_, mapper),
Cs_(ptf.Cs_, mapper) Cs_(ptf.Cs_, mapper)
{} {}
@ -115,13 +103,7 @@ mutRoughWallFunctionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), mutWallFunctionFvPatchScalarField(p, iF, dict),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kName_(dict.lookupOrDefault<word>("k", "k")),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)),
Ks_("Ks", dict, p.size()), Ks_("Ks", dict, p.size()),
Cs_("Cs", dict, p.size()) Cs_("Cs", dict, p.size())
{} {}
@ -133,13 +115,7 @@ mutRoughWallFunctionFvPatchScalarField
const mutRoughWallFunctionFvPatchScalarField& rwfpsf const mutRoughWallFunctionFvPatchScalarField& rwfpsf
) )
: :
fixedValueFvPatchScalarField(rwfpsf), mutWallFunctionFvPatchScalarField(rwfpsf),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kName_(rwfpsf.kName_),
Cmu_(rwfpsf.Cmu_),
kappa_(rwfpsf.kappa_),
E_(rwfpsf.E_),
Ks_(rwfpsf.Ks_), Ks_(rwfpsf.Ks_),
Cs_(rwfpsf.Cs_) Cs_(rwfpsf.Cs_)
{} {}
@ -152,13 +128,7 @@ mutRoughWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(rwfpsf, iF), mutWallFunctionFvPatchScalarField(rwfpsf, iF),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kName_(rwfpsf.kName_),
Cmu_(rwfpsf.Cmu_),
kappa_(rwfpsf.kappa_),
E_(rwfpsf.E_),
Ks_(rwfpsf.Ks_), Ks_(rwfpsf.Ks_),
Cs_(rwfpsf.Cs_) Cs_(rwfpsf.Cs_)
{} {}
@ -171,7 +141,7 @@ void mutRoughWallFunctionFvPatchScalarField::autoMap
const fvPatchFieldMapper& m const fvPatchFieldMapper& m
) )
{ {
fixedValueFvPatchScalarField::autoMap(m); mutWallFunctionFvPatchScalarField::autoMap(m);
Ks_.autoMap(m); Ks_.autoMap(m);
Cs_.autoMap(m); Cs_.autoMap(m);
} }
@ -183,7 +153,7 @@ void mutRoughWallFunctionFvPatchScalarField::rmap
const labelList& addr const labelList& addr
) )
{ {
fixedValueFvPatchScalarField::rmap(ptf, addr); mutWallFunctionFvPatchScalarField::rmap(ptf, addr);
const mutRoughWallFunctionFvPatchScalarField& nrwfpsf = const mutRoughWallFunctionFvPatchScalarField& nrwfpsf =
refCast<const mutRoughWallFunctionFvPatchScalarField>(ptf); refCast<const mutRoughWallFunctionFvPatchScalarField>(ptf);
@ -193,23 +163,22 @@ void mutRoughWallFunctionFvPatchScalarField::rmap
} }
void mutRoughWallFunctionFvPatchScalarField::updateCoeffs() tmp<scalarField> mutRoughWallFunctionFvPatchScalarField::calcMut() const
{ {
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patch().index()]; const scalarField& y = rasModel.y()[patchI];
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const scalar Cmu25 = pow(Cmu_, 0.25); const scalar Cmu25 = pow(Cmu_, 0.25);
const scalarField& rhow = tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
patch().lookupPatchField<volScalarField, scalar>(rhoName_); scalarField& mutw = tmutw();
const scalarField& k = db().lookupObject<volScalarField>(kName_);
const scalarField& muw =
patch().lookupPatchField<volScalarField, scalar>(muName_);
scalarField& mutw = *this;
forAll(mutw, faceI) forAll(mutw, faceI)
{ {
@ -243,23 +212,15 @@ void mutRoughWallFunctionFvPatchScalarField::updateCoeffs()
mutw[faceI] = mutw[faceI] =
muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1); muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1);
} }
else
{
mutw[faceI] = 0.0;
}
} }
return tmutw;
} }
void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchField<scalar>::write(os); fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
Cs_.writeEntry("Cs", os); Cs_.writeEntry("Cs", os);
Ks_.writeEntry("Ks", os); Ks_.writeEntry("Ks", os);
writeEntry("value", os); writeEntry("value", os);

View File

@ -43,7 +43,7 @@ SourceFiles
#ifndef mutRoughWallFunctionFvPatchScalarField_H #ifndef mutRoughWallFunctionFvPatchScalarField_H
#define mutRoughWallFunctionFvPatchScalarField_H #define mutRoughWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H" #include "mutWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,27 +60,11 @@ namespace RASModels
class mutRoughWallFunctionFvPatchScalarField class mutRoughWallFunctionFvPatchScalarField
: :
public fixedValueFvPatchScalarField public mutWallFunctionFvPatchScalarField
{ {
// Private data protected:
//- Name of density field // Protected data
word rhoName_;
//- Name of laminar viscosity field
word muName_;
//- Name of turbulence kinetic energy field
word kName_;
//- Cmu coefficient
scalar Cmu_;
//- Von-karman constant
scalar kappa_;
//- E coefficient
scalar E_;
//- Roughness height //- Roughness height
scalarField Ks_; scalarField Ks_;
@ -92,7 +76,10 @@ class mutRoughWallFunctionFvPatchScalarField
// Private member functions // Private member functions
//- Compute the roughness function //- Compute the roughness function
scalar fnRough(const scalar KsPlus, const scalar Cs) const; virtual scalar fnRough(const scalar KsPlus, const scalar Cs) const;
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcMut() const;
public: public:
@ -181,16 +168,11 @@ public:
const labelList& const labelList&
); );
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// I-O // I-O
//- Write //- Write
void write(Ostream&) const; virtual void write(Ostream&) const;
}; };

View File

@ -27,6 +27,7 @@ License
#include "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H" #include "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H"
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
#include "volFields.H" #include "volFields.H"
#include "RASModel.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,12 +48,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(p, iF), mutWallFunctionFvPatchScalarField(p, iF),
UName_("U"),
rhoName_("rho"),
muName_("mu"),
kappa_(0.41),
E_(9.8),
roughnessHeight_(pTraits<scalar>::zero), roughnessHeight_(pTraits<scalar>::zero),
roughnessConstant_(pTraits<scalar>::zero), roughnessConstant_(pTraits<scalar>::zero),
roughnessFudgeFactor_(pTraits<scalar>::zero) roughnessFudgeFactor_(pTraits<scalar>::zero)
@ -68,12 +64,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchScalarField(ptf, p, iF, mapper), mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
UName_(ptf.UName_),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kappa_(ptf.kappa_),
E_(ptf.E_),
roughnessHeight_(ptf.roughnessHeight_), roughnessHeight_(ptf.roughnessHeight_),
roughnessConstant_(ptf.roughnessConstant_), roughnessConstant_(ptf.roughnessConstant_),
roughnessFudgeFactor_(ptf.roughnessFudgeFactor_) roughnessFudgeFactor_(ptf.roughnessFudgeFactor_)
@ -88,12 +79,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), mutWallFunctionFvPatchScalarField(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)),
roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))), roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))),
roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))), roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))),
roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor"))) roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor")))
@ -106,12 +92,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& rwfpsf const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& rwfpsf
) )
: :
fixedValueFvPatchScalarField(rwfpsf), mutWallFunctionFvPatchScalarField(rwfpsf),
UName_(rwfpsf.UName_),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kappa_(rwfpsf.kappa_),
E_(rwfpsf.E_),
roughnessHeight_(rwfpsf.roughnessHeight_), roughnessHeight_(rwfpsf.roughnessHeight_),
roughnessConstant_(rwfpsf.roughnessConstant_), roughnessConstant_(rwfpsf.roughnessConstant_),
roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_) roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_)
@ -125,12 +106,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(rwfpsf, iF), mutWallFunctionFvPatchScalarField(rwfpsf, iF),
UName_(rwfpsf.UName_),
rhoName_(rwfpsf.rhoName_),
muName_(rwfpsf.muName_),
kappa_(rwfpsf.kappa_),
E_(rwfpsf.E_),
roughnessHeight_(rwfpsf.roughnessHeight_), roughnessHeight_(rwfpsf.roughnessHeight_),
roughnessConstant_(rwfpsf.roughnessConstant_), roughnessConstant_(rwfpsf.roughnessConstant_),
roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_) roughnessFudgeFactor_(rwfpsf.roughnessFudgeFactor_)
@ -139,28 +115,24 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate tmp<scalarField>
( mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const
const Pstream::commsTypes
)
{ {
const scalar yPlusLam = 11.225; const label patchI = patch().index();
// The reciprical of the distance to the adjacent cell centre. const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& ry = patch().deltaCoeffs(); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const fvPatchVectorField& U = const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
patch().lookupPatchField<volVectorField, vector>(UName_); const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const fvPatchScalarField& rho = scalarField magUp = mag(Uw.patchInternalField() - Uw);
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
// The flow velocity at the adjacent cell centre. const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI];
scalarField magUp = mag(U.patchInternalField() - U);
const scalarField& muw = tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
patch().lookupPatchField<volScalarField, scalar>(muName_); scalarField& mutw = tmutw();
scalarField& mutw = *this;
if (roughnessHeight_ > 0.0) if (roughnessHeight_ > 0.0)
{ {
@ -177,7 +149,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
forAll(mutw, facei) forAll(mutw, facei)
{ {
const scalar magUpara = magUp[facei]; const scalar magUpara = magUp[facei];
const scalar Re = rho[facei]*magUpara/(muw[facei]*ry[facei]); const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei];
const scalar kappaRe = kappa_*Re; const scalar kappaRe = kappa_*Re;
scalar yPlus = yPlusLam; scalar yPlus = yPlusLam;
@ -185,7 +157,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
int iter = 0; int iter = 0;
scalar yPlusLast = 0.0; scalar yPlusLast = 0.0;
scalar dKsPlusdYPlus = roughnessHeight_*ry[facei]; scalar dKsPlusdYPlus = roughnessHeight_/y[facei];
// Enforce the roughnessHeight to be less than the distance to // Enforce the roughnessHeight to be less than the distance to
// the first cell centre. // the first cell centre.
@ -194,18 +166,17 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
dKsPlusdYPlus = 1; dKsPlusdYPlus = 1;
} }
// Fudge factor to get results to be similar to fluent // Additional tuning parameter (fudge factor) - nominally = 1
// (at least difference between rough and smooth).
dKsPlusdYPlus *= roughnessFudgeFactor_; dKsPlusdYPlus *= roughnessFudgeFactor_;
do do
{ {
yPlusLast = yPlus; yPlusLast = yPlus;
// The non-dimensional roughness height. // The non-dimensional roughness height
scalar KsPlus = yPlus*dKsPlusdYPlus; scalar KsPlus = yPlus*dKsPlusdYPlus;
// The extra term in the law-of-the-wall. // The extra term in the law-of-the-wall
scalar G = 0.0; scalar G = 0.0;
scalar yPlusGPrime = 0.0; scalar yPlusGPrime = 0.0;
@ -238,7 +209,7 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
} }
else else
{ {
// Ensure immediate end and mutw = 0. // Ensure immediate end and mutw = 0
yPlus = 0; yPlus = 0;
} }
@ -253,20 +224,16 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
{ {
mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1);
} }
else
{
mutw[facei] = 0.0;
}
} }
} }
} }
else else
{ {
// Smooth Walls. // Smooth Walls
forAll(mutw, facei) forAll(mutw, facei)
{ {
const scalar magUpara = magUp[facei]; const scalar magUpara = magUp[facei];
const scalar Re = rho[facei]*magUpara/(muw[facei]*ry[facei]); const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei];
const scalar kappaRe = kappa_*Re; const scalar kappaRe = kappa_*Re;
scalar yPlus = yPlusLam; scalar yPlus = yPlusLam;
@ -290,12 +257,23 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate
{ {
mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1); mutw[facei] = muw[facei]*(yPlus*yPlus/Re - 1);
} }
else
{
mutw[facei] = 0.0;
}
} }
} }
return tmutw;
}
tmp<scalarField>
mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const
{
notImplemented
(
"mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus()"
"const"
);
return tmp<scalarField>(NULL);
} }
@ -305,11 +283,6 @@ void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write
) const ) const
{ {
fixedValueFvPatchScalarField::write(os); fixedValueFvPatchScalarField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
os.writeKeyword("roughnessHeight") os.writeKeyword("roughnessHeight")
<< roughnessHeight_ << token::END_STATEMENT << nl; << roughnessHeight_ << token::END_STATEMENT << nl;
os.writeKeyword("roughnessConstant") os.writeKeyword("roughnessConstant")

View File

@ -37,7 +37,7 @@ SourceFiles
#ifndef mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H #ifndef mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H
#define mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H #define mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H" #include "mutWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,25 +54,11 @@ Class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration
class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
: :
public fixedValueFvPatchScalarField public mutWallFunctionFvPatchScalarField
{ {
// Private data protected:
//- Name of velocity field
word UName_;
//- Name of density field
word rhoName_;
//- Name of laminar viscosity field
word muName_;
//- Von Karman constant
scalar kappa_;
//- E coefficient
scalar E_;
// Protected data
// Roughness parameters // Roughness parameters
@ -86,6 +72,12 @@ class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField
scalar roughnessFudgeFactor_; scalar roughnessFudgeFactor_;
// Protected member functions
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcMut() const;
public: public:
//- Runtime type information //- Runtime type information
@ -206,15 +198,14 @@ public:
// Evaluation functions // Evaluation functions
//- Evaluate the patchField //- Calculate and return the yPlus at the boundary
virtual void evaluate virtual tmp<scalarField> yPlus() const;
(
const Pstream::commsTypes commsType=Pstream::blocking
);
//- Write // I-O
virtual void write(Ostream& os) const;
//- Write
virtual void write(Ostream& os) const;
}; };

View File

@ -48,12 +48,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(p, iF), mutWallFunctionFvPatchScalarField(p, iF)
UName_("U"),
rhoName_("rho"),
muName_("mu"),
kappa_(0.41),
E_(9.8)
{} {}
@ -66,12 +61,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchScalarField(ptf, p, iF, mapper), mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
UName_(ptf.UName_),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kappa_(ptf.kappa_),
E_(ptf.E_)
{} {}
@ -83,12 +73,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), mutWallFunctionFvPatchScalarField(p, iF, dict)
UName_(dict.lookupOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8))
{} {}
@ -98,12 +83,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
) )
: :
fixedValueFvPatchScalarField(sawfpsf), mutWallFunctionFvPatchScalarField(sawfpsf)
UName_(sawfpsf.UName_),
rhoName_(sawfpsf.rhoName_),
muName_(sawfpsf.muName_),
kappa_(sawfpsf.kappa_),
E_(sawfpsf.E_)
{} {}
@ -114,46 +94,37 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(sawfpsf, iF), mutWallFunctionFvPatchScalarField(sawfpsf, iF)
UName_(sawfpsf.UName_),
rhoName_(sawfpsf.rhoName_),
muName_(sawfpsf.muName_),
kappa_(sawfpsf.kappa_),
E_(sawfpsf.E_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate tmp<scalarField>
( mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const
const Pstream::commsTypes
)
{ {
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patchI];
const scalarField& ry = patch().deltaCoeffs(); const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
const fvPatchVectorField& U = const scalarField magUp = mag(Uw.patchInternalField() - Uw);
patch().lookupPatchField<volVectorField, vector>(UName_);
scalarField magUp = mag(U.patchInternalField() - U); const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI];
const scalarField& rhow = const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const scalarField& muw = tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
patch().lookupPatchField<volScalarField, scalar>(muName_); scalarField& mutw = tmutw();
scalarField& mutw = *this;
scalarField magFaceGradU = mag(U.snGrad());
forAll(mutw, faceI) forAll(mutw, faceI)
{ {
scalar magUpara = magUp[faceI]; scalar magUpara = magUp[faceI];
scalar kappaRe = kappa_*magUpara/((muw[faceI]/rhow[faceI])*ry[faceI]); scalar kappaRe = kappa_*magUpara*y[faceI]/(muw[faceI]/rhow[faceI]);
scalar yPlus = yPlusLam; scalar yPlus = yPlusLam;
scalar ryPlusLam = 1.0/yPlus; scalar ryPlusLam = 1.0/yPlus;
@ -166,17 +137,28 @@ void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate
yPlusLast = yPlus; yPlusLast = yPlus;
yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus)); yPlus = (kappaRe + yPlus)/(1.0 + log(E_*yPlus));
} while (mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); } while (mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10);
if (yPlus > yPlusLam) if (yPlus > yPlusLam)
{ {
mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1); mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0);
}
else
{
mutw[faceI] = 0.0;
} }
} }
return tmutw;
}
tmp<scalarField>
mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
{
notImplemented
(
"mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() "
"const"
);
return tmp<scalarField>(NULL);
} }
@ -186,9 +168,6 @@ void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
) const ) const
{ {
fvPatchField<scalar>::write(os); fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);

View File

@ -37,7 +37,7 @@ SourceFiles
#ifndef mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H #ifndef mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
#define mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H #define mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H" #include "mutWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,24 +54,14 @@ namespace RASModels
class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
: :
public fixedValueFvPatchScalarField public mutWallFunctionFvPatchScalarField
{ {
// Private data protected:
//- Name of velocity field // Protected member functions
word UName_;
//- Name of density field //- Calculate the turbulence viscosity
word rhoName_; virtual tmp<scalarField> calcMut() const;
//- Name of laminar viscosity field
word muName_;
//- Von Karman constant
scalar kappa_;
//- E coefficient
scalar E_;
public: public:
@ -154,14 +144,14 @@ public:
// Evaluation functions // Evaluation functions
//- Evaluate the patchField //- Calculate and return the yPlus at the boundary
virtual void evaluate virtual tmp<scalarField> yPlus() const;
(
const Pstream::commsTypes commsType=Pstream::blocking
);
//- Write
virtual void write(Ostream& os) const; // I-O
//- Write
virtual void write(Ostream& os) const;
}; };

View File

@ -27,6 +27,7 @@ License
#include "mutSpalartAllmarasWallFunctionFvPatchScalarField.H" #include "mutSpalartAllmarasWallFunctionFvPatchScalarField.H"
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
#include "volFields.H" #include "volFields.H"
#include "RASModel.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -38,6 +39,72 @@ namespace compressible
namespace RASModels namespace RASModels
{ {
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
tmp<scalarField> mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
(
const scalarField& magGradU
) const
{
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patch().index()];
const fvPatchVectorField& Uw =
rasModel.U().boundaryField()[patch().index()];
scalarField magUp = mag(Uw.patchInternalField() - Uw);
const fvPatchScalarField& rhow =
rasModel.rho().boundaryField()[patch().index()];
const fvPatchScalarField& muw =
rasModel.mu().boundaryField()[patch().index()];
const scalarField& mutw = *this;
tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
scalarField& uTau = tuTau();
forAll(mutw, faceI)
{
scalar magUpara = magUp[faceI];
scalar ut =
sqrt((mutw[faceI] + muw[faceI])*magGradU[faceI]/rhow[faceI]);
if (ut > VSMALL)
{
int iter = 0;
scalar err = GREAT;
do
{
scalar kUu = min(kappa_*magUpara/ut, 50);
scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
scalar f =
- ut*y[faceI]/(muw[faceI]/rhow[faceI])
+ magUpara/ut
+ 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
scalar df =
y[faceI]/(muw[faceI]/rhow[faceI])
+ magUpara/sqr(ut)
+ 1/E_*kUu*fkUu/ut;
scalar uTauNew = ut + f/df;
err = mag((ut - uTauNew)/ut);
ut = uTauNew;
} while (ut > VSMALL && err > 0.01 && ++iter < 10);
uTau[faceI] = max(0.0, ut);
}
}
return tuTau;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutSpalartAllmarasWallFunctionFvPatchScalarField:: mutSpalartAllmarasWallFunctionFvPatchScalarField::
@ -47,12 +114,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(p, iF), mutWallFunctionFvPatchScalarField(p, iF)
UName_("U"),
rhoName_("rho"),
muName_("mu"),
kappa_(0.41),
E_(9.8)
{} {}
@ -65,12 +127,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchScalarField(ptf, p, iF, mapper), mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
UName_(ptf.UName_),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kappa_(ptf.kappa_),
E_(ptf.E_)
{} {}
@ -82,12 +139,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), mutWallFunctionFvPatchScalarField(p, iF, dict)
UName_(dict.lookupOrDefault<word>("U", "U")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8))
{} {}
@ -97,12 +149,7 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField
const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
) )
: :
fixedValueFvPatchScalarField(wfpsf), mutWallFunctionFvPatchScalarField(wfpsf)
UName_(wfpsf.UName_),
rhoName_(wfpsf.rhoName_),
muName_(wfpsf.muName_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_)
{} {}
@ -113,83 +160,45 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(wfpsf, iF), mutWallFunctionFvPatchScalarField(wfpsf, iF)
UName_(wfpsf.UName_),
rhoName_(wfpsf.rhoName_),
muName_(wfpsf.muName_),
kappa_(wfpsf.kappa_),
E_(wfpsf.E_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate tmp<scalarField>
( mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const
const Pstream::commsTypes
)
{ {
const scalarField& ry = patch().deltaCoeffs(); const label patchI = patch().index();
const fvPatchVectorField& U = const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
patch().lookupPatchField<volVectorField, vector>(UName_); const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
scalarField magUp = mag(U.patchInternalField() - U); const scalarField magGradU = mag(Uw.snGrad());
const scalarField& rhow = const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
const scalarField& muw = const scalarField& muw = rasModel.mu().boundaryField()[patchI];
patch().lookupPatchField<volScalarField, scalar>(muName_);
scalarField& mutw = *this; return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw);
}
scalarField magFaceGradU = mag(U.snGrad());
forAll(mutw, faceI) tmp<scalarField>
{ mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
scalar magUpara = magUp[faceI]; {
const label patchI = patch().index();
scalar utau = const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
sqrt((mutw[faceI] + muw[faceI])*magFaceGradU[faceI]/rhow[faceI]); const scalarField& y = rasModel.y()[patchI];
if (utau > VSMALL) const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
{
int iter = 0;
scalar err = GREAT;
do const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
{
scalar kUu = min(kappa_*magUpara/utau, 50);
scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
scalar f = const scalarField& muw = rasModel.mu().boundaryField()[patchI];
- utau/(ry[faceI]*(muw[faceI]/rhow[faceI]))
+ magUpara/utau
+ 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
scalar df = return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow);
1.0/(ry[faceI]*(muw[faceI]/rhow[faceI]))
+ magUpara/sqr(utau)
+ 1/E_*kUu*fkUu/utau;
scalar utauNew = utau + f/df;
err = mag((utau - utauNew)/utau);
utau = utauNew;
} while (utau > VSMALL && err > 0.01 && ++iter < 10);
mutw[faceI] = max
(
rhow[faceI]*sqr(max(utau, 0))/magFaceGradU[faceI] - muw[faceI],
0.0
);
}
else
{
mutw[faceI] = 0;
}
}
} }
@ -199,9 +208,6 @@ void mutSpalartAllmarasWallFunctionFvPatchScalarField::write
) const ) const
{ {
fvPatchField<scalar>::write(os); fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);

View File

@ -37,7 +37,7 @@ SourceFiles
#ifndef mutSpalartAllmarasWallFunctionFvPatchScalarField_H #ifndef mutSpalartAllmarasWallFunctionFvPatchScalarField_H
#define mutSpalartAllmarasWallFunctionFvPatchScalarField_H #define mutSpalartAllmarasWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchFields.H" #include "mutWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,24 +54,17 @@ namespace RASModels
class mutSpalartAllmarasWallFunctionFvPatchScalarField class mutSpalartAllmarasWallFunctionFvPatchScalarField
: :
public fixedValueFvPatchScalarField public mutWallFunctionFvPatchScalarField
{ {
// Private data protected:
//- Name of velocity field // Protected member functions
word UName_;
//- Name of density field //- Calculate the turbulence viscosity
word rhoName_; virtual tmp<scalarField> calcMut() const;
//- Name of laminar viscosity field //- Calculate the friction velocity
word muName_; virtual tmp<scalarField> calcUTau(const scalarField& magGradU) const;
//- Von Karman constant
scalar kappa_;
//- E coefficient
scalar E_;
public: public:
@ -147,14 +140,14 @@ public:
// Evaluation functions // Evaluation functions
//- Evaluate the patchField //- Calculate and return the yPlus at the boundary
virtual void evaluate virtual tmp<scalarField> yPlus() const;
(
const Pstream::commsTypes commsType=Pstream::blocking
);
//- Write
virtual void write(Ostream& os) const; // I-O
//- Write
virtual void write(Ostream& os) const;
}; };

View File

@ -28,6 +28,7 @@ License
#include "RASModel.H" #include "RASModel.H"
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
#include "volFields.H" #include "volFields.H"
#include "wallFvPatch.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,27 +40,38 @@ namespace compressible
namespace RASModels namespace RASModels
{ {
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void mutWallFunctionFvPatchScalarField::checkType()
{
if (!isA<wallFvPatch>(patch()))
{
FatalErrorIn("mutWallFunctionFvPatchScalarField::checkType()")
<< "Invalid wall function specification" << nl
<< " Patch type for patch " << patch().name()
<< " must be wall" << nl
<< " Current patch type is " << patch().type() << nl << endl
<< abort(FatalError);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mutWallFunctionFvPatchScalarField:: mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
mutWallFunctionFvPatchScalarField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
rhoName_("rho"),
muName_("mu"),
kName_("k"),
Cmu_(0.09), Cmu_(0.09),
kappa_(0.41), kappa_(0.41),
E_(9.8) E_(9.8)
{} {}
mutWallFunctionFvPatchScalarField:: mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
mutWallFunctionFvPatchScalarField
( (
const mutWallFunctionFvPatchScalarField& ptf, const mutWallFunctionFvPatchScalarField& ptf,
const fvPatch& p, const fvPatch& p,
@ -68,17 +80,13 @@ mutWallFunctionFvPatchScalarField
) )
: :
fixedValueFvPatchScalarField(ptf, p, iF, mapper), fixedValueFvPatchScalarField(ptf, p, iF, mapper),
rhoName_(ptf.rhoName_),
muName_(ptf.muName_),
kName_(ptf.kName_),
Cmu_(ptf.Cmu_), Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_), kappa_(ptf.kappa_),
E_(ptf.E_) E_(ptf.E_)
{} {}
mutWallFunctionFvPatchScalarField:: mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
mutWallFunctionFvPatchScalarField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF, const DimensionedField<scalar, volMesh>& iF,
@ -86,42 +94,31 @@ mutWallFunctionFvPatchScalarField
) )
: :
fixedValueFvPatchScalarField(p, iF, dict), fixedValueFvPatchScalarField(p, iF, dict),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
muName_(dict.lookupOrDefault<word>("mu", "mu")),
kName_(dict.lookupOrDefault<word>("k", "k")),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)), Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)) E_(dict.lookupOrDefault<scalar>("E", 9.8))
{} {}
mutWallFunctionFvPatchScalarField:: mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
mutWallFunctionFvPatchScalarField
( (
const mutWallFunctionFvPatchScalarField& wfpsf const mutWallFunctionFvPatchScalarField& wfpsf
) )
: :
fixedValueFvPatchScalarField(wfpsf), fixedValueFvPatchScalarField(wfpsf),
rhoName_(wfpsf.rhoName_),
muName_(wfpsf.muName_),
kName_(wfpsf.kName_),
Cmu_(wfpsf.Cmu_), Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_), kappa_(wfpsf.kappa_),
E_(wfpsf.E_) E_(wfpsf.E_)
{} {}
mutWallFunctionFvPatchScalarField:: mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
mutWallFunctionFvPatchScalarField
( (
const mutWallFunctionFvPatchScalarField& wfpsf, const mutWallFunctionFvPatchScalarField& wfpsf,
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
fixedValueFvPatchScalarField(wfpsf, iF), fixedValueFvPatchScalarField(wfpsf, iF),
rhoName_(wfpsf.rhoName_),
muName_(wfpsf.muName_),
kName_(wfpsf.kName_),
Cmu_(wfpsf.Cmu_), Cmu_(wfpsf.Cmu_),
kappa_(wfpsf.kappa_), kappa_(wfpsf.kappa_),
E_(wfpsf.E_) E_(wfpsf.E_)
@ -132,21 +129,27 @@ mutWallFunctionFvPatchScalarField
void mutWallFunctionFvPatchScalarField::updateCoeffs() void mutWallFunctionFvPatchScalarField::updateCoeffs()
{ {
operator==(calcMut());
fixedValueFvPatchScalarField::updateCoeffs();
}
tmp<scalarField> mutWallFunctionFvPatchScalarField::calcMut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_);
const scalarField& y = rasModel.y()[patch().index()]; const scalarField& y = rasModel.y()[patchI];
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const scalar Cmu25 = pow(Cmu_, 0.25); const scalar Cmu25 = pow(Cmu_, 0.25);
const scalarField& rhow = tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
patch().lookupPatchField<volScalarField, scalar>(rhoName_); scalarField& mutw = tmutw();
const volScalarField& k = db().lookupObject<volScalarField>(kName_);
const scalarField& muw =
patch().lookupPatchField<volScalarField, scalar>(muName_);
scalarField& mutw = *this;
forAll(mutw, faceI) forAll(mutw, faceI)
{ {
@ -160,20 +163,32 @@ void mutWallFunctionFvPatchScalarField::updateCoeffs()
{ {
mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1); mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1);
} }
else
{
mutw[faceI] = 0.0;
}
} }
return tmutw;
}
tmp<scalarField> mutWallFunctionFvPatchScalarField::yPlus() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const scalarField kwc = k.boundaryField()[patchI].patchInternalField();
const scalarField& muw = rasModel.mu().boundaryField()[patchI];
const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
return pow(Cmu_, 0.25)*y*sqrt(kwc)/(muw/rhow);
} }
void mutWallFunctionFvPatchScalarField::write(Ostream& os) const void mutWallFunctionFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchField<scalar>::write(os); fvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
writeEntryIfDifferent<word>(os, "k", "k", kName_);
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;

View File

@ -57,16 +57,9 @@ class mutWallFunctionFvPatchScalarField
: :
public fixedValueFvPatchScalarField public fixedValueFvPatchScalarField
{ {
// Private data protected:
//- Name of density field // Protected data
word rhoName_;
//- Name of laminar viscosity field
word muName_;
//- Name of turbulence kinetic energy field
word kName_;
//- Cmu coefficient //- Cmu coefficient
scalar Cmu_; scalar Cmu_;
@ -78,6 +71,15 @@ class mutWallFunctionFvPatchScalarField
scalar E_; scalar E_;
// Protected member functions
//- Check the type of the patch
virtual void checkType();
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcMut() const;
public: public:
//- Runtime type information //- Runtime type information
@ -151,6 +153,9 @@ public:
// Evaluation functions // Evaluation functions
//- Calculate and return the yPlus at the boundary
virtual tmp<scalarField> yPlus() const;
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();