tabulatedCumulative.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::tabulatedCumulative
26 
27 Description
28  Distribution in which the cumulative distribution function is given as a
29  table of values
30 
31 Usage
32  Example usage:
33  \verbatim
34  {
35  type tabulatedCumulative;
36  Q 0;
37  values
38  (
39  (10e-6 0)
40  (12e-6 0.1972235)
41  (15e-6 2.6711166)
42  (19e-6 11.643361)
43  (25e-6 28.968245)
44  (31e-6 52.155796)
45  (39e-6 74.381959)
46  (50e-6 91.162850)
47  (63e-6 100)
48  );
49  }
50  \endverbatim
51 
52 SourceFiles
53  tabulatedCumulative.C
54 
55 See also
56  Foam::distribution
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef tabulatedCumulative_H
61 #define tabulatedCumulative_H
62 
63 #include "distribution.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 namespace distributions
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class tabulatedCumulative Declaration
74 \*---------------------------------------------------------------------------*/
75 
77 :
78  public FieldDistribution<distribution, tabulatedCumulative>
79 {
80 private:
81 
82  // Private Data
83 
84  //- X-coordinates
85  scalarField x_;
86 
87  //- Probability Density Function
88  scalarField PDF_;
89 
90  //- Cumulative Distribution Function
91  scalarField CDF_;
92 
93 
94 public:
95 
96  //- Runtime type information
97  TypeName("tabulatedCumulative");
98 
99 
100  // Constructors
101 
102  //- Construct from a dictionary
104  (
105  const unitConversion& units,
106  const dictionary& dict,
107  const label sampleQ,
109  );
110 
111  //- Construct copy
112  tabulatedCumulative(const tabulatedCumulative& d, const label sampleQ);
113 
114  //- Construct and return a clone
115  virtual autoPtr<distribution> clone(const label sampleQ) const
116  {
117  return autoPtr<distribution>
118  (
119  new tabulatedCumulative(*this, sampleQ)
120  );
121  }
122 
123 
124  //- Destructor
125  virtual ~tabulatedCumulative();
126 
127 
128  // Member Functions
129 
130  //- Sample the distribution
131  virtual scalar sample() const;
132 
133  //- Sample the distribution
135 
136  //- Return the minimum value
137  virtual scalar min() const;
138 
139  //- Return the maximum value
140  virtual scalar max() const;
141 
142  //- Return the mean value
143  virtual scalar mean() const;
144 
145  //- Write to a stream
146  virtual void write(Ostream& os, const unitConversion& units) const;
147 
148  //- Return coordinates to plot across the range of the distribution
149  virtual tmp<scalarField> x(const label n) const;
150 
151  //- Return the distribution probability density function
152  virtual tmp<scalarField> PDF(const scalarField& x) const;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace distributions
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
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
autoPtr< distribution > clone() const
Construct and return a clone.
Definition: distribution.H:168
Distribution in which the cumulative distribution function is given as a table of values.
TypeName("tabulatedCumulative")
Runtime type information.
virtual scalar min() const
Return the minimum value.
virtual scalar sample() const
Sample the distribution.
virtual tmp< scalarField > PDF(const scalarField &x) const
Return the distribution probability density function.
tabulatedCumulative(const unitConversion &units, const dictionary &dict, const label sampleQ, randomGenerator &&rndGen)
Construct from a dictionary.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
virtual void write(Ostream &os, const unitConversion &units) const
Write to a stream.
virtual scalar max() const
Return the maximum value.
virtual scalar mean() const
Return the mean value.
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)