VPTissue Reference Manual
VLeaf.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "VLeaf.h"
21 
22 #include "Transport.h"
23 
24 #include "algo/CellDivider.h"
25 #include "algo/CellHousekeeper.h"
26 #include "algo/NodeInserter.h"
27 #include "algo/NodeMover.h"
28 
29 namespace SimPT_Default {
30 namespace TimeEvolver {
31 
32 using namespace std;
33 using namespace SimPT_Sim::ClockMan;
34 using boost::property_tree::ptree;
35 
37 {
38  Initialize(cd);
39 }
40 
41 void VLeaf::Initialize(const CoreData& cd)
42 {
43  assert( cd.Check() && "CoreData not ok.");
44  m_cd = cd;
45  auto& p = m_cd.m_parameters;
46 
47  m_mc_abs_tolerance = p->get<double>("cell_mechanics.mc_abs_tolerance");
48  m_mc_cell_step_size = p->get<double>("cell_mechanics.mc_cell_stepsize");
49  m_mc_step_size = p->get<double>("cell_mechanics.mc_stepsize");
50  m_mc_sweep_limit = p->get<double>("cell_mechanics.mc_sweep_limit");
51  m_mc_temperature = p->get<double>("cell_mechanics.mc_temperature");
52 }
53 
54 std::tuple<SimTimingTraits::CumulativeTimings, bool> VLeaf::operator()(double time_slice, SimPhase)
55 {
56  // Only allow for node insertion, cell division and cell chemistry if the system has
57  // reached equilibrium i.e. cell wall tension equilibrium is achieved faster than
58  // biological processes, including division, cell wall yielding and cell expansion
59 
60  // -------------------------------------------------------------------------------
61  // Initialize
62  // -------------------------------------------------------------------------------
63  NodeMover node_mover;
64  node_mover.Initialize(m_cd);
65  NodeInserter node_inserter;
66  node_inserter.Initialize(m_cd);
67  bool is_stationary = false;
68  unsigned int sweep_count = 0U;
69  CumulativeTimings timings;
70  bool go_on = false;
71 
72  do {
73  ++sweep_count;
74 
75  // -------------------------------------------------------------------------------
76  // Metropolis
77  // -------------------------------------------------------------------------------
78  Stopclock chrono_met("growth", true);
79  const auto info = node_mover.SweepOverNodes(m_mc_step_size, m_mc_temperature);
80  //const double dh = info.down_dh + info.up_dh;
81  const double dh = info.down_dh + info.up_dh;
82  node_inserter.InsertNodes();
83  timings.Record(chrono_met.GetName(), chrono_met.Get());
84 
85  go_on = !( (-dh) < m_mc_abs_tolerance );
86 
87  } while (go_on && sweep_count < m_mc_sweep_limit);
88 
89  // ---------------------------------------------------------------------------
90  // Cell housekeeping
91  // ---------------------------------------------------------------------------
92  Stopclock chrono_hk("housekeeping", true);
93  CellDivider divider(m_cd);
94  divider.DivideCells();
95  CellHousekeeper cell_housekeeper;
96  cell_housekeeper.Initialize(m_cd);
97  cell_housekeeper.Exec();
98  timings.Record(chrono_hk.GetName(), chrono_hk.Get());
99 
100  // ---------------------------------------------------------------------------
101  // Reaction and transport dynamics
102  // -------------------------------------------------------------------------------
103  Stopclock chrono_ode("transport", true);
104  Transport transporter(m_cd);
105  auto tup = transporter(time_slice);
106  timings.Record(chrono_ode.GetName(), chrono_ode.Get());
107 
108 
109  return make_tuple(timings, is_stationary);
110 }
111 
112 } // namespace
113 } // namespace
void Initialize(const CoreData &cd)
Initialize or re-initialize.
Definition: VLeaf.cpp:41
void Initialize(const CoreData &cd)
Initializes based on values in property tree.
Interface for CellHousekeeper.
Core data with mesh, parameters, random engine and time data.
Definition: CoreData.h:38
STL namespace.
Interface for CellDivider.
Time evolution of reaction, diffusion and active transport process.
Definition: Transport.h:34
unsigned int DivideCells()
Execute cell divisions.
Interface for NodeMover.
Class for handling maintenance of cell mechanics (cell housekeeping).
std::string GetName() const
Return name of this stopwatch.
Definition: Stopwatch.h:88
VLeaf(const CoreData &cd)
Initializing constructor.
Definition: VLeaf.cpp:36
MetropolisInfo SweepOverNodes(double step_size, double temperature)
Sweep over all nodes, do metropolis move for each of them.
Definition: NodeMover.cpp:234
Cell mechanics by displacement and insertion of nodes.
Definition: NodeMover.h:46
Namespace for components of the Default model group.
Utility class to record durations in a cumulative manner.
Time evolver for diffusion and active transport.
void Initialize(const CoreData &cd)
Initializes.
std::tuple< SimTimingTraits::CumulativeTimings, bool > operator()(double time_slice, SimPhase phase=SimPhase::NONE)
Take a time step.
Definition: VLeaf.cpp:54
Class for handling cell division.
Definition: CellDivider.h:48
Insertion of nodes in existing edges (contributes to the cell mechanics).
Definition: NodeInserter.h:34
T::duration Get() const
Returns the accumulated value without altering the stopwatch state.
Definition: Stopwatch.h:94
void Initialize(const CoreData &cd)
Initializes based on values in property tree.
Definition: NodeMover.cpp:81
unsigned int InsertNodes()
Insert nodes in those edges that have been stretched.
boost::property_tree::ptree Exec() const
Housekeeping rules.
Provides a stopwatch interface to time: it accumulates time between start/stop pairs.
Definition: Stopwatch.h:39
Interface for NodeInserter.
Interface for time evolver of Merks et al.
void Record(const std::string &name, const std::chrono::duration< R, P > &duration)
Record the duration for the given name.
bool Check() const
Verify all pointers non-null.
Definition: CoreData.h:53
Namespace for clock and timekeeping related classes.
Definition: ClockCLib.h:27