populationBalanceMoments.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) 2022-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::populationBalanceMoments
26 
27 Description
28  Calculates and writes out integral (integer moments) or mean properties
29  (mean, variance, standard deviation) of a size distribution determined by a
30  population balance model. Requires solver post-processing.
31 
32  The following function object specification for example returns the first
33  moment of the volume-based number density function which is equivalent to
34  the phase fraction of the particulate phase:
35 
36  \verbatim
37  populationBalanceMoments
38  {
39  type populationBalanceMoments;
40  libs ("libmultiphaseEulerFunctionObjects.so");
41  executeControl timeStep;
42  writeControl writeTime;
43  populationBalance bubbles;
44  momentType integerMoment;
45  coordinateType volume;
46  order 1;
47  }
48  \endverbatim
49 
50 Usage
51  \table
52  Property | Description | Required | Default
53  populationBalance | population balance name | yes |
54  momentType | desired moment of the distribution\\
55  | yes |
56  coordinateType | particle property | yes |
57  weightType | number/volume/area concentration\\
58  | no\\
59  | numberConcentration
60  order | order of integer moment | for integer moments |
61  meanType | arithmetic or geometric | for non-integer moments\\
62  | arithmetic
63  \endtable
64 
65 See also
66  Foam::diameterModels::populationBalanceModel
67  Foam::functionObjects::fvMeshFunctionObject
68  Foam::functionObject
69 
70 SourceFiles
71  populationBalanceMoments.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef populationBalanceMoments_functionObject_H
76 #define populationBalanceMoments_functionObject_H
77 
78 #include "fvMeshFunctionObject.H"
79 #include "populationBalanceModel.H"
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 namespace functionObjects
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class populationBalanceMoments Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 class populationBalanceMoments
93 :
94  public fvMeshFunctionObject
95 {
96 public:
97 
98  //- Enumeration for the moment types
99  enum class momentType
100  {
102  mean,
103  variance,
104  stdDev
105  };
106 
107  //- Names of the moment types
108  static const NamedEnum<momentType, 4> momentTypeNames_;
109 
110  //- Enumeration for the coordinate types
111  enum class coordinateType
112  {
113  volume,
114  area,
115  diameter
116  };
117 
118  //- Names of the coordinate types
119  static const NamedEnum<coordinateType, 3> coordinateTypeNames_;
120 
121  //- Enumeration for the weight types
122  enum class weightType
123  {
127  };
128 
129  //- Names of the weight types
131 
132  //- Enumeration for the mean types
133  enum class meanType
134  {
135  arithmetic,
136  geometric,
138  };
139 
140  //- Names of the mean types
142 
143 
144 private:
145 
146  // Private Data
147 
148  //- Name of the population balance
149  const word popBalName_;
150 
151  //- Moment type
152  momentType momentType_;
153 
154  //- Coordinate type
155  coordinateType coordinateType_;
156 
157  //- Weight type
158  weightType weightType_;
159 
160  //- Mean type
161  meanType meanType_;
162 
163  //- Integer moment order
164  int order_;
165 
166  //- Result field
167  autoPtr<volScalarField> fldPtr_;
168 
169 
170  // Private Member Functions
171 
172  //- Coordinate type symbolic name for shorter field names
173  word coordinateTypeSymbolicName();
174 
175  //- Weight type symbolic name for shorter field names
176  word weightTypeSymbolicName();
177 
178  //- Default field name
179  word defaultFldName();
180 
181  //- Integer moment field name
182  word integerMomentFldName();
183 
184  //- Set dimensions
185  void setDimensions(volScalarField& fld, momentType momType);
186 
187  //- Total concentration
188  tmp<volScalarField> totalConcentration
189  (
191  );
192 
193  //- Mean value
195  (
197  );
198 
199  //- Variance
200  tmp<volScalarField> variance
201  (
203  );
204 
205  //- Standard deviation
206  tmp<volScalarField> stdDev
207  (
209  );
210 
211 
212 public:
213 
214  //- Runtime type information
215  TypeName("populationBalanceMoments");
216 
217 
218  // Constructors
219 
220  //- Construct from Time and dictionary
222  (
223  const word& name,
224  const Time& runTime,
225  const dictionary&
226  );
227 
228  //- Disallow default bitwise copy construction
230 
231 
232  //- Destructor
233  virtual ~populationBalanceMoments();
234 
235 
236  // Member Functions
237 
238  //- Read the data
239  virtual bool read(const dictionary&);
240 
241  //- Return the list of fields required
242  virtual wordList fields() const
243  {
244  return wordList::null();
245  }
246 
247  //- Calculate the moment fields
248  virtual bool execute();
249 
250  //- Write the moment fields
251  virtual bool write();
252 
253 
254  // Member Operators
255 
256  //- Disallow default bitwise assignment
257  void operator=(const populationBalanceMoments&) = delete;
258 };
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace functionObjects
264 } // End namespace Foam
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
Generic GeometricField class.
static const List< word > & 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: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
Model for tracking the evolution of a dispersed phase size distribution due to coalescence (synonymou...
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.
Calculates and writes out integral (integer moments) or mean properties (mean, variance,...
static const NamedEnum< coordinateType, 3 > coordinateTypeNames_
Names of the coordinate types.
virtual wordList fields() const
Return the list of fields required.
TypeName("populationBalanceMoments")
Runtime type information.
static const NamedEnum< meanType, 3 > meanTypeNames_
Names of the mean types.
static const NamedEnum< momentType, 4 > momentTypeNames_
Names of the moment types.
static const NamedEnum< weightType, 3 > weightTypeNames_
Names of the weight types.
void operator=(const populationBalanceMoments &)=delete
Disallow default bitwise assignment.
coordinateType
Enumeration for the coordinate types.
populationBalanceMoments(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
virtual bool execute()
Calculate the moment fields.
virtual bool write()
Write the moment fields.
virtual bool read(const dictionary &)
Read the data.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.