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

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-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 "mutSpalartAllmarasWallFunctionFvPatchScalarField.H"
00027 #include <finiteVolume/fvPatchFieldMapper.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <compressibleRASModels/RASModel.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> mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau
00044 (
00045     const scalarField& magGradU
00046 ) const
00047 {
00048     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00049     const scalarField& y = rasModel.y()[patch().index()];
00050 
00051     const fvPatchVectorField& Uw =
00052         rasModel.U().boundaryField()[patch().index()];
00053 
00054     scalarField magUp = mag(Uw.patchInternalField() - Uw);
00055 
00056     const fvPatchScalarField& rhow =
00057         rasModel.rho().boundaryField()[patch().index()];
00058 
00059     const fvPatchScalarField& muw =
00060         rasModel.mu().boundaryField()[patch().index()];
00061     const scalarField& mutw = *this;
00062 
00063     tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
00064     scalarField& uTau = tuTau();
00065 
00066     forAll(mutw, faceI)
00067     {
00068         scalar magUpara = magUp[faceI];
00069 
00070         scalar ut =
00071             sqrt((mutw[faceI] + muw[faceI])*magGradU[faceI]/rhow[faceI]);
00072 
00073         if (ut > VSMALL)
00074         {
00075             int iter = 0;
00076             scalar err = GREAT;
00077 
00078             do
00079             {
00080                 scalar kUu = min(kappa_*magUpara/ut, 50);
00081                 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
00082 
00083                 scalar f =
00084                     - ut*y[faceI]/(muw[faceI]/rhow[faceI])
00085                     + magUpara/ut
00086                     + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00087 
00088                 scalar df =
00089                     y[faceI]/(muw[faceI]/rhow[faceI])
00090                   + magUpara/sqr(ut)
00091                   + 1/E_*kUu*fkUu/ut;
00092 
00093                 scalar uTauNew = ut + f/df;
00094                 err = mag((ut - uTauNew)/ut);
00095                 ut = uTauNew;
00096 
00097             } while (ut > VSMALL && err > 0.01 && ++iter < 10);
00098 
00099             uTau[faceI] = max(0.0, ut);
00100         }
00101     }
00102 
00103     return tuTau;
00104 }
00105 
00106 
00107 tmp<scalarField>
00108 mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const
00109 {
00110     const label patchI = patch().index();
00111 
00112     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00113     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00114     const scalarField magGradU = mag(Uw.snGrad());
00115     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00116     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00117 
00118     return max
00119     (
00120         scalar(0),
00121         rhow*sqr(calcUTau(magGradU))/(magGradU + ROOTVSMALL) - muw
00122     );
00123 }
00124 
00125 
00126 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00127 
00128 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00129 mutSpalartAllmarasWallFunctionFvPatchScalarField
00130 (
00131     const fvPatch& p,
00132     const DimensionedField<scalar, volMesh>& iF
00133 )
00134 :
00135     mutWallFunctionFvPatchScalarField(p, iF)
00136 {}
00137 
00138 
00139 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00140 mutSpalartAllmarasWallFunctionFvPatchScalarField
00141 (
00142     const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf,
00143     const fvPatch& p,
00144     const DimensionedField<scalar, volMesh>& iF,
00145     const fvPatchFieldMapper& mapper
00146 )
00147 :
00148     mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper)
00149 {}
00150 
00151 
00152 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00153 mutSpalartAllmarasWallFunctionFvPatchScalarField
00154 (
00155     const fvPatch& p,
00156     const DimensionedField<scalar, volMesh>& iF,
00157     const dictionary& dict
00158 )
00159 :
00160     mutWallFunctionFvPatchScalarField(p, iF, dict)
00161 {}
00162 
00163 
00164 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00165 mutSpalartAllmarasWallFunctionFvPatchScalarField
00166 (
00167     const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf
00168 )
00169 :
00170     mutWallFunctionFvPatchScalarField(wfpsf)
00171 {}
00172 
00173 
00174 mutSpalartAllmarasWallFunctionFvPatchScalarField::
00175 mutSpalartAllmarasWallFunctionFvPatchScalarField
00176 (
00177     const mutSpalartAllmarasWallFunctionFvPatchScalarField& wfpsf,
00178     const DimensionedField<scalar, volMesh>& iF
00179 )
00180 :
00181     mutWallFunctionFvPatchScalarField(wfpsf, iF)
00182 {}
00183 
00184 
00185 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00186 
00187 tmp<scalarField>
00188 mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const
00189 {
00190     const label patchI = patch().index();
00191 
00192     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00193     const scalarField& y = rasModel.y()[patchI];
00194     const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI];
00195     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00196     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00197 
00198     return y*calcUTau(mag(Uw.snGrad()))/(muw/rhow);
00199 }
00200 
00201 
00202 void mutSpalartAllmarasWallFunctionFvPatchScalarField::write
00203 (
00204     Ostream& os
00205 ) const
00206 {
00207     fvPatchField<scalar>::write(os);
00208     writeLocalEntries(os);
00209     writeEntry("value", os);
00210 }
00211 
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField);
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 } // End namespace RASModels
00220 } // End namespace compressible
00221 } // End namespace Foam
00222 
00223 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines