All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
standardNormal.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) 2024 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::standardNormal
26 
27 Description
28  Standard normal distribution. Not selectable.
29 
30  \f[
31  PDF(x) = \frac{1}{\sqrt{2 \pi}} \exp \left( - \frac{1}{2} x^2 \right)
32  \f]
33 
34 SourceFiles
35  standardNormal.C
36 
37 See also
38  Foam::distribution
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef standardNormal_H
43 #define standardNormal_H
44 
45 #include "unintegrable.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 namespace distributions
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class standardNormal Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class standardNormal
59 :
60  public FieldDistribution<distribution, standardNormal>
61 {
62  // Private Data
63 
64  //- Constant for approximate error function and inverse error function
65  static const scalar a_;
66 
67 
68 public:
69 
70  //- Runtime type information
71  TypeName("standardNormal");
72 
73 
74  //- Permit the multiNormal distribution to use private parts of this class
75  friend class multiNormal;
76 
77 
78  // Static Member Functions
79 
80  //- Approximate error function
81  static tmp<scalarField> approxErf(const scalarField& x);
82 
83  //- Approximate error function inverse
84  static scalar approxErfInv(const scalar y);
85 
86 
87  // Constructors
88 
89  //- Construct from a random generator
91 
92  //- Construct from a seed
94  (
95  const randomGenerator::seed& s,
96  const bool global = false
97  );
98 
99  //- Construct copy
100  standardNormal(const standardNormal& d);
101 
102  //- Construct and return a clone
103  virtual autoPtr<distribution> clone(const label sampleQ) const
104  {
105  return autoPtr<distribution>(new standardNormal(*this));
106  }
107 
108 
109  //- Destructor
110  virtual ~standardNormal();
111 
112 
113  // Member Functions
114 
115  //- Sample the distribution
116  virtual scalar sample() const;
117 
118  //- Sample the distribution
120 
121  //- Return the minimum value
122  virtual scalar min() const;
123 
124  //- Return the maximum value
125  virtual scalar max() const;
126 
127  //- Return the mean value
128  virtual scalar mean() const;
129 
130  //- Return coordinates to plot across the range of the distribution
131  virtual tmp<scalarField> x(const label n) const;
132 
133  //- Return the distribution probability density function
134  virtual tmp<scalarField> PDF(const scalarField& x) const;
135 };
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace distributions
141 } // End namespace Foam
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #endif
146 
147 // ************************************************************************* //
scalar y
label n
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
autoPtr< distribution > clone() const
Construct and return a clone.
Definition: distribution.H:168
Multiple superimposed normal distributions.
Definition: multiNormal.H:75
Standard normal distribution. Not selectable.
static tmp< scalarField > approxErf(const scalarField &x)
Approximate error function.
virtual scalar min() const
Return the minimum value.
virtual ~standardNormal()
Destructor.
virtual scalar sample() const
Sample the distribution.
virtual tmp< scalarField > PDF(const scalarField &x) const
Return the distribution probability density function.
TypeName("standardNormal")
Runtime type information.
virtual tmp< scalarField > x(const label n) const
Return coordinates to plot across the range of the distribution.
static scalar approxErfInv(const scalar y)
Approximate error function inverse.
standardNormal(randomGenerator &&rndGen)
Construct from a random generator.
virtual scalar max() const
Return the maximum value.
virtual scalar mean() const
Return the mean value.
Random number generator.
A class for managing temporary objects.
Definition: tmp.H:55
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
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
randomGenerator rndGen(653213)