nutSpalartAllmarasWallFunctionFvPatchScalarField.C
Go to the documentation of this file.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 "nutSpalartAllmarasWallFunctionFvPatchScalarField.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 tmp<scalarField>
00045 nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const
00046 {
00047 const label patchI = patch().index();
00048
00049 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00050 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00051 const scalarField magGradU = mag(Uw.snGrad());
00052 const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
00053
00054 return max(scalar(0), sqr(calcUTau(magGradU))/magGradU - nuw);
00055 }
00056
00057
00058 tmp<scalarField> nutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
00059 (
00060 const scalarField& magGradU
00061 ) const
00062 {
00063 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00064 const scalarField& y = rasModel.y()[patch().index()];
00065
00066 const fvPatchVectorField& Uw =
00067 rasModel.U().boundaryField()[patch().index()];
00068 const scalarField magUp = mag(Uw.patchInternalField() - Uw);
00069
00070 const scalarField& nuw = rasModel.nu().boundaryField()[patch().index()];
00071 const scalarField& nutw = *this;
00072
00073 tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
00074 scalarField& uTau = tuTau();
00075
00076 forAll(uTau, facei)
00077 {
00078 scalar magUpara = magUp[facei];
00079
00080 scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]);
00081
00082 if (ut > VSMALL)
00083 {
00084 int iter = 0;
00085 scalar err = GREAT;
00086
00087 do
00088 {
00089 scalar kUu = min(kappa_*magUpara/ut, 50);
00090 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
00091
00092 scalar f =
00093 - ut*y[facei]/nuw[facei]
00094 + magUpara/ut
00095 + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00096
00097 scalar df =
00098 y[facei]/nuw[facei]
00099 + magUpara/sqr(ut)
00100 + 1/E_*kUu*fkUu/ut;
00101
00102 scalar uTauNew = ut + f/df;
00103 err = mag((ut - uTauNew)/ut);
00104 ut = uTauNew;
00105
00106 } while (ut > VSMALL && err > 0.01 && ++iter < 10);
00107 uTau[facei] = max(0.0, ut);
00108 }
00109 }
00110
00111 return tuTau;
00112 }
00113
00114
00115
00116
00117 nutSpalartAllmarasWallFunctionFvPatchScalarField::
00118 nutSpalartAllmarasWallFunctionFvPatchScalarField
00119 (
00120 const fvPatch& p,
00121 const DimensionedField<scalar, volMesh>& iF
00122 )
00123 :
00124 nutWallFunctionFvPatchScalarField(p, iF)
00125 {}
00126
00127
00128 nutSpalartAllmarasWallFunctionFvPatchScalarField::
00129 nutSpalartAllmarasWallFunctionFvPatchScalarField
00130 (
00131 const nutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
00132 const fvPatch& p,
00133 const DimensionedField<scalar, volMesh>& iF,
00134 const fvPatchFieldMapper& mapper
00135 )
00136 :
00137 nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
00138 {}
00139
00140
00141 nutSpalartAllmarasWallFunctionFvPatchScalarField::
00142 nutSpalartAllmarasWallFunctionFvPatchScalarField
00143 (
00144 const fvPatch& p,
00145 const DimensionedField<scalar, volMesh>& iF,
00146 const dictionary& dict
00147 )
00148 :
00149 nutWallFunctionFvPatchScalarField(p, iF, dict)
00150 {}
00151
00152
00153 nutSpalartAllmarasWallFunctionFvPatchScalarField::
00154 nutSpalartAllmarasWallFunctionFvPatchScalarField
00155 (
00156 const nutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
00157 )
00158 :
00159 nutWallFunctionFvPatchScalarField(wfpsf)
00160 {}
00161
00162
00163 nutSpalartAllmarasWallFunctionFvPatchScalarField::
00164 nutSpalartAllmarasWallFunctionFvPatchScalarField
00165 (
00166 const nutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf,
00167 const DimensionedField<scalar, volMesh>& iF
00168 )
00169 :
00170 nutWallFunctionFvPatchScalarField(wfpsf, iF)
00171 {}
00172
00173
00174
00175
00176 tmp<scalarField>
00177 nutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
00178 {
00179 const label patchI = patch().index();
00180
00181 const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00182 const scalarField& y = rasModel.y()[patchI];
00183 const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00184 const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
00185
00186 return y*calcUTau(mag(Uw.snGrad()))/nuw;
00187 }
00188
00189
00190 void nutSpalartAllmarasWallFunctionFvPatchScalarField::write
00191 (
00192 Ostream& os
00193 ) const
00194 {
00195 fvPatchField<scalar>::write(os);
00196 writeLocalEntries(os);
00197 writeEntry("value", os);
00198 }
00199
00200
00201
00202
00203 makePatchTypeField
00204 (
00205 fvPatchScalarField,
00206 nutSpalartAllmarasWallFunctionFvPatchScalarField
00207 );
00208
00209
00210
00211 }
00212 }
00213 }
00214
00215
Copyright © 2000-2009 OpenCFD Ltd