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-2018 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  The distributionModel is tabulated in equidistant nPoints, in an interval.
43  These values are integrated to obtain the cumulated distribution model,
44  which is then used to change the distribution from unifrom to
45  the actual distributionModel.
46 
47 SourceFiles
48  distributionModel.C
49  distributionModelNew.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef distributionModel_H
54 #define distributionModel_H
55 
56 #include "IOdictionary.H"
57 #include "autoPtr.H"
58 #include "Random.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 
65 /*---------------------------------------------------------------------------*\
66  Class distributionModel Declaration
67 \*---------------------------------------------------------------------------*/
68 
70 {
71 
72 protected:
73 
74  // Protected data
75 
76  //- Coefficients dictionary
78 
79  //- Reference to the random number generator
80  Random& rndGen_;
81 
82 
83  // Protected Member Functions
84 
85  //- Check that the distribution model is valid
86  virtual void check() const;
87 
88 
89 public:
90 
91  //-Runtime type information
92  TypeName("distributionModel");
93 
94 
95  //- Declare runtime constructor selection table
97  (
98  autoPtr,
100  dictionary,
101  (
102  const dictionary& dict,
103  Random& rndGen
104  ),
105  (dict, rndGen)
106  );
107 
108 
109  // Constructors
110 
111  //- Construct from dictionary
113  (
114  const word& name,
115  const dictionary& dict,
116  Random& rndGen
117  );
118 
119  //- Construct copy
121 
122  //- Construct and return a clone
123  virtual autoPtr<distributionModel> clone() const = 0;
124 
125 
126  //- Selector
128  (
129  const dictionary& dict,
130  Random& rndGen
131  );
132 
133 
134  //- Destructor
135  virtual ~distributionModel();
136 
137 
138  // Member Functions
139 
140  //- Sample the distributionModel
141  virtual scalar sample() const = 0;
142 
143  //- Return the minimum value
144  virtual scalar minValue() const = 0;
145 
146  //- Return the maximum value
147  virtual scalar maxValue() const = 0;
148 
149  //- Return the maximum value
150  virtual scalar meanValue() const = 0;
151 };
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
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 maximum value.
Random rndGen(label(0))
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.