source: src/Dynamics/BondVectors.hpp@ 9861d0

AutomationFragmentation_failures Candidate_v1.6.1 ChemicalSpaceEvaluator Exclude_Hydrogens_annealWithBondGraph ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_contraction-expansion Gui_displays_atomic_force_velocity PythonUI_with_named_parameters StoppableMakroAction TremoloParser_IncreasedPrecision
Last change on this file since 9861d0 was 9861d0, checked in by Frederik Heber <frederik.heber@…>, 7 years ago

BondVectors now return subset of BondVectors for a given atom.

  • functionality extracted from ForceAnnealing::annealWithBondgraph().
  • also the mapped_t type is now kept up-to-date internally as we need it for returning the subset efficiently over a number of atoms, e.g. all in the given range.
  • also moved a few simple implementations over to _impl module.
  • Property mode set to 100644
File size: 2.7 KB
Line 
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 */
30class BondVectors
31{
32public:
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
85private:
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
92private:
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_ */
Note: See TracBrowser for help on using the repository browser.