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 "mutRoughWallFunctionFvPatchScalarField.H"
00028 #include "RASModel.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "addToRunTimeSelectionTable.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 namespace compressible
00038 {
00039 namespace RASModels
00040 {
00041
00042
00043
00044
00045 scalar mutRoughWallFunctionFvPatchScalarField::fnRough
00046 (
00047 const scalar KsPlus,
00048 const scalar Cs
00049 ) const
00050 {
00051
00052
00053 if (KsPlus < 90.0)
00054 {
00055 return pow
00056 (
00057 (KsPlus - 2.25)/87.75 + Cs*KsPlus,
00058 sin(0.4258*(log(KsPlus) - 0.811))
00059 );
00060 }
00061 else
00062 {
00063 return (1.0 + Cs*KsPlus);
00064 }
00065 }
00066
00067
00068 tmp<scalarField> mutRoughWallFunctionFvPatchScalarField::calcMut() const
00069 {
00070 const label patchI = patch().index();
00071
00072 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00073 const scalarField& y = rasModel.y()[patchI];
00074 const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00075 const tmp<volScalarField> tk = rasModel.k();
00076 const volScalarField& k = tk();
00077 const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00078
00079 const scalar Cmu25 = pow(Cmu_, 0.25);
00080
00081 tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
00082 scalarField& mutw = tmutw();
00083
00084 forAll(mutw, faceI)
00085 {
00086 label faceCellI = patch().faceCells()[faceI];
00087
00088 scalar uStar = Cmu25*sqrt(k[faceCellI]);
00089
00090 scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
00091
00092 scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
00093
00094 scalar Edash = E_;
00095 scalar yPlusLamNew = yPlusLam_;
00096 if (KsPlus > 2.25)
00097 {
00098 Edash /= fnRough(KsPlus, Cs_[faceI]);
00099 yPlusLamNew = rasModel.yPlusLam(kappa_, Edash);
00100 }
00101
00102 if (debug)
00103 {
00104 Info<< "yPlus = " << yPlus
00105 << ", KsPlus = " << KsPlus
00106 << ", Edash = " << Edash
00107 << ", yPlusLam = " << yPlusLam_
00108 << endl;
00109 }
00110
00111 if (yPlus > yPlusLamNew)
00112 {
00113 mutw[faceI] =
00114 muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1);
00115 }
00116 }
00117
00118 return tmutw;
00119 }
00120
00121
00122
00123
00124 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00125 (
00126 const fvPatch& p,
00127 const DimensionedField<scalar, volMesh>& iF
00128 )
00129 :
00130 mutWallFunctionFvPatchScalarField(p, iF),
00131 Ks_(p.size(), 0.0),
00132 Cs_(p.size(), 0.0)
00133 {}
00134
00135
00136 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00137 (
00138 const mutRoughWallFunctionFvPatchScalarField& ptf,
00139 const fvPatch& p,
00140 const DimensionedField<scalar, volMesh>& iF,
00141 const fvPatchFieldMapper& mapper
00142 )
00143 :
00144 mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
00145 Ks_(ptf.Ks_, mapper),
00146 Cs_(ptf.Cs_, mapper)
00147 {}
00148
00149
00150 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00151 (
00152 const fvPatch& p,
00153 const DimensionedField<scalar, volMesh>& iF,
00154 const dictionary& dict
00155 )
00156 :
00157 mutWallFunctionFvPatchScalarField(p, iF, dict),
00158 Ks_("Ks", dict, p.size()),
00159 Cs_("Cs", dict, p.size())
00160 {}
00161
00162
00163 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00164 (
00165 const mutRoughWallFunctionFvPatchScalarField& rwfpsf
00166 )
00167 :
00168 mutWallFunctionFvPatchScalarField(rwfpsf),
00169 Ks_(rwfpsf.Ks_),
00170 Cs_(rwfpsf.Cs_)
00171 {}
00172
00173
00174 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00175 (
00176 const mutRoughWallFunctionFvPatchScalarField& rwfpsf,
00177 const DimensionedField<scalar, volMesh>& iF
00178 )
00179 :
00180 mutWallFunctionFvPatchScalarField(rwfpsf, iF),
00181 Ks_(rwfpsf.Ks_),
00182 Cs_(rwfpsf.Cs_)
00183 {}
00184
00185
00186
00187
00188 void mutRoughWallFunctionFvPatchScalarField::autoMap
00189 (
00190 const fvPatchFieldMapper& m
00191 )
00192 {
00193 mutWallFunctionFvPatchScalarField::autoMap(m);
00194 Ks_.autoMap(m);
00195 Cs_.autoMap(m);
00196 }
00197
00198
00199 void mutRoughWallFunctionFvPatchScalarField::rmap
00200 (
00201 const fvPatchScalarField& ptf,
00202 const labelList& addr
00203 )
00204 {
00205 mutWallFunctionFvPatchScalarField::rmap(ptf, addr);
00206
00207 const mutRoughWallFunctionFvPatchScalarField& nrwfpsf =
00208 refCast<const mutRoughWallFunctionFvPatchScalarField>(ptf);
00209
00210 Cs_.rmap(nrwfpsf.Cs_, addr);
00211 Ks_.rmap(nrwfpsf.Ks_, addr);
00212 }
00213
00214
00215 void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
00216 {
00217 fvPatchField<scalar>::write(os);
00218 writeLocalEntries(os);
00219 Cs_.writeEntry("Cs", os);
00220 Ks_.writeEntry("Ks", os);
00221 writeEntry("value", os);
00222 }
00223
00224
00225
00226
00227 makePatchTypeField(fvPatchScalarField, mutRoughWallFunctionFvPatchScalarField);
00228
00229
00230
00231 }
00232 }
00233 }
00234
00235