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 | private:
|
---|
86 | /** Calculates the bond vector for each bond in the internal container.
|
---|
87 | *
|
---|
88 | * \param _step time step for which the bond vector is request
|
---|
89 | */
|
---|
90 | void recalculateBondVectorsAtStep(const size_t &_step) const;
|
---|
91 |
|
---|
92 | private:
|
---|
93 | //!> internal container for sorted bonds
|
---|
94 | container_t container;
|
---|
95 |
|
---|
96 | //!> states whether map needs update or not
|
---|
97 | mutable bool map_is_dirty;
|
---|
98 |
|
---|
99 | //!> contains the step for which the map was calculated
|
---|
100 | mutable size_t current_step_for_map;
|
---|
101 |
|
---|
102 | //!> internal map for bond Bondvector association
|
---|
103 | mutable mapped_t current_mapped_vectors;
|
---|
104 | };
|
---|
105 |
|
---|
106 | #include "BondVectors_impl.hpp"
|
---|
107 |
|
---|
108 | #endif /* DYNAMICS_BONDVECTORS_HPP_ */
|
---|