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 outputTime;
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
144  static const Enum<abszissaTypes> abszissaTypeNames_;
145 
146 
147 protected:
148 
149  // Protected data
150 
151  //- Construction dictionary
153 
154  //- Selection mode type
156 
157  //- Name of selection
159 
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_;
174 
175  //- Optionally write the volume of the sizeDistribution
176  bool writeVolume_;
177 
178  //- PopulationBalance
180 
181  //- Number concentrations
183 
184  //- Write moments up to specified order with respect to abszissaType
186 
187  //- Normalization switch
188  const Switch normalize_;
189 
190  //- Sum of number concentrations
191  scalar sumN_;
192 
193  //- Volumertic sum
194  scalar sumV_;
195 
196 
197  // Protected Member Functions
198 
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
213 
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 
223 
224  // Constructors
225 
226  //- Construct from Time and dictionary
228  (
229  const word& name,
230  const Time& runTime,
232  );
233 
234 
235  //- Destructor
236  virtual ~sizeDistribution();
237 
238 
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  }
258 
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 };
268 
269 
270 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 
272 } // End namespace functionObjects
273 } // End namespace Foam
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 #endif
278 
279 // ************************************************************************* //
Foam::functionObjects::sizeDistribution::normalize_
const Switch normalize_
Normalization switch.
Definition: sizeDistribution.H:234
populationBalanceModel.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
writeFile.H
Foam::functionObjects::regionFunctionObject::obr_
const objectRegistry & obr_
Reference to the region objectRegistry.
Definition: regionFunctionObject.H:102
Foam::functionObjects::sizeDistribution::atDiameter
Definition: sizeDistribution.H:185
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:77
Foam::Enum< selectionModeTypes >
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
Foam::functionObjects::sizeDistribution::~sizeDistribution
virtual ~sizeDistribution()
Destructor.
Definition: sizeDistribution.C:387
fvMeshFunctionObject.H
Foam::functionObjects::sizeDistribution::rtCellZone
Definition: sizeDistribution.H:161
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::functionObjects::sizeDistribution::writeVolume_
bool writeVolume_
Optionally write the volume of the sizeDistribution.
Definition: sizeDistribution.H:222
Foam::functionObjects::sizeDistribution::ftNdf
Definition: sizeDistribution.H:172
Foam::functionObjects::sizeDistribution::read
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: sizeDistribution.C:393
Foam::functionObjects::sizeDistribution::rtAll
Definition: sizeDistribution.H:162
Foam::functionObjects::sizeDistribution::combineFields
void combineFields(scalarField &field)
Combine fields from all processor domains into single field.
Definition: sizeDistribution.C:220
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::sizeDistribution::volume_
scalar volume_
Total volume of the evaluated selection.
Definition: sizeDistribution.H:219
Foam::functionObjects::sizeDistribution::N_
List< scalar > N_
Number concentrations.
Definition: sizeDistribution.H:228
Foam::functionObjects::sizeDistribution::TypeName
TypeName("sizeDistribution")
Runtime type information.
Foam::functionObjects::sizeDistribution::dict_
dictionary dict_
Construction dictionary.
Definition: sizeDistribution.H:198
Foam::functionObjects::sizeDistribution
This function object calculates and outputs information about the size distribution of the dispersed ...
Definition: sizeDistribution.H:148
Foam::functionObjects::sizeDistribution::sumV_
scalar sumV_
Volumertic sum.
Definition: sizeDistribution.H:240
Foam::functionObjects::sizeDistribution::functionTypeNames_
static const Enum< functionTypes > functionTypeNames_
Function type names.
Definition: sizeDistribution.H:179
Foam::functionObjects::sizeDistribution::selectionModeTypeNames_
static const Enum< selectionModeTypes > selectionModeTypeNames_
Selection mode type names.
Definition: sizeDistribution.H:166
Foam::functionObjects::sizeDistribution::functionTypes
functionTypes
Function type enumeration.
Definition: sizeDistribution.H:170
Foam::Field< scalar >
Foam::functionObjects::sizeDistribution::setCellZoneCells
void setCellZoneCells()
Set cells to evaluate based on a cell zone.
Definition: sizeDistribution.C:168
Foam::functionObjects::sizeDistribution::sumN_
scalar sumN_
Sum of number concentrations.
Definition: sizeDistribution.H:237
Foam::functionObjects::sizeDistribution::cellId
const labelList & cellId() const
Return the local list of cell IDs.
Definition: sizeDistribution.H:294
Foam::functionObjects::sizeDistribution::ftNc
Definition: sizeDistribution.H:174
field
rDeltaTY field()
Foam::functionObjects::sizeDistribution::volume
scalar volume() const
Calculate and return volume of the evaluated cell zone.
Definition: sizeDistribution.C:214
Foam::functionObjects::sizeDistribution::selectionModeTypes
selectionModeTypes
Selection mode type enumeration.
Definition: sizeDistribution.H:159
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::diameterModels::populationBalanceModel
Class that solves the univariate population balance equation by means of a class method (also called ...
Definition: populationBalanceModel.H:179
Foam::functionObjects::sizeDistribution::initialise
void initialise(const dictionary &dict)
Initialise, e.g. cell addressing.
Definition: sizeDistribution.C:84
Foam::functionObjects::sizeDistribution::filterField
tmp< scalarField > filterField(const scalarField &field) const
Filter field according to cellIds.
Definition: sizeDistribution.C:242
Foam::functionObjects::sizeDistribution::nCells_
label nCells_
Global number of cells.
Definition: sizeDistribution.H:213
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::sizeDistribution::sizeDistribution
sizeDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: sizeDistribution.C:346
Foam::functionObjects::sizeDistribution::selectionModeType_
selectionModeTypes selectionModeType_
Selection mode type.
Definition: sizeDistribution.H:201
Foam::functionObjects::sizeDistribution::dict
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: sizeDistribution.H:288
Foam::functionObjects::sizeDistribution::atVolume
Definition: sizeDistribution.H:186
Foam::functionObjects::sizeDistribution::write
virtual bool write()
Write.
Definition: sizeDistribution.C:415
Foam::functionObjects::sizeDistribution::abszissaTypeNames_
static const Enum< abszissaTypes > abszissaTypeNames_
Abszissa type names.
Definition: sizeDistribution.H:190
Foam::functionObjects::sizeDistribution::abszissaType_
abszissaTypes abszissaType_
Abszissa type.
Definition: sizeDistribution.H:210
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::sizeDistribution::abszissaTypes
abszissaTypes
abszissa type enumeration
Definition: sizeDistribution.H:183
Foam::List< label >
Foam::functionObjects::sizeDistribution::selectionModeTypeName_
word selectionModeTypeName_
Name of selection.
Definition: sizeDistribution.H:204
Foam::functionObjects::sizeDistribution::cellId_
labelList cellId_
Local list of cell IDs.
Definition: sizeDistribution.H:216
Foam::functionObjects::sizeDistribution::ftVdf
Definition: sizeDistribution.H:173
Foam::functionObjects::sizeDistribution::ftMom
Definition: sizeDistribution.H:175
Foam::functionObjects::sizeDistribution::mesh
const fvMesh & mesh() const
Helper function to return the reference to the mesh.
Definition: sizeDistribution.H:300
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::functionObjects::sizeDistribution::writeFileHeader
void writeFileHeader(const label i=0)
Output file header information.
Definition: sizeDistribution.C:251
Foam::functionObjects::sizeDistribution::functionType_
functionTypes functionType_
Function type.
Definition: sizeDistribution.H:207
Foam::functionObjects::sizeDistribution::execute
virtual bool execute()
Execute.
Definition: sizeDistribution.C:409
Foam::functionObjects::sizeDistribution::momentOrder_
label momentOrder_
Write moments up to specified order with respect to abszissaType.
Definition: sizeDistribution.H:231
Foam::functionObjects::sizeDistribution::popBal_
const Foam::diameterModels::populationBalanceModel & popBal_
PopulationBalance.
Definition: sizeDistribution.H:225
Enum.H