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  Example of function object specification:
37  \verbatim
38  box.all.numberDensity.volume.bubbles
39  {
40  type sizeDistribution;
41  libs (reactingEulerFoamFunctionObjects);
42  writeControl writeTime;
43  writeInterval 1;
44  log true;
45  ...
46  functionType numberDensity;
47  abszissaType volume;
48  selectionMode all;
49  populationBalanceModel bubbles;
50  normalize true;
51  }
52  \endverbatim
53 
54 Usage
55  \table
56  Property | Description | Required | Default value
57  type | type name: sizeDistribution | yes |
58  functionType | numberDensity, volumeDensity, numberConcentration,
59  moments | yes |
60  abszissaType | volume, diameter | yes |
61  momentOrder | Write moment up to given order | no | 0
62  selectionMode | Evaluate for cellZone or entire mesh | yes |
63  cellZone | Required if selectionMode is cellZone | |
64  populationBalanceModel | Respective populationBalanceModel | yes |
65  normalize | Normalization | no |
66  \endtable
67 
68 See also
69  Foam::diameterModels::populationBalanceModel
70  Foam::functionObject
71  Foam::functionObjects::fvMeshFunctionObject
72  Foam::functionObjects::writeFile
73 
74 SourceFiles
75  sizeDistribution.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef functionObjects_sizeDistribution_H
80 #define functionObjects_sizeDistribution_H
81 
82 #include "fvMeshFunctionObject.H"
83 #include "writeFile.H"
84 #include "populationBalanceModel.H"
85 #include "Enum.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 
92 // Forward declaration of classes
93 class fvMesh;
94 
95 namespace functionObjects
96 {
97 
98 /*---------------------------------------------------------------------------*\
99  Class sizeDistribution Declaration
100 \*---------------------------------------------------------------------------*/
101 
102 class sizeDistribution
103 :
104  public fvMeshFunctionObject,
105  public writeFile
106 {
107 
108 public:
109 
110  // Public data types
111 
112  //- Selection mode type enumeration
113  enum selectionModeTypes
114  {
115  rtCellZone,
116  rtAll
117  };
118 
119  //- Selection mode type names
120  static const Enum<selectionModeTypes> selectionModeTypeNames_;
121 
122 
123  //- Function type enumeration
124  enum functionTypes
125  {
126  ftNdf,
127  ftVdf,
128  ftNc,
129  ftMom
130  };
131 
132  //- Function type names
133  static const Enum<functionTypes> functionTypeNames_;
134 
135 
136  //- abszissa type enumeration
137  enum abszissaTypes
138  {
139  atDiameter,
140  atVolume,
141  };
142 
143  //- Abszissa type names
145 
146 
147 protected:
148 
149  // Protected data
150 
151  //- Construction dictionary
153 
154  //- Selection mode type
156 
157  //- Name of selection
160  //- Function type
162 
163  //- Abszissa type
165 
166  //- Global number of cells
167  label nCells_;
168 
169  //- Local list of cell IDs
171 
172  //- Total volume of the evaluated selection
173  scalar volume_;
175  //- Optionally write the volume of the sizeDistribution
178  //- PopulationBalance
180 
181  //- Number concentrations
184  //- Write moments up to specified order with respect to abszissaType
185  label momentOrder_;
186 
187  //- Normalization switch
188  const Switch normalize_;
190  //- Sum of number concentrations
191  scalar sumN_;
193  //- Volumertic sum
194  scalar sumV_;
195 
196 
197  // Protected Member Functions
199  //- Initialise, e.g. cell addressing
200  void initialise(const dictionary& dict);
201 
202  //- Set cells to evaluate based on a cell zone
203  void setCellZoneCells();
204 
205  //- Calculate and return volume of the evaluated cell zone
206  scalar volume() const;
207 
208  //- Combine fields from all processor domains into single field
210 
211  //- Filter field according to cellIds
214  //- Output file header information
215  void writeFileHeader(const label i = 0);
216 
217 
218 public:
219 
220  //- Runtime type information
221  TypeName("sizeDistribution");
222 
224  // Constructors
225 
226  //- Construct from Time and dictionary
228  (
229  const word& name,
230  const Time& runTime,
231  const dictionary& dict
232  );
234 
235  //- Destructor
236  virtual ~sizeDistribution();
237 
239  // Member Functions
240 
241  //- Return the reference to the construction dictionary
242  const dictionary& dict() const
243  {
244  return dict_;
245  }
246 
247  //- Return the local list of cell IDs
248  const labelList& cellId() const
249  {
250  return cellId_;
251  }
252 
253  //- Helper function to return the reference to the mesh
254  const fvMesh& mesh() const
255  {
256  return refCast<const fvMesh>(obr_);
257  }
259  //- Read from dictionary
260  virtual bool read(const dictionary& dict);
261 
262  //- Execute
263  virtual bool execute();
264 
265  //- Write
266  virtual bool write();
267 };
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 } // End namespace functionObjects
273 } // End namespace Foam
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 #endif
279 // ************************************************************************* //
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:129
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:77
virtual bool read(const dictionary &dict)
Read from 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:69
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 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.
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.