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 #include "omegaWallFunctionFvPatchScalarField.H"
00027 #include <incompressibleRASModels/RASModel.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 #include <finiteVolume/wallFvPatch.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037 namespace incompressible
00038 {
00039 namespace RASModels
00040 {
00041
00042
00043
00044 void omegaWallFunctionFvPatchScalarField::checkType()
00045 {
00046 if (!isA<wallFvPatch>(patch()))
00047 {
00048 FatalErrorIn("omegaWallFunctionFvPatchScalarField::checkType()")
00049 << "Invalid wall function specification" << nl
00050 << " Patch type for patch " << patch().name()
00051 << " must be wall" << nl
00052 << " Current patch type is " << patch().type() << nl << endl
00053 << abort(FatalError);
00054 }
00055 }
00056
00057
00058
00059
00060 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00061 (
00062 const fvPatch& p,
00063 const DimensionedField<scalar, volMesh>& iF
00064 )
00065 :
00066 fixedInternalValueFvPatchField<scalar>(p, iF),
00067 UName_("U"),
00068 kName_("k"),
00069 GName_("RASModel::G"),
00070 nuName_("nu"),
00071 nutName_("nut"),
00072 Cmu_(0.09),
00073 kappa_(0.41),
00074 E_(9.8),
00075 beta1_(0.075)
00076 {
00077 checkType();
00078 }
00079
00080
00081 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00082 (
00083 const omegaWallFunctionFvPatchScalarField& ptf,
00084 const fvPatch& p,
00085 const DimensionedField<scalar, volMesh>& iF,
00086 const fvPatchFieldMapper& mapper
00087 )
00088 :
00089 fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
00090 UName_(ptf.UName_),
00091 kName_(ptf.kName_),
00092 GName_(ptf.GName_),
00093 nuName_(ptf.nuName_),
00094 nutName_(ptf.nutName_),
00095 Cmu_(ptf.Cmu_),
00096 kappa_(ptf.kappa_),
00097 E_(ptf.E_),
00098 beta1_(ptf.beta1_)
00099 {
00100 checkType();
00101 }
00102
00103
00104 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00105 (
00106 const fvPatch& p,
00107 const DimensionedField<scalar, volMesh>& iF,
00108 const dictionary& dict
00109 )
00110 :
00111 fixedInternalValueFvPatchField<scalar>(p, iF, dict),
00112 UName_(dict.lookupOrDefault<word>("U", "U")),
00113 kName_(dict.lookupOrDefault<word>("k", "k")),
00114 GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
00115 nuName_(dict.lookupOrDefault<word>("nu", "nu")),
00116 nutName_(dict.lookupOrDefault<word>("nut", "nut")),
00117 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
00118 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00119 E_(dict.lookupOrDefault<scalar>("E", 9.8)),
00120 beta1_(dict.lookupOrDefault<scalar>("beta1", 0.075))
00121 {
00122 checkType();
00123 }
00124
00125
00126 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00127 (
00128 const omegaWallFunctionFvPatchScalarField& owfpsf
00129 )
00130 :
00131 fixedInternalValueFvPatchField<scalar>(owfpsf),
00132 UName_(owfpsf.UName_),
00133 kName_(owfpsf.kName_),
00134 GName_(owfpsf.GName_),
00135 nuName_(owfpsf.nuName_),
00136 nutName_(owfpsf.nutName_),
00137 Cmu_(owfpsf.Cmu_),
00138 kappa_(owfpsf.kappa_),
00139 E_(owfpsf.E_),
00140 beta1_(owfpsf.beta1_)
00141 {
00142 checkType();
00143 }
00144
00145
00146 omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField
00147 (
00148 const omegaWallFunctionFvPatchScalarField& owfpsf,
00149 const DimensionedField<scalar, volMesh>& iF
00150 )
00151 :
00152 fixedInternalValueFvPatchField<scalar>(owfpsf, iF),
00153 UName_(owfpsf.UName_),
00154 kName_(owfpsf.kName_),
00155 GName_(owfpsf.GName_),
00156 nuName_(owfpsf.nuName_),
00157 nutName_(owfpsf.nutName_),
00158 Cmu_(owfpsf.Cmu_),
00159 kappa_(owfpsf.kappa_),
00160 E_(owfpsf.E_),
00161 beta1_(owfpsf.beta1_)
00162 {
00163 checkType();
00164 }
00165
00166
00167
00168
00169 void omegaWallFunctionFvPatchScalarField::updateCoeffs()
00170 {
00171 if (updated())
00172 {
00173 return;
00174 }
00175
00176 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00177 const scalarField& y = rasModel.y()[patch().index()];
00178
00179 const scalar Cmu25 = pow(Cmu_, 0.25);
00180
00181 volScalarField& G = const_cast<volScalarField&>
00182 (db().lookupObject<volScalarField>(GName_));
00183
00184 volScalarField& omega = const_cast<volScalarField&>
00185 (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
00186
00187 const scalarField& k = db().lookupObject<volScalarField>(kName_);
00188
00189 const scalarField& nuw =
00190 patch().lookupPatchField<volScalarField, scalar>(nuName_);
00191
00192 const scalarField& nutw =
00193 patch().lookupPatchField<volScalarField, scalar>(nutName_);
00194
00195 const fvPatchVectorField& Uw =
00196 patch().lookupPatchField<volVectorField, vector>(UName_);
00197
00198 vectorField n = patch().nf();
00199
00200 const scalarField magGradUw = mag(Uw.snGrad());
00201
00202
00203 forAll(nutw, faceI)
00204 {
00205 label faceCellI = patch().faceCells()[faceI];
00206
00207 scalar omegaVis = 6.0*nuw[faceI]/(beta1_*sqr(y[faceI]));
00208 scalar omegaLog = sqrt(k[faceCellI])/(Cmu25*kappa_*y[faceI]);
00209 omega[faceCellI] = sqrt(sqr(omegaVis) + sqr(omegaLog));
00210
00211 G[faceCellI] =
00212 (nutw[faceI] + nuw[faceI])
00213 *magGradUw[faceI]
00214 *Cmu25*sqrt(k[faceCellI])
00215 /(kappa_*y[faceI]);
00216 }
00217
00218
00219
00220 fixedInternalValueFvPatchField<scalar>::updateCoeffs();
00221 }
00222
00223
00224 void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const
00225 {
00226 fixedInternalValueFvPatchField<scalar>::write(os);
00227 writeEntryIfDifferent<word>(os, "U", "U", UName_);
00228 writeEntryIfDifferent<word>(os, "k", "k", kName_);
00229 writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
00230 writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
00231 writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
00232 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
00233 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00234 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00235 os.writeKeyword("beta1") << beta1_ << token::END_STATEMENT << nl;
00236 writeEntry("value", os);
00237 }
00238
00239
00240
00241
00242 makePatchTypeField
00243 (
00244 fvPatchScalarField,
00245 omegaWallFunctionFvPatchScalarField
00246 );
00247
00248
00249
00250 }
00251 }
00252 }
00253
00254