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-2023 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 ("libmultiphaseEulerFoamFunctionObjects.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 functionObjects_populationBalanceMoments_H
76 #define functionObjects_populationBalanceMoments_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  //- Reference to population balance
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 
190  //- Mean value
191  tmp<volScalarField> mean();
192 
193  //- Variance
194  tmp<volScalarField> variance();
195 
196  //- Standard deviation
197  tmp<volScalarField> stdDev();
198 
199 
200 public:
201 
202  //- Runtime type information
203  TypeName("populationBalanceMoments");
204 
205 
206  // Constructors
207 
208  //- Construct from Time and dictionary
210  (
211  const word& name,
212  const Time& runTime,
213  const dictionary&
214  );
215 
216  //- Disallow default bitwise copy construction
218 
219 
220  //- Destructor
221  virtual ~populationBalanceMoments();
222 
223 
224  // Member Functions
225 
226  //- Read the data
227  virtual bool read(const dictionary&);
228 
229  //- Return the list of fields required
230  virtual wordList fields() const
231  {
232  return wordList::null();
233  }
234 
235  //- Calculate the moment fields
236  virtual bool execute();
237 
238  //- Write the moment fields
239  virtual bool write();
240 
241 
242  // Member Operators
243 
244  //- Disallow default bitwise assignment
245  void operator=(const populationBalanceMoments&) = delete;
246 };
247 
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 } // End namespace functionObjects
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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(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(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.