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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::distributionModels::uniform
29 
30 Description
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 
61 Usage
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 
95 SourceFiles
96  uniform.C
97 
98 \*---------------------------------------------------------------------------*/
99 
100 #ifndef distributionModels_uniform_H
101 #define distributionModels_uniform_H
102 
103 #include "distributionModel.H"
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 namespace distributionModels
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class uniform Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 class uniform
117 :
118  public distributionModel
119 {
120 public:
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 // ************************************************************************* //
Foam::Random
Random number generator.
Definition: Random.H:59
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::distributionModels::uniform::~uniform
virtual ~uniform()=default
Destructor.
Foam::distributionModel
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
Definition: distributionModel.H:72
Foam::distributionModels::uniform::sample
virtual scalar sample() const
Sample the distribution.
Definition: uniform.C:65
Foam::distributionModels::uniform::operator=
void operator=(const uniform &)=delete
No copy assignment.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::distributionModels::uniform::uniform
uniform(const dictionary &dict, Random &rndGen)
Construct from components.
Definition: uniform.C:46
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::distributionModels::uniform
Particle-size distribution model wherein random samples are drawn from the doubly-truncated uniform p...
Definition: uniform.H:161
Foam::distributionModels::uniform::clone
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition: uniform.H:180
rndGen
Random rndGen
Definition: createFields.H:23
Foam::distributionModels::uniform::meanValue
virtual scalar meanValue() const
Return the theoretical mean of the distribution.
Definition: uniform.C:71
Foam::distributionModels::uniform::TypeName
TypeName("uniform")
Runtime type information.
distributionModel.H