eddyDiffusivity.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 
26 #include "eddyDiffusivity.H"
27 #include "fvmLaplacian.H"
28 #include "fvcLaplacian.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace turbulenceThermophysicalTransportModels
35 {
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class TurbulenceThermophysicalTransportModel>
41 {
42  alphat_ =
43  this->momentumTransport().rho()
44  *this->momentumTransport().nut()/Prt_;
45  alphat_.correctBoundaryConditions();
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 template<class TurbulenceThermophysicalTransportModel>
53 (
54  const momentumTransportModel& momentumTransport,
55  const thermoModel& thermo,
56  const word& type
57 )
58 :
59  TurbulenceThermophysicalTransportModel
60  (
61  type,
62  momentumTransport,
63  thermo
64  ),
65 
66  Prt_("Prt", dimless, this->typeDict(type)),
67 
68  alphat_
69  (
70  IOobject
71  (
72  IOobject::groupName
73  (
74  "alphat",
75  this->thermo().phaseName()
76  ),
77  momentumTransport.time().name(),
78  momentumTransport.mesh(),
79  IOobject::MUST_READ,
80  IOobject::AUTO_WRITE
81  ),
82  momentumTransport.mesh(),
83  dimensions::dynamicDiffusivity
84  )
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
90 template<class TurbulenceThermophysicalTransportModel>
92 {
94  {
95  Prt_.read(this->typeDict());
96 
97  return true;
98  }
99  else
100  {
101  return false;
102  }
103 }
104 
105 
106 template<class TurbulenceThermophysicalTransportModel>
109 (
110  const volScalarField& Yi
111 ) const
112 {
114  << type() << " supports single component systems only, " << nl
115  << " for multi-component transport select"
116  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
117  << exit(FatalError);
118 
119  return tmp<volScalarField>(nullptr);
120 }
121 
122 
123 template<class TurbulenceThermophysicalTransportModel>
126 (
127  const volScalarField& Yi,
128  const label patchi
129 ) const
130 {
132  << type() << " supports single component systems only, " << nl
133  << " for multi-component transport select"
134  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
135  << exit(FatalError);
136 
137  return tmp<scalarField>(nullptr);
138 }
139 
140 
141 template<class TurbulenceThermophysicalTransportModel>
144 (
145  const volScalarField& Yi
146 ) const
147 {
149  << type() << " supports single component systems only, " << nl
150  << " for multi-component transport select"
151  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
152  << exit(FatalError);
153 
154  return tmp<volScalarField>(nullptr);
155 }
156 
157 
158 template<class TurbulenceThermophysicalTransportModel>
161 (
162  const volScalarField& Yi,
163  const label patchi
164 ) const
165 {
167  << type() << " supports single component systems only, " << nl
168  << " for multi-component transport select"
169  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
170  << exit(FatalError);
171 
172  return tmp<scalarField>(nullptr);
173 }
174 
175 
176 template<class TurbulenceThermophysicalTransportModel>
179 {
181  (
183  (
184  "q",
185  this->thermo().phaseName()
186  ),
187  -fvc::interpolate(this->alpha()*this->kappaEff())
188  *fvc::snGrad(this->thermo().T())
189  );
190 }
191 
192 
193 template<class TurbulenceThermophysicalTransportModel>
195 (
196  const label patchi
197 ) const
198 {
199  return
200  - (
201  this->alpha().boundaryField()[patchi]
202  *this->kappaEff(patchi)
203  *this->thermo().T().boundaryField()[patchi].snGrad()
204  );
205 }
206 
207 
208 template<class TurbulenceThermophysicalTransportModel>
211 (
212  volScalarField& he
213 ) const
214 {
215  // Return heat flux source as an implicit energy correction
216  // to the temperature gradient flux
217  return
218  -fvc::laplacian(this->alpha()*this->kappaEff(), this->thermo().T())
219  -fvm::laplacianCorrection(this->alpha()*this->alphaEff(), he);
220 }
221 
222 
223 template<class TurbulenceThermophysicalTransportModel>
226 (
227  const volScalarField& Yi
228 ) const
229 {
231  << type() << " supports single component systems only, " << nl
232  << " for multi-component transport select"
233  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
234  << exit(FatalError);
235 
236  return tmp<surfaceScalarField>(nullptr);
237 }
238 
239 
240 template<class TurbulenceThermophysicalTransportModel>
243 (
244  const volScalarField& Yi,
245  const label patchi
246 ) const
247 {
249  << type() << " supports single component systems only, " << nl
250  << " for multi-component transport select"
251  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
252  << exit(FatalError);
253 
254  return tmp<scalarField>(nullptr);
255 }
256 
257 
258 template<class TurbulenceThermophysicalTransportModel>
261 (
262  volScalarField& Yi
263 ) const
264 {
266  << type() << " supports single component systems only, " << nl
267  << " for multi-component transport select"
268  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
269  << exit(FatalError);
270 
271  return tmp<fvScalarMatrix>(nullptr);
272 }
273 
274 
275 template<class TurbulenceThermophysicalTransportModel>
277 {
278  TurbulenceThermophysicalTransportModel::predict();
279  correctAlphat();
280 }
281 
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace turbulenceThermophysicalTransportModels
286 } // End namespace Foam
287 
288 // ************************************************************************* //
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,.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
static word groupName(Name name, const word &group)
A class for managing temporary objects.
Definition: tmp.H:55
virtual tmp< volScalarField > DEff(const volScalarField &Yi) const
Effective mass diffusion coefficient.
TurbulenceThermophysicalTransportModel::thermoModel thermoModel
virtual tmp< fvScalarMatrix > divq(volScalarField &he) const
Return the source term for the energy equation.
eddyDiffusivity(const momentumTransportModel &momentumTransport, const thermoModel &thermo, const word &type=typeName)
Construct from a momentum transport model and a thermo model.
virtual tmp< fvScalarMatrix > divj(volScalarField &Yi) const
Return the source term for the given specie mass-fraction equation.
virtual void predict()
Correct the eddyDiffusivity viscosity.
virtual tmp< surfaceScalarField > j(const volScalarField &Yi) const
Return the specie flux for the given specie mass-fraction [kg/m^2/s].
TurbulenceThermophysicalTransportModel::momentumTransportModel momentumTransportModel
virtual tmp< surfaceScalarField > q() const
Return the heat flux [W/m^2].
virtual tmp< volScalarField > D(const volScalarField &Yi) const
Mass diffusivity.
virtual bool read()
Read thermophysicalTransport dictionary.
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)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Calculate the laplacian of the given field.
Calculate the matrix for the laplacian of the field.
label patchi
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const dimensionSet dimless
const dimensionSet time
const dimensionSet dynamicDiffusivity
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< 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
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
static const char nl
Definition: Ostream.H:297
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
fluidMulticomponentThermo & thermo
Definition: createFields.H:15