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 Evolves a passive scalar transport equation.
35
36 - To specify the field name set the \c field entry
37 - To employ the same numerical schemes as another field set
38 the \c schemesField entry,
39 - The diffusivity can be set manually using the 'D' entry, retrieved
40 from the turbulence model or specified nut
41 - Alternatively if a turbulence model is available a turbulent diffusivity
42 may be constructed from the laminar and turbulent viscosities using the
43 optional diffusivity coefficients \c alphaD and \c alphaDt (which default
44 to 1):
45 \verbatim
46 D = alphaD*nu + alphaDt*nut
47 \endverbatim
48 - To specify a transport quantity within a phase enter phase.
49 - bounded01 bounds the transported scalar within 0 and 1.
50
51Usage
52 Example of function object specification to solve a scalar transport
53 equation:
54 \verbatim
55 functions
56 {
57 scalar1
58 {
59 type scalarTransport;
60 libs (solverFunctionObjects);
61
62 resetOnStartUp no;
63 region cabin;
64 field H2O;
65
66
67 fvOptions
68 {
69 ...
70 }
71 }
72 }
73 \endverbatim
74
75 Example of function object specification to solve a residence time
76 in a two phase flow:
77 equation:
78 \verbatim
79 functions
80 {
81 sTransport
82 {
83 type scalarTransport;
84 libs (solverFunctionObjects);
85
86 enabled true;
87 writeControl outputTime;
88 writeInterval 1;
89
90 field s;
91 bounded01 false;
92 phase alpha.water;
93
94 write true;
95
96 fvOptions
97 {
98 unitySource
99 {
100 type scalarSemiImplicitSource;
101 enabled true;
102
103 selectionMode all;
104 volumeMode specific;
105
106 sources
107 {
108 s (1 0);
109 }
110 }
111 }
112
113 resetOnStartUp false;
114 }
115 }
116 \endverbatim
117
118 Where the entries comprise:
119 \table
120 Property | Description | Required | Default value
121 type | Type name: scalarTransport | yes |
122 field | Name of the scalar field | no | s
123 phi | Name of flux field | no | phi
124 rho | Name of density field | no | rho
125 phase | Name of the phase | no | none
126 nut | Name of the turbulence viscosity | no | none
127 D | Diffusion coefficient | no | auto generated
128 nCorr | Number of correctors | no | 0
129 resetOnStartUp | Reset scalar to zero on start-up | no | no
130 schemesField | Name of field to specify schemes | no | field name
131 fvOptions | List of scalar sources | no |
132 bounded01 | Bounds scalar between 0-1 for multiphase | no | true
133 phasePhiCompressed | Compressed flux for VOF | no | alphaPhiUn
134 \endtable
135
136See also
137 Foam::functionObjects::fvMeshFunctionObject
138
139SourceFiles
140 scalarTransport.C
141
142\*---------------------------------------------------------------------------*/
143
144#ifndef functionObjects_scalarTransport_H
145#define functionObjects_scalarTransport_H
146
147#include "fvMeshFunctionObject.H"
148#include "volFields.H"
149#include "fvOptionList.H"
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153namespace Foam
154{
155namespace functionObjects
156{
157
158/*---------------------------------------------------------------------------*\
159 Class scalarTransport Declaration
160\*---------------------------------------------------------------------------*/
161
162class scalarTransport
163:
164 public fvMeshFunctionObject
165{
166 // Private data
167
168 //- Name of the transport field.
169 word fieldName_;
170
171 //- Name of flux field (optional)
172 word phiName_;
173
174 //- Name of density field (optional)
175 word rhoName_;
176
177 //- Name of turbulent viscosity field (optional)
178 word nutName_;
179
180 //- Name of phase field (optional)
181 word phaseName_;
182
183 //- Name of phase field compressed flux (optional)
184 word phasePhiCompressedName_;
185
186 //- Diffusion coefficient (optional)
187 scalar D_;
188
189 //- Flag to indicate whether a constant, uniform D_ is specified
190 bool constantD_;
191
192 //- Laminar diffusion coefficient (optional)
193 scalar alphaD_;
194
195 //- Turbulent diffusion coefficient (optional)
196 scalar alphaDt_;
197
198 //- Number of corrector iterations (optional)
199 label nCorr_;
200
201 //- Flag to reset the scalar to zero on start-up
202 bool resetOnStartUp_;
203
204 //- Name of field whose schemes are used (optional)
205 word schemesField_;
206
207 //- Run-time selectable finite volume options, e.g. sources, constraints
208 fv::optionList fvOptions_;
209
210 //- Bound scalar between 0-1 using MULES for multiphase case
211 bool bounded01_;
212
213
214 // Private Member Functions
215
216 //- Return reference to registered transported field
217 volScalarField& transportedField();
218
219 //- Return the diffusivity field
220 tmp<volScalarField> D
221 (
222 const volScalarField& s,
224 ) const;
225
226 //- No copy construct
227 scalarTransport(const scalarTransport&) = delete;
228
229 //- No copy assignment
230 void operator=(const scalarTransport&) = delete;
232
233public:
234
235 //- Runtime type information
236 TypeName("scalarTransport");
237
238
239 // Constructors
240
241 //- Construct from Time and dictionary
243 (
244 const word& name,
245 const Time& runTime,
246 const dictionary& dict
247 );
248
249
250 //- Destructor
251 virtual ~scalarTransport();
252
253
254 // Member Functions
255
256 //- Read the scalarTransport data
257 virtual bool read(const dictionary&);
258
259 //- Calculate the scalarTransport
260 virtual bool execute();
261
262 //- Do nothing.
263 // The volScalarField is registered and written automatically
264 virtual bool write();
265};
266
267
268// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269
270} // End namespace functionObjects
271} // End namespace Foam
272
273// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274
275#endif
276
277// ************************************************************************* //
surfaceScalarField & phi
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
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...
Evolves a passive scalar transport equation.
TypeName("scalarTransport")
Runtime type information.
virtual bool execute()
Calculate the scalarTransport.
virtual bool read(const dictionary &)
Read the scalarTransport data.
List of finite volume options.
Definition: fvOptionList.H:72
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
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))
Namespace for OpenFOAM.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
dictionary dict
const dimensionedScalar & D
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73