Smagorinsky.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) 2011-2015 OpenFOAM Foundation
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 "Smagorinsky.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace LESModels
33 {
34 
35 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
36 
37 template<class BasicTurbulenceModel>
38 tmp<volScalarField> Smagorinsky<BasicTurbulenceModel>::k
39 (
40  const tmp<volTensorField>& gradU
41 ) const
42 {
43  volSymmTensorField D(symm(gradU));
44 
45  volScalarField a(this->Ce_/this->delta());
46  volScalarField b((2.0/3.0)*tr(D));
47  volScalarField c(2*Ck_*this->delta()*(dev(D) && D));
48 
49  return tmp<volScalarField>
50  (
51  new volScalarField
52  (
53  IOobject
54  (
55  IOobject::groupName("k", this->U_.group()),
56  this->runTime_.timeName(),
57  this->mesh_
58  ),
59  sqr((-b + sqrt(sqr(b) + 4*a*c))/(2*a))
60  )
61  );
62 }
63 
64 
65 template<class BasicTurbulenceModel>
67 {
68  volScalarField k(this->k(fvc::grad(this->U_)));
69 
70  this->nut_ = Ck_*this->delta()*sqrt(k);
71  this->nut_.correctBoundaryConditions();
72 
73  BasicTurbulenceModel::correctNut();
74 }
75 
76 
77 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
78 
79 template<class BasicTurbulenceModel>
81 (
82  const alphaField& alpha,
83  const rhoField& rho,
84  const volVectorField& U,
85  const surfaceScalarField& alphaRhoPhi,
86  const surfaceScalarField& phi,
87  const transportModel& transport,
88  const word& propertiesName,
89  const word& type
90 )
91 :
93  (
94  type,
95  alpha,
96  rho,
97  U,
98  alphaRhoPhi,
99  phi,
100  transport,
101  propertiesName
102  ),
103 
104  Ck_
105  (
107  (
108  "Ck",
109  this->coeffDict_,
110  0.094
111  )
112  )
113 {
114  if (type == typeName)
115  {
116  correctNut();
117  this->printCoeffs(type);
118  }
119 }
120 
121 
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 
124 template<class BasicTurbulenceModel>
126 {
128  {
129  Ck_.readIfPresent(this->coeffDict());
130 
131  return true;
132  }
133  else
134  {
135  return false;
136  }
137 }
138 
139 
140 template<class BasicTurbulenceModel>
142 {
143  volScalarField k(this->k(fvc::grad(this->U_)));
144 
145  return tmp<volScalarField>
146  (
147  new volScalarField
148  (
149  IOobject
150  (
151  IOobject::groupName("epsilon", this->U_.group()),
152  this->runTime_.timeName(),
153  this->mesh_
154  ),
155  this->Ce_*k*sqrt(k)/this->delta()
156  )
157  );
158 }
159 
160 
161 template<class BasicTurbulenceModel>
163 {
165  correctNut();
166 }
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace LESModels
172 } // End namespace Foam
173 
174 // ************************************************************************* //
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
virtual void correctNut()
Update the SGS eddy viscosity.
Definition: Smagorinsky.C:66
virtual tmp< volScalarField > k() const
Return SGS kinetic energy.
Definition: Smagorinsky.H:155
A class for handling words, derived from string.
Definition: word.H:59
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
virtual tmp< volScalarField > epsilon() const
Return sub-grid disipation rate.
Definition: Smagorinsky.C:141
virtual void correct()=0
Solve the turbulence equations and correct the turbulence viscosity.
Namespace for OpenFOAM.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
static word groupName(Name name, const word &group)
BasicTurbulenceModel::alphaField alphaField
virtual bool read()
Read model coefficients if they have changed.
Definition: Smagorinsky.C:125
Generic dimensioned Type class.
virtual void correct()
Correct Eddy-Viscosity and related properties.
Definition: Smagorinsky.C:162
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
label k
Boltzmann constant.
BasicTurbulenceModel::rhoField rhoField
scalar delta
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
surfaceScalarField & phi
BasicTurbulenceModel::transportModel transportModel
The Smagorinsky SGS model.
Definition: Smagorinsky.H:89
const dimensionedScalar c
Speed of light in a vacuum.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Eddy viscosity LES SGS model base class.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A class for managing temporary objects.
Definition: PtrList.H:118
U
Definition: pEqn.H:82