scalarTransport.H
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) 2012-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 Class
25  Foam::functionObjects::scalarTransport
26 
27 Description
28  Evolves a passive scalar transport equation.
29 
30  - To specify the field name set the \c field entry
31  - To employ the same numerical schemes as another field set
32  the \c schemesField entry,
33  - To employ the same solver settings as another field set
34  the \c solverField entry,
35  - The \c diffusivity entry can be set to \c none, \c constant, \c viscosity
36  - A constant diffusivity is specified with the \c D entry,
37  - If a momentum transport model is available and the \c viscosity
38  diffusivity option specified an effective diffusivity may be constructed
39  from the laminar and turbulent viscosities using the diffusivity
40  coefficients \c alphal and \c alphat:
41  \verbatim
42  D = alphal*nu + alphat*nut
43  \endverbatim
44 
45  Example:
46  \verbatim
47  #includeFunc scalarTransport(T, alphal=1, alphat=1)
48  \endverbatim
49 
50  For incompressible flow the passive scalar may optionally be solved with the
51  MULES limiter and sub-cycling or semi-implicit in order to maintain
52  boundedness, particularly if a compressive, PLIC or MPLIC convection
53  scheme is used.
54 
55  Example:
56  \verbatim
57  #includeFunc scalarTransport(tracer, diffusivity=none)
58 
59  with scheme specification:
60  div(phi,tracer) Gauss interfaceCompression vanLeer 1;
61 
62  and solver specification:
63  tracer
64  {
65  nCorr 1;
66  nSubCycles 3;
67 
68  MULESCorr no;
69  nLimiterIter 5;
70  applyPrevCorr yes;
71 
72  solver smoothSolver;
73  smoother symGaussSeidel;
74  tolerance 1e-8;
75  relTol 0;
76 
77  diffusivity
78  {
79  solver smoothSolver;
80  smoother symGaussSeidel;
81  tolerance 1e-8;
82  relTol 0;
83  }
84  }
85  \endverbatim
86 
87 See also
88  Foam::functionObjects::fvMeshFunctionObject
89 
90 SourceFiles
91  scalarTransport.C
92 
93 \*---------------------------------------------------------------------------*/
94 
95 #ifndef scalarTransport_functionObject_H
96 #define scalarTransport_functionObject_H
97 
98 #include "fvMeshFunctionObject.H"
99 #include "volFields.H"
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 namespace Foam
104 {
105 namespace functionObjects
106 {
107 
108 /*---------------------------------------------------------------------------*\
109  Class scalarTransport Declaration
110 \*---------------------------------------------------------------------------*/
111 
112 class scalarTransport
113 :
114  public fvMeshFunctionObject
115 {
116 public:
117 
118  //- Enumeration defining the type of the diffusivity
119  enum class diffusivityType
120  {
121  none,
122  constant,
123  viscosity
124  };
125 
126  //- Diffusivity type names
128 
129 
130 private:
131 
132  // Private Data
133 
134  //- Name of field to process
135  word fieldName_;
136 
137  //- Name of flux field (optional)
138  word phiName_;
139 
140  //- Name of density field (optional)
141  word rhoName_;
142 
143  //- The type of diffusivity
144  diffusivityType diffusivity_;
145 
146  //- Constant diffusivity coefficient (optional)
147  scalar D_;
148 
149  //- Laminar diffusivity coefficient (optional)
150  scalar alphal_;
151 
152  //- Turbulent diffusivity coefficient (optional)
153  scalar alphat_;
154 
155  //- Name of field whose schemes are used (optional)
156  word schemesField_;
157 
158  //- Name of field whose solver is used (optional)
159  word solverField_;
160 
161  //- The scalar field
162  volScalarField s_;
163 
164  //- Switch for MULES limited solution
165  bool MULES_;
166 
167  //- Stabilisation for normalisation of the interface normal
168  // needed if a compressive convection scheme is used
169  const dimensionedScalar deltaN_;
170 
171  //- MULES Correction
172  tmp<surfaceScalarField> tsPhiCorr0_;
173 
174 
175  // Private Member Functions
176 
177  //- Return the diffusivity field
178  tmp<volScalarField> D() const;
179 
180  void subCycleMULES();
181  void solveMULES();
182 
183 
184 public:
185 
186  //- Runtime type information
187  TypeName("scalarTransport");
188 
189 
190  // Constructors
191 
192  //- Construct from Time and dictionary
194  (
195  const word& name,
196  const Time& runTime,
197  const dictionary& dict
198  );
199 
200  //- Disallow default bitwise copy construction
201  scalarTransport(const scalarTransport&) = delete;
202 
203 
204  //- Destructor
205  virtual ~scalarTransport();
206 
207 
208  // Member Functions
209 
210  //- Read the scalarTransport data
211  virtual bool read(const dictionary&);
212 
213  //- Return the list of fields required
214  virtual wordList fields() const;
215 
216  //- Do not execute at the start of the run
217  virtual bool executeAtStart() const
218  {
219  return false;
220  }
221 
222  //- Calculate the scalarTransport
223  virtual bool execute();
224 
225  //- Write the updated scalar field
226  virtual bool write();
227 
228 
229  // Member Operators
230 
231  //- Disallow default bitwise assignment
232  void operator=(const scalarTransport&) = delete;
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace functionObjects
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #endif
244 
245 // ************************************************************************* //
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Evolves a passive scalar transport equation.
TypeName("scalarTransport")
Runtime type information.
static const NamedEnum< diffusivityType, 3 > diffusivityTypeNames_
Diffusivity type names.
virtual wordList fields() const
Return the list of fields required.
diffusivityType
Enumeration defining the type of the diffusivity.
virtual bool executeAtStart() const
Do not execute at the start of the run.
virtual bool execute()
Calculate the scalarTransport.
virtual bool write()
Write the updated scalar field.
void operator=(const scalarTransport &)=delete
Disallow default bitwise assignment.
virtual bool read(const dictionary &)
Read the scalarTransport data.
scalarTransport(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
dictionary dict