PDRkEpsilon.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-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2020,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 "PDRkEpsilon.H"
30 #include "PDRDragModel.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace compressible
38 {
39 namespace RASModels
40 {
41 
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
43 
44 defineTypeNameAndDebug(PDRkEpsilon, 0);
45 addToRunTimeSelectionTable(RASModel, PDRkEpsilon, dictionary);
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const geometricOneField& alpha,
52  const volScalarField& rho,
53  const volVectorField& U,
54  const surfaceScalarField& alphaRhoPhi,
55  const surfaceScalarField& phi,
56  const fluidThermo& thermophysicalModel,
57  const word& turbulenceModelName,
58  const word& modelName
59 )
60 :
61  Foam::RASModels::kEpsilon<EddyDiffusivity<compressible::turbulenceModel>>
62  (
63  geometricOneField(),
64  rho,
65  U,
66  phi,
67  phi,
68  thermophysicalModel,
69  turbulenceModelName,
70  modelName
71  ),
72 
73  C4_
74  (
75  dimensioned<scalar>::getOrAddToDict
76  (
77  "C4",
78  coeffDict_,
79  0.1
80  )
81  )
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
86 
87 PDRkEpsilon::~PDRkEpsilon()
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 bool PDRkEpsilon::read()
94 {
95  if (RASModel::read())
96  {
97  C4_.readIfPresent(coeffDict_);
98  return true;
99  }
100 
101  return false;
102 }
103 
104 
106 {
107  if (!turbulence_)
108  {
109  // Re-calculate viscosity
110  nut_ = Cmu_*sqr(k_)/epsilon_;
111  nut_.correctBoundaryConditions();
112 
113  // Re-calculate thermal diffusivity
114  //***HGWalphat_ = mut_/Prt_;
115  //alphat_.correctBoundaryConditions();
116 
117  return;
118  }
119 
121 
123 
124  if (mesh_.moving())
125  {
126  divU += fvc::div(mesh_.phi());
127  }
128 
129  tmp<volTensorField> tgradU = fvc::grad(U_);
130  volScalarField G(GName(), rho_*nut_*(tgradU() && dev(twoSymm(tgradU()))));
131  tgradU.clear();
132 
133  // Update epsilon and G at the wall
134  epsilon_.boundaryFieldRef().updateCoeffs();
135  // Push new cell values to
136  // coupled neighbours. Note that we want to avoid the re-updateCoeffs
137  // of the wallFunctions so make sure to bypass the evaluate on
138  // those patches and only do the coupled ones.
139  epsilon_.boundaryFieldRef().evaluateCoupled<coupledFvPatch>();
140 
141  // Add the blockage generation term so that it is included consistently
142  // in both the k and epsilon equations
143  const volScalarField& betav =
144  U_.db().lookupObject<volScalarField>("betav");
145 
146  const volScalarField& Lobs =
147  U_.db().lookupObject<volScalarField>("Lobs");
148 
149  const PDRDragModel& drag =
150  U_.db().lookupObject<PDRDragModel>("PDRDragModel");
151 
152  volScalarField GR(drag.Gk());
153 
154  volScalarField LI
155  (C4_*(Lobs + dimensionedScalar("minLength", dimLength, VSMALL)));
156 
157  // Dissipation equation
158  tmp<fvScalarMatrix> epsEqn
159  (
160  betav*fvm::ddt(rho_, epsilon_)
161  + fvm::div(phi_, epsilon_)
162  - fvm::laplacian(rho_*DepsilonEff(), epsilon_)
163  ==
164  C1_*betav*G*epsilon_/k_
165  + 1.5*pow(Cmu_, 3.0/4.0)*GR*sqrt(k_)/LI
166  - fvm::SuSp(((2.0/3.0)*C1_)*betav*rho_*divU, epsilon_)
167  - fvm::Sp(C2_*betav*rho_*epsilon_/k_, epsilon_)
168  );
169 
170  epsEqn.ref().relax();
171 
172  epsEqn.ref().boundaryManipulate(epsilon_.boundaryFieldRef());
173 
174  solve(epsEqn);
175  bound(epsilon_, epsilonMin_);
176 
177 
178  // Turbulent kinetic energy equation
179 
180  tmp<fvScalarMatrix> kEqn
181  (
182  betav*fvm::ddt(rho_, k_)
183  + fvm::div(phi_, k_)
184  - fvm::laplacian(rho_*DkEff(), k_)
185  ==
186  betav*G + GR
187  - fvm::SuSp((2.0/3.0)*betav*rho_*divU, k_)
188  - fvm::Sp(betav*rho_*epsilon_/k_, k_)
189  );
190 
191  kEqn.ref().relax();
192  solve(kEqn);
193  bound(k_, kMin_);
194 
195  // Re-calculate viscosity
196  nut_ = Cmu_*sqr(k_)/epsilon_;
197  nut_.correctBoundaryConditions();
198 
199  // Re-calculate thermal diffusivity
200  //***HGWalphat_ = mut_/Prt_;
201  //alphat_.correctBoundaryConditions();
202 }
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace RASModels
208 } // End namespace compressible
209 } // End namespace Foam
210 
211 // ************************************************************************* //
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:47
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
const dimensionedScalar G
Newtonian constant of gravitation.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:42
PDRkEpsilon(const geometricOneField &alpha, const volScalarField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const fluidThermo &thermophysicalModel, const word &turbulenceModelName=turbulenceModel::typeName, const word &modelName=typeName)
Construct from components.
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
dimensionedScalar sqrt(const dimensionedScalar &ds)
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:76
virtual bool read()
Read model coefficients if they have changed.
Definition: RASModel.C:164
Info<< "Reading strained laminar flame speed field Su\"<< endl;volScalarField Su(IOobject("Su", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field betav\"<< endl;volScalarField betav(IOobject("betav", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field Lobs\"<< endl;volScalarField Lobs(IOobject("Lobs", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field CT\"<< endl;volSymmTensorField CT(IOobject("CT", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field Nv\"<< endl;volScalarField Nv(IOobject("Nv", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field nsv\"<< endl;volSymmTensorField nsv(IOobject("nsv", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);IOdictionary PDRProperties(IOobject("PDRProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE));autoPtr< PDRDragModel > drag
Definition: createFields.H:167
Macros for easy insertion into run-time selection tables.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:72
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
const volScalarField & betav
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:41
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:450
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.
SolverPerformance< Type > solve(faMatrix< Type > &, const dictionary &solverControls)
Solve returning the solution statistics given convergence tolerance.
bool compressible
Definition: pEqn.H:2
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:41
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/chef2/andy/OpenFOAM/release/v2406/OpenFOAM-v2406/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:63
RASModel< EddyDiffusivity< turbulenceModel > > RASModel
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.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
U
Definition: pEqn.H:72
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:29
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:41
defineTypeNameAndDebug(alphatPhaseChangeWallFunctionFvPatchScalarField, 0)
zeroField divU
Definition: alphaSuSp.H:3
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: RASModel.C:215
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)