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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::distributionModel
28 
29 Description
30  A library of runtime-selectable distribution models.
31 
32  Returns a sampled value given the expectation (nu) and variance (sigma^2)
33 
34  Current distribution models include:
35  - exponential
36  - fixedValue
37  - general
38  - multi-normal
39  - normal
40  - Rosin-Rammler
41  - Mass-based Rosin-Rammler
42  - uniform
43 
44  The distributionModel is tabulated in equidistant nPoints, in an interval.
45  These values are integrated to obtain the cumulated distribution model,
46  which is then used to change the distribution from unifrom to
47  the actual distributionModel.
48 
49 SourceFiles
50  distributionModel.C
51  distributionModelNew.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef distributionModel_H
56 #define distributionModel_H
57 
58 #include "IOdictionary.H"
59 #include "autoPtr.H"
60 #include "Random.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class distributionModel Declaration
69 \*---------------------------------------------------------------------------*/
70 
72 {
73 
74 protected:
75 
76  // Protected data
77 
78  //- Coefficients dictionary
80 
81  //- Reference to the random number generator
82  Random& rndGen_;
83 
84 
85  // Protected Member Functions
86 
87  //- Check that the distribution model is valid
88  virtual void check() const;
89 
90 
91 public:
92 
93  //-Runtime type information
94  TypeName("distributionModel");
95 
96 
97  //- Declare runtime constructor selection table
99  (
100  autoPtr,
102  dictionary,
103  (
104  const dictionary& dict,
105  Random& rndGen
106  ),
107  (dict, rndGen)
108  );
109 
110 
111  // Constructors
112 
113  //- Construct from dictionary
115  (
116  const word& name,
117  const dictionary& dict,
118  Random& rndGen
119  );
120 
121  //- Construct copy
123 
124  //- Construct and return a clone
125  virtual autoPtr<distributionModel> clone() const = 0;
126 
127 
128  //- Selector
130  (
131  const dictionary& dict,
132  Random& rndGen
133  );
134 
135 
136  //- Destructor
137  virtual ~distributionModel();
138 
139 
140  // Member Functions
141 
142  //- Sample the distributionModel
143  virtual scalar sample() const = 0;
144 
145  //- Return the minimum value
146  virtual scalar minValue() const = 0;
147 
148  //- Return the maximum value
149  virtual scalar maxValue() const = 0;
150 
151  //- Return the maximum value
152  virtual scalar meanValue() const = 0;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
Foam::distributionModel::rndGen_
Random & rndGen_
Reference to the random number generator.
Definition: distributionModel.H:81
Foam::distributionModel::check
virtual void check() const
Check that the distribution model is valid.
Definition: distributionModel.C:41
Foam::Random
Random number generator.
Definition: Random.H:59
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::distributionModel::clone
virtual autoPtr< distributionModel > clone() const =0
Construct and return a clone.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::distributionModel::TypeName
TypeName("distributionModel")
Runtime type information.
Foam::distributionModel
A library of runtime-selectable distribution models.
Definition: distributionModel.H:70
Foam::distributionModel::meanValue
virtual scalar meanValue() const =0
Return the maximum value.
Foam::distributionModel::maxValue
virtual scalar maxValue() const =0
Return the maximum value.
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::distributionModel::distributionModel
distributionModel(const word &name, const dictionary &dict, Random &rndGen)
Construct from dictionary.
Definition: distributionModel.C:65
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Random.H
Foam::distributionModel::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, distributionModel, dictionary,(const dictionary &dict, Random &rndGen),(dict, rndGen))
Declare runtime constructor selection table.
Foam::distributionModel::New
static autoPtr< distributionModel > New(const dictionary &dict, Random &rndGen)
Selector.
Definition: distributionModelNew.C:34
IOdictionary.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::distributionModel::sample
virtual scalar sample() const =0
Sample the distributionModel.
Foam::distributionModel::distributionModelDict_
const dictionary distributionModelDict_
Coefficients dictionary.
Definition: distributionModel.H:78
Foam::distributionModel::minValue
virtual scalar minValue() const =0
Return the minimum value.
rndGen
Random rndGen
Definition: createFields.H:23
Foam::distributionModel::~distributionModel
virtual ~distributionModel()
Destructor.
Definition: distributionModel.C:88
autoPtr.H