exponential.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) 2011-2024 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::distributions::exponential
26 
27 Description
28  Exponential distribution, scaled so that it spans between a specified
29  minimum and maximum value, rather than from zero to infinity
30 
31  \f[
32  PDF(x) = \lambda \exp(- \lambda x)
33  \f]
34 
35 Usage
36  Example usage:
37  \verbatim
38  {
39  type exponential;
40  Q 3;
41  min 0.01;
42  max 0.5;
43  lambda 3;
44  }
45  \endverbatim
46 
47 SourceFiles
48  exponential.C
49 
50 See also
51  Foam::distribution
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef exponential_H
56 #define exponential_H
57 
58 #include "unintegrable.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 namespace distributions
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class exponential Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 class exponential
72 :
73  public FieldDistribution<unintegrableForNonZeroQ, exponential>
74 {
75  // Private Data
76 
77  //- Minimum value
78  const scalar min_;
79 
80  //- Maximum value
81  const scalar max_;
82 
83  //- Parameter
84  const scalar lambda_;
85 
86 
87  // Private Member Functions
88 
89  //- Return values of the un-normalised PDF for the given size exponent
90  // and x-coordinates.
91  virtual tmp<scalarField> phi
92  (
93  const label q,
94  const scalarField& x
95  ) const;
96 
97  //- Return values of the un-normalised CDF for the given size exponent
98  // and x-coordinates.
99  virtual tmp<scalarField> Phi
100  (
101  const label q,
102  const scalarField& x
103  ) const;
104 
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("exponential");
110 
111 
112  // Constructors
113 
114  //- Construct from a dictionary
116  (
117  const unitConversion& units,
118  const dictionary& dict,
119  const label sampleQ,
121  );
122 
123  //- Construct copy
124  exponential(const exponential& d, const label sampleQ);
125 
126  //- Construct and return a clone
127  virtual autoPtr<distribution> clone(const label sampleQ) const
128  {
129  return autoPtr<distribution>(new exponential(*this, sampleQ));
130  }
131 
132 
133  //- Destructor
134  virtual ~exponential();
135 
136 
137  // Member Functions
138 
139  //- Sample the distribution
140  virtual scalar sample() const;
141 
142  //- Sample the distribution
144 
145  //- Return the minimum value
146  virtual scalar min() const;
147 
148  //- Return the maximum value
149  virtual scalar max() const;
150 
151  //- Write to a stream
152  virtual void write(Ostream& os, const unitConversion& units) const;
153 
154  //- Return coordinates to plot across the range of the distribution
155  virtual tmp<scalarField> x(const label n) const;
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace distributions
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
label n
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Exponential distribution, scaled so that it spans between a specified minimum and maximum value,...
Definition: exponential.H:73
exponential(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
Definition: exponential.C:73
virtual autoPtr< distribution > clone(const label sampleQ) const
Construct and return a clone.
Definition: exponential.H:126
virtual scalar min() const
Return the minimum value.
Definition: exponential.C:135
virtual scalar sample() const
Sample the distribution.
Definition: exponential.C:119
TypeName("exponential")
Runtime type information.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
Definition: exponential.C:162
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
Definition: exponential.C:148
virtual scalar max() const
Return the maximum value.
Definition: exponential.C:141
virtual ~exponential()
Destructor.
Definition: exponential.C:113
Random number generator.
A class for managing temporary objects.
Definition: tmp.H:55
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
Namespace for OpenFOAM.
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
const HashTable< unitConversion > & units()
Get the table of unit conversions.
dictionary dict
randomGenerator rndGen(653213)