Random.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::Random
26 
27 Description
28  Simple random number generator.
29 
30 SourceFiles
31  Random.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef Random_H
36 #define Random_H
37 
38 #include "vector.H"
39 #include "tensor.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class Random Declaration
48 \*---------------------------------------------------------------------------*/
49 
50 class Random
51 {
52  // Private data
53 
54  label Seed;
55 
56 
57 public:
58 
59 
60  // Constructors
61 
62  //- Construct given seed
63  Random(const label);
64 
65 
66  // Member functions
67 
68  int bit();
69 
70  //- Scalar [0..1] (so including 0,1)
71  scalar scalar01();
72 
73  //- Vector with every component scalar01
74  vector vector01();
75 
76  //- sphericalTensor with every component scalar01
78 
79  //- symmTensor with every component scalar01
81 
82  //- Tensor with every component scalar01
83  tensor tensor01();
84 
85  //- Label [lower..upper]
86  label integer(const label lower, const label upper);
87 
88  vector position(const vector&, const vector&);
89 
90  void randomise(scalar&);
91  void randomise(vector&);
93  void randomise(symmTensor&);
94  void randomise(tensor&);
95 
96  //- Return a normal Gaussian randon number
97  // with zero mean and unity variance N(0, 1)
98  scalar GaussNormal();
99 };
100 
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 } // End namespace Foam
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 #endif
109 
110 // ************************************************************************* //
Simple random number generator.
Definition: Random.H:49
vector position(const vector &, const vector &)
Definition: Random.C:124
scalar GaussNormal()
Return a normal Gaussian randon number.
Definition: Random.C:168
sphericalTensor sphericalTensor01()
sphericalTensor with every component scalar01
Definition: Random.C:85
Templated 3D symmetric tensor derived from VectorSpace adding construction from 6 components...
Definition: SymmTensor.H:53
tensor tensor01()
Tensor with every component scalar01.
Definition: Random.C:106
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
Templated 3D SphericalTensor derived from VectorSpace adding construction from 1 component, element access using th ii() member function and the inner-product (dot-product) and outer-product operators.
Namespace for OpenFOAM.
vector vector01()
Vector with every component scalar01.
Definition: Random.C:73
int bit()
Definition: Random.C:54
void randomise(scalar &)
Definition: Random.C:138
Random(const label)
Construct given seed.
Definition: Random.C:39
symmTensor symmTensor01()
symmTensor with every component scalar01
Definition: Random.C:94
scalar scalar01()
Scalar [0..1] (so including 0,1)
Definition: Random.C:67
label integer(const label lower, const label upper)
Label [lower..upper].
Definition: Random.C:118