FreeFOAM The Cross-Platform CFD Toolkit
GenSGSStress.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 
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
32 namespace incompressible
33 {
34 namespace LESModels
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
39 GenSGSStress::GenSGSStress
40 (
41  const volVectorField& U,
42  const surfaceScalarField& phi,
43  transportModel& transport
44 )
45 :
46  LESModel(word("GenSGSStress"), U, phi, transport),
47 
48  ce_
49  (
51  (
52  "ce",
53  coeffDict_,
54  1.048
55  )
56  ),
57 
58  couplingFactor_
59  (
61  (
62  "couplingFactor",
63  coeffDict_,
64  0.0
65  )
66  ),
67 
68  B_
69  (
70  IOobject
71  (
72  "B",
73  runTime_.timeName(),
74  mesh_,
77  ),
78  mesh_
79  ),
80 
81  nuSgs_
82  (
83  IOobject
84  (
85  "nuSgs",
86  runTime_.timeName(),
87  mesh_,
90  ),
91  nu(),
92  B_.boundaryField().types()
93  )
94 {
95  if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
96  {
98  (
99  "GenSGSStress::GenSGSStress"
100  "(const volVectorField& U, const surfaceScalarField& phi,"
101  "transportModel& lamTransportModel)"
102  ) << "couplingFactor = " << couplingFactor_
103  << " is not in range 0 - 1" << nl
104  << exit(FatalError);
105  }
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 {
114  (
116  (
117  IOobject
118  (
119  "devRhoReff",
120  runTime_.timeName(),
121  mesh_,
124  ),
125  B_ - nu()*dev(twoSymm(fvc::grad(U())))
126  )
127  );
128 }
129 
130 
132 (
133  volVectorField& U
134 ) const
135 {
136  if (couplingFactor_.value() > 0.0)
137  {
138  return
139  (
140  fvc::div(B_ + couplingFactor_*nuSgs_*fvc::grad(U))
142  (
143  (1.0 - couplingFactor_)*nuSgs_, U, "laplacian(nuEff,U)"
144  )
145  - fvm::laplacian(nuEff(), U)
146  );
147  }
148  else
149  {
150  return
151  (
152  fvc::div(B_)
153  + fvc::laplacian(nuSgs_, U, "laplacian(nuEff,U)")
154  - fvm::laplacian(nuEff(), U)
155  );
156  }
157 }
158 
159 
161 {
162  if (LESModel::read())
163  {
165 
167 
168  if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
169  {
170  FatalErrorIn("GenSGSStress::read()")
171  << "couplingFactor = " << couplingFactor_
172  << " is not in range 0 - 1"
173  << exit(FatalError);
174  }
175 
176  return true;
177  }
178  else
179  {
180  return false;
181  }
182 }
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace LESModels
188 } // End namespace incompressible
189 } // End namespace Foam
190 
191 // ************************ vim: set sw=4 sts=4 et: ************************ //