source: src/Dynamics/BondVectors_impl.hpp@ 43552e

Candidate_v1.6.1
Last change on this file since 43552e 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: 1.4 KB
Line 
1/*
2 * BondVectors_impl.hpp
3 *
4 * Created on: Jun 13, 2017
5 * Author: heber
6 */
7
8
9#ifndef DYNAMICS_BONDVECTORS_IMPL_HPP_
10#define DYNAMICS_BONDVECTORS_IMPL_HPP_
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include "BondVectors.hpp"
18
19#include <algorithm>
20
21#include "Atom/atom.hpp"
22
23BondVectors::BondVectors() :
24 map_is_dirty(false),
25 current_step_for_map((size_t)-1)
26{}
27
28template <class T>
29void BondVectors::setFromAtomRange(
30 typename T::iterator _start,
31 typename T::iterator _end,
32 const size_t &_step)
33{
34 container.clear();
35 for (typename T::iterator iter = _start; iter != _end; ++iter) {
36 const atom &walker = **iter;
37 const BondList &ListOfBonds = walker.getListOfBondsAtStep(_step);
38 container.insert(container.end(), ListOfBonds.begin(), ListOfBonds.end());
39 }
40 // sort and make unique
41 std::sort(container.begin(), container.end());
42 container.erase(std::unique(container.begin(), container.end()), container.end());
43 map_is_dirty = true;
44}
45
46const BondVectors::mapped_t&
47BondVectors::getBondVectorsAtStep(const size_t &_step) const
48{
49 if (map_is_dirty || (current_step_for_map != _step))
50 recalculateBondVectorsAtStep(_step);
51 return current_mapped_vectors;
52}
53
54const BondVectors::container_t&
55BondVectors::getSorted() const
56{
57 ASSERT( !container.empty(),
58 "BondVectors::getSorted() - empty internal container, not set properly?");
59 return container;
60}
61
62#endif /* DYNAMICS_BONDVECTORS_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.