VPTissue Reference Manual
DirectedUniform.h
Go to the documentation of this file.
1 #ifndef SIMPT_DEFAULT_MOVE_GEN_DIRECTED_UNIFORM_H_INCLUDED
2 #define SIMPT_DEFAULT_MOVE_GEN_DIRECTED_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 <boost/property_tree/ptree.hpp>
27 #include <trng/uniform_dist.hpp>
28 #include <array>
29 #include <cmath>
30 
31 namespace SimPT_Default {
32 namespace MoveGenerator {
33 
34 using namespace SimPT_Sim;
35 using namespace SimPT_Sim::Util;
36 using boost::property_tree::ptree;
37 
42 {
43 public:
46  {
47  assert( cd.Check() && "CoreData not ok.");
48  Initialize(cd);
49  }
50 
52  void Initialize(const CoreData& cd)
53  {
54  m_uniform_generator = cd.m_random_engine->GetGenerator(trng::uniform_dist<double>(-1.0e0, 1.0e0));
55  m_mc_step_x_scale = cd.m_parameters->get<double>("cell_mechanics.mc_step_x_scale");
56  m_mc_step_y_scale = cd.m_parameters->get<double>("cell_mechanics.mc_step_y_scale");
57  }
58 
60  std::array<double, 3> operator()()
61  {
62  // Both x and y range [-1.0, 1.0] and are scaled with direction.
63  const double x = m_uniform_generator() * m_mc_step_x_scale;
64  const double y = m_uniform_generator() * m_mc_step_y_scale;
65  return std::array<double, 3>{{ x, y, 0.0 }};
66  }
67 
68 private:
69  std::function<double()> m_uniform_generator;
70  double m_mc_step_x_scale;
71  double m_mc_step_y_scale;
72 };
73 
74 } // namespace
75 } // namespace
76 
77 #endif // end_of_include_guard
Math constants.
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
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.
std::array< double, 3 > operator()()
Generate a random move.
Move Generator with uniform distribution and directional bias.
DirectedUniform(const CoreData &cd)
Straight initialization.
void Initialize(const CoreData &cd)
Initialize or re-initialize.
bool Check() const
Verify all pointers non-null.
Definition: CoreData.h:53