v2f.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2026 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 "v2f.H"
27 #include "fvModels.H"
28 #include "fvConstraints.H"
29 #include "bound.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace RASModels
36 {
37 
38 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
39 
40 template<class BasicMomentumTransportModel>
42 {
43  tmp<volScalarField> tCmuk2(CmuKEps_*sqr(k_));
44  epsilon_ = max(epsilon_, tCmuk2()/(this->nutMaxCoeff_*this->nu()));
45  return tCmuk2;
46 }
47 
48 
49 template<class BasicMomentumTransportModel>
51 {
52  return max(k_/epsilon_, 6.0*sqrt(this->nu()/epsilon_));
53 }
54 
55 
56 template<class BasicMomentumTransportModel>
58 {
59  return
60  CL_*max(pow(k_, 1.5)
61  /epsilon_, Ceta_*pow025(pow3(this->nu())/epsilon_));
62 }
63 
64 
65 template<class BasicMomentumTransportModel>
67 {
68  this->nut_ = min(boundEpsilon()/epsilon_, this->Cmu_*v2_*Ts());
69  this->nut_.correctBoundaryConditions();
70  fvConstraints::New(this->mesh_).constrain(this->nut_);
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
75 
76 template<class BasicMomentumTransportModel>
78 (
79  const alphaField& alpha,
80  const rhoField& rho,
81  const volVectorField& U,
82  const surfaceScalarField& alphaRhoPhi,
83  const surfaceScalarField& phi,
84  const viscosity& viscosity,
85  const word& type
86 )
87 :
88  eddyViscosity<RASModel<BasicMomentumTransportModel>>
89  (
90  type,
91  alpha,
92  rho,
93  U,
94  alphaRhoPhi,
95  phi,
96  viscosity
97  ),
98  v2fBase(),
99 
100  Cmu_("Cmu", this->typeDict(type), 0.22),
101  CmuKEps_("CmuKEps", this->typeDict(type), 0.09),
102  C1_("C1", this->typeDict(type), 1.4),
103  C2_("C2", this->typeDict(type), 0.3),
104  CL_("CL", this->typeDict(type), 0.23),
105  Ceta_("Ceta", this->typeDict(type), 70.0),
106  Ceps2_("Ceps2", this->typeDict(type), 1.9),
107  Ceps3_("Ceps3", this->typeDict(type), -0.33),
108  sigmaK_("sigmaK", this->typeDict(type), 1.0),
109  sigmaEps_("sigmaEps", this->typeDict(type), 1.3),
110 
111  k_
112  (
113  IOobject
114  (
115  this->groupName("k"),
116  this->runTime_.name(),
117  this->mesh_,
118  IOobject::MUST_READ,
119  IOobject::AUTO_WRITE
120  ),
121  this->mesh_,
122  dimensions::turbulentKineticEnergy
123  ),
124  epsilon_
125  (
126  IOobject
127  (
128  this->groupName("epsilon"),
129  this->runTime_.name(),
130  this->mesh_,
131  IOobject::MUST_READ,
132  IOobject::AUTO_WRITE
133  ),
134  this->mesh_,
135  dimensions::turbulentEpsilon
136  ),
137  v2_
138  (
139  IOobject
140  (
141  this->groupName("v2"),
142  this->runTime_.name(),
143  this->mesh_,
144  IOobject::MUST_READ,
145  IOobject::AUTO_WRITE
146  ),
147  this->mesh_,
148  dimensions::turbulentKineticEnergy
149  ),
150  f_
151  (
152  IOobject
153  (
154  this->groupName("f"),
155  this->runTime_.name(),
156  this->mesh_,
157  IOobject::MUST_READ,
158  IOobject::AUTO_WRITE
159  ),
160  this->mesh_,
161  dimensions::rate
162  ),
163  v2Min_(dimensionedScalar(v2_.dimensions(), small)),
164  fMin_(dimensionedScalar(f_.dimensions(), 0))
165 {
166  bound(k_, this->kMin_);
167  boundEpsilon();
168  bound(v2_, v2Min_);
169  bound(f_, fMin_);
170 }
171 
172 
173 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
174 
175 template<class BasicMomentumTransportModel>
177 {
179  {
180  Cmu_.readIfPresent(this->typeDict());
181  CmuKEps_.readIfPresent(this->typeDict());
182  C1_.readIfPresent(this->typeDict());
183  C2_.readIfPresent(this->typeDict());
184  CL_.readIfPresent(this->typeDict());
185  Ceta_.readIfPresent(this->typeDict());
186  Ceps2_.readIfPresent(this->typeDict());
187  Ceps3_.readIfPresent(this->typeDict());
188  sigmaK_.readIfPresent(this->typeDict());
189  sigmaEps_.readIfPresent(this->typeDict());
190 
191  return true;
192  }
193  else
194  {
195  return false;
196  }
197 }
198 
199 
200 template<class BasicMomentumTransportModel>
202 {
203  if (!this->turbulence_)
204  {
205  return;
206  }
207 
208  // Local references
209  const alphaField& alpha = this->alpha_;
210  const rhoField& rho = this->rho_;
211  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
212  const volVectorField& U = this->U_;
213  volScalarField& nut = this->nut_;
214  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
216  (
217  Foam::fvConstraints::New(this->mesh_)
218  );
219 
221 
222  volScalarField divU(fvc::div(fvc::absolute(this->phi(), U)));
223 
224  // Use N=6 so that f=0 at walls
225  const dimensionedScalar N("N", dimless, 6.0);
226 
227  const volTensorField gradU(fvc::grad(U));
228  const volScalarField S2(2*magSqr(dev(symm(gradU))));
229 
230  const volScalarField G(this->GName(), nut*S2);
231  const volScalarField Ts(this->Ts());
232  const volScalarField L2(typedName("L2"), sqr(Ls()));
233  const volScalarField v2fAlpha
234  (
235  typedName("alpha"),
236  1.0/Ts*((C1_ - N)*v2_ - 2.0/3.0*k_*(C1_ - 1.0))
237  );
238 
239  const volScalarField Ceps1
240  (
241  typedName("Ceps1"),
242  1.4*(1.0 + 0.05*min(sqrt(k_/v2_), scalar(100.0)))
243  );
244 
245  // Update epsilon (and possibly G) at the wall
246  epsilon_.boundaryFieldRef().updateCoeffs();
247 
248  // Dissipation equation
249  tmp<fvScalarMatrix> epsEqn
250  (
251  fvm::ddt(alpha, rho, epsilon_)
252  + fvm::div(alphaRhoPhi, epsilon_)
253  - fvm::laplacian(alpha*rho*DepsilonEff(), epsilon_)
254  ==
255  Ceps1*alpha*rho*G/Ts
256  - fvm::SuSp(((2.0/3.0)*Ceps1 + Ceps3_)*alpha*rho*divU, epsilon_)
257  - fvm::Sp(Ceps2_*alpha*rho/Ts, epsilon_)
258  + fvModels.source(alpha, rho, epsilon_)
259  );
260 
261  epsEqn.ref().relax();
262  fvConstraints.constrain(epsEqn.ref());
263  epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
264  solve(epsEqn);
265  fvConstraints.constrain(epsilon_);
266  boundEpsilon();
267 
268 
269  // Turbulent kinetic energy equation
271  (
272  fvm::ddt(alpha, rho, k_)
273  + fvm::div(alphaRhoPhi, k_)
274  - fvm::laplacian(alpha*rho*DkEff(), k_)
275  ==
276  alpha*rho*G
277  - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k_)
278  - fvm::Sp(alpha*rho*epsilon_/k_, k_)
279  + fvModels.source(alpha, rho, k_)
280  );
281 
282  kEqn.ref().relax();
283  fvConstraints.constrain(kEqn.ref());
284  solve(kEqn);
286  bound(k_, this->kMin_);
287 
288 
289  // Relaxation function equation
291  (
292  - fvm::laplacian(f_)
293  ==
294  - fvm::Sp(1.0/L2, f_)
295  - 1.0/L2/k_*(v2fAlpha - C2_*G)
296  );
297 
298  fEqn.ref().relax();
299  fvConstraints.constrain(fEqn.ref());
300  solve(fEqn);
302  bound(f_, fMin_);
303 
304 
305  // Turbulence stress normal to streamlines equation
306  tmp<fvScalarMatrix> v2Eqn
307  (
308  fvm::ddt(alpha, rho, v2_)
309  + fvm::div(alphaRhoPhi, v2_)
310  - fvm::laplacian(alpha*rho*DkEff(), v2_)
311  ==
312  alpha*rho*min(k_*f_, C2_*G - v2fAlpha)
313  - fvm::Sp(N*alpha*rho*epsilon_/k_, v2_)
314  + fvModels.source(alpha, rho, v2_)
315  );
316 
317  v2Eqn.ref().relax();
318  fvConstraints.constrain(v2Eqn.ref());
319  solve(v2Eqn);
321  bound(v2_, v2Min_);
322 
323  correctNut();
324 }
325 
326 
327 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 
329 } // End namespace RASModels
330 } // End namespace Foam
331 
332 // ************************************************************************* //
Bound the given scalar field where it is below the specified minimum.
static fvConstraints & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Templated abstract base class for RAS turbulence models.
Definition: RASModel.H:56
Abstract base-class for v2-f models to provide BCs access to the v2 and f fields.
Definition: v2fBase.H:55
volScalarField k_
Turbulence kinetic energy.
Definition: v2f.H:144
v2f(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity, const word &type=typeName)
Construct from components.
Definition: v2f.C:78
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: v2f.C:201
tmp< volScalarField > boundEpsilon()
Bound epsilon and return Cmu*sqr(k) for nut.
Definition: v2f.C:41
dimensionedScalar fMin_
Definition: v2f.H:159
dimensionedScalar v2Min_
Definition: v2f.H:158
tmp< volScalarField > Ts() const
Return time scale, Ts.
Definition: v2f.C:50
virtual void correctNut()
Correct the eddy-viscosity nut.
Definition: v2f.C:66
volScalarField f_
Damping function.
Definition: v2f.H:153
tmp< volScalarField > Ls() const
Return length scale, Ls.
Definition: v2f.C:57
virtual bool read()
Read RASProperties dictionary.
Definition: v2f.C:176
volScalarField v2_
Turbulence stress normal to streamlines.
Definition: v2f.H:150
Eddy viscosity turbulence model base class.
Definition: eddyViscosity.H:52
Finite volume constraints.
Definition: fvConstraints.H:68
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
Finite volume models.
Definition: fvModels.H:69
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
BasicMomentumTransportModel::alphaField alphaField
BasicMomentumTransportModel::rhoField rhoField
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
const scalar nut
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
void correct(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiCorr, const SpType &Sp)
const dimensionedScalar G
Newtonian constant of gravitation.
const dimensionSet turbulentKineticEnergy
const dimensionSet dimless
const dimensionSet turbulentEpsilon
const dimensionSet rate
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:202
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > SuSp(const volScalarField::Internal &, const VolField< Type > &)
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
Namespace for OpenFOAM.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
void pow025(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void dev(pointPatchField< tensor > &, const pointPatchField< tensor > &)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:188
void symm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
bool bound(volScalarField &, const dimensionedScalar &min)
Bound the given scalar field where it is below the specified min value.
Definition: bound.C:31
void pow3(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.