continuousGasKEpsilon.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) 2013-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "continuousGasKEpsilon.H"
30 #include "fvOptions.H"
31 #include "twoPhaseSystem.H"
32 #include "virtualMassModel.H"
33 #include "dragModel.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace RASModels
40 {
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 template<class BasicTurbulenceModel>
46 (
47  const alphaField& alpha,
48  const rhoField& rho,
49  const volVectorField& U,
50  const surfaceScalarField& alphaRhoPhi,
51  const surfaceScalarField& phi,
52  const transportModel& transport,
53  const word& propertiesName,
54  const word& type
55 )
56 :
58  (
59  alpha,
60  rho,
61  U,
62  alphaRhoPhi,
63  phi,
64  transport,
65  propertiesName,
66  type
67  ),
68 
69  liquidTurbulencePtr_(nullptr),
70 
71  nutEff_
72  (
73  IOobject
74  (
75  IOobject::groupName("nutEff", alphaRhoPhi.group()),
76  this->runTime_.timeName(),
77  this->mesh_,
80  ),
81  this->nut_
82  ),
83 
84  alphaInversion_
85  (
87  (
88  "alphaInversion",
89  this->coeffDict_,
90  0.7
91  )
92  )
93 {
94  if (type == typeName)
95  {
96  this->printCoeffs(type);
97  }
98 }
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
103 template<class BasicTurbulenceModel>
105 {
107  {
108  alphaInversion_.readIfPresent(this->coeffDict());
109 
110  return true;
111  }
112 
113  return false;
114 }
115 
116 
117 template<class BasicTurbulenceModel>
119 {
121 
122  const turbulenceModel& liquidTurbulence = this->liquidTurbulence();
123  const transportModel& gas = this->transport();
124  const twoPhaseSystem& fluid = refCast<const twoPhaseSystem>(gas.fluid());
125  const transportModel& liquid = fluid.otherPhase(gas);
126 
127  const virtualMassModel& virtualMass =
128  fluid.lookupSubModel<virtualMassModel>(gas, liquid);
129 
130  volScalarField thetal(liquidTurbulence.k()/liquidTurbulence.epsilon());
131  volScalarField rhodv(gas.rho() + virtualMass.Cvm()*liquid.rho());
132  volScalarField thetag((rhodv/(18*liquid.rho()*liquid.nu()))*sqr(gas.d()));
133  volScalarField expThetar
134  (
135  min
136  (
137  exp(min(thetal/thetag, scalar(50))),
138  scalar(1)
139  )
140  );
141  volScalarField omega((1 - expThetar)/(1 + expThetar));
142 
143  nutEff_ = omega*liquidTurbulence.nut();
144  fv::options::New(this->mesh_).correct(nutEff_);
145 }
146 
147 
148 template<class BasicTurbulenceModel>
149 const turbulenceModel&
151 {
152  if (!liquidTurbulencePtr_)
153  {
154  const volVectorField& U = this->U_;
155 
156  const transportModel& gas = this->transport();
157  const twoPhaseSystem& fluid =
158  refCast<const twoPhaseSystem>(gas.fluid());
159  const transportModel& liquid = fluid.otherPhase(gas);
160 
161  liquidTurbulencePtr_ =
162  &U.db().lookupObject<turbulenceModel>
163  (
165  (
167  liquid.name()
168  )
169  );
170  }
172  return *liquidTurbulencePtr_;
173 }
174 
175 
176 template<class BasicTurbulenceModel>
179 {
180  volScalarField blend
181  (
182  max
183  (
184  min
185  (
186  (this->alpha_ - scalar(0.5))/(alphaInversion_ - 0.5),
187  scalar(1)
188  ),
189  scalar(0)
190  )
191  );
192 
193  return tmp<volScalarField>
194  (
195  new volScalarField
196  (
197  IOobject::groupName("nuEff", this->alphaRhoPhi_.group()),
198  blend*this->nut_
199  + (1.0 - blend)*rhoEff()*nutEff_/this->transport().rho()
200  + this->nu()
201  )
202  );
203 }
204 
205 
206 template<class BasicTurbulenceModel>
209 {
210  const transportModel& gas = this->transport();
211  const twoPhaseSystem& fluid = refCast<const twoPhaseSystem>(gas.fluid());
212  const transportModel& liquid = fluid.otherPhase(gas);
213 
214  const virtualMassModel& virtualMass =
215  fluid.lookupSubModel<virtualMassModel>(gas, liquid);
216 
217  return tmp<volScalarField>
218  (
219  new volScalarField
220  (
221  IOobject::groupName("rhoEff", this->alphaRhoPhi_.group()),
222  gas.rho() + (virtualMass.Cvm() + 3.0/20.0)*liquid.rho()
223  )
224  );
225 }
226 
227 
228 template<class BasicTurbulenceModel>
231 {
232  const volVectorField& U = this->U_;
233  const alphaField& alpha = this->alpha_;
234  const rhoField& rho = this->rho_;
235 
236  const turbulenceModel& liquidTurbulence = this->liquidTurbulence();
237 
238  return
239  (
240  max(alphaInversion_ - alpha, scalar(0))
241  *rho
242  *min
243  (
244  liquidTurbulence.epsilon()/liquidTurbulence.k(),
245  1.0/U.time().deltaT()
246  )
247  );
248 }
249 
250 
251 template<class BasicTurbulenceModel>
254 {
255  const turbulenceModel& liquidTurbulence = this->liquidTurbulence();
256  const volScalarField phaseTransferCoeff(this->phaseTransferCoeff());
257 
258  return
259  phaseTransferCoeff*liquidTurbulence.k()
260  - fvm::Sp(phaseTransferCoeff, this->k_);
261 }
262 
263 
264 template<class BasicTurbulenceModel>
267 {
268  const turbulenceModel& liquidTurbulence = this->liquidTurbulence();
269  const volScalarField phaseTransferCoeff(this->phaseTransferCoeff());
270 
271  return
272  phaseTransferCoeff*liquidTurbulence.epsilon()
273  - fvm::Sp(phaseTransferCoeff, this->epsilon_);
274 }
275 
276 
277 template<class BasicTurbulenceModel>
280 {
281  tmp<volScalarField> tk(this->k());
282 
284  (
286  (
287  IOobject
288  (
289  IOobject::groupName("R", this->alphaRhoPhi_.group()),
290  this->runTime_.timeName(),
291  this->mesh_,
294  ),
295  ((2.0/3.0)*I)*tk() - (nutEff_)*devTwoSymm(fvc::grad(this->U_)),
296  tk().boundaryField().types()
297  )
298  );
299 }
300 
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 } // End namespace RASModels
305 } // End namespace Foam
306 
307 // ************************************************************************* //
BasicTurbulenceModel::transportModel transportModel
Generic thermophysical properties class for a liquid in which the functions and coefficients for each...
Definition: liquid.H:50
twoPhaseSystem & fluid
void correct(GeometricField< Type, PatchField, GeoMesh > &field)
Apply correction to field.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:85
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:47
virtual tmp< fvScalarMatrix > epsilonSource() const
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
virtual bool read()
Re-read model coefficients if they have changed.
label k
Boltzmann constant.
Generic dimensioned Type class.
Ignore writing from objectRegistry::writeObject()
Abstract base class for turbulence models (RAS, LES and laminar).
Class which solves the volume fraction equations for two phases.
virtual tmp< volScalarField > k() const =0
Return the turbulence kinetic energy.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
scalar rho(scalar p, scalar T) const
Liquid density [kg/m^3].
Definition: liquidI.H:21
dimensionedScalar exp(const dimensionedScalar &ds)
k-epsilon model for the gas-phase in a two-phase system supporting phase-inversion.
static const Identity< scalar > I
Definition: Identity.H:100
Standard k-epsilon turbulence model for incompressible and compressible flows including rapid distort...
Definition: kEpsilon.H:85
static const word propertiesName
Default name of the turbulence properties dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
Reading is optional [identical to LAZY_READ].
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
zeroField Sp(const Foam::zero, const GeometricField< Type, fvPatchField, volMesh > &)
A no-op source.
virtual tmp< fvScalarMatrix > kSource() const
virtual tmp< volScalarField > Cvm() const =0
Return the virtual mass coefficient.
virtual bool read()
Re-read model coefficients if they have changed.
Definition: kEpsilon.C:196
virtual tmp< volSymmTensorField > R() const
Return the Reynolds stress tensor.
BasicTurbulenceModel::alphaField alphaField
U
Definition: pEqn.H:72
tmp< volScalarField > phaseTransferCoeff() const
Base-class for all transport models used by the incompressible turbulence models. ...
virtual tmp< volScalarField > epsilon() const =0
Return the turbulence kinetic energy dissipation rate.
Nothing to be read.
Automatically write from objectRegistry::writeObject()
virtual void correctNut()
Definition: kEpsilon.C:36
BasicTurbulenceModel::rhoField rhoField
virtual tmp< volScalarField > rhoEff() const
Return the effective density for the stress.
const turbulenceModel & liquidTurbulence() const
Return the turbulence model for the liquid phase.
virtual tmp< volScalarField > nut() const =0
Return the turbulence viscosity.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present.
Definition: fvOptions.C:96
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
volScalarField & nu
Namespace for OpenFOAM.
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
Definition: SymmTensorI.H:491