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-2025 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 ("libmultiphaseEulerFunctionObjects.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  cellZone | cellZone | yes |
63  name | name of cellZone if required | no |
64  setFormat | output format | yes |
65  \endtable
66 
67 See also
68  Foam::populationBalanceModel
69  Foam::functionObjects::fvMeshFunctionObject
70  Foam::fvCellZone
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 "fvCellZone.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 {
102 public:
103 
104  // Public Data Types
105 
106  //- Function type enumeration
107  enum functionType
108  {
115  };
116 
117  //- Function type names
118  static const NamedEnum<functionType, 6> functionTypeNames_;
119 
120  //- Coordinate type enumeration
121  enum coordinateType
122  {
123  volume,
124  area,
125  diameter,
127  };
128 
129  //- Coordinate type names
130  static const NamedEnum<coordinateType, 4> coordinateTypeNames_;
131 
132  //- Enumeration for the weight types
133  enum class weightType
134  {
138  cellVolume
139  };
140 
141  //- Names of the weight types
142  static const NamedEnum<weightType, 4> weightTypeNames_;
143 
144 
145 private:
146 
147  // Private Data
148 
149  //- Write file
150  writeFile file_;
151 
152  //- Reference to mesh
153  const fvMesh& mesh_;
154 
155  //- cellZone
156  fvCellZone zone_;
157 
158  //- Name of the population balance
159  const word popBalName_;
160 
161  //- Function type
162  functionType functionType_;
163 
164  //- Coordinate type
165  coordinateType coordinateType_;
166 
167  //- Add values for all coordinate types to output
168  Switch allCoordinates_;
169 
170  //- Normalise result through division by sum
171  Switch normalise_;
172 
173  //- Log transform
174  Switch logTransform_;
175 
176  //- Weight types, relevant if particle properties are field dependent
177  weightType weightType_;
178 
179  //- Set formatter
180  autoPtr<setWriter> formatterPtr_;
181 
182 
183  // Private Member Functions
184 
185  //- Function type symbolic name for shorter file header
186  word functionTypeSymbolicName();
187 
188  //- Coordinate type symbolic name for shorter file header
189  word coordinateTypeSymbolicName(const coordinateType& cType);
190 
191  //- Filter a field according to cellIds
192  tmp<scalarField> filterField(const scalarField& field) const;
193 
194  //- Field averaged coordinate value
195  scalar averageCoordinateValue
196  (
197  const populationBalanceModel&,
198  const label i,
199  const coordinateType&
200  );
201 
202  //- Weighted average
203  scalar weightedAverage
204  (
205  const populationBalanceModel&,
206  const label i,
207  const scalarField& field
208  );
209 
210 
211 public:
212 
213  //- Runtime type information
214  TypeName("populationBalanceSizeDistribution");
215 
216 
217  // Constructors
218 
219  //- Construct from Time and dictionary
221  (
222  const word& name,
223  const Time& runTime,
224  const dictionary& dict
225  );
226 
227  //- Disallow default bitwise copy construction
229  (
231  ) = delete;
232 
233 
234  //- Destructor
236 
237 
238  // Member Functions
239 
240  //- Return the list of fields required
241  virtual wordList fields() const
242  {
243  return wordList::null();
244  }
245 
246  //- Read the populationBalanceSizeDistribution data
247  virtual bool read(const dictionary&);
248 
249  //- Execute, currently does nothing
250  virtual bool execute();
251 
252  //- Calculate and write the size distribution
253  virtual bool write();
254 
255 
256  // Mesh changes
257 
258  //- Update for mesh motion
259  virtual void movePoints(const polyMesh&);
260 
261  //- Update topology using the given map
262  virtual void topoChange(const polyTopoChangeMap&);
263 
264  //- Update from another mesh using the given map
265  virtual void mapMesh(const polyMeshMap&);
266 
267  //- Redistribute or update using the given distribution map
268  virtual void distribute(const polyDistributionMap&);
269 
270 
271  // Member Operators
272 
273  //- Disallow default bitwise assignment
274  void operator=(const populationBalanceSizeDistribution&) = delete;
275 };
276 
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 } // End namespace functionObjects
281 } // End namespace Foam
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 #endif
286 
287 // ************************************************************************* //
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Writes out the size distribution determined by a population balance model, either for the entire doma...
virtual wordList fields() const
Return the list of fields required.
TypeName("populationBalanceSizeDistribution")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
void operator=(const populationBalanceSizeDistribution &)=delete
Disallow default bitwise assignment.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
populationBalanceSizeDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual void movePoints(const polyMesh &)
Update for mesh motion.
static const NamedEnum< weightType, 4 > weightTypeNames_
Names of the weight types.
static const NamedEnum< functionType, 6 > functionTypeNames_
Function type names.
static const NamedEnum< coordinateType, 4 > coordinateTypeNames_
Coordinate type names.
virtual bool write()
Calculate and write the size distribution.
virtual bool read(const dictionary &)
Read the populationBalanceSizeDistribution data.
functionObject base class for writing single files
Definition: writeFile.H:56
cellZone selection or generation class with caching of zone volume
Definition: fvCellZone.H:94
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Model for tracking the evolution of a dispersed phase size distribution due to coalescence (synonymou...
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
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
dictionary dict