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

nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.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 "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.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 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00043 
00044 tmp<scalarField>
00045 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::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 magUp = mag(Uw.patchInternalField() - Uw);
00052     const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
00053 
00054     tmp<scalarField> tyPlus = calcYPlus(magUp);
00055     scalarField& yPlus = tyPlus();
00056 
00057     tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
00058     scalarField& nutw = tnutw();
00059 
00060     forAll(yPlus, facei)
00061     {
00062         if (yPlus[facei] > yPlusLam_)
00063         {
00064             nutw[facei] =
00065                 nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
00066         }
00067     }
00068 
00069     return tnutw;
00070 }
00071 
00072 
00073 tmp<scalarField>
00074 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
00075 (
00076     const scalarField& magUp
00077 ) const
00078 {
00079     const label patchI = patch().index();
00080 
00081     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00082     const scalarField& y = rasModel.y()[patchI];
00083     const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
00084 
00085     tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
00086     scalarField& yPlus = tyPlus();
00087 
00088     forAll(yPlus, facei)
00089     {
00090         scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
00091 
00092         scalar yp = yPlusLam_;
00093         scalar ryPlusLam = 1.0/yp;
00094 
00095         int iter = 0;
00096         scalar yPlusLast = 0.0;
00097 
00098         do
00099         {
00100             yPlusLast = yp;
00101             yp = (kappaRe + yp)/(1.0 + log(E_*yp));
00102 
00103         } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
00104 
00105         yPlus[facei] = max(0.0, yp);
00106     }
00107 
00108     return tyPlus;
00109 }
00110 
00111 
00112 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00113 
00114 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00115 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00116 (
00117     const fvPatch& p,
00118     const DimensionedField<scalar, volMesh>& iF
00119 )
00120 :
00121     nutWallFunctionFvPatchScalarField(p, iF)
00122 {}
00123 
00124 
00125 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00126 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00127 (
00128     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
00129     const fvPatch& p,
00130     const DimensionedField<scalar, volMesh>& iF,
00131     const fvPatchFieldMapper& mapper
00132 )
00133 :
00134     nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
00135 {}
00136 
00137 
00138 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00139 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00140 (
00141     const fvPatch& p,
00142     const DimensionedField<scalar, volMesh>& iF,
00143     const dictionary& dict
00144 )
00145 :
00146     nutWallFunctionFvPatchScalarField(p, iF, dict)
00147 {}
00148 
00149 
00150 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00151 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00152 (
00153     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
00154 )
00155 :
00156     nutWallFunctionFvPatchScalarField(sawfpsf)
00157 {}
00158 
00159 
00160 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00161 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00162 (
00163     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf,
00164     const DimensionedField<scalar, volMesh>& iF
00165 )
00166 :
00167     nutWallFunctionFvPatchScalarField(sawfpsf, iF)
00168 {}
00169 
00170 
00171 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00172 
00173 tmp<scalarField>
00174 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
00175 {
00176     const label patchI = patch().index();
00177     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00178     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00179     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
00180 
00181     return calcYPlus(magUp);
00182 }
00183 
00184 
00185 void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
00186 (
00187     Ostream& os
00188 ) const
00189 {
00190     fvPatchField<scalar>::write(os);
00191     writeLocalEntries(os);
00192     writeEntry("value", os);
00193 }
00194 
00195 
00196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00197 
00198 makePatchTypeField
00199 (
00200     fvPatchScalarField,
00201     nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00202 );
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 } // End namespace RASModels
00207 } // End namespace incompressible
00208 } // End namespace Foam
00209 
00210 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd