VPTissue Reference Manual
StandardUniform.h
Go to the documentation of this file.
1 #ifndef SIMPT_DEFAULT_MOVE_GEN_STANDARD_UNIFORM_H_INCLUDED
2 #define SIMPT_DEFAULT_MOVE_GEN_STANDARD_UNIFORM_H_INCLUDED
3 /*
4  * Copyright 2011-2016 Universiteit Antwerpen
5  *
6  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
7  * the European Commission - subsequent versions of the EUPL (the "Licence");
8  * You may not use this work except in compliance with the Licence.
9  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the Licence is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the Licence for the specific language governing
15  * permissions and limitations under the Licence.
16  */
22 #include "math/constants.h"
23 #include "math/RandomEngine.h"
24 #include "sim/CoreData.h"
25 
26 #include <trng/uniform01_dist.hpp>
27 #include <array>
28 #include <cmath>
29 
30 namespace SimPT_Default {
31 namespace MoveGenerator {
32 
33 using namespace SimPT_Sim;
34 using namespace SimPT_Sim::Util;
35 
40 {
41 public:
44  {
45  assert( cd.Check() && "CoreData not ok.");
46  Initialize(cd);
47  }
48 
50  void Initialize(const CoreData& cd)
51  {
52  m_uniform_generator = cd.m_random_engine->GetGenerator(trng::uniform01_dist<double>());
53  }
54 
56  std::array<double, 3> operator()()
57  {
58  // Angle ranges [0.0, 2*pi] and ampli [0.0, 1.0].
59  const double angle = m_uniform_generator() * two_pi();
60  const double ampli = m_uniform_generator();
61  return std::array<double, 3>{{ ampli * std::sin(angle), ampli * std::cos(angle), 0.0 }};
62  }
63 
64 private:
65  std::function<double()> m_uniform_generator;
66 };
67 
68 } // namespace
69 } // namespace
70 
71 #endif // end_of_include_guard
Math constants.
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
StandardUniform(const CoreData &cd)
Straight initialization.
Core data used during model execution.
Namespace for miscellaneous utilities.
Definition: PTreeFile.cpp:44
Interface of RandomEngine.
Namespace for components of the Default model group.
Namespace for the core simulator.
constexpr double two_pi()
Math constant 2*pi.
Definition: constants.h:32
Move Generator with uniform distribution (no directional bias).
std::array< double, 3 > operator()()
Generate a random move.
void Initialize(const CoreData &cd)
Straight initialization of empty object.
bool Check() const
Verify all pointers non-null.
Definition: CoreData.h:53