FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
00027 #include <incompressibleRASModels/RASModel.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 namespace incompressible
00037 {
00038 namespace RASModels
00039 {
00040 
00041 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00042 
00043 tmp<scalarField>
00044 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const
00045 {
00046     const label patchI = patch().index();
00047 
00048     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00049     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00050     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
00051     const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
00052 
00053     tmp<scalarField> tyPlus = calcYPlus(magUp);
00054     scalarField& yPlus = tyPlus();
00055 
00056     tmp<scalarField> tnutw(new scalarField(patch().size(), 0.0));
00057     scalarField& nutw = tnutw();
00058 
00059     forAll(yPlus, facei)
00060     {
00061         if (yPlus[facei] > yPlusLam_)
00062         {
00063             nutw[facei] =
00064                 nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0);
00065         }
00066     }
00067 
00068     return tnutw;
00069 }
00070 
00071 
00072 tmp<scalarField>
00073 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
00074 (
00075     const scalarField& magUp
00076 ) const
00077 {
00078     const label patchI = patch().index();
00079 
00080     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00081     const scalarField& y = rasModel.y()[patchI];
00082     const scalarField& nuw = rasModel.nu().boundaryField()[patchI];
00083 
00084     tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
00085     scalarField& yPlus = tyPlus();
00086 
00087     forAll(yPlus, facei)
00088     {
00089         scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei];
00090 
00091         scalar yp = yPlusLam_;
00092         scalar ryPlusLam = 1.0/yp;
00093 
00094         int iter = 0;
00095         scalar yPlusLast = 0.0;
00096 
00097         do
00098         {
00099             yPlusLast = yp;
00100             yp = (kappaRe + yp)/(1.0 + log(E_*yp));
00101 
00102         } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10 );
00103 
00104         yPlus[facei] = max(0.0, yp);
00105     }
00106 
00107     return tyPlus;
00108 }
00109 
00110 
00111 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00112 
00113 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00114 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00115 (
00116     const fvPatch& p,
00117     const DimensionedField<scalar, volMesh>& iF
00118 )
00119 :
00120     nutWallFunctionFvPatchScalarField(p, iF)
00121 {}
00122 
00123 
00124 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00125 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00126 (
00127     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
00128     const fvPatch& p,
00129     const DimensionedField<scalar, volMesh>& iF,
00130     const fvPatchFieldMapper& mapper
00131 )
00132 :
00133     nutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
00134 {}
00135 
00136 
00137 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00138 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00139 (
00140     const fvPatch& p,
00141     const DimensionedField<scalar, volMesh>& iF,
00142     const dictionary& dict
00143 )
00144 :
00145     nutWallFunctionFvPatchScalarField(p, iF, dict)
00146 {}
00147 
00148 
00149 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00150 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00151 (
00152     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
00153 )
00154 :
00155     nutWallFunctionFvPatchScalarField(sawfpsf)
00156 {}
00157 
00158 
00159 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00160 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00161 (
00162     const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf,
00163     const DimensionedField<scalar, volMesh>& iF
00164 )
00165 :
00166     nutWallFunctionFvPatchScalarField(sawfpsf, iF)
00167 {}
00168 
00169 
00170 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00171 
00172 tmp<scalarField>
00173 nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const
00174 {
00175     const label patchI = patch().index();
00176     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00177     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00178     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
00179 
00180     return calcYPlus(magUp);
00181 }
00182 
00183 
00184 void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::write
00185 (
00186     Ostream& os
00187 ) const
00188 {
00189     fvPatchField<scalar>::write(os);
00190     writeLocalEntries(os);
00191     writeEntry("value", os);
00192 }
00193 
00194 
00195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00196 
00197 makePatchTypeField
00198 (
00199     fvPatchScalarField,
00200     nutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00201 );
00202 
00203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00204 
00205 } // End namespace RASModels
00206 } // End namespace incompressible
00207 } // End namespace Foam
00208 
00209 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines