Loading...
Searching...
No Matches
scalarTransport.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2012-2017 OpenFOAM Foundation
9 Copyright (C) 2016-2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::functionObjects::scalarTransport
29
30Group
31 grpSolversFunctionObjects
32
33Description
34 Computes the transport equation for a passive scalar in single-phase or
35 two-phase flow, considering both incompressible and compressible cases:
36
37 \f[
38 \frac{\partial \rho \, T}{\partial t}
39 + \nabla \cdot \left( \phi_\alpha \, T \right)
40 - \nabla \cdot (D_T \, \nabla T)
41 = \alpha \, S_T
42 \f]
43
44 where:
45 \vartable
46 T | Passive scalar field
47 \rho | (Generic) Fluid density which is unity when not specified
48 \phi_\alpha | (Generic) Flux field
49 \alpha | Phase fraction which is unity for single-phase flows
50 D_T | Diffusivity representing the diffusive transport of T
51 S_T | Passive-scalar field source term
52 \endvartable
53
54Usage
55 Minimal example in \c system/controlDict.functions:
56 \verbatim
57 scalarTransportFO
58 {
59 // Mandatory entries
60 type scalarTransport;
61 libs (solverFunctionObjects);
62
63 // Optional entries
64 field <word>;
65 phi <word>;
66 rho <word>;
67 nut <word>;
68 phase <word>;
69 phasePhiCompressed <word>;
70 schemesField <word>;
71 bounded01 <bool>;
72 D <scalar>;
73 alphaD <scalar>;
74 alphaDt <scalar>;
75 tolerance <scalar>;
76 nCorr <int>;
77 resetOnStartUp <bool>;
78 fvOptions <dict>;
79
80 // Inherited entries
81 ...
82 }
83
84 where:
85 \table
86 Property | Description | Type | Reqd | Deflt
87 type | Type name: scalarTransport | word | yes | -
88 libs | Library name: solverFunctionObjects | word | yes | -
89 field | Name of the passive-scalar field | word | no | s
90 phi | Name of flux field | word | no | phi
91 rho | Name of density field | word | no | rho
92 nut | Name of the turbulence viscosity | word | no | none
93 phase | Name of the phase | word | no | none
94 phasePhiCompressed | Name of compressed VOF flux | word | no | alphaPhiUn
95 schemesField | Name of field to specify schemes | word | no | field
96 bounded01 | Bounds scalar between 0-1 for multiphase | bool | no | true
97 D | Diffusion coefficient | scalar | no | -
98 alphaD | Laminar diffusivity coefficient | scalar | no | 1
99 alphaDt | Turbulent diffusivity coefficient | scalar | no | 1
100 tolerance | Outer-loop initial-residual tolerance | scalar | no | 1
101 nCorr | Number of outer-loop correctors | int | no | 0
102 resetOnStartUp | Flag to reset field to zero on start-up | bool | no | no
103 fvOptions | List of finite-volume options | dict | no | -
104 \endtable
105
106 The inherited entries are elaborated in:
107 - \link functionObject.H \endlink
108 - \link fvOption.H \endlink
109
110 An example of function object specification to solve a residence time
111 in a two-phase flow:
112 \verbatim
113 scalarTransport1
114 {
115 // Mandatory entries
116 type scalarTransport;
117 libs (solverFunctionObjects);
118
119 // Optional entries
120 field s;
121 bounded01 false;
122 phase alpha.water;
123 tolerance 1e-5;
124 resetOnStartUp false;
125 fvOptions
126 {
127 unitySource
128 {
129 type scalarSemiImplicitSource;
130 enabled true;
131
132 selectionMode all;
133 volumeMode specific;
134
135 sources
136 {
137 s (1 0);
138 }
139 }
140 }
141
142 // Inherited entries
143 enabled true;
144 writeControl writeTime;
145 writeInterval 1;
146 }
147 \endverbatim
148
149Note
150 - To use the same numerical schemes as another field,
151 set the \c schemesField entry.
152 - The diffusivity can be set manually using the \c D entry, obtained
153 from the turbulence model or specified as `nut`.
154 - Alternatively, if a turbulence model is available, turbulent diffusivity
155 can be constructed from the laminar and turbulent viscosities using the
156 optional diffusivity coefficients \c alphaD and \c alphaDt
157 (which default to 1):
158
159 \f[
160 D = \alpha_D \, \nu + \alpha_{Dt} \, \nu_t
161 \f]
162
163SourceFiles
164 scalarTransport.C
165
166\*---------------------------------------------------------------------------*/
167
168#ifndef Foam_functionObjects_scalarTransport_H
169#define Foam_functionObjects_scalarTransport_H
170
171#include "fvMeshFunctionObject.H"
172#include "volFields.H"
173#include "fvOptionList.H"
174
175// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176
177namespace Foam
178{
179namespace functionObjects
180{
181
182/*---------------------------------------------------------------------------*\
183 Class scalarTransport Declaration
184\*---------------------------------------------------------------------------*/
185
186class scalarTransport
187:
189{
190 // Private Data
191
192 //- Run-time selectable finite volume options, e.g. sources, constraints
193 fv::optionList fvOptions_;
194
195 //- Name of the transport field.
196 word fieldName_;
197
198 //- Name of field whose schemes are used
199 word schemesField_;
200
201 //- Name of flux field
202 word phiName_;
203
204 //- Name of density field
205 word rhoName_;
206
207 //- Name of turbulent viscosity field
208 word nutName_;
209
210 //- Name of phase field
211 word phaseName_;
212
213 //- Name of phase field compressed flux
214 word phasePhiCompressedName_;
215
216 //- Diffusion coefficient
217 scalar D_;
218
219 //- Laminar diffusion coefficient
220 scalar alphaD_;
221
222 //- Turbulent diffusion coefficient
223 scalar alphaDt_;
224
225 //- Outer-loop initial-residual tolerance
226 scalar tol_;
227
228 //- Number of corrector iterations
229 int nCorr_;
230
231 //- Flag to reset the scalar to zero on start-up
232 bool resetOnStartUp_;
233
234 //- Flag to indicate whether a constant, uniform D_ is specified
235 bool constantD_;
236
237 //- Bound scalar between 0-1 using MULES for multiphase case
238 bool bounded01_;
239
240
241 // Private Member Functions
242
243 //- Return reference to registered transported field
244 volScalarField& transportedField();
245
246 //- Return the diffusivity field
247 tmp<volScalarField> D
248 (
249 const volScalarField& s,
251 ) const;
252
253
254public:
255
256 //- Runtime type information
257 TypeName("scalarTransport");
258
259
260 // Constructors
261
262 //- Construct from name, Time and dictionary
264 (
265 const word& name,
266 const Time& runTime,
267 const dictionary& dict
268 );
269
270
271 //- Destructor
272 virtual ~scalarTransport() = default;
273
274
275 // Member Functions
276
277 //- Read the function-object dictionary
278 virtual bool read(const dictionary&);
279
280 //- Execute the function-object operations
281 virtual bool execute();
282
283 //- Write the function object output
284 // The volScalarField is registered and written automatically
285 virtual bool write();
286};
287
288
289// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290
291} // End namespace functionObjects
292} // End namespace Foam
293
294// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295
296#endif
297
298// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Computes the transport equation for a passive scalar in single-phase or two-phase flow,...
TypeName("scalarTransport")
Runtime type information.
virtual ~scalarTransport()=default
Destructor.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function object output.
virtual bool read(const dictionary &)
Read the function-object dictionary.
scalarTransport(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
List of finite volume options.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
const dimensionedScalar & D
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68