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-2024 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 )
57 :
58  TurbulenceThermophysicalTransportModel
59  (
60  typeName,
61  momentumTransport,
62  thermo
63  ),
64 
65  Prt_("Prt", dimless, this->coeffDict()),
66 
67  alphat_
68  (
69  IOobject
70  (
71  IOobject::groupName
72  (
73  "alphat",
74  this->momentumTransport().alphaRhoPhi().group()
75  ),
76  momentumTransport.time().name(),
77  momentumTransport.mesh(),
78  IOobject::MUST_READ,
79  IOobject::AUTO_WRITE
80  ),
81  momentumTransport.mesh()
82  )
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
88 template<class TurbulenceThermophysicalTransportModel>
90 {
92  {
93  Prt_.read(this->coeffDict());
94 
95  return true;
96  }
97  else
98  {
99  return false;
100  }
101 }
102 
103 
104 template<class TurbulenceThermophysicalTransportModel>
107 (
108  const volScalarField& Yi
109 ) const
110 {
112  << type() << " supports single component systems only, " << nl
113  << " for multi-component transport select"
114  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
115  << exit(FatalError);
116 
117  return tmp<volScalarField>(nullptr);
118 }
119 
120 
121 template<class TurbulenceThermophysicalTransportModel>
124 (
125  const volScalarField& Yi,
126  const label patchi
127 ) const
128 {
130  << type() << " supports single component systems only, " << nl
131  << " for multi-component transport select"
132  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
133  << exit(FatalError);
134 
135  return tmp<scalarField>(nullptr);
136 }
137 
138 
139 template<class TurbulenceThermophysicalTransportModel>
142 {
144  (
146  (
147  "q",
148  this->momentumTransport().alphaRhoPhi().group()
149  ),
150  -fvc::interpolate(this->alpha()*this->kappaEff())
151  *fvc::snGrad(this->thermo().T())
152  );
153 }
154 
155 
156 template<class TurbulenceThermophysicalTransportModel>
158 (
159  const label patchi
160 ) const
161 {
162  return
163  - (
164  this->alpha().boundaryField()[patchi]
165  *this->kappaEff(patchi)
166  *this->thermo().T().boundaryField()[patchi].snGrad()
167  );
168 }
169 
170 
171 template<class TurbulenceThermophysicalTransportModel>
174 (
176 ) const
177 {
178  // Return heat flux source as an implicit energy correction
179  // to the temperature gradient flux
180  return
181  -fvc::laplacian(this->alpha()*this->kappaEff(), this->thermo().T())
182  -fvm::laplacianCorrection(this->alpha()*this->alphaEff(), he);
183 }
184 
185 
186 template<class TurbulenceThermophysicalTransportModel>
189 (
190  const volScalarField& Yi
191 ) const
192 {
194  << type() << " supports single component systems only, " << nl
195  << " for multi-component transport select"
196  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
197  << exit(FatalError);
198 
199  return tmp<surfaceScalarField>(nullptr);
200 }
201 
202 
203 template<class TurbulenceThermophysicalTransportModel>
206 (
207  const volScalarField& Yi,
208  const label patchi
209 ) const
210 {
212  << type() << " supports single component systems only, " << nl
213  << " for multi-component transport select"
214  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
215  << exit(FatalError);
216 
217  return tmp<scalarField>(nullptr);
218 }
219 
220 
221 template<class TurbulenceThermophysicalTransportModel>
224 (
225  volScalarField& Yi
226 ) const
227 {
229  << type() << " supports single component systems only, " << nl
230  << " for multi-component transport select"
231  " nonUnityLewisEddyDiffusivity or unityLewisEddyDiffusivity"
232  << exit(FatalError);
233 
234  return tmp<fvScalarMatrix>(nullptr);
235 }
236 
237 
238 template<class TurbulenceThermophysicalTransportModel>
240 {
241  TurbulenceThermophysicalTransportModel::predict();
242  correctAlphat();
243 }
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 } // End namespace turbulenceThermophysicalTransportModels
249 } // End namespace Foam
250 
251 // ************************************************************************* //
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)
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 bool read()
Read thermophysicalTransport dictionary.
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 char *const group
Group name for atomic constants.
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
const dimensionSet dimless
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
static const char nl
Definition: Ostream.H:267
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
thermo he()
fluidMulticomponentThermo & thermo
Definition: createFields.H:31