Loading...
Searching...
No Matches
kineticTheoryModel.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-2018 OpenFOAM Foundation
9 Copyright (C) 2019-2023 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 "kineticTheoryModel.H"
31#include "twoPhaseSystem.H"
32#include "fvOptions.H"
33
34// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35
36Foam::RASModels::kineticTheoryModel::kineticTheoryModel
37(
38 const volScalarField& alpha,
39 const volScalarField& rho,
40 const volVectorField& U,
41 const surfaceScalarField& alphaRhoPhi,
42 const surfaceScalarField& phi,
43 const transportModel& phase,
44 const word& propertiesName,
45 const word& type
46)
47:
48 eddyViscosity
49 <
51 >
52 (
53 type,
54 alpha,
55 rho,
56 U,
57 alphaRhoPhi,
58 phi,
59 phase,
60 propertiesName
61 ),
62
63 phase_(phase),
64
65 viscosityModel_
66 (
67 kineticTheoryModels::viscosityModel::New
68 (
69 coeffDict_
70 )
71 ),
72 conductivityModel_
73 (
74 kineticTheoryModels::conductivityModel::New
75 (
76 coeffDict_
77 )
78 ),
79 radialModel_
80 (
81 kineticTheoryModels::radialModel::New
82 (
83 coeffDict_
84 )
85 ),
86 granularPressureModel_
87 (
88 kineticTheoryModels::granularPressureModel::New
89 (
90 coeffDict_
91 )
92 ),
93 frictionalStressModel_
94 (
95 kineticTheoryModels::frictionalStressModel::New
96 (
97 coeffDict_
98 )
99 ),
100
101 equilibrium_(coeffDict_.get<bool>("equilibrium")),
102 e_("e", dimless, coeffDict_),
103 alphaMax_("alphaMax", dimless, coeffDict_),
104 alphaMinFriction_("alphaMinFriction", dimless, coeffDict_),
105 residualAlpha_("residualAlpha", dimless, coeffDict_),
106 maxNut_("maxNut", dimViscosity, 1000, coeffDict_),
107
108 Theta_
109 (
110 IOobject
111 (
112 IOobject::groupName("Theta", phase.name()),
113 U.time().timeName(),
114 U.mesh(),
115 IOobject::MUST_READ,
116 IOobject::AUTO_WRITE,
117 IOobject::REGISTER
118 ),
119 U.mesh()
120 ),
121
122 lambda_
123 (
124 IOobject
125 (
126 IOobject::groupName("lambda", phase.name()),
127 U.time().timeName(),
128 U.mesh(),
129 IOobject::NO_READ,
130 IOobject::NO_WRITE
131 ),
132 U.mesh(),
134 ),
135
136 gs0_
137 (
138 IOobject
139 (
140 IOobject::groupName("gs0", phase.name()),
141 U.time().timeName(),
142 U.mesh(),
143 IOobject::NO_READ,
144 IOobject::NO_WRITE
145 ),
146 U.mesh(),
148 ),
149
150 kappa_
151 (
152 IOobject
153 (
154 IOobject::groupName("kappa", phase.name()),
155 U.time().timeName(),
156 U.mesh(),
157 IOobject::NO_READ,
158 IOobject::NO_WRITE
159 ),
160 U.mesh(),
162 ),
163
164 nuFric_
165 (
166 IOobject
167 (
168 IOobject::groupName("nuFric", phase.name()),
169 U.time().timeName(),
170 U.mesh(),
171 IOobject::NO_READ,
172 IOobject::AUTO_WRITE,
173 IOobject::REGISTER
174 ),
175 U.mesh(),
177 )
178{
179 if (type == typeName)
180 {
183}
184
185
186// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
189{}
190
191
192// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
193
195{
196 if
197 (
199 <
201 >::read()
202 )
203 {
204 coeffDict().readEntry("equilibrium", equilibrium_);
205 e_.readIfPresent(coeffDict());
206 alphaMax_.readIfPresent(coeffDict());
207 alphaMinFriction_.readIfPresent(coeffDict());
208
209 viscosityModel_->read();
210 conductivityModel_->read();
211 radialModel_->read();
212 granularPressureModel_->read();
213 frictionalStressModel_->read();
214
215 return true;
217
218 return false;
219}
220
221
226 return nut_;
227}
228
229
234 return nut_;
235}
236
237
242 return nullptr;
243}
244
245
248{
250 (
251 IOobject::groupName("R", U_.group()),
253 (
254 - (nut_)*devTwoSymm(fvc::grad(U_))
256 )
257 );
258}
259
260
263{
264 const tmp<volScalarField> trho(phase_.rho());
265 const volScalarField& rho = trho();
266
267 tmp<volScalarField> tpPrime
268 (
269 Theta_
270 *granularPressureModel_->granularPressureCoeffPrime
271 (
272 alpha_,
273 radialModel_->g0(alpha_, alphaMinFriction_, alphaMax_),
274 radialModel_->g0prime(alpha_, alphaMinFriction_, alphaMax_),
275 rho,
276 e_
277 )
278 + frictionalStressModel_->frictionalPressurePrime
279 (
280 phase_,
281 alphaMinFriction_,
282 alphaMax_
283 )
284 );
285
286 volScalarField::Boundary& bpPrime =
287 tpPrime.ref().boundaryFieldRef();
288
289 forAll(bpPrime, patchi)
290 {
291 if (!bpPrime[patchi].coupled())
292 {
293 bpPrime[patchi] == 0;
294 }
296
297 return tpPrime;
298}
299
300
306
307
325 (
326 - (rho_*nut_)
329 )
330 );
331}
332
333
336(
338) const
339{
340 return
341 (
342 - fvm::laplacian(rho_*nut_, U)
343 - fvc::div
344 (
345 (rho_*nut_)*dev2(T(fvc::grad(U)))
346 + ((rho_*lambda_)*fvc::div(phi_))
348 )
349 );
350}
351
352
354{
355 // Local references
356 volScalarField alpha(max(alpha_, scalar(0)));
357 const tmp<volScalarField> trho(phase_.rho());
358 const volScalarField& rho = trho();
359 const surfaceScalarField& alphaRhoPhi = alphaRhoPhi_;
360 const volVectorField& U = U_;
361 const tmp<volVectorField> tUc =
362 refCast<const twoPhaseSystem>(phase_.fluid()).otherPhase(phase_).U();
363 const volVectorField& Uc = tUc();
364
365 const scalar sqrtPi = sqrt(constant::mathematical::pi);
366 dimensionedScalar ThetaSmall("ThetaSmall", Theta_.dimensions(), 1e-6);
367 dimensionedScalar ThetaSmallSqrt(sqrt(ThetaSmall));
368
369 tmp<volScalarField> tda(phase_.d());
370 const volScalarField& da = tda();
371
372 tmp<volTensorField> tgradU(fvc::grad(U_));
373 const volTensorField& gradU(tgradU());
374 volSymmTensorField D(symm(gradU));
375
376 // Calculating the radial distribution function
377 gs0_ = radialModel_->g0(alpha, alphaMinFriction_, alphaMax_);
378
379 if (!equilibrium_)
380 {
381 // Particle viscosity (Table 3.2, p.47)
382 nut_ = viscosityModel_->nu(alpha, Theta_, gs0_, rho, da, e_);
383
384 volScalarField ThetaSqrt("sqrtTheta", sqrt(Theta_));
385
386 // Bulk viscosity p. 45 (Lun et al. 1984).
387 lambda_ = (4.0/3.0)*sqr(alpha)*da*gs0_*(1 + e_)*ThetaSqrt/sqrtPi;
388
389 // Stress tensor, Definitions, Table 3.1, p. 43
391 (
392 rho*(2*nut_*D + (lambda_ - (2.0/3.0)*nut_)*tr(D)*I)
393 );
394
395 // Dissipation (Eq. 3.24, p.50)
396 volScalarField gammaCoeff
397 (
398 "gammaCoeff",
399 12*(1 - sqr(e_))
400 *max(sqr(alpha), residualAlpha_)
401 *rho*gs0_*(1.0/da)*ThetaSqrt/sqrtPi
402 );
403
404 // Drag
406 (
407 refCast<const twoPhaseSystem>(phase_.fluid()).Kd()
408 );
409
410 // Eq. 3.25, p. 50 Js = J1 - J2
411 volScalarField J1("J1", 3*beta);
413 (
414 "J2",
415 0.25*sqr(beta)*da*magSqr(U - Uc)
416 /(
417 max(alpha, residualAlpha_)*rho
418 *sqrtPi*(ThetaSqrt + ThetaSmallSqrt)
419 )
420 );
421
422 // particle pressure - coefficient in front of Theta (Eq. 3.22, p. 45)
423 volScalarField PsCoeff
424 (
425 granularPressureModel_->granularPressureCoeff
426 (
427 alpha,
428 gs0_,
429 rho,
430 e_
431 )
432 );
433
434 // 'thermal' conductivity (Table 3.3, p. 49)
435 kappa_ = conductivityModel_->kappa(alpha, Theta_, gs0_, rho, da, e_);
436
438
439 // Construct the granular temperature equation (Eq. 3.20, p. 44)
440 // NB. note that there are two typos in Eq. 3.20:
441 // Ps should be without grad
442 // the laplacian has the wrong sign
443 fvScalarMatrix ThetaEqn
444 (
445 1.5*
446 (
447 fvm::ddt(alpha, rho, Theta_)
448 + fvm::div(alphaRhoPhi, Theta_)
449 - fvc::Sp(fvc::ddt(alpha, rho) + fvc::div(alphaRhoPhi), Theta_)
450 )
451 - fvm::laplacian(kappa_, Theta_, "laplacian(kappa,Theta)")
452 ==
453 - fvm::SuSp((PsCoeff*I) && gradU, Theta_)
454 + (tau && gradU)
455 + fvm::Sp(-gammaCoeff, Theta_)
456 + fvm::Sp(-J1, Theta_)
457 + fvm::Sp(J2/(Theta_ + ThetaSmall), Theta_)
458 + fvOptions(alpha, rho, Theta_)
459 );
460
461 ThetaEqn.relax();
462 fvOptions.constrain(ThetaEqn);
463 ThetaEqn.solve();
464 fvOptions.correct(Theta_);
465 }
466 else
467 {
468 // Equilibrium => dissipation == production
469 // Eq. 4.14, p.82
470 volScalarField K1("K1", 2*(1 + e_)*rho*gs0_);
472 (
473 "K3",
474 0.5*da*rho*
475 (
476 (sqrtPi/(3*(3.0 - e_)))
477 *(1 + 0.4*(1 + e_)*(3*e_ - 1)*alpha*gs0_)
478 +1.6*alpha*gs0_*(1 + e_)/sqrtPi
479 )
480 );
481
483 (
484 "K2",
485 4*da*rho*(1 + e_)*alpha*gs0_/(3*sqrtPi) - 2*K3/3.0
486 );
487
488 volScalarField K4("K4", 12*(1 - sqr(e_))*rho*gs0_/(da*sqrtPi));
489
491 (
492 "trD",
493 alpha/(alpha + residualAlpha_)
494 *fvc::div(phi_)
495 );
496 volScalarField tr2D("tr2D", sqr(trD));
497 volScalarField trD2("trD2", tr(D & D));
498
499 volScalarField t1("t1", K1*alpha + rho);
500 volScalarField l1("l1", -t1*trD);
501 volScalarField l2("l2", sqr(t1)*tr2D);
503 (
504 "l3",
505 4.0
506 *K4
507 *alpha
508 *(2*K3*trD2 + K2*tr2D)
509 );
510
511 Theta_ = sqr
512 (
513 (l1 + sqrt(l2 + l3))
514 /(2*max(alpha, residualAlpha_)*K4)
515 );
516
517 kappa_ = conductivityModel_->kappa(alpha, Theta_, gs0_, rho, da, e_);
518 }
519
520 Theta_.clamp_range(0, 100);
521
522 {
523 // particle viscosity (Table 3.2, p.47)
524 nut_ = viscosityModel_->nu(alpha, Theta_, gs0_, rho, da, e_);
525
526 volScalarField ThetaSqrt("sqrtTheta", sqrt(Theta_));
527
528 // Bulk viscosity p. 45 (Lun et al. 1984).
529 lambda_ = (4.0/3.0)*sqr(alpha)*da*gs0_*(1 + e_)*ThetaSqrt/sqrtPi;
530
531 // Frictional pressure
533 (
534 frictionalStressModel_->frictionalPressure
535 (
536 phase_,
537 alphaMinFriction_,
538 alphaMax_
539 )
540 );
541
542 nuFric_ = frictionalStressModel_->nu
543 (
544 phase_,
545 alphaMinFriction_,
546 alphaMax_,
547 pf/rho,
548 D
549 );
550
551 // Limit viscosity and add frictional viscosity
552 nut_.clamp_max(maxNut_);
553
554 nuFric_ = min(nuFric_, maxNut_ - nut_);
555 nut_ += nuFric_;
556 }
557
558 if (debug)
559 {
560 Info<< typeName << ':' << nl
561 << " max(Theta) = " << max(Theta_).value() << nl
562 << " max(nut) = " << max(nut_).value() << endl;
563 }
564}
565
566
567// ************************************************************************* //
#define K3
Definition SHA1.C:145
#define K1
Definition SHA1.C:143
#define K4
Definition SHA1.C:146
#define K2
Definition SHA1.C:144
fv::options & fvOptions
Templated abstract base class for single-phase compressible turbulence models.
static tmp< GeometricField< symmTensor, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< symmTensor >::calculatedType())
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
@ NO_REGISTER
Do not request registration (bool: false).
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Templated abstract base class for RAS turbulence models.
Definition RASModel.H:81
virtual tmp< volScalarField > epsilon() const
Return the turbulence kinetic energy dissipation rate.
virtual tmp< volSymmTensorField > R() const
Return the Reynolds stress tensor.
virtual void correct()
Solve the kinetic theory equations and correct the viscosity.
virtual tmp< volScalarField > k() const
Return the turbulence kinetic energy.
virtual tmp< fvVectorMatrix > divDevRhoReff(volVectorField &U) const
Return the source term for the momentum equation.
virtual tmp< volScalarField > pPrime() const
Return the phase-pressure'.
virtual tmp< surfaceScalarField > pPrimef() const
Return the face-phase-pressure'.
virtual tmp< volScalarField > omega() const
Return the specific dissipation rate.
virtual tmp< volSymmTensorField > devRhoReff() const
Return the effective stress tensor.
virtual bool read()
Re-read model coefficients if they have changed.
static const SymmTensor I
Definition SymmTensor.H:74
Generic dimensioned Type class.
Eddy viscosity turbulence model base class.
eddyViscosity(const word &modelName, const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName)
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
Definition fvMatrix.C:1094
SolverPerformance< Type > solve(const dictionary &)
Solve returning the solution statistics.
Finite-volume options, which is an IOdictionary of values and a fv::optionList.
Definition fvOptions.H:69
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present otherwise lookup and return.
Definition fvOptions.C:116
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
const surfaceScalarField & alphaRhoPhi() const
Access function to phase flux field.
const surfaceScalarField & phi_
const volVectorField & U_
const surfaceScalarField & alphaRhoPhi_
U
Definition pEqn.H:72
const volScalarField & T
bool coupled
dynamicFvMesh & mesh
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
auto & name
word timeName
Definition getTimeIndex.H:3
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
RASModel< EddyDiffusivity< turbulenceModel > > RASModel
constexpr scalar pi(M_PI)
Namespace for handling debugging switches.
Definition debug.C:45
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition fvcGrad.C:47
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition fvcDiv.C:42
tmp< GeometricField< Type, fvPatchField, volMesh > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition fvcDdt.C:40
tmp< GeometricField< Type, fvPatchField, volMesh > > Sp(const volScalarField &sp, const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition fvcSup.C:62
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition fvmDiv.C:41
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition fvmDdt.C:41
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.
type
Types of root.
Definition Roots.H:53
dimensionedSymmTensor dev2(const dimensionedSymmTensor &dt)
const dimensionSet dimViscosity
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
GeometricField< vector, fvPatchField, volMesh > volVectorField
const dimensionSet dimless
Dimensionless.
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition int32.H:127
dimensionedSymmTensor sqr(const dimensionedVector &dv)
fvMatrix< scalar > fvScalarMatrix
GeometricField< scalar, fvPatchField, volMesh > volScalarField
SymmTensor< Cmpt > devTwoSymm(const SymmTensor< Cmpt > &st)
Return the deviatoric part of twice the symmetric part of a SymmTensor.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static const Identity< scalar > I
Definition Identity.H:100
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
GeometricField< tensor, fvPatchField, volMesh > volTensorField
dimensionedScalar sqrt(const dimensionedScalar &ds)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
ThermalDiffusivity< PhaseCompressibleTurbulenceModel< phaseModel > > phaseCompressibleTurbulenceModel
Typedef for phaseCompressibleTurbulenceModel.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
const dimensionSet dimDynamicViscosity
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
volScalarField & alpha
tmp< volScalarField > trho
const dimensionedScalar & D
volScalarField & e
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299