kEqn.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2020-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "kEqn.H"
30#include "fvOptions.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36namespace LESModels
37{
38
39// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
40
41template<class BasicTurbulenceModel>
43{
44 this->nut_ = Ck_*sqrt(k_)*this->delta();
45 this->nut_.correctBoundaryConditions();
46 fv::options::New(this->mesh_).correct(this->nut_);
47
48 BasicTurbulenceModel::correctNut();
49}
50
51
52template<class BasicTurbulenceModel>
54{
56 (
58 (
59 k_,
60 dimVolume*this->rho_.dimensions()*k_.dimensions()
61 /dimTime
62 )
63 );
64}
65
66
67// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68
69template<class BasicTurbulenceModel>
71(
72 const alphaField& alpha,
73 const rhoField& rho,
74 const volVectorField& U,
75 const surfaceScalarField& alphaRhoPhi,
77 const transportModel& transport,
78 const word& propertiesName,
79 const word& type
80)
81:
82 LESeddyViscosity<BasicTurbulenceModel>
83 (
84 type,
85 alpha,
86 rho,
87 U,
88 alphaRhoPhi,
89 phi,
90 transport,
91 propertiesName
92 ),
93
94 k_
95 (
97 (
98 IOobject::groupName("k", this->alphaRhoPhi_.group()),
99 this->runTime_.timeName(),
100 this->mesh_,
101 IOobject::MUST_READ,
102 IOobject::AUTO_WRITE
103 ),
104 this->mesh_
105 ),
106
107 Ck_
108 (
109 dimensioned<scalar>::getOrAddToDict
110 (
111 "Ck",
112 this->coeffDict_,
113 0.094
114 )
115 )
116{
117 bound(k_, this->kMin_);
118
119 if (type == typeName)
120 {
121 this->printCoeffs(type);
122 }
123}
124
125
126// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127
128template<class BasicTurbulenceModel>
130{
132 {
133 Ck_.readIfPresent(this->coeffDict());
134
135 return true;
136 }
137
138 return false;
139}
140
141
142template<class BasicTurbulenceModel>
144{
145 if (!this->turbulence_)
146 {
147 return;
148 }
149
150 // Local references
151 const alphaField& alpha = this->alpha_;
152 const rhoField& rho = this->rho_;
153 const surfaceScalarField& alphaRhoPhi = this->alphaRhoPhi_;
154 const volVectorField& U = this->U_;
155 volScalarField& nut = this->nut_;
157
159
161
163 volScalarField G(this->GName(), nut*(tgradU() && dev(twoSymm(tgradU()))));
164 tgradU.clear();
165
167 (
168 fvm::ddt(alpha, rho, k_)
169 + fvm::div(alphaRhoPhi, k_)
170 - fvm::laplacian(alpha*rho*DkEff(), k_)
171 ==
172 alpha*rho*G
173 - fvm::SuSp((2.0/3.0)*alpha*rho*divU, k_)
174 - fvm::Sp(this->Ce_*alpha*rho*sqrt(k_)/this->delta(), k_)
175 + kSource()
176 + fvOptions(alpha, rho, k_)
177 );
178
179 kEqn.ref().relax();
180 fvOptions.constrain(kEqn.ref());
181 solve(kEqn);
182 fvOptions.correct(k_);
183 bound(k_, this->kMin_);
184
185 correctNut();
186}
187
188
189// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190
191} // End namespace LESModels
192} // End namespace Foam
193
194// ************************************************************************* //
scalar delta
fv::options & fvOptions
surfaceScalarField & phi
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Eddy viscosity LES SGS model base class.
One equation eddy-viscosity model.
Definition: kEqn.H:80
BasicTurbulenceModel::alphaField alphaField
Definition: kEqn.H:110
BasicTurbulenceModel::rhoField rhoField
Definition: kEqn.H:111
volScalarField k_
Definition: kEqn.H:87
virtual void correct()
Correct eddy-Viscosity and related properties.
Definition: kEqn.C:143
virtual void correctNut()
Definition: kEqn.C:42
virtual tmp< fvScalarMatrix > kSource() const
Definition: kEqn.C:53
BasicTurbulenceModel::transportModel transportModel
Definition: kEqn.H:112
virtual bool read()
Read model coefficients if they have changed.
Definition: kEqn.C:129
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Generic dimensioned Type class.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
Finite-volume options.
Definition: fvOptions.H:59
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
A class for handling words, derived from Foam::string.
Definition: word.H:68
U
Definition: pEqn.H:72
scalar nut
zeroField divU
Definition: alphaSuSp.H:3
word timeName
Definition: getTimeIndex.H:3
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:49
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:190
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:48
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:48
zeroField SuSp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
Namespace for OpenFOAM.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:35
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
volScalarField & alpha
CEqn solve()