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 | Copyright (C) 2011-2015 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 "PDRkEpsilon.H"
27 #include "PDRDragModel.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace compressible
35 {
36 namespace RASModels
37 {
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 defineTypeNameAndDebug(PDRkEpsilon, 0);
42 addToRunTimeSelectionTable(RASModel, PDRkEpsilon, dictionary);
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const geometricOneField& alpha,
49  const volScalarField& rho,
50  const volVectorField& U,
51  const surfaceScalarField& alphaRhoPhi,
52  const surfaceScalarField& phi,
53  const fluidThermo& thermophysicalModel,
54  const word& turbulenceModelName,
55  const word& modelName
56 )
57 :
58  Foam::RASModels::kEpsilon<EddyDiffusivity<compressible::turbulenceModel> >
59  (
60  geometricOneField(),
61  rho,
62  U,
63  phi,
64  phi,
65  thermophysicalModel,
66  turbulenceModelName,
67  modelName
68  ),
69 
70  C4_
71  (
72  dimensioned<scalar>::lookupOrAddToDict
73  (
74  "C4",
75  coeffDict_,
76  0.1
77  )
78  )
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
83 
84 PDRkEpsilon::~PDRkEpsilon()
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
90 bool PDRkEpsilon::read()
91 {
92  if (RASModel::read())
93  {
94  C4_.readIfPresent(coeffDict_);
95  return true;
96  }
97  else
98  {
99  return false;
100  }
101 }
102 
103 
105 {
106  if (!turbulence_)
107  {
108  // Re-calculate viscosity
109  nut_ = Cmu_*sqr(k_)/epsilon_;
110  nut_.correctBoundaryConditions();
111 
112  // Re-calculate thermal diffusivity
113  //***HGWalphat_ = mut_/Prt_;
114  //alphat_.correctBoundaryConditions();
115 
116  return;
117  }
118 
120 
122 
123  if (mesh_.moving())
124  {
125  divU += fvc::div(mesh_.phi());
126  }
127 
128  tmp<volTensorField> tgradU = fvc::grad(U_);
129  volScalarField G(GName(), rho_*nut_*(tgradU() && dev(twoSymm(tgradU()))));
130  tgradU.clear();
131 
132  // Update espsilon and G at the wall
133  epsilon_.boundaryField().updateCoeffs();
134 
135  // Add the blockage generation term so that it is included consistently
136  // in both the k and epsilon equations
137  const volScalarField& betav =
138  U_.db().lookupObject<volScalarField>("betav");
139 
140  const volScalarField& Lobs =
141  U_.db().lookupObject<volScalarField>("Lobs");
142 
143  const PDRDragModel& drag =
144  U_.db().lookupObject<PDRDragModel>("PDRDragModel");
145 
146  volScalarField GR(drag.Gk());
147 
148  volScalarField LI
149  (C4_*(Lobs + dimensionedScalar("minLength", dimLength, VSMALL)));
150 
151  // Dissipation equation
152  tmp<fvScalarMatrix> epsEqn
153  (
154  betav*fvm::ddt(rho_, epsilon_)
155  + fvm::div(phi_, epsilon_)
156  - fvm::laplacian(rho_*DepsilonEff(), epsilon_)
157  ==
158  C1_*betav*G*epsilon_/k_
159  + 1.5*pow(Cmu_, 3.0/4.0)*GR*sqrt(k_)/LI
160  - fvm::SuSp(((2.0/3.0)*C1_)*betav*rho_*divU, epsilon_)
161  - fvm::Sp(C2_*betav*rho_*epsilon_/k_, epsilon_)
162  );
163 
164  epsEqn().relax();
165 
166  epsEqn().boundaryManipulate(epsilon_.boundaryField());
167 
168  solve(epsEqn);
169  bound(epsilon_, epsilonMin_);
170 
171 
172  // Turbulent kinetic energy equation
173 
174  tmp<fvScalarMatrix> kEqn
175  (
176  betav*fvm::ddt(rho_, k_)
177  + fvm::div(phi_, k_)
178  - fvm::laplacian(rho_*DkEff(), k_)
179  ==
180  betav*G + GR
181  - fvm::SuSp((2.0/3.0)*betav*rho_*divU, k_)
182  - fvm::Sp(betav*rho_*epsilon_/k_, k_)
183  );
184 
185  kEqn().relax();
186  solve(kEqn);
187  bound(k_, kMin_);
188 
189  // Re-calculate viscosity
190  nut_ = Cmu_*sqr(k_)/epsilon_;
191  nut_.correctBoundaryConditions();
192 
193  // Re-calculate thermal diffusivity
194  //***HGWalphat_ = mut_/Prt_;
195  //alphat_.correctBoundaryConditions();
196 }
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace RASModels
202 } // End namespace compressible
203 } // End namespace Foam
204 
205 // ************************************************************************* //
drag
Info<< "Reading strained laminar flame speed field Su\n"<< endl;volScalarField Su(IOobject("Su", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);Info<< "Reading field betav\n"<< endl;volScalarField betav(IOobject("betav", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field Lobs\n"<< endl;volScalarField Lobs(IOobject("Lobs", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field CT\n"<< endl;volSymmTensorField CT(IOobject("CT", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field Nv\n"<< endl;volScalarField Nv(IOobject("Nv", mesh.facesInstance(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE), mesh);Info<< "Reading field nsv\n"<< 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:183
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
Foam::constant::universal::G
const dimensionedScalar G
Newtonian constant of gravitation.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::bound
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
Definition: bound.C:33
Foam::fvc::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Definition: surfaceInterpolate.C:110
Foam::compressible::RASModels::PDRkEpsilon::PDRkEpsilon
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.
Foam::fvc::div
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
U
U
Definition: pEqn.H:46
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)
Foam::compressible::turbulenceModel
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Definition: turbulentFluidThermoModel.H:60
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
correct
fvOptions correct(rho)
Foam::fvm::SuSp
tmp< fvMatrix< Type > > SuSp(const DimensionedField< scalar, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
PDRkEpsilon.H
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:73
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
rho
rho
Definition: pEqn.H:3
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
Foam::RASModel::correct
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
Definition: RASModel.C:195
Foam::solve
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
Foam::fvm::ddt
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvmDdt.C:46
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::compressible::RASModel
RASModel< EddyDiffusivity< turbulenceModel > > RASModel
Definition: turbulentFluidThermoModel.H:62
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
divU
volScalarField divU(fvc::div(fvc::absolute(phi, U)))
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:142
compressible
bool compressible
Definition: pEqn.H:40
betav
const volScalarField & betav
Definition: setRegionSolidFields.H:30
PDRDragModel.H
Foam::fvm::div
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmDiv.C:46
Foam::twoSymm
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:93
Foam::compressible::defineTypeNameAndDebug
defineTypeNameAndDebug(alphatPhaseChangeWallFunctionFvPatchScalarField, 0)
Foam::RASModel::read
virtual bool read()
Read model coefficients if they have changed.
Definition: RASModel.C:169
Foam::dev
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:104