nonUnityLewisEddyDiffusivity.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020-2026 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 
27 #include "fvcDiv.H"
28 #include "fvcLaplacian.H"
29 #include "fvcSnGrad.H"
30 #include "fvmSup.H"
31 #include "surfaceInterpolate.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace turbulenceThermophysicalTransportModels
38 {
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 template<class TurbulenceThermophysicalTransportModel>
45 (
46  const momentumTransportModel& momentumTransport,
47  const thermoModel& thermo,
48  const word& type
49 )
50 :
51  unityLewisEddyDiffusivity<TurbulenceThermophysicalTransportModel>
52  (
53  type,
54  momentumTransport,
55  thermo,
56  false
57  ),
58 
59  Sct_("Sct", dimless, this->typeDict(type))
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class TurbulenceThermophysicalTransportModel>
66 bool
68 {
69  if
70  (
72  ::read()
73  )
74  {
75  Sct_.read(this->typeDict());
76 
77  return true;
78  }
79  else
80  {
81  return false;
82  }
83 }
84 
85 
86 template<class TurbulenceThermophysicalTransportModel>
89 {
91  (
93  (
95  (
96  "q",
97  this->thermo().phaseName()
98  ),
99  -fvc::interpolate(this->alpha()*this->kappaEff())
100  *fvc::snGrad(this->thermo().T())
101  )
102  );
103 
104  const PtrList<volScalarField>& Y = this->thermo().Y();
105  const volScalarField& p = this->thermo().p();
106  const volScalarField& T = this->thermo().T();
107 
108  if (Y.size())
109  {
110  surfaceScalarField hGradY
111  (
113  (
114  "hGradY",
115  Y[0].mesh(),
117  )
118  );
119 
120  forAll(Y, i)
121  {
122  const volScalarField hi(this->thermo().hsi(i, p, T));
123 
124  hGradY += fvc::interpolate(hi)*fvc::snGrad(Y[i]);
125  }
126 
127  tmpq.ref() -=
129  (
130  this->alpha()
131  *(
132  this->thermo().kappa()/this->thermo().Cp()
133  + (this->Prt_/Sct_)*this->alphat()
134  )
135  )*hGradY;
136  }
137 
138  return tmpq;
139 }
140 
141 
142 template<class TurbulenceThermophysicalTransportModel>
145 (
146  const label patchi
147 ) const
148 {
149  tmp<scalarField> tmpq
150  (
151  - (
152  this->alpha().boundaryField()[patchi]
153  *this->kappaEff(patchi)
154  *this->thermo().T().boundaryField()[patchi].snGrad()
155  )
156  );
157 
158  const PtrList<volScalarField>& Y = this->thermo().Y();
159  const fvPatchScalarField& p = this->thermo().p().boundaryField()[patchi];
160  const fvPatchScalarField& T = this->thermo().T().boundaryField()[patchi];
161 
162  if (Y.size())
163  {
164  scalarField hGradY(tmpq->size(), scalar(0));
165 
166  forAll(Y, i)
167  {
168  const scalarField hi(this->thermo().hsi(i, p, T));
169 
170  hGradY += hi*Y[i].boundaryField()[patchi].snGrad();
171  }
172 
173  tmpq.ref() -=
174  (
175  this->alpha().boundaryField()[patchi]
176  *(
177  this->thermo().kappa().boundaryField()[patchi]
178  /this->thermo().Cp().boundaryField()[patchi]
179  + (this->Prt_.value()/Sct_.value())*this->alphat(patchi)
180  )
181  )*hGradY;
182  }
183 
184  return tmpq;
185 }
186 
187 
188 template<class TurbulenceThermophysicalTransportModel>
191 (
192  volScalarField& he
193 ) const
194 {
195  tmp<fvScalarMatrix> tmpDivq
196  (
197  fvm::Su
198  (
199  -fvc::laplacian(this->alpha()*this->kappaEff(), this->thermo().T()),
200  he
201  )
202  );
203 
204  const PtrList<volScalarField>& Y = this->thermo().Y();
205 
206  tmpDivq.ref() -=
207  fvm::laplacianCorrection(this->alpha()*this->alphaEff(), he);
208 
209  surfaceScalarField hGradY
210  (
212  (
213  "hGradY",
214  he.mesh(),
216  )
217  );
218 
219  forAll(Y, i)
220  {
221  const volScalarField hi
222  (
223  this->thermo().hsi(i, this->thermo().p(), this->thermo().T())
224  );
225 
226  hGradY += fvc::interpolate(hi)*fvc::snGrad(Y[i]);
227  }
228 
229  tmpDivq.ref() -=
230  fvc::div
231  (
233  (
234  this->alpha()
235  *(
236  this->thermo().kappa()/this->thermo().Cp()
237  + (this->Prt_/Sct_)*this->alphat()
238  )
239  )*hGradY*he.mesh().magSf()
240  );
241 
242  return tmpDivq;
243 }
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 } // End namespace turbulenceThermophysicalTransportModels
249 } // End namespace Foam
250 
251 // ************************************************************************* //
scalar Cp(const scalar p, const scalar T) const
Definition: EtoHthermo.H:2
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
const dimensionSet & dimensions() const
Return dimensions.
const GeoMesh & mesh() const
Return mesh.
Generic GeometricField class.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
static word groupName(Name name, const word &group)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
virtual tmp< fvScalarMatrix > divq(volScalarField &he) const
Return the source term for the energy equation.
TurbulenceThermophysicalTransportModel::momentumTransportModel momentumTransportModel
virtual tmp< surfaceScalarField > q() const
Return the heat flux [W/m^2].
nonUnityLewisEddyDiffusivity(const momentumTransportModel &momentumTransport, const thermoModel &thermo, const word &type=typeName)
Construct from a momentum transport model and a thermo model.
Eddy-diffusivity based energy gradient heat flux model for RAS or LES of turbulent flow....
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the divergence of the given field.
Calculate the laplacian of the given field.
Calculate the snGrad of the given volField.
Calculate the matrix for implicit and explicit sources.
label patchi
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvcLaplacian.C:45
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< SurfaceField< Type > > snGrad(const VolField< Type > &vf, const word &name)
Definition: fvcSnGrad.C:45
tmp< fvMatrix< Type > > laplacianCorrection(const VolField< scalar > &gamma, const VolField< Type > &vf)
Definition: fvmLaplacian.C:340
tmp< fvMatrix< Type > > Su(const DimensionedField< Type, fvMesh > &, const VolField< Type > &)
Namespace for OpenFOAM.
const dimensionSet & dimless
Definition: dimensions.C:138
bool read(const char *, int32_t &)
Definition: int32IO.C:85
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
const dimensionSet & dimMass
Definition: dimensions.C:140
const dimensionSet & dimLength
Definition: dimensions.C:141
const dimensionSet & dimEnergy
Definition: dimensions.C:160
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
volScalarField & p
PtrList< volScalarField > & Y
fluidMulticomponentThermo & thermo
Definition: createFields.H:15