OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

mutSpalartAllmarasWallFunctionFvPatchScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "mutSpalartAllmarasWallFunctionFvPatchScalarField.H"
00028 #include "fvPatchFieldMapper.H"
00029 #include "volFields.H"
00030 #include "RASModel.H"
00031 #include "addToRunTimeSelectionTable.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 namespace compressible
00038 {
00039 namespace RASModels
00040 {
00041 
00042 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00043 
00044 tmp<scalarField> mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
00045 (
00046     const scalarField& magGradU
00047 ) const
00048 {
00049     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00050     const scalarField& y = rasModel.y()[patch().index()];
00051 
00052     const fvPatchVectorField& Uw =
00053         rasModel.U().boundaryField()[patch().index()];
00054 
00055     scalarField magUp = mag(Uw.patchInternalField() - Uw);
00056 
00057     const fvPatchScalarField& rhow =
00058         rasModel.rho().boundaryField()[patch().index()];
00059 
00060     const fvPatchScalarField& muw =
00061         rasModel.mu().boundaryField()[patch().index()];
00062     const scalarField& mutw = *this;
00063 
00064     tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
00065     scalarField& uTau = tuTau();
00066 
00067     forAll(mutw, faceI)
00068     {
00069         scalar magUpara = magUp[faceI];
00070 
00071         scalar ut =
00072             sqrt((mutw[faceI] + muw[faceI])*magGradU[faceI]/rhow[faceI]);
00073 
00074         if (ut > VSMALL)
00075         {
00076             int iter = 0;
00077             scalar err = GREAT;
00078 
00079             do
00080             {
00081                 scalar kUu = min(kappa_*magUpara/ut, 50);
00082                 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
00083 
00084                 scalar f =
00085                     - ut*y[faceI]/(muw[faceI]/rhow[faceI])
00086                     + magUpara/ut
00087                     + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00088 
00089                 scalar df =
00090                     y[faceI]/(muw[faceI]/rhow[faceI])
00091                   + magUpara/sqr(ut)
00092                   + 1/E_*kUu*fkUu/ut;
00093 
00094                 scalar uTauNew = ut + f/df;
00095                 err = mag((ut - uTauNew)/ut);
00096                 ut = uTauNew;
00097 
00098             } while (ut > VSMALL && err > 0.01 && ++iter < 10);
00099 
00100             uTau[faceI] = max(0.0, ut);
00101         }
00102     }
00103 
00104     return tuTau;
00105 }
00106 
00107 
00108 tmp<scalarField>
00109 mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const
00110 {
00111     const label patchI = patch().index();
00112 
00113     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00114     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00115     const scalarField magGradU = mag(Uw.snGrad());
00116     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00117     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00118 
00119     return max(scalar(0), rhow*sqr(calcUTau(magGradU))/magGradU - muw);
00120 }
00121 
00122 
00123 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00124 
00125 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00126 mutSpalartAllmarasWallFunctionFvPatchScalarField
00127 (
00128     const fvPatch& p,
00129     const DimensionedField<scalar, volMesh>& iF
00130 )
00131 :
00132     mutWallFunctionFvPatchScalarField(p, iF)
00133 {}
00134 
00135 
00136 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00137 mutSpalartAllmarasWallFunctionFvPatchScalarField
00138 (
00139     const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
00140     const fvPatch& p,
00141     const DimensionedField<scalar, volMesh>& iF,
00142     const fvPatchFieldMapper& mapper
00143 )
00144 :
00145     mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
00146 {}
00147 
00148 
00149 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00150 mutSpalartAllmarasWallFunctionFvPatchScalarField
00151 (
00152     const fvPatch& p,
00153     const DimensionedField<scalar, volMesh>& iF,
00154     const dictionary& dict
00155 )
00156 :
00157     mutWallFunctionFvPatchScalarField(p, iF, dict)
00158 {}
00159 
00160 
00161 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00162 mutSpalartAllmarasWallFunctionFvPatchScalarField
00163 (
00164     const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
00165 )
00166 :
00167     mutWallFunctionFvPatchScalarField(wfpsf)
00168 {}
00169 
00170 
00171 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00172 mutSpalartAllmarasWallFunctionFvPatchScalarField
00173 (
00174     const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf,
00175     const DimensionedField<scalar, volMesh>& iF
00176 )
00177 :
00178     mutWallFunctionFvPatchScalarField(wfpsf, iF)
00179 {}
00180 
00181 
00182 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00183 
00184 tmp<scalarField>
00185 mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
00186 {
00187     const label patchI = patch().index();
00188 
00189     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00190     const scalarField& y = rasModel.y()[patchI];
00191     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00192     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00193     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00194 
00195     return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow);
00196 }
00197 
00198 
00199 void mutSpalartAllmarasWallFunctionFvPatchScalarField::write
00200 (
00201     Ostream& os
00202 ) const
00203 {
00204     fvPatchField<scalar>::write(os);
00205     writeLocalEntries(os);
00206     writeEntry("value", os);
00207 }
00208 
00209 
00210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00211 
00212 makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField);
00213 
00214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00215 
00216 } // End namespace RASModels
00217 } // End namespace compressible
00218 } // End namespace Foam
00219 
00220 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd