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