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