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-------------------------------------------------------------------------------
11License
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
27Namespace
28 Foam::distributionModels
29
30Description
31 A namespace for various probability distribution model implementations.
32
33Class
34 Foam::distributionModel
35
36Description
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
51SourceFiles
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
66namespace Foam
67{
68
69/*---------------------------------------------------------------------------*\
70 Class distributionModel Declaration
71\*---------------------------------------------------------------------------*/
74{
75protected:
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
98public:
99
100 //-Runtime type information
101 TypeName("distributionModel");
102
103
104 //- Declare runtime constructor selection table
106 (
107 autoPtr,
110 (
111 const dictionary& dict,
113 ),
114 (dict, rndGen)
115 );
116
117
118 // Constructors
119
120 //- Construct from dictionary
122 (
123 const word& name,
124 const dictionary& dict,
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,
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// ************************************************************************* //
Random number generator.
Definition: Random.H:60
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A library of runtime-selectable doubly-truncated probability distribution models. Returns random samp...
declareRunTimeSelectionTable(autoPtr, distributionModel, dictionary,(const dictionary &dict, Random &rndGen),(dict, rndGen))
Declare runtime constructor selection table.
const dictionary distributionModelDict_
Coefficients dictionary.
virtual void check() const
Check that the distribution model is valid.
virtual ~distributionModel()=default
Destructor.
Random & rndGen_
Reference to the random number generator.
virtual scalar maxValue() const
Return the maximum of the distribution.
virtual scalar sample() const =0
Sample the distribution.
static autoPtr< distributionModel > New(const dictionary &dict, Random &rndGen)
Selector.
TypeName("distributionModel")
Runtime type information.
scalar minValue_
Minimum of the distribution.
scalar maxValue_
Maximum of the distribution.
virtual autoPtr< distributionModel > clone() const =0
Construct and return a clone.
virtual scalar meanValue() const =0
virtual scalar minValue() const
Return the minimum of the distribution.
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
Random rndGen
Definition: createFields.H:23