FreeFOAM The Cross-Platform CFD Toolkit
DeardorffDiffStress.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 "DeardorffDiffStress.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace incompressible
34 {
35 namespace LESModels
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
42 
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
44 
45 void DeardorffDiffStress::updateSubGridScaleFields(const volScalarField& K)
46 {
47  nuSgs_ = ck_*sqrt(K)*delta();
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 DeardorffDiffStress::DeardorffDiffStress
55 (
56  const volVectorField& U,
57  const surfaceScalarField& phi,
58  transportModel& transport
59 )
60 :
61  LESModel(typeName, U, phi, transport),
62  GenSGSStress(U, phi, transport),
63 
64  ck_
65  (
67  (
68  "ck",
69  coeffDict_,
70  0.094
71  )
72  ),
73  cm_
74  (
76  (
77  "cm",
78  coeffDict_,
79  4.13
80  )
81  )
82 {
83  updateSubGridScaleFields(0.5*tr(B_));
84 
85  printCoeffs();
86 }
87 
88 
89 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90 
92 {
93  const volTensorField& gradU = tgradU();
94 
95  GenSGSStress::correct(gradU);
96 
97  volSymmTensorField D = symm(gradU);
98 
99  volSymmTensorField P = -twoSymm(B_ & gradU);
100 
101  volScalarField K = 0.5*tr(B_);
102  volScalarField Epsilon = 2*nuEff()*magSqr(D);
103 
104  fvSymmTensorMatrix BEqn
105  (
106  fvm::ddt(B_)
107  + fvm::div(phi(), B_)
108  - fvm::laplacian(DBEff(), B_)
109  + fvm::Sp(cm_*sqrt(K)/delta(), B_)
110  ==
111  P
112  + 0.8*K*D
113  - (2*ce_ - 0.667*cm_)*I*Epsilon
114  );
115 
116  BEqn.relax();
117  BEqn.solve();
118 
119  // Bounding the component kinetic energies
120 
121  forAll(B_, celli)
122  {
123  B_[celli].component(symmTensor::XX) =
124  max(B_[celli].component(symmTensor::XX), k0().value());
125  B_[celli].component(symmTensor::YY) =
126  max(B_[celli].component(symmTensor::YY), k0().value());
127  B_[celli].component(symmTensor::ZZ) =
128  max(B_[celli].component(symmTensor::ZZ), k0().value());
129  }
130 
131  K = 0.5*tr(B_);
132  bound(K, k0());
133 
134  updateSubGridScaleFields(K);
135 }
136 
137 
139 {
140  if (GenSGSStress::read())
141  {
142  ck_.readIfPresent(coeffDict());
143  cm_.readIfPresent(coeffDict());
144 
145  return true;
146  }
147  else
148  {
149  return false;
150  }
151 }
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace LESModels
157 } // End namespace incompressible
158 } // End namespace Foam
159 
160 // ************************ vim: set sw=4 sts=4 et: ************************ //