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