sizeDistribution.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-2021 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::sizeDistribution
26 
27 Description
28  This function object calculates and outputs volume-averaged information
29  about the size distribution of the dispersed phase, such as the number
30  density function or its moments. It is designed to be used exclusively with
31  the population balance modeling functionality of the multiphaseEulerFoam
32  solver. It can be applied to a specific cellZone or the entire domain. The
33  function type determines whether the density function and its moments are
34  based on the number of dispersed phase elements in a size group or their
35  total volume.
36 
37  Example of function object specification:
38  \verbatim
39  numberDensity
40  {
41  type sizeDistribution;
42  libs ("libmultiphaseEulerFoamFunctionObjects.so");
43  ...
44  populationBalance bubbles;
45  regionType cellZone;
46  name zone0;
47  functionType number;
48  coordinateType volume;
49  densityFunction yes;
50  }
51  \endverbatim
52 
53 Usage
54  \table
55  Property | Description | Required | Default value
56  type | type name: sizeDistribution | yes |
57  populationBalance | corresponding populationBalance | yes |
58  functionType | number/volume/moments/stdDev | yes |
59  coordinateType | used for density/moment calculation | yes |
60  normalise | normalise concentrations | no | no
61  densityFunction | compute densityFunction | no | no
62  logBased | use log of coordinate for density | no | no
63  maxOrder | maxim order of moment output | no | 3
64  \endtable
65 
66 SourceFiles
67  sizeDistribution.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef sizeDistribution_H
72 #define sizeDistribution_H
73 
74 #include "fvMeshFunctionObject.H"
75 #include "volRegion.H"
76 #include "logFiles.H"
77 #include "populationBalanceModel.H"
78 #include "writeFile.H"
79 #include "setWriter.H"
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85 namespace functionObjects
86 {
87 
88 /*---------------------------------------------------------------------------*\
89  Class sizeDistribution Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 class sizeDistribution
93 :
94  public fvMeshFunctionObject,
95  public volRegion,
96  public logFiles
97 {
98 public:
99 
100  // Public Data Types
101 
102  //- Function type enumeration
103  enum functionType
104  {
105  ftMoments,
106  ftStdDev,
107  ftNumber,
108  ftVolume
109  };
110 
111  //- Ordinate type names
112  static const NamedEnum<functionType, 4> functionTypeNames_;
113 
114  //- Coordinate type enumeration
115  enum coordinateType
116  {
117  ctVolume,
118  ctArea,
119  ctDiameter,
121  };
122 
123  //- Coordinate type names
124  static const NamedEnum<coordinateType, 4> coordinateTypeNames_;
125 
126 
127 protected:
128 
129  // Protected Data
130 
131  //- Reference to fvMesh
132  const fvMesh& mesh_;
133 
134  //- File containing data for all functionTypes except moments
137  //- Output formatter, set to raw
139 
140  //- Reference to populationBalanceModel
142 
143  //- Function to evaluate
145 
146  //- Abscissa type
148 
149  //- List of volume-averaged number concentrations
152  //- List of volume-averaged surface areas
153  scalarField a_;
154 
155  //- List of volume-averaged diameters
157 
158  //- Normalise number/volume concentrations
160 
161  //- Determines whether density function is calculated
164  //- Geometric standard deviation/density function
166 
167  //- Highest moment order
169 
170  //- Bins (representative volume/area/diameter)
172 
173  //- Bin component used according to chosen coordinate type
174  label binCmpt_;
175 
177  // Protected Member Functions
178 
179  //- Filter field according to cellIds
181 
182  //- Correct volume averages
183  void correctVolAverages();
184 
185  //- Write moments
186  void writeMoments();
187 
188  //- Write standard deviation
189  void writeStdDev();
190 
191  //- Write distribution
192  void writeDistribution();
193 
194  //- Output file header information for functionType moments
195  virtual void writeFileHeader(const label i);
196 
197  //- Output function for all functionType number/volume
198  void writeGraph
199  (
200  const coordSet& coords,
201  const word& functionTypeName,
202  const scalarField& values
203  );
204 
205 
206 public:
207 
208  //- Runtime type information
209  TypeName("sizeDistribution");
210 
211 
212  // Constructors
213 
214  //- Construct from Time and dictionary
216  (
217  const word& name,
218  const Time& runTime,
219  const dictionary& dict
220  );
221 
222  //- Disallow default bitwise copy construction
223  sizeDistribution(const sizeDistribution&) = delete;
224 
225 
226  //- Destructor
227  virtual ~sizeDistribution();
228 
229 
230  // Member Functions
231 
232  //- Read the sizeDistribution data
233  virtual bool read(const dictionary&);
234 
235  //- Execute, currently does nothing
236  virtual bool execute();
237 
238  //- Execute at the final time-loop, currently does nothing
239  virtual bool end();
240 
241  //- Calculate and write the size distribution
242  virtual bool write();
243 
244 
245  // Member Operators
246 
247  //- Disallow default bitwise assignment
248  void operator=(const sizeDistribution&) = delete;
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace functionObjects
255 } // End namespace Foam
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #endif
260 
261 // ************************************************************************* //
tmp< scalarField > filterField(const scalarField &field) const
Filter field according to cellIds.
dictionary dict
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
pointField bins_
Bins (representative volume/area/diameter)
functionType
Function type enumeration.
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Class that solves the univariate population balance equation by means of a class method (also called ...
virtual ~sizeDistribution()
Destructor.
autoPtr< setWriter< scalar > > scalarFormatter_
Output formatter, set to raw.
label binCmpt_
Bin component used according to chosen coordinate type.
void writeGraph(const coordSet &coords, const word &functionTypeName, const scalarField &values)
Output function for all functionType number/volume.
engineTime & runTime
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
label maxOrder_
Highest moment order.
virtual bool read(const dictionary &)
Read the sizeDistribution data.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
coordinateType coordinateType_
Abscissa type.
void writeStdDev()
Write standard deviation.
Switch normalise_
Normalise number/volume concentrations.
TypeName("sizeDistribution")
Runtime type information.
Holds list of sampling positions.
Definition: coordSet.H:49
This function object calculates and outputs volume-averaged information about the size distribution o...
virtual void writeFileHeader(const label i)
Output file header information for functionType moments.
A class for handling words, derived from string.
Definition: word.H:59
writeFile(const objectRegistry &obr, const word &prefix)
Construct from objectRegistry and prefix.
Definition: writeFile.C:85
virtual bool execute()
Execute, currently does nothing.
coordinateType
Coordinate type enumeration.
virtual bool write()
Calculate and write the size distribution.
static const NamedEnum< coordinateType, 4 > coordinateTypeNames_
Coordinate type names.
sizeDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
const fvMesh & mesh_
Reference to fvMesh.
scalarField a_
List of volume-averaged surface areas.
void writeDistribution()
Write distribution.
void correctVolAverages()
Correct volume averages.
writeFile file_
File containing data for all functionTypes except moments.
scalarField d_
List of volume-averaged diameters.
static const NamedEnum< functionType, 4 > functionTypeNames_
Ordinate type names.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
void operator=(const sizeDistribution &)=delete
Disallow default bitwise assignment.
functionType functionType_
Function to evaluate.
rDeltaTY field()
A class for managing temporary objects.
Definition: PtrList.H:53
const Foam::diameterModels::populationBalanceModel & popBal_
Reference to populationBalanceModel.
Switch densityFunction_
Determines whether density function is calculated.
virtual bool end()
Execute at the final time-loop, currently does nothing.
Switch geometric_
Geometric standard deviation/density function.
Namespace for OpenFOAM.
scalarField N_
List of volume-averaged number concentrations.