kEqn.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) 2011-2024 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 "kEqn.H"
27 #include "fvModels.H"
28 #include "fvConstraints.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace LESModels
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class BasicMomentumTransportModel>
41 {
42  this->nut_ = Ck_*sqrt(k_)*this->delta();
43  this->nut_.correctBoundaryConditions();
44  fvConstraints::New(this->mesh_).constrain(this->nut_);
45 }
46 
47 
48 template<class BasicMomentumTransportModel>
50 {
51  return tmp<fvScalarMatrix>
52  (
53  new fvScalarMatrix
54  (
55  k_,
56  dimVolume*this->rho_.dimensions()*k_.dimensions()
57  /dimTime
58  )
59  );
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
65 template<class BasicMomentumTransportModel>
67 (
68  const alphaField& alpha,
69  const rhoField& rho,
70  const volVectorField& U,
71  const surfaceScalarField& alphaRhoPhi,
72  const surfaceScalarField& phi,
73  const viscosity& viscosity,
74  const word& type
75 )
76 :
77  LESeddyViscosity<BasicMomentumTransportModel>
78  (
79  type,
80  alpha,
81  rho,
82  U,
83  alphaRhoPhi,
84  phi,
85  viscosity
86  ),
87 
88  k_
89  (
90  IOobject
91  (
92  this->groupName("k"),
93  this->runTime_.name(),
94  this->mesh_,
95  IOobject::MUST_READ,
96  IOobject::AUTO_WRITE
97  ),
98  this->mesh_
99  ),
100 
101  Ck_("Ck", this->coeffDict(), 0.094)
102 {
103  bound(k_, this->kMin_);
104 }
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
109 template<class BasicMomentumTransportModel>
111 {
113  {
114  Ck_.readIfPresent(this->coeffDict());
115 
116  return true;
117  }
118  else
119  {
120  return false;
121  }
122 }
123 
124 
125 template<class BasicMomentumTransportModel>
127 {
128  return volScalarField::New
129  (
130  this->groupName("epsilon"),
131  this->Ce_*k()*sqrt(k())/this->delta()
132  );
133 }
134 
135 
136 template<class BasicMomentumTransportModel>
138 {
139  if (!this->turbulence_)
140  {
141  return;
142  }
143 
144  // Local references
145  const alphaField& alpha = this->alpha_;
146  const rhoField& rho = this->rho_;
147  const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
148  const volVectorField& U = this->U_;
149  volScalarField& nut = this->nut_;
150  const Foam::fvModels& fvModels(Foam::fvModels::New(this->mesh_));
152  (
153  Foam::fvConstraints::New(this->mesh_)
154  );
155 
157 
158  volScalarField divU(fvc::div(fvc::absolute(this->phi(), U)));
159 
161  volScalarField G(this->GName(), nut*(tgradU() && dev(twoSymm(tgradU()))));
162  tgradU.clear();
163 
165  (
166  fvm::ddt(alpha, rho, k_)
167  + fvm::div(alphaRhoPhi, k_)
168  - fvm::laplacian(alpha*rho*DkEff(), k_)
169  ==
170  alpha*rho*G
171  - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k_)
172  - fvm::Sp(this->Ce_*alpha*rho*sqrt(k_)/this->delta(), k_)
173  + kSource()
174  + fvModels.source(alpha, rho, k_)
175  );
176 
177  kEqn.ref().relax();
179  solve(kEqn);
181  bound(k_, this->kMin_);
182 
183  correctNut();
184 }
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace LESModels
190 } // End namespace Foam
191 
192 // ************************************************************************* //
label k
scalar delta
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Eddy viscosity LES SGS model base class.
One equation eddy-viscosity model.
Definition: kEqn.H:74
BasicMomentumTransportModel::alphaField alphaField
Definition: kEqn.H:97
volScalarField k_
Definition: kEqn.H:81
virtual void correct()
Correct eddy-Viscosity and related properties.
Definition: kEqn.C:137
virtual tmp< volScalarField > epsilon() const
Return sub-grid disipation rate.
Definition: kEqn.C:126
virtual void correctNut()
Definition: kEqn.C:40
virtual tmp< fvScalarMatrix > kSource() const
Definition: kEqn.C:49
kEqn(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const viscosity &viscosity, const word &type=typeName)
Constructor from components.
Definition: kEqn.C:67
virtual bool read()
Read model coefficients if they have changed.
Definition: kEqn.C:110
BasicMomentumTransportModel::rhoField rhoField
Definition: kEqn.H:98
static autoPtr< dictionary > New(Istream &)
Construct top-level dictionary on freestore from Istream.
Definition: dictionaryIO.C:103
virtual void correct()=0
Solve the turbulence equations and correct the turbulence viscosity.
Finite volume constraints.
Definition: fvConstraints.H:67
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Finite volume models.
Definition: fvModels.H:65
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
A class for managing temporary objects.
Definition: tmp.H:55
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:253
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
const scalar nut
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionedScalar G
Newtonian constant of gravitation.
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.
void dev(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
void twoSymm(LagrangianPatchField< tensor > &f, const LagrangianPatchField< tensor > &f1)
const dimensionSet dimTime
const dimensionSet dimVolume
bool bound(volScalarField &, const dimensionedScalar &min)
Bound the given scalar field where it is below the specified min value.
Definition: bound.C:31
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
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.