uniform.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-2016 OpenFOAM Foundation
9 Copyright (C) 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::uniform
29
30Description
31 Particle-size distribution model wherein random samples are drawn
32 from the doubly-truncated uniform probability density function:
33
34 \f[
35 f(x; A, B) = \frac{1}{B - A}
36 \f]
37 where
38
39 \vartable
40 f(x; A, B) | Doubly-truncated uniform distribution
41 x | Sample
42 A | Minimum of the distribution
43 B | Maximum of the distribution
44 \endvartable
45
46 Constraints:
47 - \f$ \infty > B > A > 0 \f$
48 - \f$ x \in [B,A] \f$
49 - \f$ \sigma^2 > 0 \f$
50
51 Random samples are generated by the inverse transform sampling technique
52 by using the quantile function of the uniform probability density function:
53
54 \f[
55 x = u \, (B - A) + A
56 \f]
57
58 where \f$ u \f$ is sample drawn from the uniform probability
59 density function on the unit interval \f$ (0, 1) \f$.
60
61Usage
62 Minimal example by using \c constant/<CloudProperties>:
63 \verbatim
64 subModels
65 {
66 injectionModels
67 {
68 <name>
69 {
70 ...
71
72 sizeDistribution
73 {
74 type uniform;
75 uniformDistribution
76 {
77 minValue <min>;
78 maxValue <max>;
79 }
80 }
81 }
82 }
83 }
84 \endverbatim
85
86 where the entries mean:
87 \table
88 Property | Description | Type | Reqd | Deflt
89 type | Type name: uniform | word | yes | -
90 uniformDistribution | Distribution settings | dict | yes | -
91 minValue | Minimum of the distribution | scalar | yes | -
92 maxValue | Maximum of the distribution | scalar | yes | -
93 \endtable
94
95SourceFiles
96 uniform.C
97
98\*---------------------------------------------------------------------------*/
99
100#ifndef distributionModels_uniform_H
101#define distributionModels_uniform_H
102
103#include "distributionModel.H"
104
105// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106
107namespace Foam
108{
109namespace distributionModels
110{
111
112/*---------------------------------------------------------------------------*\
113 Class uniform Declaration
114\*---------------------------------------------------------------------------*/
115
116class uniform
117:
118 public distributionModel
119{
120public:
121
122 //- Runtime type information
123 TypeName("uniform");
124
125
126 // Constructors
127
128 //- Construct from components
129 uniform(const dictionary& dict, Random& rndGen);
130
131 //- Copy construct
132 uniform(const uniform& p);
133
134 //- Construct and return a clone
135 virtual autoPtr<distributionModel> clone() const
136 {
137 return autoPtr<distributionModel>(new uniform(*this));
138 }
139
140 //- No copy assignment
141 void operator=(const uniform&) = delete;
142
143
144 //- Destructor
145 virtual ~uniform() = default;
146
147
148 // Member Functions
149
150 //- Sample the distribution
151 virtual scalar sample() const;
152
153 //- Return the theoretical mean of the distribution
154 virtual scalar meanValue() const;
155};
156
157
158// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159
160} // End namespace distributionModels
161} // End namespace Foam
162
163// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164
165#endif
166
167// ************************************************************************* //
Random number generator.
Definition: Random.H:60
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
Particle-size distribution model wherein random samples are drawn from the doubly-truncated uniform p...
Definition: uniform.H:164
virtual scalar meanValue() const
Return the theoretical mean of the distribution.
Definition: uniform.C:71
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition: uniform.H:180
virtual scalar sample() const
Sample the distribution.
Definition: uniform.C:65
virtual ~uniform()=default
Destructor.
void operator=(const uniform &)=delete
No copy assignment.
uniform(const dictionary &dict, Random &rndGen)
Construct from components.
Definition: uniform.C:46
TypeName("uniform")
Runtime type information.
volScalarField & p
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
Random rndGen
Definition: createFields.H:23