Loading...
Searching...
No Matches
general.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2019 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::distributionModels::general
29
30Description
31 Particle-size distribution model wherein random samples are
32 drawn from a given arbitrary probability density function
33 or cumulative distribution function. Input distributions are
34 specified as pairs of (size, probability) (i.e. (point, value) ).
35
36Usage
37 Minimal example by using \c constant/<CloudProperties>:
38 \verbatim
39 subModels
40 {
41 injectionModels
42 {
43 <name>
44 {
45 ...
46
47 sizeDistribution
48 {
49 type general;
50 generalDistribution
51 {
52 cumulative false;
53
54 distribution
55 (
56 (<size1> <probability1>)
57 (<size2> <probability2>)
58 ...
59 (<sizeN> <probabilityN>)
60 );
61 }
62 }
63 }
64 }
65 }
66 \endverbatim
67
68 where the entries mean:
69 \table
70 Property | Description | Type | Reqd | Deflt
71 type | Type name: general | word | yes | -
72 generalDistribution | Distribution settings | dict | yes | -
73 distribution | <size>-<probability> pairs | dict | yes | -
74 <size> | Particle size | scalar | yes | -
75 <probability> | Volume fraction/probability | scalar | yes | -
76 cumulative | Flag to determine if input distribution is specified <!--
77 --> as cumulative or as density | bool | no | false
78 \endtable
79
80Note
81 - An example for a pair within \c distribution subdictionary
82 can be given as follows: "(1e-07 1.3)" means 1.3\% of particles
83 are modelled with a particle diameter of "1e-7" [m], and so on.
84 - Variation between input pairs is assumed to be linear.
85 - Elements in the second column (i.e. probability) are normalised.
86 - Elements in the second column for cumulative distribution
87 functions must start from zero and must be non-decreasing (i.e. monotonic).
88 - Elements in the first column (i.e. size) must be specified
89 in an ascending order.
90 - Input pairs cannot contain any negative element.
91
92SourceFiles
93 general.C
94
95\*---------------------------------------------------------------------------*/
96
97#ifndef distributionModels_general_H
98#define distributionModels_general_H
99
100#include "distributionModel.H"
101#include "Vector.H"
102#include "VectorSpace.H"
103#include "Field.H"
104
105// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106
107namespace Foam
108{
109namespace distributionModels
110{
111 // Forward Declarations
112 class general;
113}
114
115// Forward Declarations
118
119namespace distributionModels
120{
121
122/*---------------------------------------------------------------------------*\
123 Class general Declaration
124\*---------------------------------------------------------------------------*/
125
126class general
127:
128 public distributionModel
129{
130 typedef VectorSpace<Vector<scalar>, scalar, 2> pair;
131
132 // Private Data
133
134 //- List of (x, y=f(x)) pairs
135 List<pair> xy_;
136
137 //- Number of entries in the xy_ list
138 label nEntries_;
139
140 //- Mean of the distribution
141 scalar meanValue_;
142
143 //- Values of cumulative distribution function
144 List<scalar> integral_;
145
146 //- Flag to determine if input is specified as cumulative or as density
147 bool cumulative_;
148
149
150 // Private Member Functions
151
152 //- Initialise the distribution parameters
153 void initialise();
154
155
156public:
157
158 //- Runtime type information
159 TypeName("general");
160
161
162 // Constructors
163
164 //- Construct from components
166
167 //- Construct from components
168 // Allows negative entries
169 general
170 (
171 const UList<scalar>& sampleData,
172 const scalar binWidth,
174 );
175
176 //- Copy construct
177 general(const general& p);
178
179 //- Construct and return a clone
180 virtual autoPtr<distributionModel> clone() const
181 {
182 return autoPtr<distributionModel>(new general(*this));
183 }
184
185 //- No copy assignment
186 void operator=(const general&) = delete;
187
188
189 //- Destructor
190 virtual ~general() = default;
191
192
193 // Member Functions
194
195 //- Bin boundaries
196 virtual tmp<scalarField> x() const;
197
198 //- Probabilities
199 virtual tmp<scalarField> y() const;
200
201 //- Sample the distribution
202 virtual scalar sample() const;
203
204 //- Return the arithmetic mean of the distribution data
205 virtual scalar meanValue() const;
206
207 //- Write data to stream
208 virtual void writeData(Ostream& os) const;
209
210 //- Read data from stream
211 virtual void readData(Istream& os);
213 //- Write data in dictionary format
214 virtual dictionary writeDict(const word& dictName) const;
215
216 //- Read data from dictionary
217 virtual void readDict(const dictionary& dict);
218};
219
220
221// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222
223} // End namespace distributionModels
224} // End namespace Foam
225
226// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227
228#endif
229
230// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Random number generator.
Definition Random.H:56
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Templated vector space.
Definition VectorSpace.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
Particle-size distribution model wherein random samples are drawn from a given arbitrary probability ...
Definition general.H:168
virtual scalar meanValue() const
Return the arithmetic mean of the distribution data.
Definition general.C:274
virtual tmp< scalarField > y() const
Probabilities.
Definition general.C:341
virtual dictionary writeDict(const word &dictName) const
Write data in dictionary format.
Definition general.C:296
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition general.H:242
virtual tmp< scalarField > x() const
Bin boundaries.
Definition general.C:327
virtual void writeData(Ostream &os) const
Write data to stream.
Definition general.C:288
virtual scalar sample() const
Sample the distribution.
Definition general.C:229
void operator=(const general &)=delete
No copy assignment.
virtual void readDict(const dictionary &dict)
Read data from dictionary.
Definition general.C:309
virtual void readData(Istream &os)
Read data from stream.
Definition general.C:280
general(const dictionary &dict, Random &rndGen)
Construct from components.
Definition general.C:90
TypeName("general")
Runtime type information.
virtual ~general()=default
Destructor.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const word dictName("faMeshDefinition")
A namespace for various probability distribution model implementations.
Definition binned.C:29
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68
Random rndGen