FreeFOAM The Cross-Platform CFD Toolkit
cubeRootVolDelta.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cubeRootVolDelta.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 defineTypeNameAndDebug(cubeRootVolDelta, 0);
37 addToRunTimeSelectionTable(LESdelta, cubeRootVolDelta, dictionary);
38 
39 
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
42 void cubeRootVolDelta::calcDelta()
43 {
44  label nD = mesh().nGeometricD();
45 
46  if (nD == 3)
47  {
48  delta_.internalField() = deltaCoeff_*pow(mesh().V(), 1.0/3.0);
49  }
50  else if (nD == 2)
51  {
52  WarningIn("cubeRootVolDelta::calcDelta()")
53  << "Case is 2D, LES is not strictly applicable\n"
54  << endl;
55 
56  const Vector<label>& directions = mesh().geometricD();
57 
58  scalar thickness = 0.0;
59  for (direction dir=0; dir<directions.nComponents; dir++)
60  {
61  if (directions[dir] == -1)
62  {
63  thickness = mesh().bounds().span()[dir];
64  break;
65  }
66  }
67 
68  delta_.internalField() = deltaCoeff_*sqrt(mesh().V()/thickness);
69  }
70  else
71  {
72  FatalErrorIn("cubeRootVolDelta::calcDelta()")
73  << "Case is not 3D or 2D, LES is not applicable"
74  << exit(FatalError);
75  }
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
80 
81 cubeRootVolDelta::cubeRootVolDelta
82 (
83  const word& name,
84  const fvMesh& mesh,
85  const dictionary& dd
86 )
87 :
88  LESdelta(name, mesh),
89  deltaCoeff_(readScalar(dd.subDict(type() + "Coeffs").lookup("deltaCoeff")))
90 {
91  calcDelta();
92 }
93 
94 
95 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96 
98 {
99  dd.subDict(type() + "Coeffs").lookup("deltaCoeff") >> deltaCoeff_;
100  calcDelta();
101 }
102 
103 
105 {
106  if (mesh_.changing())
107  {
108  calcDelta();
109  }
110 }
111 
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 } // End namespace Foam
116 
117 // ************************ vim: set sw=4 sts=4 et: ************************ //