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

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