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  )
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
89 template<class TurbulenceThermophysicalTransportModel>
91 {
93  {
94  Prt_.read(this->typeDict());
95 
96  return true;
97  }
98  else
99  {
100  return false;
101  }
102 }
103 
104 
105 template<class TurbulenceThermophysicalTransportModel>
108 (
109  const volScalarField& Yi
110 ) const
111 {
113  << type() << " supports single component systems only, " << nl
114  << " for multi-component transport select"
115  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
116  << exit(FatalError);
117 
118  return tmp<volScalarField>(nullptr);
119 }
120 
121 
122 template<class TurbulenceThermophysicalTransportModel>
125 (
126  const volScalarField& Yi,
127  const label patchi
128 ) const
129 {
131  << type() << " supports single component systems only, " << nl
132  << " for multi-component transport select"
133  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
134  << exit(FatalError);
135 
136  return tmp<scalarField>(nullptr);
137 }
138 
139 
140 template<class TurbulenceThermophysicalTransportModel>
143 (
144  const volScalarField& Yi
145 ) const
146 {
148  << type() << " supports single component systems only, " << nl
149  << " for multi-component transport select"
150  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
151  << exit(FatalError);
152 
153  return tmp<volScalarField>(nullptr);
154 }
155 
156 
157 template<class TurbulenceThermophysicalTransportModel>
160 (
161  const volScalarField& Yi,
162  const label patchi
163 ) const
164 {
166  << type() << " supports single component systems only, " << nl
167  << " for multi-component transport select"
168  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
169  << exit(FatalError);
170 
171  return tmp<scalarField>(nullptr);
172 }
173 
174 
175 template<class TurbulenceThermophysicalTransportModel>
178 {
180  (
182  (
183  "q",
184  this->thermo().phaseName()
185  ),
186  -fvc::interpolate(this->alpha()*this->kappaEff())
187  *fvc::snGrad(this->thermo().T())
188  );
189 }
190 
191 
192 template<class TurbulenceThermophysicalTransportModel>
194 (
195  const label patchi
196 ) const
197 {
198  return
199  - (
200  this->alpha().boundaryField()[patchi]
201  *this->kappaEff(patchi)
202  *this->thermo().T().boundaryField()[patchi].snGrad()
203  );
204 }
205 
206 
207 template<class TurbulenceThermophysicalTransportModel>
210 (
211  volScalarField& he
212 ) const
213 {
214  // Return heat flux source as an implicit energy correction
215  // to the temperature gradient flux
216  return
217  -fvc::laplacian(this->alpha()*this->kappaEff(), this->thermo().T())
218  -fvm::laplacianCorrection(this->alpha()*this->alphaEff(), he);
219 }
220 
221 
222 template<class TurbulenceThermophysicalTransportModel>
225 (
226  const volScalarField& Yi
227 ) const
228 {
230  << type() << " supports single component systems only, " << nl
231  << " for multi-component transport select"
232  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
233  << exit(FatalError);
234 
235  return tmp<surfaceScalarField>(nullptr);
236 }
237 
238 
239 template<class TurbulenceThermophysicalTransportModel>
242 (
243  const volScalarField& Yi,
244  const label patchi
245 ) const
246 {
248  << type() << " supports single component systems only, " << nl
249  << " for multi-component transport select"
250  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
251  << exit(FatalError);
252 
253  return tmp<scalarField>(nullptr);
254 }
255 
256 
257 template<class TurbulenceThermophysicalTransportModel>
260 (
261  volScalarField& Yi
262 ) const
263 {
265  << type() << " supports single component systems only, " << nl
266  << " for multi-component transport select"
267  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
268  << exit(FatalError);
269 
270  return tmp<fvScalarMatrix>(nullptr);
271 }
272 
273 
274 template<class TurbulenceThermophysicalTransportModel>
276 {
277  TurbulenceThermophysicalTransportModel::predict();
278  correctAlphat();
279 }
280 
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 } // End namespace turbulenceThermophysicalTransportModels
285 } // End namespace Foam
286 
287 // ************************************************************************* //
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 time
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
const dimensionSet & dimless
Definition: dimensions.C:138
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