sizeDistribution.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
6  \\/ M anipulation |
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::functionObjects::sizeDistribution
26 
27 Description
28  This function object calculates and outputs information about the size
29  distribution of the dispersed phase, such as the number density function or
30  its moments. It is designed to be used exclusively with the population
31  balance modeling functionality of the reactingEulerFoam solvers. It can be
32  applied to a specific cellZone or the entire domain.
33 
34  Example of function object specification:
35  \verbatim
36  box.all.numberDensity.volume.bubbles
37  {
38  type sizeDistribution;
39  libs ("libreactingEulerFoamFunctionObjects.so");
40  writeControl outputTime;
41  writeInterval 1;
42  log true;
43  ...
44  functionType numberDensity;
45  abszissaType volume;
46  regionType all;
47  populationBalanceModel bubbles;
48  normalize true;
49  }
50  \endverbatim
51 
52 Usage
53  \table
54  Property | Description | Required | Default value
55  type | type name: sizeDistribution | yes |
56  functionType | numberDensity, volumeDensity, numberConcentration,
57  moments | yes |
58  abszissaType | volume, diameter | yes |
59  momentOrder | Write moment up to given order | no | 0
60  regionType | Evaluate for cellZone or entire mesh | yes |
61  cellZoneName | Required if regionType is cellZone | |
62  populationBalanceModel | Respective populationBalanceModel | yes |
63  normalize | Normalization | no |
64  \endtable
65 
66 See also
67  Foam::diameterModels::populationBalanceModel
68  Foam::functionObject
69  Foam::functionObjects::fvMeshFunctionObject
70  Foam::functionObjects::logFiles
71 
72 SourceFiles
73  sizeDistribution.C
74 
75 \*---------------------------------------------------------------------------*/
76 
77 #ifndef functionObjects_sizeDistribution_H
78 #define functionObjects_sizeDistribution_H
79 
80 #include "fvMeshFunctionObject.H"
81 #include "logFiles.H"
82 #include "populationBalanceModel.H"
83 
84 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
85 
86 namespace Foam
87 {
88 
89 // Forward declaration of classes
90 class fvMesh;
91 
92 namespace functionObjects
93 {
94 
95 /*---------------------------------------------------------------------------*\
96  Class sizeDistribution Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 class sizeDistribution
100 :
101  public fvMeshFunctionObject,
102  public logFiles
103 {
104 
105 public:
106 
107  // Public data types
108 
109  //- Region type enumeration
110  enum regionTypes
111  {
112  rtCellZone,
113  rtAll
114  };
115 
116  //- Region type names
117  static const NamedEnum<regionTypes, 2> regionTypeNames_;
118 
119 
120  //- Function type enumeration
121  enum functionTypes
122  {
123  ftNdf,
124  ftVdf,
125  ftNc,
126  ftMom
127  };
128 
129  //- Function type names
130  static const NamedEnum<functionTypes, 4> functionTypeNames_;
131 
132 
133  //- abszissa type enumeration
134  enum abszissaTypes
135  {
136  atDiameter,
137  atVolume,
138  };
139 
140  //- Abszissa type names
141  static const NamedEnum<abszissaTypes, 2> abszissaTypeNames_;
142 
143 
144 protected:
146  // Protected data
147 
148  //- Construction dictionary
150 
151  //- Region type
153 
154  //- Name of region
157  //- Function type
160  //- Abszissa type
162 
163  //- Global number of cells
164  label nCells_;
165 
166  //- Local list of cell IDs
168 
169  //- Total volume of the evaluated region
170  scalar volume_;
172  //- Optionally write the volume of the sizeDistribution
173  bool writeVolume_;
174 
175  //- PopulationBalance
177 
178  //- Number concentrations
181  //- Write moments up to specified order with respect to abszissaType
184  //- Normalization switch
185  const Switch normalize_;
186 
187  //- Sum of number concentrations
188  scalar sumN_;
189 
190  //- Volumertic sum
191  scalar sumV_;
192 
193 
194  // Protected Member Functions
196  //- Initialise, e.g. cell addressing
197  void initialise(const dictionary& dict);
199  //- Set cells to evaluate based on a cell zone
200  void setCellZoneCells();
202  //- Calculate and return volume of the evaluated cell zone
203  scalar volume() const;
205  //- Combine fields from all processor domains into single field
206  void combineFields(scalarField& field);
208  //- Filter field according to cellIds
209  tmp<scalarField> filterField(const scalarField& field) const;
211  //- Output file header information
212  virtual void writeFileHeader(const label i);
214 
215 public:
217  //- Runtime type information
218  TypeName("sizeDistribution");
220 
221  // Constructors
223  //- Construct from Time and dictionary
225  (
226  const word& name,
227  const Time& runTime,
229  );
230 
232  //- Destructor
233  virtual ~sizeDistribution();
235 
236  // Member Functions
238  //- Return the reference to the construction dictionary
239  const dictionary& dict() const
240  {
241  return dict_;
242  }
243 
244  //- Return the local list of cell IDs
245  const labelList& cellId() const
246  {
247  return cellId_;
248  }
249 
250  //- Helper function to return the reference to the mesh
251  const fvMesh& mesh() const
252  {
253  return refCast<const fvMesh>(obr_);
254  }
255 
256  //- Read from dictionary
257  virtual bool read(const dictionary& dict);
258 
259  //- Execute
260  virtual bool execute();
261 
262  //- Write
263  virtual bool write();
264 };
265 
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 } // End namespace functionObjects
270 } // End namespace Foam
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #endif
275 
276 // ************************************************************************* //
label momentOrder_
Write moments up to specified order with respect to abszissaType.
scalar volume_
Total volume of the evaluated region.
tmp< scalarField > filterField(const scalarField &field) const
Filter field according to cellIds.
const labelList & cellId() const
Return the local list of cell IDs.
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
const word & name() const
Return the name of this functionObject.
static const NamedEnum< regionTypes, 2 > regionTypeNames_
Region type names.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Class that solves the univariate population balance equation by means of a class method (also called ...
scalar sumN_
Sum of number concentrations.
virtual ~sizeDistribution()
Destructor.
static const NamedEnum< functionTypes, 4 > functionTypeNames_
Function type names.
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, y/n, t/f, or none.
Definition: Switch.H:60
static const NamedEnum< abszissaTypes, 2 > abszissaTypeNames_
Abszissa type names.
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:68
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.
virtual void writeFileHeader(const label i)
Output file header information.
A class for handling words, derived from string.
Definition: word.H:59
scalar volume() const
Calculate and return volume of the evaluated cell zone.
labelList cellId_
Local list of cell IDs.
const fvMesh & mesh() const
Helper function to return the reference to the mesh.
sizeDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
label nCells_
Global number of cells.
void setCellZoneCells()
Set cells to evaluate based on a cell zone.
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
A class for managing temporary objects.
Definition: PtrList.H:53
const Foam::diameterModels::populationBalanceModel & popBal_
PopulationBalance.
functionTypes
Function type enumeration.
Namespace for OpenFOAM.