FreeFOAM The Cross-Platform CFD Toolkit
homogeneousDynSmagorinsky.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-2011 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 
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace incompressible
34 {
35 namespace LESModels
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(homogeneousDynSmagorinsky, 0);
41 addToRunTimeSelectionTable(LESModel, homogeneousDynSmagorinsky, dictionary);
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 void homogeneousDynSmagorinsky::updateSubGridScaleFields
46 (
47  const volSymmTensorField& D
48 )
49 {
50  nuSgs_ = cD(D)*sqr(delta())*sqrt(magSqr(D));
52 }
53 
54 
55 dimensionedScalar homogeneousDynSmagorinsky::cD
56 (
57  const volSymmTensorField& D
58 ) const
59 {
60  volSymmTensorField LL = dev(filter_(sqr(U())) - (sqr(filter_(U()))));
61 
63  sqr(delta())*(filter_(mag(D)*(D)) - 4*mag(filter_(D))*filter_(D));
64 
65  dimensionedScalar MMMM = average(magSqr(MM));
66 
67  if (MMMM.value() > VSMALL)
68  {
69  return average(LL && MM)/MMMM;
70  }
71  else
72  {
73  return 0.0;
74  }
75 }
76 
77 
78 dimensionedScalar homogeneousDynSmagorinsky::cI
79 (
80  const volSymmTensorField& D
81 ) const
82 {
83  volScalarField KK = 0.5*(filter_(magSqr(U())) - magSqr(filter_(U())));
84 
85  volScalarField mm =
86  sqr(delta())*(4*sqr(mag(filter_(D))) - filter_(sqr(mag(D))));
87 
88  dimensionedScalar mmmm = average(magSqr(mm));
89 
90  if (mmmm.value() > VSMALL)
91  {
92  return average(KK*mm)/mmmm;
93  }
94  else
95  {
96  return 0.0;
97  }
98 }
99 
100 
101 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
102 
103 homogeneousDynSmagorinsky::homogeneousDynSmagorinsky
104 (
105  const volVectorField& U,
106  const surfaceScalarField& phi,
107  transportModel& transport
108 )
109 :
110  LESModel(typeName, U, phi, transport),
111  GenEddyVisc(U, phi, transport),
112 
113  k_
114  (
115  IOobject
116  (
117  "k",
118  runTime_.timeName(),
119  mesh_,
122  ),
123  mesh_
124  ),
125 
126  filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
127  filter_(filterPtr_())
128 {
129  updateSubGridScaleFields(dev(symm(fvc::grad(U))));
130 
131  printCoeffs();
132 }
133 
134 
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 
138 {
139  LESModel::correct(gradU);
140 
141  volSymmTensorField D = dev(symm(gradU));
142 
143  k_ = cI(D)*sqr(delta())*magSqr(D);
144 
145  updateSubGridScaleFields(D);
146 }
147 
148 
150 {
151  if (GenEddyVisc::read())
152  {
153  filter_.read(coeffDict());
154 
155  return true;
156  }
157  else
158  {
159  return false;
160  }
161 }
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace LESModels
167 } // End namespace incompressible
168 } // End namespace Foam
169 
170 // ************************ vim: set sw=4 sts=4 et: ************************ //