www.cemf.ir
uniformRandomReal.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __uniformRandomReal_hpp__
22 #define __uniformRandomReal_hpp__
23 
24 #include <random>
25 
26 #include "types.hpp"
27 #include "typeInfo.hpp"
28 
29 namespace pFlow
30 {
31 
33 {
34 protected:
35 
36  std::mt19937_64 engineGen_;
37 
38  std::uniform_real_distribution<double> distrbution_;
39 
40 public:
41 
42  // type info
43  TypeInfoNV("uniform");
44 
45  explicit uniformRandomReal()
46  :
47  engineGen_(std::random_device()()),
48  distrbution_(0.0, 1.0)
49  {}
50 
51  ~uniformRandomReal()= default;
52 
53  inline real randomNumber(real a, real b)
54  {
55  return a + (b-a)*distrbution_(engineGen_);
56  }
57 
58  inline realx3 randomNumber(const realx3& a, const realx3& b)
59  {
60  realx3 r3
61  (
62  randomNumber(0.0,1.0),
63  randomNumber(0.0,1.0),
64  randomNumber(0.0,1.0)
65  );
66 
67  return a + (b-a)*r3;
68  }
69 
70  inline realx3 operator()(const realx3& a, const realx3& b)
71  {
72  return randomNumber(a,b);
73  }
74 
75  inline real operator()(real a, real b)
76  {
77  return randomNumber(a,b);
78  }
79 
80 };
81 
82 }
83 
84 #endif
pFlow::uniformRandomReal::uniformRandomReal
uniformRandomReal()
Definition: uniformRandomReal.hpp:45
pFlow::uniformRandomReal::~uniformRandomReal
~uniformRandomReal()=default
pFlow::uniformRandomReal::operator()
realx3 operator()(const realx3 &a, const realx3 &b)
Definition: uniformRandomReal.hpp:70
pFlow::real
float real
Definition: builtinTypes.hpp:45
types.hpp
pFlow::uniformRandomReal::operator()
real operator()(real a, real b)
Definition: uniformRandomReal.hpp:75
pFlow::uniformRandomReal::TypeInfoNV
TypeInfoNV("uniform")
pFlow
Definition: demGeometry.hpp:27
pFlow::uniformRandomReal
Definition: uniformRandomReal.hpp:32
pFlow::uniformRandomReal::distrbution_
std::uniform_real_distribution< double > distrbution_
Definition: uniformRandomReal.hpp:38
pFlow::uniformRandomReal::engineGen_
std::mt19937_64 engineGen_
Definition: uniformRandomReal.hpp:36
pFlow::uniformRandomReal::randomNumber
realx3 randomNumber(const realx3 &a, const realx3 &b)
Definition: uniformRandomReal.hpp:58
typeInfo.hpp
pFlow::triple< real >
pFlow::uniformRandomReal::randomNumber
real randomNumber(real a, real b)
Definition: uniformRandomReal.hpp:53