multiNormal.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-2013 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::multiNormal
26 
27 Description
28  A multiNormal distribution model
29 
30  \verbatim
31  model = sum_i strength_i * exp(-0.5*((x - expectation_i)/variance_i)^2 )
32  \endverbatim
33 
34 
35 SourceFiles
36  multiNormal.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef multiNormal_H
41 #define multiNormal_H
42 
43 #include "distributionModel.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace distributionModels
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class multiNormal Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class multiNormal
57 :
58  public distributionModel
59 {
60  // Private data
61 
62  //- Distribution minimum
63  scalar minValue_;
64 
65  //- Distribution maximum
66  scalar maxValue_;
67 
68  //- Distribution range
69  scalar range_;
70 
71 
72  // Model coefficients
73 
74  List<scalar> expectation_;
75  List<scalar> variance_;
76  List<scalar> strength_;
77 
78 
79 public:
80 
81  //- Runtime type information
82  TypeName("multiNormal");
83 
84 
85  // Constructors
86 
87  //- Construct from components
89 
90  //- Construct copy
91  multiNormal(const multiNormal& p);
92 
93  //- Construct and return a clone
94  virtual autoPtr<distributionModel> clone() const
95  {
96  return autoPtr<distributionModel>(new multiNormal(*this));
97  }
98 
99 
100  //- Destructor
101  virtual ~multiNormal();
102 
103 
104  // Member Functions
105 
106  //- Sample the distributionModel
107  virtual scalar sample() const;
108 
109  //- Return the minimum value
110  virtual scalar minValue() const;
111 
112  //- Return the maximum value
113  virtual scalar maxValue() const;
114 
115  //- Return the mean value
116  virtual scalar meanValue() const;
117 };
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace distributionModels
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #endif
128 
129 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual scalar minValue() const
Return the minimum value.
Definition: multiNormal.C:136
Random number generator.
Definition: cachedRandom.H:63
TypeName("multiNormal")
Runtime type information.
virtual autoPtr< distributionModel > clone() const
Construct and return a clone.
Definition: multiNormal.H:93
virtual scalar meanValue() const
Return the mean value.
Definition: multiNormal.C:148
cachedRandom rndGen(label(0), -1)
virtual scalar maxValue() const
Return the maximum value.
Definition: multiNormal.C:142
A library of runtime-selectable distribution models.
virtual scalar sample() const
Sample the distributionModel.
Definition: multiNormal.C:104
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
multiNormal(const dictionary &dict, cachedRandom &rndGen)
Construct from components.
Definition: multiNormal.C:43
virtual ~multiNormal()
Destructor.
Definition: multiNormal.C:98
Namespace for OpenFOAM.