multiNormal.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-2023 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::distributions::multiNormal
26 
27 Description
28  Multiple superimposed normal distributions
29 
30  \f[
31  PDF(x) = \sum_i S_i \frac{1}{\sigma_i \sqrt{2 \pi}} \\
32  \exp \left( \frac{1}{2} \left( \frac{x - \mu_i}{\sigma_i} \\
33  \right)^2 \right)
34  \f]
35 
36 Usage
37  Example usage:
38  \verbatim
39  {
40  type multiNormal;
41  Q 0;
42  min 0.001;
43  max 0.019;
44  mu (0.005 0.011 0.015);
45  sigma (0.002 0.001 0.0015);
46  strength (2 1 3);
47  }
48  \endverbatim
49 
50 SourceFiles
51  multiNormal.C
52 
53 See also
54  Foam::distribution
55  Foam::distributions::normal
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef multiNormal_H
60 #define multiNormal_H
61 
62 #include "normal.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 namespace distributions
69 {
70 
71 /*---------------------------------------------------------------------------*\
72  Class multiNormal Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 class multiNormal
76 :
77  public FieldDistribution<unintegrableForNonZeroQ, multiNormal>
78 {
79  // Private Data
80 
81  //- Relative strengths of the different distributions
82  const scalarList cumulativeStrengths_;
83 
84  //- Normal distributions
85  PtrList<normal> distributions_;
86 
87 
88  // Private Member Functions
89 
90  //- Normalise the strengths
91  static scalarList readCumulativeStrengths(const dictionary& dict);
92 
93  //- Return values of the un-multiNormalised PDF for the given size
94  // exponent and x-coordinates.
95  virtual tmp<scalarField> phi
96  (
97  const label q,
98  const scalarField& x
99  ) const;
100 
101  //- Return values of the un-multiNormalised CDF for the given size
102  // exponent and x-coordinates.
103  virtual tmp<scalarField> Phi
104  (
105  const label q,
106  const scalarField& x
107  ) const;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeName("multiNormal");
114 
115 
116  // Constructors
117 
118  //- Construct from a dictionary
120  (
121  const dictionary& dict,
122  Random& rndGen,
123  const label sampleQ
124  );
125 
126  //- Construct copy
127  multiNormal(const multiNormal& d, const label sampleQ);
128 
129  //- Construct and return a clone
130  virtual autoPtr<distribution> clone(const label sampleQ) const
131  {
132  return autoPtr<distribution>(new multiNormal(*this, sampleQ));
133  }
134 
135 
136  //- Destructor
137  virtual ~multiNormal();
138 
139 
140  // Member Functions
141 
142  //- Sample the distribution
143  virtual scalar sample() const;
144 
145  //- Sample the distribution
147 
148  //- Return the minimum value
149  virtual scalar min() const;
150 
151  //- Return the maximum value
152  virtual scalar max() const;
153 
154  //- Return coordinates to plot across the range of the distribution
155  virtual tmp<scalarField> x(const label n) const;
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace distributions
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
label n
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Random number generator.
Definition: Random.H:58
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Multiple superimposed normal distributions.
Definition: multiNormal.H:75
multiNormal(const dictionary &dict, Random &rndGen, const label sampleQ)
Construct from a dictionary.
Definition: multiNormal.C:114
virtual autoPtr< distribution > clone(const label sampleQ) const
Construct and return a clone.
Definition: multiNormal.H:127
virtual scalar min() const
Return the minimum value.
Definition: multiNormal.C:248
virtual scalar sample() const
Sample the distribution.
Definition: multiNormal.C:225
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
Definition: multiNormal.C:261
virtual ~multiNormal()
Destructor.
Definition: multiNormal.C:219
virtual scalar max() const
Return the maximum value.
Definition: multiNormal.C:254
TypeName("multiNormal")
Runtime type information.
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dictionary dict
Random rndGen(label(0))