sizeDistribution.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) 2017-2019 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionObjects::sizeDistribution
28 
29 Description
30  This function object calculates and outputs information about the size
31  distribution of the dispersed phase, such as the number density function or
32  its moments. It is designed to be used exclusively with the population
33  balance modeling functionality of the reactingEulerFoam solvers. It can be
34  applied to a specific cellZone or the entire domain.
35 
36 Usage
37  Minimal example by using \c system/controlDict.functions:
38  \verbatim
39  sizeDistributionFO
40  {
41  // Mandatory entries
42  type sizeDistribution;
43  libs (reactingEulerFoamFunctionObjects);
44  selectionMode <word>;
45  functionType <word>;
46  abszissaType <word>;
47  populationBalance <word>;
48 
49  // Conditional entries
50 
51  // when 'selectionMode' is 'cellZone'
52  cellZone <word>;
53 
54  // Optional entries
55  writeVolume <bool>;
56  momentOrder <label>;
57  normalize <bool>;
58 
59  // Inherited entries
60  ...
61  }
62  \endverbatim
63 
64  where the entries mean:
65  \table
66  Property | Description | Type | Reqd | Deflt
67  type | Type name: sizeDistribution | word | yes | -
68  libs | Library name: reactingEulerFoamFunctionObjects | word | yes | -
69  selectionMode | Evaluate for cellZone or entire mesh | word | yes | -
70  functionType | Name of the function type | word | yes | -
71  abszissaType | Name of the abszissa type | word | yes | -
72  populationBalance | Name of the model | word | yes | -
73  momentOrder | Write the moment up to given order | label | no | 0
74  normalize | Flag to normalize the results | bool | no | false
75  cellZone | Name of the cell zone | word | conditional | -
76  \endtable
77 
78  Options for the \c selectionMode entry:
79  \verbatim
80  cellZone | Select the specified cell zone
81  all | Select all the cells
82  \endverbatim
83 
84  Options for the \c functionType entry:
85  \verbatim
86  numberDensity | Calculates the number density function (NDF)
87  volumeDensity | Calculates the volume density function (VDF)
88  numberConcentration | Calculates the number concentration
89  moments | Calculates the moments of the distribution
90  \endverbatim
91 
92  Options for the \c abszissaType entry:
93  \verbatim
94  diameter | Use particle diameter as abscissa
95  volume | Use particle volume as abscissa
96  \endverbatim
97 
98  The inherited entries are elaborated in:
99  - \link functionObject.H \endlink
100  - \link writeFile.H \endlink
101  - \link populationBalanceModel.H \endlink
102 
103 Note
104  The choice of \c abszissaType determines whether the distribution and
105  its moments are calculated with respect to particle diameter or particle
106  volume.
107 
108 SourceFiles
109  sizeDistribution.C
110 
111 \*---------------------------------------------------------------------------*/
112 
113 #ifndef Foam_functionObjects_sizeDistribution_H
114 #define Foam_functionObjects_sizeDistribution_H
115 
116 #include "fvMeshFunctionObject.H"
117 #include "writeFile.H"
118 #include "populationBalanceModel.H"
119 #include "Enum.H"
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 namespace Foam
124 {
125 
126 // Forward declaration of classes
127 class fvMesh;
128 
129 namespace functionObjects
130 {
131 
132 /*---------------------------------------------------------------------------*\
133  Class sizeDistribution Declaration
134 \*---------------------------------------------------------------------------*/
135 
136 class sizeDistribution
137 :
138  public fvMeshFunctionObject,
139  public writeFile
140 {
141 public:
142 
143  // Public Enumerations
144 
145  //- Selection mode type enumeration
146  enum selectionModeTypes
147  {
148  rtCellZone,
149  rtAll
150  };
151 
152  //- Selection mode type names
153  static const Enum<selectionModeTypes> selectionModeTypeNames_;
154 
155 
156  //- Function type enumeration
157  enum functionTypes
158  {
159  ftNdf,
160  ftVdf,
161  ftNc,
162  ftMom
163  };
164 
165  //- Function type names
166  static const Enum<functionTypes> functionTypeNames_;
167 
168 
169  //- Abszissa type enumeration
170  enum abszissaTypes
171  {
172  atDiameter,
173  atVolume,
174  };
175 
176  //- Abszissa type names
177  static const Enum<abszissaTypes> abszissaTypeNames_;
178 
179 
180 protected:
181 
182  // Protected Data
183 
184  //- Construction dictionary
186 
187  //- Selection mode type
189 
190  //- Name of selection
192 
193  //- Function type
195 
196  //- Abszissa type
198 
199  //- Global number of cells
200  label nCells_;
201 
202  //- Local list of cell IDs
204 
205  //- Total volume of the evaluated selection
206  scalar volume_;
207 
208  //- Optionally write the volume of the sizeDistribution
209  bool writeVolume_;
210 
211  //- PopulationBalance
213 
214  //- Number concentrations
216 
217  //- Write moments up to specified order with respect to abszissaType
219 
220  //- Normalization switch
223  //- Sum of number concentrations
224  scalar sumN_;
225 
226  //- Volumertic sum
227  scalar sumV_;
228 
230  // Protected Member Functions
231 
232  //- Initialise, e.g. cell addressing
233  void initialise(const dictionary& dict);
234 
235  //- Set cells to evaluate based on a cell zone
236  void setCellZoneCells();
238  //- Calculate and return volume of the evaluated cell zone
239  scalar volume() const;
240 
241  //- Combine fields from all processor domains into single field
243 
244  //- Filter field according to cellIds
246 
247  //- Output file header information
248  void writeFileHeader(const label i = 0);
249 
250 
251 public:
252 
253  //- Runtime type information
254  TypeName("sizeDistribution");
255 
256 
257  // Constructors
258 
259  //- Construct from name, Time and dictionary
261  (
262  const word& name,
263  const Time& runTime,
265  );
266 
267 
268  //- Destructor
269  virtual ~sizeDistribution();
270 
271 
272  // Member Functions
273 
274  //- Return the reference to the construction dictionary
275  const dictionary& dict() const
276  {
277  return dict_;
278  }
280  //- Return the local list of cell IDs
281  const labelList& cellId() const
282  {
283  return cellId_;
284  }
285 
286  //- Helper function to return the reference to the mesh
287  const fvMesh& mesh() const
288  {
289  return refCast<const fvMesh>(obr_);
290  }
291 
292  // I-O
293 
294  //- Read the function-object dictionary
295  virtual bool read(const dictionary& dict);
296 
297  //- Execute the function-object operations
298  virtual bool execute();
300  //- Write the function-object results
301  virtual bool write();
302 };
303 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 } // End namespace functionObjects
308 } // End namespace Foam
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #endif
313 
314 // ************************************************************************* //
label momentOrder_
Write moments up to specified order with respect to abszissaType.
scalar volume_
Total volume of the evaluated selection.
const labelList & cellId() const
Return the local list of cell IDs.
static const Enum< functionTypes > functionTypeNames_
Function type names.
scalar volume() const
Calculate and return volume of the evaluated cell zone.
rDeltaTY field()
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
Class that solves the univariate population balance equation by means of a class method (also called ...
static const Enum< abszissaTypes > abszissaTypeNames_
Abszissa type names.
scalar sumN_
Sum of number concentrations.
void writeFileHeader(const label i=0)
Output file header information.
void combineFields(scalarField &field)
Combine fields from all processor domains into single field.
engineTime & runTime
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:80
virtual bool execute()
Execute the function-object operations.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
void initialise(const dictionary &dict)
Initialise, e.g. cell addressing.
const Switch normalize_
Normalization switch.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const word & name() const noexcept
Return the name of this functionObject.
const dictionary & dict() const
Return the reference to the construction dictionary.
bool writeVolume_
Optionally write the volume of the sizeDistribution.
List< scalar > N_
Number concentrations.
TypeName("sizeDistribution")
Runtime type information.
functionTypes functionType_
Function type.
dictionary dict_
Construction dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList cellId_
Local list of cell IDs.
const fvMesh & mesh() const
Helper function to return the reference to the mesh.
selectionModeTypes
Selection mode type enumeration.
sizeDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
label nCells_
Global number of cells.
selectionModeTypes selectionModeType_
Selection mode type.
void setCellZoneCells()
Set cells to evaluate based on a cell zone.
word selectionModeTypeName_
Name of selection.
virtual bool write()
Write the function-object results.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const objectRegistry & obr_
Reference to the region objectRegistry.
abszissaTypes abszissaType_
Abszissa type.
abszissaTypes
Abszissa type enumeration.
tmp< scalarField > filterField(const scalarField &field) const
Filter field according to cellIds.
static const Enum< selectionModeTypes > selectionModeTypeNames_
Selection mode type names.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
const Foam::diameterModels::populationBalanceModel & popBal_
PopulationBalance.
functionTypes
Function type enumeration.
Namespace for OpenFOAM.