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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::functionObjects::scalarTransport
29 
30 Group
31  grpSolversFunctionObjects
32 
33 Description
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 
51 Usage
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  scalarSemiImplicitSourceCoeffs
104  {
105  selectionMode all;
106  volumeMode specific;
107  injectionRateSuSp
108  {
109  s (1 0);
110  }
111  }
112  }
113  }
114 
115  resetOnStartUp false;
116  }
117  }
118  \endverbatim
119 
120  Where the entries comprise:
121  \table
122  Property | Description | Required | Default value
123  type | Type name: scalarTransport | yes |
124  field | Name of the scalar field | no | s
125  phi | Name of flux field | no | phi
126  rho | Name of density field | no | rho
127  phase | Name of the phase | no | none
128  nut | Name of the turbulence viscosity | no | none
129  D | Diffusion coefficient | no | auto generated
130  nCorr | Number of correctors | no | 0
131  resetOnStartUp | Reset scalar to zero on start-up | no | no
132  schemesField | Name of field to specify schemes | no | field name
133  fvOptions | List of scalar sources | no |
134  bounded01 | Bounds scalar between 0-1 for multiphase | no | true
135  phasePhiCompressed | Compressed flux for VOF | no | alphaPhiUn
136  \endtable
137 
138 See also
139  Foam::functionObjects::fvMeshFunctionObject
140 
141 SourceFiles
142  scalarTransport.C
143 
144 \*---------------------------------------------------------------------------*/
145 
146 #ifndef functionObjects_scalarTransport_H
147 #define functionObjects_scalarTransport_H
148 
149 #include "fvMeshFunctionObject.H"
150 #include "volFields.H"
151 #include "fvOptionList.H"
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 namespace Foam
156 {
157 namespace functionObjects
158 {
159 
160 /*---------------------------------------------------------------------------*\
161  Class scalarTransport Declaration
162 \*---------------------------------------------------------------------------*/
163 
164 class scalarTransport
165 :
166  public fvMeshFunctionObject
167 {
168  // Private data
169 
170  //- Name of the transport field.
171  word fieldName_;
172 
173  //- Name of flux field (optional)
174  word phiName_;
175 
176  //- Name of density field (optional)
177  word rhoName_;
178 
179  //- Name of turbulent viscosity field (optional)
180  word nutName_;
181 
182  //- Name of phase field (optional)
183  word phaseName_;
184 
185  //- Name of phase field compressed flux (optional)
186  word phasePhiCompressedName_;
187 
188  //- Diffusion coefficient (optional)
189  scalar D_;
190 
191  //- Flag to indicate whether a constant, uniform D_ is specified
192  bool constantD_;
193 
194  //- Laminar diffusion coefficient (optional)
195  scalar alphaD_;
196 
197  //- Turbulent diffusion coefficient (optional)
198  scalar alphaDt_;
199 
200  //- Number of corrector iterations (optional)
201  label nCorr_;
202 
203  //- Flag to reset the scalar to zero on start-up
204  bool resetOnStartUp_;
205 
206  //- Name of field whose schemes are used (optional)
207  word schemesField_;
208 
209  //- Run-time selectable finite volume options, e.g. sources, constraints
210  fv::optionList fvOptions_;
211 
212  //- Bound scalar between 0-1 using MULES for multiphase case
213  bool bounded01_;
214 
215 
216  // Private Member Functions
217 
218  //- Return reference to registered transported field
219  volScalarField& transportedField();
220 
221  //- Return the diffusivity field
222  tmp<volScalarField> D
223  (
224  const volScalarField& s,
225  const surfaceScalarField& phi
226  ) const;
227 
228  //- No copy construct
229  scalarTransport(const scalarTransport&) = delete;
230 
231  //- No copy assignment
232  void operator=(const scalarTransport&) = delete;
233 
234 
235 public:
236 
237  //- Runtime type information
238  TypeName("scalarTransport");
239 
240 
241  // Constructors
242 
243  //- Construct from Time and dictionary
245  (
246  const word& name,
247  const Time& runTime,
248  const dictionary& dict
249  );
250 
251 
252  //- Destructor
253  virtual ~scalarTransport();
254 
255 
256  // Member Functions
257 
258  //- Read the scalarTransport data
259  virtual bool read(const dictionary&);
260 
261  //- Calculate the scalarTransport
262  virtual bool execute();
263 
264  //- Do nothing.
265  // The volScalarField is registered and written automatically
266  virtual bool write();
267 };
268 
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 } // End namespace functionObjects
273 } // End namespace Foam
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 #endif
278 
279 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
s
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))
Definition: gmvOutputSpray.H:25
fvMeshFunctionObject.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::scalarTransport::execute
virtual bool execute()
Calculate the scalarTransport.
Definition: scalarTransport.C:249
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::scalarTransport::read
virtual bool read(const dictionary &)
Read the scalarTransport data.
Definition: scalarTransport.C:222
Foam::functionObjects::scalarTransport::~scalarTransport
virtual ~scalarTransport()
Destructor.
Definition: scalarTransport.C:216
fvOptionList.H
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::functionObjects::scalarTransport::write
virtual bool write()
Do nothing.
Definition: scalarTransport.C:375
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::scalarTransport::TypeName
TypeName("scalarTransport")
Runtime type information.
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fv::optionList
List of finite volume options.
Definition: fvOptionList.H:69
Foam::functionObjects::scalarTransport
Evolves a passive scalar transport equation.
Definition: scalarTransport.H:233