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

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-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 "IDDESDelta.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "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     // initialise hwn as wall distance
00047     volScalarField hwn = wallDist(mesh()).y();
00048 
00049     scalar deltamaxTmp = 0.;
00050 
00051     const cellList& cells = mesh().cells();
00052 
00053     forAll(cells,cellI)
00054     {
00055         scalar deltaminTmp = 1.e10;
00056         const labelList& cFaces = mesh().cells()[cellI];
00057         const point& centrevector = mesh().cellCentres()[cellI];
00058 
00059         forAll(cFaces, cFaceI)
00060         {
00061             label faceI = cFaces[cFaceI];
00062             const point& facevector = mesh().faceCentres()[faceI];
00063             scalar tmp = mag(facevector - centrevector);
00064 
00065             if (tmp > deltamaxTmp)
00066             {
00067                 deltamaxTmp = tmp;
00068             }
00069             if (tmp < deltaminTmp)
00070             {
00071                 deltaminTmp = tmp;
00072             }
00073         }
00074         hwn[cellI] = 2.0*deltaminTmp;
00075     }
00076 
00077     dimensionedScalar deltamax("deltamax",dimLength,2.0*deltamaxTmp);
00078 
00079     if (nD == 3)
00080     {
00081         delta_.internalField() =
00082             deltaCoeff_
00083            *min
00084             (
00085                 max(max(cw_*wallDist(mesh()).y(), cw_*deltamax), hwn),
00086                 deltamax
00087             );
00088     }
00089     else if (nD == 2)
00090     {
00091         WarningIn("IDDESDelta::calcDelta()")
00092             << "Case is 2D, LES is not strictly applicable\n"
00093             << endl;
00094 
00095         delta_.internalField() =
00096             deltaCoeff_
00097            *min
00098             (
00099                 max(max(cw_*wallDist(mesh()).y(), cw_*deltamax), hwn),
00100                 deltamax
00101             );
00102     }
00103     else
00104     {
00105         FatalErrorIn("IDDESDelta::calcDelta()")
00106             << "Case is not 3D or 2D, LES is not strictly applicable"
00107             << exit(FatalError);
00108     }
00109 }
00110 
00111 
00112 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00113 
00114 Foam::IDDESDelta::IDDESDelta
00115 (
00116     const word& name,
00117     const fvMesh& mesh,
00118     const dictionary& dd
00119 )
00120 :
00121     LESdelta(name, mesh),
00122     deltaCoeff_(readScalar(dd.subDict(type() + "Coeffs").lookup("deltaCoeff"))),
00123     cw_(0)
00124 {
00125     dd.subDict(type() + "Coeffs").readIfPresent("cw", cw_);
00126     calcDelta();
00127 }
00128 
00129 
00130 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00131 
00132 void Foam::IDDESDelta::read(const dictionary& dd)
00133 {
00134     dd.subDict(type() + "Coeffs").lookup("deltaCoeff") >> deltaCoeff_;
00135     calcDelta();
00136 }
00137 
00138 
00139 void Foam::IDDESDelta::correct()
00140 {
00141     if (mesh_.changing())
00142     {
00143         calcDelta();
00144     }
00145 }
00146 
00147 
00148 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd