FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/vector.H>
39 #include <OpenFOAM/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  //- vector with every component scalar01
73  vector vector01();
74  //- sphericalTensor with every component scalar01
76  //- symmTensor with every component scalar01
78  //- tensor with every component scalar01
79  tensor tensor01();
80  //- label [lower..upper]
81  label integer(const label lower, const label upper);
82 
83  vector position(const vector&, const vector&);
84 
85  void randomise(scalar&);
86  void randomise(vector&);
88  void randomise(symmTensor&);
89  void randomise(tensor&);
90 
91  //- Return a normal Gaussian randon number
92  // with zero mean and unity variance N(0, 1)
93  scalar GaussNormal();
94 };
95 
96 
97 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
98 
99 } // End namespace Foam
100 
101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
102 
103 #endif
104 
105 // ************************ vim: set sw=4 sts=4 et: ************************ //