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

mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.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 "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H"
00027 #include <compressibleRASModels/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 compressible
00037 {
00038 namespace RASModels
00039 {
00040 
00041 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00042 
00043 tmp<scalarField>
00044 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus
00045 (
00046     const scalarField& magUp
00047 ) const
00048 {
00049     const label patchI = patch().index();
00050 
00051     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00052     const scalarField& y = rasModel.y()[patchI];
00053     const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI];
00054     const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
00055 
00056     tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0));
00057     scalarField& yPlus = tyPlus();
00058 
00059     forAll(yPlus, faceI)
00060     {
00061         scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]);
00062 
00063         scalar yp = yPlusLam_;
00064         scalar ryPlusLam = 1.0/yp;
00065 
00066         int iter = 0;
00067         scalar yPlusLast = 0.0;
00068 
00069         do
00070         {
00071             yPlusLast = yp;
00072             yp = (kappaRe + yp)/(1.0 + log(E_*yp));
00073 
00074         } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.01 && ++iter < 10);
00075 
00076         yPlus[faceI] = max(0.0, yp);
00077     }
00078 
00079     return tyPlus;
00080 }
00081 
00082 
00083 tmp<scalarField>
00084 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const
00085 {
00086     const label patchI = patch().index();
00087 
00088     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00089     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00090     const scalarField magUp = mag(Uw.patchInternalField() - Uw);
00091     const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI];
00092 
00093     tmp<scalarField> tyPlus = calcYPlus(magUp);
00094     scalarField& yPlus = tyPlus();
00095 
00096     tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0));
00097     scalarField& mutw = tmutw();
00098 
00099     forAll(yPlus, faceI)
00100     {
00101         if (yPlus[faceI] > yPlusLam_)
00102         {
00103             mutw[faceI] =
00104                 muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0);
00105         }
00106     }
00107 
00108     return tmutw;
00109 }
00110 
00111 
00112 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00113 
00114 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00115 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00116 (
00117     const fvPatch& p,
00118     const DimensionedField<scalar, volMesh>& iF
00119 )
00120 :
00121     mutWallFunctionFvPatchScalarField(p, iF)
00122 {}
00123 
00124 
00125 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00126 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00127 (
00128     const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf,
00129     const fvPatch& p,
00130     const DimensionedField<scalar, volMesh>& iF,
00131     const fvPatchFieldMapper& mapper
00132 )
00133 :
00134     mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
00135 {}
00136 
00137 
00138 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00139 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00140 (
00141     const fvPatch& p,
00142     const DimensionedField<scalar, volMesh>& iF,
00143     const dictionary& dict
00144 )
00145 :
00146     mutWallFunctionFvPatchScalarField(p, iF, dict)
00147 {}
00148 
00149 
00150 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00151 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00152 (
00153     const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf
00154 )
00155 :
00156     mutWallFunctionFvPatchScalarField(sawfpsf)
00157 {}
00158 
00159 
00160 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::
00161 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00162 (
00163     const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& sawfpsf,
00164     const DimensionedField<scalar, volMesh>& iF
00165 )
00166 :
00167     mutWallFunctionFvPatchScalarField(sawfpsf, iF)
00168 {}
00169 
00170 
00171 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00172 
00173 tmp<scalarField>
00174 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::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 mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::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     mutSpalartAllmarasStandardWallFunctionFvPatchScalarField
00202 );
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 } // End namespace RASModels
00207 } // End namespace compressible
00208 } // End namespace Foam
00209 
00210 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines