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 | Copyright (C) 2011-2015 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  - uniform
40 
41  The distributionModel is tabulated in equidistant nPoints, in an interval.
42  These values are integrated to obtain the cumulated distribution model,
43  which is then used to change the distribution from unifrom to
44  the actual distributionModel.
45 
46 SourceFiles
47  distributionModel.C
48  distributionModelNew.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef distributionModel_H
53 #define distributionModel_H
54 
55 #include "IOdictionary.H"
56 #include "autoPtr.H"
57 #include "cachedRandom.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 namespace distributionModels
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class distributionModel Declaration
68 \*---------------------------------------------------------------------------*/
69 
71 {
72 
73 protected:
74 
75  // Protected data
76 
77  //- Coefficients dictionary
79 
80  //- Reference to the random number generator
82 
83 
84  // Protected Member Functions
85 
86  //- Check that the distribution model is valid
87  virtual void check() const;
88 
89 
90 public:
91 
92  //-Runtime type information
93  TypeName("distributionModel");
94 
95 
96  //- Declare runtime constructor selection table
98  (
99  autoPtr,
101  dictionary,
102  (
103  const dictionary& dict,
105  ),
106  (dict, rndGen)
107  );
108 
109 
110  // Constructors
111 
112  //- Construct from dictionary
114  (
115  const word& name,
116  const dictionary& dict,
117  cachedRandom& rndGen
118  );
119 
120  //- Construct copy
122 
123  //- Construct and return a clone
124  virtual autoPtr<distributionModel> clone() const = 0;
125 
126 
127  //- Selector
129  (
130  const dictionary& dict,
131  cachedRandom& rndGen
132  );
133 
134 
135  //- Destructor
136  virtual ~distributionModel();
137 
138 
139  // Member Functions
140 
141  //- Sample the distributionModel
142  virtual scalar sample() const = 0;
143 
144  //- Return the minimum value
145  virtual scalar minValue() const = 0;
146 
147  //- Return the maximum value
148  virtual scalar maxValue() const = 0;
149 
150  //- Return the maximum value
151  virtual scalar meanValue() const = 0;
152 };
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 } // End namespace distributionModels
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #endif
163 
164 // ************************************************************************* //
cachedRandom rndGen(label(0),-1)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
const dictionary distributionModelDict_
Coefficients dictionary.
TypeName("distributionModel")
Runtime type information.
virtual scalar meanValue() const =0
Return the maximum value.
A class for handling words, derived from string.
Definition: word.H:59
virtual scalar maxValue() const =0
Return the maximum value.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual autoPtr< distributionModel > clone() const =0
Construct and return a clone.
Namespace for OpenFOAM.
cachedRandom & rndGen_
Reference to the random number generator.
virtual scalar minValue() const =0
Return the minimum value.
dictionary dict
declareRunTimeSelectionTable(autoPtr, distributionModel, dictionary,( const dictionary &dict, cachedRandom &rndGen ),(dict, rndGen))
Declare runtime constructor selection table.
virtual scalar sample() const =0
Sample the distributionModel.
volScalarField & p
Definition: createFields.H:51
distributionModel(const word &name, const dictionary &dict, cachedRandom &rndGen)
Construct from dictionary.
static autoPtr< distributionModel > New(const dictionary &dict, cachedRandom &rndGen)
Selector.
Random number generator.
Definition: cachedRandom.H:63
virtual void check() const
Check that the distribution model is valid.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117