1 #ifndef HAMILTONIAN_HHELPER_H_INCLUDED
2 #define HAMILTONIAN_HHELPER_H_INCLUDED
32 namespace Hamiltonian {
48 const auto cit_start = cell->
GetNodes().begin();
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);
62 static double CellLengthTerm(
Cell* cell)
68 static double EdgeTerm(
Cell* cell,
double stiffness,
double distance)
71 const auto cit_start = cell->
GetNodes().begin();
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);
85 static double ElasticWallTerm(
Cell* cell,
double stiffness)
88 const auto wit_start = cell->
GetWalls().begin();
92 const auto& wall = *(*cit);
94 = (wall.GetC1()->IsBoundaryPolygon() || wall.GetC2()->IsBoundaryPolygon()) ? stiffness : 1.0;
96 * pow(wall.GetLength() - wall.GetRestLength(), 2) / (2. * wall.GetRestLength());
97 }
while (++cit != wit_start);
102 static double WallLengthTerm(Cell* cell,
double stiffness,
double distance)
104 double contrib = 0.0;
105 const auto wit_start = cell->GetWalls().begin();
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);
121 #endif // end-of-include-guard
A cell contains walls and nodes.
Combo header for circular iterator.
const std::list< Wall * > & GetWalls() const
Access the cell's walls.
Namespace for components of the Default model group.
Namespace for container related classes.
static double BendingTerm(Cell *cell)
Bending term.
const std::vector< Node * > & GetNodes() const
Access the nodes of cell's polygon.
static double EdgeTerm(Cell *cell, double stiffness, double distance)
Edge length term.
std::tuple< double, std::array< double, 3 >, double > GetEllipseAxes() const
Calculate axes (length and direction) area moment of inertia ellipse.
GeoData GetGeoData() const
Return GeData (area, centroid, area moment of inertia).
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.