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

nuSgsWallFunctionFvPatchScalarField.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 "nuSgsWallFunctionFvPatchScalarField.H"
00027 #include <finiteVolume/fvPatchFieldMapper.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 namespace incompressible
00036 {
00037 namespace LESModels
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 nuSgsWallFunctionFvPatchScalarField::
00043 nuSgsWallFunctionFvPatchScalarField
00044 (
00045     const fvPatch& p,
00046     const DimensionedField<scalar, volMesh>& iF
00047 )
00048 :
00049     fixedValueFvPatchScalarField(p, iF),
00050     UName_("U"),
00051     nuName_("nu"),
00052     kappa_(0.41),
00053     E_(9.8)
00054 {}
00055 
00056 
00057 nuSgsWallFunctionFvPatchScalarField::
00058 nuSgsWallFunctionFvPatchScalarField
00059 (
00060     const nuSgsWallFunctionFvPatchScalarField& ptf,
00061     const fvPatch& p,
00062     const DimensionedField<scalar, volMesh>& iF,
00063     const fvPatchFieldMapper& mapper
00064 )
00065 :
00066     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00067     UName_(ptf.UName_),
00068     nuName_(ptf.nuName_),
00069     kappa_(ptf.kappa_),
00070     E_(ptf.E_)
00071 {}
00072 
00073 
00074 nuSgsWallFunctionFvPatchScalarField::
00075 nuSgsWallFunctionFvPatchScalarField
00076 (
00077     const fvPatch& p,
00078     const DimensionedField<scalar, volMesh>& iF,
00079     const dictionary& dict
00080 )
00081 :
00082     fixedValueFvPatchScalarField(p, iF, dict),
00083     UName_(dict.lookupOrDefault<word>("U", "U")),
00084     nuName_(dict.lookupOrDefault<word>("nu", "nu")),
00085     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00086     E_(dict.lookupOrDefault<scalar>("E", 9.8))
00087 {}
00088 
00089 
00090 nuSgsWallFunctionFvPatchScalarField::
00091 nuSgsWallFunctionFvPatchScalarField
00092 (
00093     const nuSgsWallFunctionFvPatchScalarField& nwfpsf
00094 )
00095 :
00096     fixedValueFvPatchScalarField(nwfpsf),
00097     UName_(nwfpsf.UName_),
00098     nuName_(nwfpsf.nuName_),
00099     kappa_(nwfpsf.kappa_),
00100     E_(nwfpsf.E_)
00101 {}
00102 
00103 
00104 nuSgsWallFunctionFvPatchScalarField::
00105 nuSgsWallFunctionFvPatchScalarField
00106 (
00107     const nuSgsWallFunctionFvPatchScalarField& nwfpsf,
00108     const DimensionedField<scalar, volMesh>& iF
00109 )
00110 :
00111     fixedValueFvPatchScalarField(nwfpsf, iF),
00112     UName_(nwfpsf.UName_),
00113     nuName_(nwfpsf.nuName_),
00114     kappa_(nwfpsf.kappa_),
00115     E_(nwfpsf.E_)
00116 {}
00117 
00118 
00119 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00120 
00121 void nuSgsWallFunctionFvPatchScalarField::evaluate
00122 (
00123     const Pstream::commsTypes
00124 )
00125 {
00126     const scalarField& ry = patch().deltaCoeffs();
00127 
00128     const fvPatchVectorField& U =
00129         patch().lookupPatchField<volVectorField, vector>(UName_);
00130 
00131     scalarField magUp = mag(U.patchInternalField() - U);
00132 
00133     const scalarField& nuw =
00134         patch().lookupPatchField<volScalarField, scalar>(nuName_);
00135 
00136     scalarField& nuSgsw = *this;
00137 
00138     scalarField magFaceGradU = mag(U.snGrad());
00139 
00140     forAll(nuSgsw, facei)
00141     {
00142         scalar magUpara = magUp[facei];
00143 
00144         scalar utau = sqrt((nuSgsw[facei] + nuw[facei])*magFaceGradU[facei]);
00145 
00146         if (utau > VSMALL)
00147         {
00148             int iter = 0;
00149             scalar err = GREAT;
00150 
00151             do
00152             {
00153                 scalar kUu = min(kappa_*magUpara/utau, 50);
00154                 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
00155 
00156                 scalar f =
00157                     - utau/(ry[facei]*nuw[facei])
00158                     + magUpara/utau
00159                     + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00160 
00161                 scalar df =
00162                     - 1.0/(ry[facei]*nuw[facei])
00163                     - magUpara/sqr(utau)
00164                     - 1/E_*kUu*fkUu/utau;
00165 
00166                 scalar utauNew = utau - f/df;
00167                 err = mag((utau - utauNew)/utau);
00168                 utau = utauNew;
00169 
00170             } while (utau > VSMALL && err > 0.01 && ++iter < 10);
00171 
00172             nuSgsw[facei] =
00173                 max(sqr(max(utau, 0))/magFaceGradU[facei] - nuw[facei], 0.0);
00174         }
00175         else
00176         {
00177             nuSgsw[facei] = 0;
00178         }
00179     }
00180 
00181     fixedValueFvPatchScalarField::evaluate();
00182 }
00183 
00184 
00185 void nuSgsWallFunctionFvPatchScalarField::write(Ostream& os) const
00186 {
00187     fvPatchField<scalar>::write(os);
00188     writeEntryIfDifferent<word>(os, "U", "U", UName_);
00189     writeEntryIfDifferent<word>(os, "nu", "nu", nuName_);
00190     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00191     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00192     writeEntry("value", os);
00193 }
00194 
00195 
00196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00197 
00198 makePatchTypeField
00199 (
00200     fvPatchScalarField,
00201     nuSgsWallFunctionFvPatchScalarField
00202 );
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 } // End namespace LESModels
00207 } // End namespace incompressible
00208 } // End namespace Foam
00209 
00210 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines