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 | Copyright (C) 2012-2014 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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::scalarTransport
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object evolves a passive scalar transport equation. The
32  field is initially zero, to which sources are added. The field name
33  is assigned the name of the function object. Boundary conditions are
34  read from file if the field file is available, or automatically applied
35  based on the velocity boundary conditions.
36 
37  - the field can be zeroed on start-up using the resetOnStartUp flag
38  - to employ the same numerical schemes as the flow velocity, use the
39  autoSchemes flag
40  - the diffusivity can be set manually using the DT entry, or retrieved
41  from the turbulence model (if applicable)
42 
43  Example of function object specification to solve a scalar transport
44  equation:
45  \verbatim
46  functions
47  {
48  scalar1 // <--- NOTE: SCALAR NAME
49  {
50  type scalarTransport;
51  functionObjectLibs ("libutilityFunctionObjects.so");
52  resetOnStartUp no;
53 
54  autoSchemes yes;
55 
56  fvOptions
57  {
58  ...
59  }
60  }
61  }
62  \endverbatim
63 
64  \heading Function object usage
65  \table
66  Property | Description | Required | Default value
67  type | Type name: scalarTransport | yes |
68  phiName | Name of flux field | no | phi
69  UName | Name of velocity field | no | U
70  rhoName | Name of density field | no | rho
71  nCorr | Number of correctors | no | 0
72  DT | Diffision coefficient | no | auto generated
73  resetOnStartUp | Reset source to zero on start-up | no | no
74  autoSchemes | Use U schemes to evolve scalar | no | yes
75  fvOptions | List of scalar sources | yes |
76  log | Log to standard output | no | yes
77  \endtable
78 
79 SeeAlso
80  fvOption.H
81  fvOptionList.H
82 
83 SourceFiles
84  scalarTransport.C
85  IOscalarTransport.H
86 
87 
88 \*---------------------------------------------------------------------------*/
89 
90 #ifndef scalarTransport_H
91 #define scalarTransport_H
92 
93 #include "volFields.H"
94 #include "surfaceFieldsFwd.H"
95 #include "pointFieldFwd.H"
96 #include "fvMatricesFwd.H"
97 #include "fvOptionList.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 
104 // Forward declaration of classes
105 class objectRegistry;
106 class dictionary;
107 class mapPolyMesh;
108 
109 /*---------------------------------------------------------------------------*\
110  Class scalarTransport Declaration
111 \*---------------------------------------------------------------------------*/
112 
113 class scalarTransport
114 {
115  // Private data
116 
117  //- Name of this set of scalarTransport objects
118  word name_;
119 
120  //- Reference to the mesh database
121  const fvMesh& mesh_;
122 
123  //- On/off switch
124  bool active_;
125 
126  //- Name of flux field (optional)
127  word phiName_;
128 
129  //- Name of velocity field (optional)
130  word UName_;
131 
132  //- Name of density field (optional)
133  word rhoName_;
134 
135  //- Diffusion coefficient (optional)
136  scalar DT_;
137 
138  //- Flag to indicate whether user DT_ is used
139  bool userDT_;
140 
141  //- Flag to reset scalar field on start-up
142  bool resetOnStartUp_;
143 
144  //- Number of corrector iterations (optional)
145  label nCorr_;
146 
147  //- Flag to employ schemes for velocity for scalar transport
148  bool autoSchemes_;
149 
150  //- Run-time selectable finite volume options, e.g. sources, constraints
151  fv::optionList fvOptions_;
152 
153  //- Switch to send output to Info as well as to file
154  Switch log_;
155 
156 
157  // Private Member Functions
158 
159  //- Return the boundary types for the scalar field
160  wordList boundaryTypes() const;
161 
162  //- Return reference to registered transported field
164 
165  //- Return the diffusivity field
166  tmp<volScalarField> DT(const surfaceScalarField& phi) const;
167 
168  //- Disallow default bitwise copy construct
170 
171  //- Disallow default bitwise assignment
173 
174 
175 public:
176 
177  //- Runtime type information
178  TypeName("scalarTransport");
179 
180 
181  // Constructors
182 
183  //- Construct for given objectRegistry and dictionary.
184  // Allow the possibility to load fields from files
186  (
187  const word& name,
188  const objectRegistry&,
189  const dictionary&,
190  const bool loadFromFiles = false
191  );
192 
193 
194  //- Destructor
195  virtual ~scalarTransport();
196 
197 
198  // Member Functions
199 
200  //- Return name of the set of scalarTransport
201  virtual const word& name() const
202  {
203  return name_;
204  }
205 
206  //- Read the scalarTransport data
207  virtual void read(const dictionary&);
208 
209  //- Execute, currently does nothing
210  virtual void execute();
211 
212  //- Execute at the final time-loop, currently does nothing
213  virtual void end();
214 
215  //- Called when time was set at the end of the Time::operator++
216  virtual void timeSet();
217 
218  //- Calculate the scalarTransport and write
219  virtual void write();
220 
221  //- Update for changes of mesh
222  virtual void updateMesh(const mapPolyMesh&)
223  {}
224 
225  //- Update for changes of mesh
226  virtual void movePoints(const polyMesh&)
227  {}
228 };
229 
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
Foam::scalarTransport::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: scalarTransport.H:280
volFields.H
Foam::scalarTransport::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: scalarTransport.H:175
Foam::scalarTransport::write
virtual void write()
Calculate the scalarTransport and write.
Definition: scalarTransport.C:341
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::scalarTransport::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: scalarTransport.H:208
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::scalarTransport::name
virtual const word & name() const
Return name of the set of scalarTransport.
Definition: scalarTransport.H:255
Foam::scalarTransport::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: scalarTransport.H:276
Foam::scalarTransport::boundaryTypes
wordList boundaryTypes() const
Return the boundary types for the scalar field.
Definition: scalarTransport.C:50
fvMatricesFwd.H
Forward declarations of fvMatrix specializations.
Foam::scalarTransport::UName_
word UName_
Name of velocity field (optional)
Definition: scalarTransport.H:184
Foam::scalarTransport::name_
word name_
Name of this set of scalarTransport objects.
Definition: scalarTransport.H:172
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::scalarTransport::scalarTransport
scalarTransport(const scalarTransport &)
Disallow default bitwise copy construct.
Foam::scalarTransport::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: scalarTransport.C:329
Foam::scalarTransport::execute
virtual void execute()
Execute, currently does nothing.
Definition: scalarTransport.C:240
Foam::scalarTransport::transportedField
volScalarField & transportedField()
Return reference to registered transported field.
Definition: scalarTransport.C:73
Foam::label
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
fvOptionList.H
pointFieldFwd.H
Foam::scalarTransport::autoSchemes_
bool autoSchemes_
Flag to employ schemes for velocity for scalar transport.
Definition: scalarTransport.H:202
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::scalarTransport::fvOptions_
fv::optionList fvOptions_
Run-time selectable finite volume options, e.g. sources, constraints.
Definition: scalarTransport.H:205
Foam::scalarTransport::rhoName_
word rhoName_
Name of density field (optional)
Definition: scalarTransport.H:187
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::scalarTransport::TypeName
TypeName("scalarTransport")
Runtime type information.
Foam::scalarTransport::DT
tmp< volScalarField > DT(const surfaceScalarField &phi) const
Return the diffusivity field.
Definition: scalarTransport.C:102
Foam::scalarTransport::phiName_
word phiName_
Name of flux field (optional)
Definition: scalarTransport.H:181
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::scalarTransport::nCorr_
label nCorr_
Number of corrector iterations (optional)
Definition: scalarTransport.H:199
Foam::scalarTransport::resetOnStartUp_
bool resetOnStartUp_
Flag to reset scalar field on start-up.
Definition: scalarTransport.H:196
Foam::scalarTransport::DT_
scalar DT_
Diffusion coefficient (optional)
Definition: scalarTransport.H:190
Foam::scalarTransport
This function object evolves a passive scalar transport equation. The field is initially zero,...
Definition: scalarTransport.H:167
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
Foam::scalarTransport::operator=
void operator=(const scalarTransport &)
Disallow default bitwise assignment.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::scalarTransport::userDT_
bool userDT_
Flag to indicate whether user DT_ is used.
Definition: scalarTransport.H:193
surfaceFieldsFwd.H
Foam::scalarTransport::read
virtual void read(const dictionary &)
Read the scalarTransport data.
Definition: scalarTransport.C:213
Foam::scalarTransport::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: scalarTransport.C:335
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::scalarTransport::active_
bool active_
On/off switch.
Definition: scalarTransport.H:178
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fv::optionList
List of finite volume options.
Definition: fvOptionList.H:64
Foam::scalarTransport::~scalarTransport
virtual ~scalarTransport()
Destructor.
Definition: scalarTransport.C:207