distributionModel.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-2017 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 Namespace
28  Foam::distributionModels
29 
30 Description
31  A namespace for various probability distribution model implementations.
32 
33 Class
34  Foam::distributionModel
35 
36 Description
37  A library of runtime-selectable doubly-truncated probability distribution
38  models. Returns random samples based on given distribution parameters.
39 
40  Available distribution models include:
41  - binned
42  - exponential
43  - fixedValue
44  - general
45  - multi-normal
46  - normal
47  - Rosin-Rammler
48  - Mass-based Rosin-Rammler
49  - uniform
50 
51 SourceFiles
52  distributionModel.C
53  distributionModelNew.C
54 
55 \*---------------------------------------------------------------------------*/
56 
57 #ifndef distributionModel_H
58 #define distributionModel_H
59 
60 #include "IOdictionary.H"
61 #include "autoPtr.H"
62 #include "Random.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class distributionModel Declaration
71 \*---------------------------------------------------------------------------*/
72 
74 {
75 protected:
76 
77  // Protected Data
78 
79  //- Coefficients dictionary
81 
82  //- Reference to the random number generator
84 
85  //- Minimum of the distribution
86  scalar minValue_;
87 
88  //- Maximum of the distribution
89  scalar maxValue_;
90 
91 
92  // Protected Member Functions
93 
94  //- Check that the distribution model is valid
95  virtual void check() const;
96 
97 
98 public:
99 
100  //-Runtime type information
101  TypeName("distributionModel");
102 
103 
104  //- Declare runtime constructor selection table
106  (
107  autoPtr,
109  dictionary,
110  (
111  const dictionary& dict,
112  Random& rndGen
113  ),
114  (dict, rndGen)
115  );
116 
117 
118  // Constructors
119 
120  //- Construct from dictionary
122  (
123  const word& name,
124  const dictionary& dict,
125  Random& rndGen
126  );
127 
128  //- Copy construct
130 
131  //- Construct and return a clone
132  virtual autoPtr<distributionModel> clone() const = 0;
133 
134 
135  //- Selector
137  (
138  const dictionary& dict,
139  Random& rndGen
140  );
141 
142 
143  //- Destructor
144  virtual ~distributionModel() = default;
145 
146 
147  // Member Functions
148 
149  //- Sample the distribution
150  virtual scalar sample() const = 0;
151 
152  //- Return the minimum of the distribution
153  virtual scalar minValue() const;
154 
155  //- Return the maximum of the distribution
156  virtual scalar maxValue() const;
157 
158  //- Return the theoretical mean of the distribution, or
159  //- the arithmetic mean of the distribution data
160  virtual scalar meanValue() const = 0;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
dictionary dict
scalar maxValue_
Maximum of the distribution.
TypeName("distributionModel")
Runtime type information.
Random & rndGen_
Reference to the random number generator.
virtual ~distributionModel()=default
Destructor.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual autoPtr< distributionModel > clone() const =0
Construct and return a clone.
Random rndGen
Definition: createFields.H:23
declareRunTimeSelectionTable(autoPtr, distributionModel, dictionary,(const dictionary &dict, Random &rndGen),(dict, rndGen))
Declare runtime constructor selection table.
virtual scalar meanValue() const =0
Return the theoretical mean of the distribution, or the arithmetic mean of the distribution data...
virtual scalar maxValue() const
Return the maximum of the distribution.
virtual scalar sample() const =0
Sample the distribution.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
virtual scalar minValue() const
Return the minimum of the distribution.
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void check() const
Check that the distribution model is valid.
scalar minValue_
Minimum of the distribution.
Random number generator.
Definition: Random.H:55
static autoPtr< distributionModel > New(const dictionary &dict, Random &rndGen)
Selector.
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
const dictionary distributionModelDict_
Coefficients dictionary.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
volScalarField & p
Namespace for OpenFOAM.