distributionModel.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-2019 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::distributionModel
26 
27 Description
28  A library of runtime-selectable distribution models.
29 
30  Returns a sampled value given the expectation (nu) and variance (sigma^2)
31 
32  Current distribution models include:
33  - exponential
34  - fixedValue
35  - general
36  - multi-normal
37  - normal
38  - Rosin-Rammler
39  - Mass-based Rosin-Rammler
40  - uniform
41 
42 SourceFiles
43  distributionModel.C
44  distributionModelNew.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef distributionModel_H
49 #define distributionModel_H
50 
51 #include "IOdictionary.H"
52 #include "autoPtr.H"
53 #include "Random.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class distributionModel Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66 
67 protected:
68 
69  // Protected data
70 
71  //- Coefficients dictionary
73 
74  //- Reference to the random number generator
75  Random& rndGen_;
76 
77 
78  // Protected Member Functions
79 
80  //- Check that the distribution model is valid
81  virtual void check() const;
82 
83  //- Print information about the distribution
84  void info() const;
85 
86 
87 public:
88 
89  //-Runtime type information
90  TypeName("distributionModel");
91 
92 
93  //- Declare runtime constructor selection table
95  (
96  autoPtr,
98  dictionary,
99  (
100  const dictionary& dict,
101  Random& rndGen
102  ),
103  (dict, rndGen)
104  );
105 
106 
107  // Constructors
108 
109  //- Construct from dictionary
111  (
112  const word& name,
113  const dictionary& dict,
114  Random& rndGen
115  );
116 
117  //- Construct copy
119 
120  //- Construct and return a clone
121  virtual autoPtr<distributionModel> clone() const = 0;
122 
123 
124  //- Selector
126  (
127  const dictionary& dict,
128  Random& rndGen
129  );
130 
131 
132  //- Destructor
133  virtual ~distributionModel();
134 
135 
136  // Member Functions
137 
138  //- Sample the distributionModel
139  virtual scalar sample() const = 0;
140 
141  //- Return the minimum value
142  virtual scalar minValue() const = 0;
143 
144  //- Return the maximum value
145  virtual scalar maxValue() const = 0;
146 
147  //- Return the mean value
148  virtual scalar meanValue() const = 0;
149 };
150 
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 } // End namespace Foam
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #endif
159 
160 // ************************************************************************* //
dictionary dict
TypeName("distributionModel")
Runtime type information.
Random & rndGen_
Reference to the random number generator.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual autoPtr< distributionModel > clone() const =0
Construct and return a clone.
virtual scalar minValue() const =0
Return the minimum value.
virtual scalar maxValue() const =0
Return the maximum value.
declareRunTimeSelectionTable(autoPtr, distributionModel, dictionary,(const dictionary &dict, Random &rndGen),(dict, rndGen))
Declare runtime constructor selection table.
virtual scalar meanValue() const =0
Return the mean value.
Random rndGen(label(0))
void info() const
Print information about the distribution.
virtual scalar sample() const =0
Sample the distributionModel.
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
A class for handling words, derived from string.
Definition: word.H:59
virtual void check() const
Check that the distribution model is valid.
virtual ~distributionModel()
Destructor.
Random number generator.
Definition: Random.H:57
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static autoPtr< distributionModel > New(const dictionary &dict, Random &rndGen)
Selector.
A library of runtime-selectable distribution models.
const dictionary distributionModelDict_
Coefficients dictionary.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
Namespace for OpenFOAM.