populationBalanceSizeDistribution.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-2022 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::populationBalanceSizeDistribution
26 
27 Description
28  Writes out the size distribution determined by a population balance model,
29  either for the entire domain or a cell zone. Requires solver post-
30  processing.
31 
32  The following function object specification for example returns the volume-
33  based number density function:
34 
35  Example of function object specification:
36  \verbatim
37  numberDensity
38  {
39  type populationBalanceSizeDistribution;
40  libs ("libmultiphaseEulerFoamFunctionObjects.so");
41  writeControl writeTime;
42  populationBalance bubbles;
43  functionType numberDensity;
44  coordinateType volume;
45  setFormat raw;
46  }
47  \endverbatim
48 
49 Usage
50  \table
51  Property | Description | Required | Default
52  populationBalance | population balance name | yes |
53  functionType | function type | yes |
54  coordinateType | particle property | yes |
55  allCoordinates | write all coordinate values | no | false
56  normalise | divide by total concentration | no | false
57  logTransform | class width based on log of coordinate\\
58  | no | false
59  weightType | weighting in case of field-dependent particle\\
60  properties | no\\
61  | numberConcentration
62  regionType | cellZone or all | no | all
63  name | name of cellZone if required | no |
64  setFormat | output format | yes |
65  \endtable
66 
67 See also
68  Foam::diameterModels::populationBalanceModel
69  Foam::functionObjects::fvMeshFunctionObject
70  Foam::functionObjects::volRegion
71  Foam::functionObject
72 
73 SourceFiles
74  populationBalanceSizeDistribution.C
75 
76 \*---------------------------------------------------------------------------*/
77 
78 #ifndef populationBalanceSizeDistribution_H
79 #define populationBalanceSizeDistribution_H
80 
81 #include "fvMeshFunctionObject.H"
82 #include "volRegion.H"
83 #include "populationBalanceModel.H"
84 #include "writeFile.H"
85 #include "setWriter.H"
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 
89 namespace Foam
90 {
91 namespace functionObjects
92 {
93 
94 /*---------------------------------------------------------------------------*\
95  Class populationBalanceSizeDistribution Declaration
96 \*---------------------------------------------------------------------------*/
97 
98 class populationBalanceSizeDistribution
99 :
100  public fvMeshFunctionObject,
101  public volRegion
102 {
103 public:
104 
105  // Public Data Types
106 
107  //- Function type enumeration
108  enum functionType
109  {
116  };
117 
118  //- Function type names
119  static const NamedEnum<functionType, 6> functionTypeNames_;
120 
121  //- Coordinate type enumeration
122  enum coordinateType
123  {
124  volume,
125  area,
126  diameter,
128  };
129 
130  //- Coordinate type names
131  static const NamedEnum<coordinateType, 4> coordinateTypeNames_;
132 
133  //- Enumeration for the weight types
134  enum class weightType
135  {
139  cellVolume
140  };
141 
142  //- Names of the weight types
143  static const NamedEnum<weightType, 4> weightTypeNames_;
144 
145 
146 private:
147 
148  // Private Data
150  //- Write file
151  writeFile file_;
152 
153  //- Reference to mesh
154  const fvMesh& mesh_;
155 
156  //- Reference to population balance
158 
159  //- Function type
160  functionType functionType_;
162  //- Coordinate type
163  coordinateType coordinateType_;
165  //- Add values for all coordinate types to output
166  Switch allCoordinates_;
167 
168  //- Normalise result through division by sum
169  Switch normalise_;
171  //- Log transform
172  Switch logTransform_;
174  //- Weight types, relevant if particle properties are field dependent
175  weightType weightType_;
177  //- Set formatter
178  autoPtr<setWriter> formatterPtr_;
179 
180 
181  // Private Member Functions
183  //- Function type symbolic name for shorter file header
184  word functionTypeSymbolicName();
186  //- Coordinate type symbolic name for shorter file header
187  word coordinateTypeSymbolicName(const coordinateType& cType);
188 
189  //- Filter a field according to cellIds
190  tmp<scalarField> filterField(const scalarField& field) const;
191 
192  //- Field averaged coordinate value
193  scalar averageCoordinateValue
194  (
195  const diameterModels::sizeGroup& fi,
196  const coordinateType& cType
197  );
198 
199  //- Weighted average
200  scalar weightedAverage
201  (
202  const scalarField& fld,
203  const diameterModels::sizeGroup& fi
204  );
205 
206 
207 public:
208 
209  //- Runtime type information
210  TypeName("populationBalanceSizeDistribution");
211 
212 
213  // Constructors
214 
215  //- Construct from Time and dictionary
217  (
218  const word& name,
219  const Time& runTime,
220  const dictionary& dict
221  );
222 
223  //- Disallow default bitwise copy construction
225  (
227  ) = delete;
228 
229 
230  //- Destructor
232 
233 
234  // Member Functions
235 
236  //- Return the list of fields required
237  virtual wordList fields() const
238  {
239  return wordList::null();
240  }
241 
242  //- Read the populationBalanceSizeDistribution data
243  virtual bool read(const dictionary&);
244 
245  //- Execute, currently does nothing
246  virtual bool execute();
247 
248  //- Calculate and write the size distribution
249  virtual bool write();
250 
251 
252  // Member Operators
253 
254  //- Disallow default bitwise assignment
255  void operator=(const populationBalanceSizeDistribution&) = delete;
256 };
257 
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 } // End namespace functionObjects
262 } // End namespace Foam
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 #endif
267 
268 // ************************************************************************* //
dictionary dict
static const NamedEnum< functionType, 6 > functionTypeNames_
Function type names.
virtual bool write()
Calculate and write the size distribution.
virtual bool execute()
Execute, currently does nothing.
const word & name() const
Return the name of this functionObject.
virtual bool read(const dictionary &)
Read the populationBalanceSizeDistribution data.
void operator=(const populationBalanceSizeDistribution &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Model for tracking the evolution of a dispersed phase size distribution due to coalescence (synonymou...
static const NamedEnum< coordinateType, 4 > coordinateTypeNames_
Coordinate type names.
Writes out the size distribution determined by a population balance model, either for the entire doma...
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/any.
Definition: Switch.H:60
static const List< T > & null()
Return a null List.
Definition: ListI.H:118
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual wordList fields() const
Return the list of fields required.
static const NamedEnum< weightType, 4 > weightTypeNames_
Names of the weight types.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
populationBalanceSizeDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Single size class fraction field representing a fixed particle volume as defined by the user through ...
Definition: sizeGroup.H:99
A class for handling words, derived from string.
Definition: word.H:59
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
rDeltaTY field()
A class for managing temporary objects.
Definition: PtrList.H:53
TypeName("populationBalanceSizeDistribution")
Runtime type information.
functionObject base class for writing single files
Definition: writeFile.H:55
Namespace for OpenFOAM.