1 | /*
|
---|
2 | * BondVectors.hpp
|
---|
3 | *
|
---|
4 | * Created on: Jun 13, 2017
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 |
|
---|
9 | #ifndef DYNAMICS_BONDVECTORS_HPP_
|
---|
10 | #define DYNAMICS_BONDVECTORS_HPP_
|
---|
11 |
|
---|
12 | // include config.h
|
---|
13 | #ifdef HAVE_CONFIG_H
|
---|
14 | #include <config.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include <map>
|
---|
18 | #include <vector>
|
---|
19 |
|
---|
20 | #include "CodePatterns/Assert.hpp"
|
---|
21 |
|
---|
22 | #include "LinearAlgebra/Vector.hpp"
|
---|
23 |
|
---|
24 | #include "Bond/bond.hpp"
|
---|
25 |
|
---|
26 | /** This class represents all bond vectors, i.e. the normalized direction
|
---|
27 | * along a list of bonds, and provides means to extract them from a set of
|
---|
28 | * atoms such that for an arbitrary bond the vector can be quickly retrieved.
|
---|
29 | */
|
---|
30 | class BondVectors
|
---|
31 | {
|
---|
32 | public:
|
---|
33 | //!> typedef for the internal container of the bonds
|
---|
34 | typedef std::vector<bond::ptr> container_t;
|
---|
35 |
|
---|
36 | //!> typedef for the association of bonds to bond vectors
|
---|
37 | typedef std::map<bond::ptr, Vector> mapped_t;
|
---|
38 |
|
---|
39 | /** Default cstor for class BondVectors.
|
---|
40 | *
|
---|
41 | */
|
---|
42 | BondVectors();
|
---|
43 |
|
---|
44 | /** Prepares the internal container from the bonds of a range of atoms.
|
---|
45 | *
|
---|
46 | * \param _start start of range
|
---|
47 | * \param _end end of range
|
---|
48 | * \param _step time step to request bonds for
|
---|
49 | */
|
---|
50 | template <class T>
|
---|
51 | void setFromAtomRange(
|
---|
52 | typename T::iterator _start,
|
---|
53 | typename T::iterator _end,
|
---|
54 | const size_t &_step);
|
---|
55 |
|
---|
56 | /** Getter for the sorted bonds.
|
---|
57 | *
|
---|
58 | * \return const ref to internal container
|
---|
59 | */
|
---|
60 | const container_t& getSorted() const;
|
---|
61 |
|
---|
62 | /** Getter for the Bondvectors.
|
---|
63 | *
|
---|
64 | * \param _step time step for which the bond vector is request
|
---|
65 | * \return a map from bond to bond vector
|
---|
66 | */
|
---|
67 | const mapped_t& getBondVectorsAtStep(const size_t &_step) const;
|
---|
68 |
|
---|
69 | /** Get the position in the internal container for a specific bond.
|
---|
70 | *
|
---|
71 | * \param _bond given bond
|
---|
72 | * \return position in the vector, -1 if not present
|
---|
73 | */
|
---|
74 | size_t getIndexForBond(const bond::ptr &_bond) const;
|
---|
75 |
|
---|
76 | /** Gather the subset of BondVectors for the given atom.
|
---|
77 | *
|
---|
78 | * \param _walker atom to get BondVectors for
|
---|
79 | * \param _step time step for which the bond vector is request
|
---|
80 | */
|
---|
81 | std::vector<Vector> getAtomsBondVectorsAtStep(
|
---|
82 | const atom &_walker,
|
---|
83 | const size_t &_step) const;
|
---|
84 |
|
---|
85 | //!> typedef for the weights for the Bondvectors of a single atom
|
---|
86 | typedef std::deque<double> weights_t;
|
---|
87 |
|
---|
88 | /** Calculates the weights for a frame where each Bondvector of the
|
---|
89 | * given atom is a vector of the frame.
|
---|
90 | *
|
---|
91 | * The idea is that we can represent any vector by appropriate weights such
|
---|
92 | * that is still sums up to one.
|
---|
93 | *
|
---|
94 | * \param _walker atom to get BondVectors for
|
---|
95 | * \param _step time step for which the bond vector is request
|
---|
96 | */
|
---|
97 | weights_t getWeightsForAtomAtStep(
|
---|
98 | const atom &_walker,
|
---|
99 | const size_t &_step) const;
|
---|
100 |
|
---|
101 | private:
|
---|
102 | /** Calculates the bond vector for each bond in the internal container.
|
---|
103 | *
|
---|
104 | * \param _step time step for which the bond vector is request
|
---|
105 | */
|
---|
106 | void recalculateBondVectorsAtStep(const size_t &_step) const;
|
---|
107 |
|
---|
108 | private:
|
---|
109 | //!> internal container for sorted bonds
|
---|
110 | container_t container;
|
---|
111 |
|
---|
112 | //!> states whether map needs update or not
|
---|
113 | mutable bool map_is_dirty;
|
---|
114 |
|
---|
115 | //!> contains the step for which the map was calculated
|
---|
116 | mutable size_t current_step_for_map;
|
---|
117 |
|
---|
118 | //!> internal map for bond Bondvector association
|
---|
119 | mutable mapped_t current_mapped_vectors;
|
---|
120 | };
|
---|
121 |
|
---|
122 | #include "BondVectors_impl.hpp"
|
---|
123 |
|
---|
124 | #endif /* DYNAMICS_BONDVECTORS_HPP_ */
|
---|