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 "epsilonWallFunctionFvPatchScalarField.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 epsilonWallFunctionFvPatchScalarField::checkType()
00045 {
00046 if (!isA<wallFvPatch>(patch()))
00047 {
00048 FatalErrorIn("epsilonWallFunctionFvPatchScalarField::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 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
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 {
00076 checkType();
00077 }
00078
00079
00080 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00081 (
00082 const epsilonWallFunctionFvPatchScalarField& ptf,
00083 const fvPatch& p,
00084 const DimensionedField<scalar, volMesh>& iF,
00085 const fvPatchFieldMapper& mapper
00086 )
00087 :
00088 fixedInternalValueFvPatchField<scalar>(ptf, p, iF, mapper),
00089 UName_(ptf.UName_),
00090 kName_(ptf.kName_),
00091 GName_(ptf.GName_),
00092 nuName_(ptf.nuName_),
00093 nutName_(ptf.nutName_),
00094 Cmu_(ptf.Cmu_),
00095 kappa_(ptf.kappa_),
00096 E_(ptf.E_)
00097 {
00098 checkType();
00099 }
00100
00101
00102 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00103 (
00104 const fvPatch& p,
00105 const DimensionedField<scalar, volMesh>& iF,
00106 const dictionary& dict
00107 )
00108 :
00109 fixedInternalValueFvPatchField<scalar>(p, iF, dict),
00110 UName_(dict.lookupOrDefault<word>("U", "U")),
00111 kName_(dict.lookupOrDefault<word>("k", "k")),
00112 GName_(dict.lookupOrDefault<word>("G", "RASModel::G")),
00113 nuName_(dict.lookupOrDefault<word>("nu", "nu")),
00114 nutName_(dict.lookupOrDefault<word>("nut", "nut")),
00115 Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
00116 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00117 E_(dict.lookupOrDefault<scalar>("E", 9.8))
00118 {
00119 checkType();
00120 }
00121
00122
00123 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00124 (
00125 const epsilonWallFunctionFvPatchScalarField& ewfpsf
00126 )
00127 :
00128 fixedInternalValueFvPatchField<scalar>(ewfpsf),
00129 UName_(ewfpsf.UName_),
00130 kName_(ewfpsf.kName_),
00131 GName_(ewfpsf.GName_),
00132 nuName_(ewfpsf.nuName_),
00133 nutName_(ewfpsf.nutName_),
00134 Cmu_(ewfpsf.Cmu_),
00135 kappa_(ewfpsf.kappa_),
00136 E_(ewfpsf.E_)
00137 {
00138 checkType();
00139 }
00140
00141
00142 epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField
00143 (
00144 const epsilonWallFunctionFvPatchScalarField& ewfpsf,
00145 const DimensionedField<scalar, volMesh>& iF
00146 )
00147 :
00148 fixedInternalValueFvPatchField<scalar>(ewfpsf, iF),
00149 UName_(ewfpsf.UName_),
00150 kName_(ewfpsf.kName_),
00151 GName_(ewfpsf.GName_),
00152 nuName_(ewfpsf.nuName_),
00153 nutName_(ewfpsf.nutName_),
00154 Cmu_(ewfpsf.Cmu_),
00155 kappa_(ewfpsf.kappa_),
00156 E_(ewfpsf.E_)
00157 {
00158 checkType();
00159 }
00160
00161
00162
00163
00164 void epsilonWallFunctionFvPatchScalarField::updateCoeffs()
00165 {
00166 if (updated())
00167 {
00168 return;
00169 }
00170
00171 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00172 const scalarField& y = rasModel.y()[patch().index()];
00173
00174 const scalar Cmu25 = pow(Cmu_, 0.25);
00175 const scalar Cmu75 = pow(Cmu_, 0.75);
00176
00177 volScalarField& G = const_cast<volScalarField&>
00178 (db().lookupObject<volScalarField>(GName_));
00179
00180 volScalarField& epsilon = const_cast<volScalarField&>
00181 (db().lookupObject<volScalarField>(dimensionedInternalField().name()));
00182
00183 const volScalarField& k = db().lookupObject<volScalarField>(kName_);
00184
00185 const scalarField& nuw =
00186 patch().lookupPatchField<volScalarField, scalar>(nuName_);
00187
00188 const scalarField& nutw =
00189 patch().lookupPatchField<volScalarField, scalar>(nutName_);
00190
00191 const fvPatchVectorField& Uw =
00192 patch().lookupPatchField<volVectorField, vector>(UName_);
00193
00194 const scalarField magGradUw = mag(Uw.snGrad());
00195
00196
00197 forAll(nutw, faceI)
00198 {
00199 label faceCellI = patch().faceCells()[faceI];
00200
00201 epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]);
00202
00203 G[faceCellI] =
00204 (nutw[faceI] + nuw[faceI])
00205 *magGradUw[faceI]
00206 *Cmu25*sqrt(k[faceCellI])
00207 /(kappa_*y[faceI]);
00208 }
00209
00210
00211
00212 fixedInternalValueFvPatchField<scalar>::updateCoeffs();
00213 }
00214
00215
00216 void epsilonWallFunctionFvPatchScalarField::evaluate
00217 (
00218 const Pstream::commsTypes commsType
00219 )
00220 {
00221 fixedInternalValueFvPatchField<scalar>::evaluate(commsType);
00222 }
00223
00224
00225 void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const
00226 {
00227 fixedInternalValueFvPatchField<scalar>::write(os);
00228 writeEntryIfDifferent<word>(os, "U", "U", UName_);
00229 writeEntryIfDifferent<word>(os, "k", "k", kName_);
00230 writeEntryIfDifferent<word>(os, "G", "RASModel::G", GName_);
00231 writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
00232 writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
00233 os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
00234 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00235 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00236 writeEntry("value", os);
00237 }
00238
00239
00240
00241
00242 makePatchTypeField
00243 (
00244 fvPatchScalarField,
00245 epsilonWallFunctionFvPatchScalarField
00246 );
00247
00248
00249
00250 }
00251 }
00252 }
00253
00254