VPTissue Reference Manual
HHelper.h
Go to the documentation of this file.
1 #ifndef HAMILTONIAN_HHELPER_H_INCLUDED
2 #define HAMILTONIAN_HHELPER_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 "bio/Cell.h"
23 #include "bio/Node.h"
24 #include "math/Geom.h"
26 
27 using namespace std;
28 using namespace boost::property_tree;
29 using namespace SimPT_Sim::Container;
30 
31 namespace SimPT_Default {
32 namespace Hamiltonian {
33 
37 class HHelper
38 {
39 public:
43  static double BendingTerm(Cell* cell)
44  {
45  // TODO: 1.0 / 10.0 hidden parameter: curvature of decagon with edge length of 6.18034.
46  double contrib = 0.0;
47 
48  const auto cit_start = cell->GetNodes().begin();
49  auto cit = make_const_circular(cell->GetNodes());
50  do {
51  array<double, 3> ncurr = *(*cit);
52  array<double, 3> nprev = *(*prev(cit));
53  array<double, 3> nnext = *(*next(cit));
54  const auto t = Geom::CircumCircle(nprev[0], nprev[1], ncurr[0], ncurr[1], nnext[0], nnext[1]);
55  const auto r = get<2>(t);
56  contrib += pow((1.0 / r - 1.0 / 10.0), 2);
57  } while (++cit != cit_start);
58 
59  return contrib;
60  }
61 
62  static double CellLengthTerm(Cell* cell)
63  {
64  return pow(get<0>(cell->GetGeoData().GetEllipseAxes()) - cell->GetTargetLength(), 2);
65  }
66 
68  static double EdgeTerm(Cell* cell, double stiffness, double distance)
69  {
70  double contrib = 0.0;
71  const auto cit_start = cell->GetNodes().begin();
72 
73  auto cit = make_const_circular(cell->GetNodes());
74  do {
75  const auto ncurr = *cit;
76  const auto nnext = *next(cit);
77  const auto weight = ncurr->IsAtBoundary() && nnext->IsAtBoundary() ? stiffness : 1.0;
78  contrib += weight * pow(distance - Norm(*ncurr - *nnext), 2);
79  } while (++cit != cit_start);
80 
81  return contrib;
82  }
83 
85  static double ElasticWallTerm(Cell* cell, double stiffness)
86  {
87  double contrib = 0.0;
88  const auto wit_start = cell->GetWalls().begin();
89 
90  auto cit = make_const_circular(cell->GetWalls());
91  do {
92  const auto& wall = *(*cit);
93  const double w_stiff
94  = (wall.GetC1()->IsBoundaryPolygon() || wall.GetC2()->IsBoundaryPolygon()) ? stiffness : 1.0;
95  contrib += w_stiff
96  * pow(wall.GetLength() - wall.GetRestLength(), 2) / (2. * wall.GetRestLength());
97  } while (++cit != wit_start);
98 
99  return contrib;
100  }
101 
102  static double WallLengthTerm(Cell* cell, double stiffness, double distance)
103  {
104  double contrib = 0.0;
105  const auto wit_start = cell->GetWalls().begin();
106 
107  auto wit = make_const_circular(cell->GetWalls());
108  do {
109  const auto& wall = *(*wit);
110  const auto s = wall.IsAtBoundary() ? stiffness : 1.0;
111  contrib += s * wall.GetStrength() * pow(distance - wall.GetLength(), 2);
112  } while (++wit != wit_start);
113 
114  return contrib;
115  }
116 };
117 
118 } // namespace
119 } // namespace
120 
121 #endif // end-of-include-guard
STL namespace.
A cell contains walls and nodes.
Definition: Cell.h:48
Combo header for circular iterator.
const std::list< Wall * > & GetWalls() const
Access the cell's walls.
Definition: Cell.h:88
Namespace for components of the Default model group.
Interface for Cell.
Namespace for container related classes.
static double BendingTerm(Cell *cell)
Bending term.
Definition: HHelper.h:43
const std::vector< Node * > & GetNodes() const
Access the nodes of cell's polygon.
Definition: Cell.h:79
static double EdgeTerm(Cell *cell, double stiffness, double distance)
Edge length term.
Definition: HHelper.h:68
Interface for Node.
Interface for Geom.
std::tuple< double, std::array< double, 3 >, double > GetEllipseAxes() const
Calculate axes (length and direction) area moment of inertia ellipse.
Definition: GeoData.h:50
GeoData GetGeoData() const
Return GeData (area, centroid, area moment of inertia).
Definition: Cell.cpp:225
CircularIterator< T > next(CircularIterator< T > i)
Helper yields the position the iterator would have if moved forward (in circular fashion) by 1 positi...
ConstCircularIterator< typename T::const_iterator > make_const_circular(const T &c)
Helper produces const circular iterator whose range corresponds to the begin and end iterators of a c...
CircularIterator< T > prev(CircularIterator< T > i)
Helper yields the position the iterator would have if moved backward (in circular fashion) by 1 posit...
Helper function for writing hamiltonians.
Definition: HHelper.h:37