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

mutRoughWallFunctionFvPatchScalarField.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) 2008-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 "mutRoughWallFunctionFvPatchScalarField.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 
00042 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
00043 
00044 scalar mutRoughWallFunctionFvPatchScalarField::fnRough
00045 (
00046     const scalar KsPlus,
00047     const scalar Cs
00048 ) const
00049 {
00050     // Return fn based on non-dimensional roughness height
00051 
00052     if (KsPlus < 90.0)
00053     {
00054         return pow
00055         (
00056             (KsPlus - 2.25)/87.75 + Cs*KsPlus,
00057             sin(0.4258*(log(KsPlus) - 0.811))
00058         );
00059     }
00060     else
00061     {
00062         return (1.0 + Cs*KsPlus);
00063     }
00064 }
00065 
00066 
00067 tmp<scalarField> mutRoughWallFunctionFvPatchScalarField::calcMut() const
00068 {
00069     const label patchI = patch().index();
00070 
00071     const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
00072     const scalarField& y = rasModel.y()[patchI];
00073     const scalarField& rhow = rasModel.rho().boundaryField()[patchI];
00074     const tmp<volScalarField> tk = rasModel.k();
00075     const volScalarField& k = tk();
00076     const scalarField& muw = rasModel.mu().boundaryField()[patchI];
00077 
00078     const scalar Cmu25 = pow(Cmu_, 0.25);
00079 
00080     tmp<scalarField> tmutw(new scalarField(*this));
00081     scalarField& mutw = tmutw();
00082 
00083     forAll(mutw, faceI)
00084     {
00085         label faceCellI = patch().faceCells()[faceI];
00086 
00087         scalar uStar = Cmu25*sqrt(k[faceCellI]);
00088 
00089         scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
00090 
00091         scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
00092 
00093         scalar Edash = E_;
00094         scalar yPlusLamNew = yPlusLam_;
00095         if (KsPlus > 2.25)
00096         {
00097             Edash /= fnRough(KsPlus, Cs_[faceI]);
00098             yPlusLamNew = rasModel.yPlusLam(kappa_, Edash);
00099         }
00100 
00101         if (debug)
00102         {
00103             Info<< "yPlus = " << yPlus
00104                 << ", KsPlus = " << KsPlus
00105                 << ", Edash = " << Edash
00106                 << ", yPlusLam = " << yPlusLam_
00107                 << endl;
00108         }
00109 
00110         if (yPlus > yPlusLamNew)
00111         {
00112             mutw[faceI] =
00113                 muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1);
00114         }
00115     }
00116 
00117     return tmutw;
00118 }
00119 
00120 
00121 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00122 
00123 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00124 (
00125     const fvPatch& p,
00126     const DimensionedField<scalar, volMesh>& iF
00127 )
00128 :
00129     mutWallFunctionFvPatchScalarField(p, iF),
00130     Ks_(p.size(), 0.0),
00131     Cs_(p.size(), 0.0)
00132 {}
00133 
00134 
00135 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00136 (
00137     const mutRoughWallFunctionFvPatchScalarField& ptf,
00138     const fvPatch& p,
00139     const DimensionedField<scalar, volMesh>& iF,
00140     const fvPatchFieldMapper& mapper
00141 )
00142 :
00143     mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
00144     Ks_(ptf.Ks_, mapper),
00145     Cs_(ptf.Cs_, mapper)
00146 {}
00147 
00148 
00149 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00150 (
00151     const fvPatch& p,
00152     const DimensionedField<scalar, volMesh>& iF,
00153     const dictionary& dict
00154 )
00155 :
00156     mutWallFunctionFvPatchScalarField(p, iF, dict),
00157     Ks_("Ks", dict, p.size()),
00158     Cs_("Cs", dict, p.size())
00159 {}
00160 
00161 
00162 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00163 (
00164     const mutRoughWallFunctionFvPatchScalarField& rwfpsf
00165 )
00166 :
00167     mutWallFunctionFvPatchScalarField(rwfpsf),
00168     Ks_(rwfpsf.Ks_),
00169     Cs_(rwfpsf.Cs_)
00170 {}
00171 
00172 
00173 mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField
00174 (
00175     const mutRoughWallFunctionFvPatchScalarField& rwfpsf,
00176     const DimensionedField<scalar, volMesh>& iF
00177 )
00178 :
00179     mutWallFunctionFvPatchScalarField(rwfpsf, iF),
00180     Ks_(rwfpsf.Ks_),
00181     Cs_(rwfpsf.Cs_)
00182 {}
00183 
00184 
00185 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00186 
00187 void mutRoughWallFunctionFvPatchScalarField::autoMap
00188 (
00189     const fvPatchFieldMapper& m
00190 )
00191 {
00192     mutWallFunctionFvPatchScalarField::autoMap(m);
00193     Ks_.autoMap(m);
00194     Cs_.autoMap(m);
00195 }
00196 
00197 
00198 void mutRoughWallFunctionFvPatchScalarField::rmap
00199 (
00200     const fvPatchScalarField& ptf,
00201     const labelList& addr
00202 )
00203 {
00204     mutWallFunctionFvPatchScalarField::rmap(ptf, addr);
00205 
00206     const mutRoughWallFunctionFvPatchScalarField& nrwfpsf =
00207         refCast<const mutRoughWallFunctionFvPatchScalarField>(ptf);
00208 
00209     Cs_.rmap(nrwfpsf.Cs_, addr);
00210     Ks_.rmap(nrwfpsf.Ks_, addr);
00211 }
00212 
00213 
00214 void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
00215 {
00216     fvPatchField<scalar>::write(os);
00217     writeLocalEntries(os);
00218     Cs_.writeEntry("Cs", os);
00219     Ks_.writeEntry("Ks", os);
00220     writeEntry("value", os);
00221 }
00222 
00223 
00224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00225 
00226 makePatchTypeField(fvPatchScalarField, mutRoughWallFunctionFvPatchScalarField);
00227 
00228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00229 
00230 } // End namespace RASModels
00231 } // End namespace compressible
00232 } // End namespace Foam
00233 
00234 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines