00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "mutWallFunctionFvPatchScalarField.H"
00028 #include "RASModel.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "wallFvPatch.H"
00032 #include "addToRunTimeSelectionTable.H"
00033
00034
00035
00036 namespace Foam
00037 {
00038 namespace compressible
00039 {
00040 namespace RASModels
00041 {
00042
00043
00044
00045 void mutWallFunctionFvPatchScalarField::checkType()
00046 {
00047 if (!isA<wallFvPatch>(patch()))
00048 {
00049 FatalErrorIn("mutWallFunctionFvPatchScalarField::checkType()")
00050 << "Invalid wall function specification" << nl
00051 << " Patch type for patch " << patch().name()
00052 << " must be wall" << nl
00053 << " Current patch type is " << patch().type() << nl << endl
00054 << abort(FatalError);
00055 }
00056 }
00057
00058
00059 scalar mutWallFunctionFvPatchScalarField::calcYPlusLam
00060 (
00061 const scalar kappa,
00062 const scalar E
00063 ) const
00064 {
00065 scalar ypl = 11.0;
00066
00067 for (int i=0; i<10; i++)
00068 {
00069 ypl = log(E*ypl)/kappa;
00070 }
00071
00072 return ypl;
00073 }
00074
00075
00076 tmp<scalarField> mutWallFunctionFvPatchScalarField::calcMut() const
00077 {
00078 const label patchI = patch().index();
00079 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00080 const scalarField& y = rasModel.y()[patchI];
00081 const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00082 const tmp<volScalarField> tk = rasModel.k();
00083 const volScalarField& k = tk();
00084 const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00085
00086 const scalar Cmu25 = pow(Cmu_, 0.25);
00087
00088 tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
00089 scalarField& mutw = tmutw();
00090
00091 forAll(mutw, faceI)
00092 {
00093 label faceCellI = patch().faceCells()[faceI];
00094
00095 scalar yPlus =
00096 Cmu25*y[faceI]*sqrt(k[faceCellI])/(muw[faceI]/rhow[faceI]);
00097
00098 if (yPlus > yPlusLam_)
00099 {
00100 mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1);
00101 }
00102 }
00103
00104 return tmutw;
00105 }
00106
00107
00108 void mutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
00109 {
00110 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
00111 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00112 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00113 }
00114
00115
00116
00117
00118 mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
00119 (
00120 const fvPatch& p,
00121 const DimensionedField<scalar, volMesh>& iF
00122 )
00123 :
00124 fixedValueFvPatchScalarField(p, iF),
00125 Cmu_(0.09),
00126 kappa_(0.41),
00127 E_(9.8),
00128 yPlusLam_(calcYPlusLam(kappa_, E_))
00129 {}
00130
00131
00132 mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
00133 (
00134 const mutWallFunctionFvPatchScalarField& ptf,
00135 const fvPatch& p,
00136 const DimensionedField<scalar, volMesh>& iF,
00137 const fvPatchFieldMapper& mapper
00138 )
00139 :
00140 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00141 Cmu_(ptf.Cmu_),
00142 kappa_(ptf.kappa_),
00143 E_(ptf.E_),
00144 yPlusLam_(ptf.yPlusLam_)
00145 {}
00146
00147
00148 mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
00149 (
00150 const fvPatch& p,
00151 const DimensionedField<scalar, volMesh>& iF,
00152 const dictionary& dict
00153 )
00154 :
00155 fixedValueFvPatchScalarField(p, iF, dict),
00156 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
00157 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00158 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
00159 yPlusLam_(calcYPlusLam(kappa_, E_))
00160 {}
00161
00162
00163 mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
00164 (
00165 const mutWallFunctionFvPatchScalarField& wfpsf
00166 )
00167 :
00168 fixedValueFvPatchScalarField(wfpsf),
00169 Cmu_(wfpsf.Cmu_),
00170 kappa_(wfpsf.kappa_),
00171 E_(wfpsf.E_),
00172 yPlusLam_(wfpsf.yPlusLam_)
00173 {}
00174
00175
00176 mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField
00177 (
00178 const mutWallFunctionFvPatchScalarField& wfpsf,
00179 const DimensionedField<scalar, volMesh>& iF
00180 )
00181 :
00182 fixedValueFvPatchScalarField(wfpsf, iF),
00183 Cmu_(wfpsf.Cmu_),
00184 kappa_(wfpsf.kappa_),
00185 E_(wfpsf.E_),
00186 yPlusLam_(wfpsf.yPlusLam_)
00187 {}
00188
00189
00190
00191
00192 void mutWallFunctionFvPatchScalarField::updateCoeffs()
00193 {
00194 operator==(calcMut());
00195
00196 fixedValueFvPatchScalarField::updateCoeffs();
00197 }
00198
00199
00200 tmp<scalarField> mutWallFunctionFvPatchScalarField::yPlus() const
00201 {
00202 const label patchI = patch().index();
00203
00204 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00205 const scalarField& y = rasModel.y()[patchI];
00206
00207 const tmp<volScalarField> tk = rasModel.k();
00208 const volScalarField& k = tk();
00209 const scalarField kwc = k.boundaryField()[patchI].patchInternalField();
00210 const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00211 const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00212
00213 return pow(Cmu_, 0.25)*y*sqrt(kwc)/(muw/rhow);
00214 }
00215
00216
00217 void mutWallFunctionFvPatchScalarField::write(Ostream& os) const
00218 {
00219 fvPatchField<scalar>::write(os);
00220 writeLocalEntries(os);
00221 writeEntry("value", os);
00222 }
00223
00224
00225
00226
00227 makePatchTypeField(fvPatchScalarField, mutWallFunctionFvPatchScalarField);
00228
00229
00230
00231 }
00232 }
00233 }
00234
00235