OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

muSgsWallFunctionFvPatchScalarField.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "muSgsWallFunctionFvPatchScalarField.H"
00028 #include "LESModel.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "addToRunTimeSelectionTable.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 namespace compressible
00038 {
00039 namespace LESModels
00040 {
00041 
00042 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00043 
00044 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
00045 (
00046     const fvPatch& p,
00047     const DimensionedField<scalar, volMesh>& iF
00048 )
00049 :
00050     fixedValueFvPatchScalarField(p, iF),
00051     UName_("U"),
00052     rhoName_("rho"),
00053     muName_("mu"),
00054     kappa_(0.41),
00055     E_(9.8)
00056 {}
00057 
00058 
00059 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
00060 (
00061     const muSgsWallFunctionFvPatchScalarField& ptf,
00062     const fvPatch& p,
00063     const DimensionedField<scalar, volMesh>& iF,
00064     const fvPatchFieldMapper& mapper
00065 )
00066 :
00067     fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00068     UName_(ptf.UName_),
00069     rhoName_(ptf.rhoName_),
00070     muName_(ptf.muName_),
00071     kappa_(ptf.kappa_),
00072     E_(ptf.E_)
00073 {}
00074 
00075 
00076 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
00077 (
00078     const fvPatch& p,
00079     const DimensionedField<scalar, volMesh>& iF,
00080     const dictionary& dict
00081 )
00082 :
00083     fixedValueFvPatchScalarField(p, iF, dict),
00084     UName_(dict.lookupOrDefault<word>("U", "U")),
00085     rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00086     muName_(dict.lookupOrDefault<word>("mu", "mu")),
00087     kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
00088     E_(dict.lookupOrDefault<scalar>("E", 9.8))
00089 {}
00090 
00091 
00092 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
00093 (
00094     const muSgsWallFunctionFvPatchScalarField& mwfpsf
00095 )
00096 :
00097     fixedValueFvPatchScalarField(mwfpsf),
00098     UName_(mwfpsf.UName_),
00099     rhoName_(mwfpsf.rhoName_),
00100     muName_(mwfpsf.muName_),
00101     kappa_(mwfpsf.kappa_),
00102     E_(mwfpsf.E_)
00103 {}
00104 
00105 
00106 muSgsWallFunctionFvPatchScalarField::muSgsWallFunctionFvPatchScalarField
00107 (
00108     const muSgsWallFunctionFvPatchScalarField& mwfpsf,
00109     const DimensionedField<scalar, volMesh>& iF
00110 )
00111 :
00112     fixedValueFvPatchScalarField(mwfpsf, iF),
00113     UName_(mwfpsf.UName_),
00114     rhoName_(mwfpsf.rhoName_),
00115     muName_(mwfpsf.muName_),
00116     kappa_(mwfpsf.kappa_),
00117     E_(mwfpsf.E_)
00118 {}
00119 
00120 
00121 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00122 
00123 void muSgsWallFunctionFvPatchScalarField::evaluate
00124 (
00125     const Pstream::commsTypes
00126 )
00127 {
00128     const scalarField& ry = patch().deltaCoeffs();
00129 
00130     const fvPatchVectorField& U =
00131         patch().lookupPatchField<volVectorField, vector>(UName_);
00132 
00133     scalarField magUp = mag(U.patchInternalField() - U);
00134 
00135     const scalarField& muw =
00136         patch().lookupPatchField<volScalarField, scalar>(muName_);
00137 
00138     const scalarField& rhow =
00139         patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00140 
00141     scalarField& muSgsw = *this;
00142 
00143     scalarField magFaceGradU = mag(U.snGrad());
00144 
00145     forAll(muSgsw, facei)
00146     {
00147         scalar magUpara = magUp[facei];
00148 
00149         scalar utau =
00150             sqrt((muSgsw[facei] + muw[facei])*magFaceGradU[facei]/rhow[facei]);
00151 
00152         if (utau > 0)
00153         {
00154             int iter = 0;
00155             scalar err = GREAT;
00156 
00157             do
00158             {
00159                 scalar kUu = kappa_*magUpara/utau;
00160                 scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
00161 
00162                 scalar f =
00163                     - utau/(ry[facei]*muw[facei]/rhow[facei])
00164                     + magUpara/utau
00165                     + 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
00166 
00167                 scalar df =
00168                     - 1.0/(ry[facei]*muw[facei]/rhow[facei])
00169                     - magUpara/sqr(utau)
00170                     - 1/E_*kUu*fkUu/utau;
00171 
00172                 scalar utauNew = utau - f/df;
00173                 err = mag((utau - utauNew)/utau);
00174                 utau = utauNew;
00175 
00176             } while (utau > VSMALL && err > 0.01 && ++iter < 10);
00177 
00178             muSgsw[facei] =
00179                 max
00180                 (
00181                     rhow[facei]*sqr(utau)/magFaceGradU[facei] - muw[facei],
00182                     0.0
00183                 );
00184         }
00185         else
00186         {
00187             muSgsw[facei] = 0;
00188         }
00189     }
00190 }
00191 
00192 
00193 void muSgsWallFunctionFvPatchScalarField::write(Ostream& os) const
00194 {
00195     fvPatchField<scalar>::write(os);
00196     writeEntryIfDifferent<word>(os, "U", "U", UName_);
00197     writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
00198     writeEntryIfDifferent<word>(os, "mu", "mu", muName_);
00199     os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
00200     os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
00201     writeEntry("value", os);
00202 }
00203 
00204 
00205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00206 
00207 makePatchTypeField
00208 (
00209     fvPatchScalarField,
00210     muSgsWallFunctionFvPatchScalarField
00211 );
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 } // End namespace LESModels
00216 } // End namespace compressible
00217 } // End namespace Foam
00218 
00219 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd