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

IDDESDelta.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 "IDDESDelta.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/wallDistReflection.H>
00029 #include <finiteVolume/wallDist.H>
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035     defineTypeNameAndDebug(IDDESDelta, 0);
00036     addToRunTimeSelectionTable(LESdelta, IDDESDelta, dictionary);
00037 }
00038 
00039 
00040 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00041 
00042 void Foam::IDDESDelta::calcDelta()
00043 {
00044     label nD = mesh().nGeometricD();
00045 
00046     const volScalarField& hmax = hmax_();
00047 
00048     // initialise wallNorm
00049     wallDistReflection wallNorm(mesh());
00050 
00051     const volVectorField& n = wallNorm.n();
00052 
00053     tmp<volScalarField> faceToFacenMax
00054     (
00055         new volScalarField
00056         (
00057             IOobject
00058             (
00059                 "faceToFaceMax",
00060                 mesh().time().timeName(),
00061                 mesh(),
00062                 IOobject::NO_READ,
00063                 IOobject::NO_WRITE
00064             ),
00065             mesh(),
00066             dimensionedScalar("zrero", dimLength, 0.0)
00067         )
00068     );
00069 
00070     const cellList& cells = mesh().cells();
00071 
00072     forAll(cells,cellI)
00073     {
00074         scalar deltaMaxTmp = 0.0;
00075         const labelList& cFaces = mesh().cells()[cellI];
00076         const point& faceCentre = mesh().faceCentres()[cFaces[0]];
00077         const vector nCell = n[cellI];
00078         forAll(cFaces, cFaceI)
00079         {
00080             label faceI = cFaces[cFaceI];
00081             const point& faceCentreTwo = mesh().faceCentres()[faceI];
00082             scalar tmp = (faceCentre - faceCentreTwo) & nCell;
00083             if (tmp > deltaMaxTmp)
00084             {
00085                 deltaMaxTmp = tmp;
00086             }
00087         }
00088         faceToFacenMax()[cellI] = deltaMaxTmp;
00089     }
00090 
00091     if (nD == 3)
00092     {
00093         delta_.internalField() =
00094             deltaCoeff_
00095            *min
00096             (
00097                 max
00098                 (
00099                     max(cw_*wallDist(mesh()).y(), cw_*hmax),
00100                     faceToFacenMax()
00101                 ),
00102                 hmax
00103             );
00104     }
00105     else if (nD == 2)
00106     {
00107         WarningIn("IDDESDelta::calcDelta()")
00108             << "Case is 2D, LES is not strictly applicable\n"
00109             << endl;
00110 
00111         delta_.internalField() =
00112             deltaCoeff_
00113            *min
00114             (
00115                 max(max(cw_*wallDist(mesh()).y(), cw_*hmax), faceToFacenMax()),
00116                 hmax
00117             );
00118     }
00119     else
00120     {
00121         FatalErrorIn("IDDESDelta::calcDelta()")
00122             << "Case is not 3D or 2D, LES is not strictly applicable"
00123             << exit(FatalError);
00124     }
00125 }
00126 
00127 
00128 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00129 
00130 Foam::IDDESDelta::IDDESDelta
00131 (
00132     const word& name,
00133     const fvMesh& mesh,
00134     const dictionary& dd
00135 )
00136 :
00137     LESdelta(name, mesh),
00138     hmax_(LESdelta::New("hmax", mesh, dd.parent())),
00139     deltaCoeff_
00140     (
00141         readScalar(dd.subDict(type()+"Coeffs").lookup("deltaCoeff"))
00142     ),
00143     cw_(0.15)
00144 {
00145     dd.subDict(type() + "Coeffs").readIfPresent("cw", cw_);
00146     calcDelta();
00147 }
00148 
00149 
00150 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00151 
00152 void Foam::IDDESDelta::read(const dictionary& dd)
00153 {
00154     dd.subDict(type() + "Coeffs").lookup("deltaCoeff") >> deltaCoeff_;
00155     calcDelta();
00156 }
00157 
00158 
00159 void Foam::IDDESDelta::correct()
00160 {
00161     if (mesh_.changing())
00162     {
00163         calcDelta();
00164         hmax_().correct();
00165     }
00166 }
00167 
00168 
00169 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines