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 "nuSgsWallFunctionFvPatchScalarField.H"
00028 #include "fvPatchFieldMapper.H"
00029 #include "volFields.H"
00030 #include "addToRunTimeSelectionTable.H"
00031
00032
00033
00034 namespace Foam
00035 {
00036 namespace incompressible
00037 {
00038 namespace LESModels
00039 {
00040
00041
00042
00043 nuSgsWallFunctionFvPatchScalarField::
00044 nuSgsWallFunctionFvPatchScalarField
00045 (
00046 const fvPatch& p,
00047 const DimensionedField<scalar, volMesh>& iF
00048 )
00049 :
00050 fixedValueFvPatchScalarField(p, iF),
00051 UName_("U"),
00052 nuName_("nu"),
00053 kappa_(0.41),
00054 E_(9.8)
00055 {}
00056
00057
00058 nuSgsWallFunctionFvPatchScalarField::
00059 nuSgsWallFunctionFvPatchScalarField
00060 (
00061 const nuSgsWallFunctionFvPatchScalarField& ptf,
00062 const fvPatch& p,
00063 const DimensionedField<scalar, volMesh>& iF,
00064 const fvPatchFieldMapper& mapper
00065 )
00066 :
00067 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00068 UName_(ptf.UName_),
00069 nuName_(ptf.nuName_),
00070 kappa_(ptf.kappa_),
00071 E_(ptf.E_)
00072 {}
00073
00074
00075 nuSgsWallFunctionFvPatchScalarField::
00076 nuSgsWallFunctionFvPatchScalarField
00077 (
00078 const fvPatch& p,
00079 const DimensionedField<scalar, volMesh>& iF,
00080 const dictionary& dict
00081 )
00082 :
00083 fixedValueFvPatchScalarField(p, iF, dict),
00084 UName_(dict.lookupOrDefault<word>("U", "U")),
00085 nuName_(dict.lookupOrDefault<word>("nu", "nu")),
00086 kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00087 E_(dict.lookupOrDefault<scalar>("E", 9.8))
00088 {}
00089
00090
00091 nuSgsWallFunctionFvPatchScalarField::
00092 nuSgsWallFunctionFvPatchScalarField
00093 (
00094 const nuSgsWallFunctionFvPatchScalarField& nwfpsf
00095 )
00096 :
00097 fixedValueFvPatchScalarField(nwfpsf),
00098 UName_(nwfpsf.UName_),
00099 nuName_(nwfpsf.nuName_),
00100 kappa_(nwfpsf.kappa_),
00101 E_(nwfpsf.E_)
00102 {}
00103
00104
00105 nuSgsWallFunctionFvPatchScalarField::
00106 nuSgsWallFunctionFvPatchScalarField
00107 (
00108 const nuSgsWallFunctionFvPatchScalarField& nwfpsf,
00109 const DimensionedField<scalar, volMesh>& iF
00110 )
00111 :
00112 fixedValueFvPatchScalarField(nwfpsf, iF),
00113 UName_(nwfpsf.UName_),
00114 nuName_(nwfpsf.nuName_),
00115 kappa_(nwfpsf.kappa_),
00116 E_(nwfpsf.E_)
00117 {}
00118
00119
00120
00121
00122 void nuSgsWallFunctionFvPatchScalarField::evaluate
00123 (
00124 const Pstream::commsTypes
00125 )
00126 {
00127 const scalarField& ry = patch().deltaCoeffs();
00128
00129 const fvPatchVectorField& U =
00130 patch().lookupPatchField<volVectorField, vector>(UName_);
00131
00132 scalarField magUp = mag(U.patchInternalField() - U);
00133
00134 const scalarField& nuw =
00135 patch().lookupPatchField<volScalarField, scalar>(nuName_);
00136 scalarField& nuSgsw = *this;
00137
00138
00139 scalarField magFaceGradU = mag(U.snGrad());
00140
00141 forAll(nuSgsw, facei)
00142 {
00143 scalar magUpara = magUp[facei];
00144
00145 scalar utau = sqrt((nuSgsw[facei] + nuw[facei])*magFaceGradU[facei]);
00146
00147 if (utau > VSMALL)
00148 {
00149 int iter = 0;
00150 scalar err = GREAT;
00151
00152 do
00153 {
00154 scalar kUu = min(kappa_*magUpara/utau, 50);
00155 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
00156
00157 scalar f =
00158 - utau/(ry[facei]*nuw[facei])
00159 + magUpara/utau
00160 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00161
00162 scalar df =
00163 - 1.0/(ry[facei]*nuw[facei])
00164 - magUpara/sqr(utau)
00165 - 1/E_*kUu*fkUu/utau;
00166
00167 scalar utauNew = utau - f/df;
00168 err = mag((utau - utauNew)/utau);
00169 utau = utauNew;
00170
00171 } while (utau > VSMALL && err > 0.01 && ++iter < 10);
00172
00173 nuSgsw[facei] =
00174 max(sqr(max(utau, 0))/magFaceGradU[facei] - nuw[facei], 0.0);
00175 }
00176 else
00177 {
00178 nuSgsw[facei] = 0;
00179 }
00180 }
00181 }
00182
00183
00184 void nuSgsWallFunctionFvPatchScalarField::write(Ostream& os) const
00185 {
00186 fvPatchField<scalar>::write(os);
00187 writeEntryIfDifferent<word>(os, "U", "U", UName_);
00188 writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
00189 os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00190 os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00191 writeEntry("value", os);
00192 }
00193
00194
00195
00196
00197 makePatchTypeField
00198 (
00199 fvPatchScalarField,
00200 nuSgsWallFunctionFvPatchScalarField
00201 );
00202
00203
00204
00205 }
00206 }
00207 }
00208
00209