All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NeighborList.h
Go to the documentation of this file.
1 /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2  Copyright (c) 2013 The plumed team
3  (see the PEOPLE file at the root of the distribution for a list of names)
4 
5  See http://www.plumed-code.org for more information.
6 
7  This file is part of plumed, version 2.0.
8 
9  plumed is free software: you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  plumed is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with plumed. If not, see <http://www.gnu.org/licenses/>.
21 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
22 #ifndef __PLUMED_tools_NeighborList_h
23 #define __PLUMED_tools_NeighborList_h
24 
25 #include "Vector.h"
26 #include "AtomNumber.h"
27 
28 #include <vector>
29 
30 namespace PLMD{
31 
32 class Pbc;
33 
34 /// \ingroup TOOLBOX
35 /// A class that implements neighbor lists from two lists or a single list of atoms
37 {
38  bool reduced;
40  const PLMD::Pbc* pbc_;
41  std::vector<PLMD::AtomNumber> fullatomlist_,requestlist_;
42  std::vector<std::pair<unsigned,unsigned> > neighbors_;
43  double distance_;
45 /// Initialize the neighbor list with all possible pairs
46  void initialize();
47 /// Return the pair of indexes in the positions array
48 /// of the two atoms forming the i-th pair among all possible pairs
49  std::pair<unsigned,unsigned> getIndexPair(unsigned i);
50 /// Extract the list of atoms from the current list of close pairs
51  void setRequestList();
52 public:
53  NeighborList(const std::vector<PLMD::AtomNumber>& list0,
54  const std::vector<PLMD::AtomNumber>& list1,
55  const bool& do_pair, const bool& do_pbc, const PLMD::Pbc& pbc,
56  const double& distance=1.0e+30, const unsigned& stride=0);
57  NeighborList(const std::vector<PLMD::AtomNumber>& list0, const bool& do_pbc,
58  const PLMD::Pbc& pbc, const double& distance=1.0e+30,
59  const unsigned& stride=0);
60 /// Return the list of all atoms. These are needed to rebuild the neighbor list.
61  std::vector<PLMD::AtomNumber>& getFullAtomList();
62 /// Update the indexes in the neighbor list to match the
63 /// ordering in the new positions array
64 /// and return the new list of atoms that must be requested to the main code
65  std::vector<PLMD::AtomNumber>& getReducedAtomList();
66 /// Update the neighbor list and prepare the new
67 /// list of atoms that will be requested to the main code
68  void update(const std::vector<PLMD::Vector>& positions);
69 /// Get the update stride of the neighbor list
70  unsigned getStride() const;
71 /// Get the last step in which the neighbor list was updated
72  unsigned getLastUpdate() const;
73 /// Set the step of the last update
74  void setLastUpdate(unsigned step);
75 /// Get the size of the neighbor list
76  unsigned size() const;
77 /// Get the i-th pair of the neighbor list
78  std::pair<unsigned,unsigned> getClosePair(unsigned i) const;
79 /// Get the list of neighbors of the i-th atom
80  std::vector<unsigned> getNeighbors(unsigned i);
82 };
83 
84 }
85 
86 #endif
std::vector< std::pair< unsigned, unsigned > > neighbors_
Definition: NeighborList.h:42
std::vector< PLMD::AtomNumber > & getFullAtomList()
Return the list of all atoms. These are needed to rebuild the neighbor list.
std::vector< unsigned > getNeighbors(unsigned i)
Get the list of neighbors of the i-th atom.
std::vector< PLMD::AtomNumber > requestlist_
Definition: NeighborList.h:41
std::vector< PLMD::AtomNumber > fullatomlist_
Definition: NeighborList.h:41
void setRequestList()
Extract the list of atoms from the current list of close pairs.
void update(const std::vector< PLMD::Vector > &positions)
Update the neighbor list and prepare the new list of atoms that will be requested to the main code...
Definition: Pbc.h:38
void setLastUpdate(unsigned step)
Set the step of the last update.
A class that implements neighbor lists from two lists or a single list of atoms.
Definition: NeighborList.h:36
std::pair< unsigned, unsigned > getClosePair(unsigned i) const
Get the i-th pair of the neighbor list.
std::pair< unsigned, unsigned > getIndexPair(unsigned i)
Return the pair of indexes in the positions array of the two atoms forming the i-th pair among all po...
void initialize()
Initialize the neighbor list with all possible pairs.
unsigned getStride() const
Get the update stride of the neighbor list.
std::vector< PLMD::AtomNumber > & getReducedAtomList()
Update the indexes in the neighbor list to match the ordering in the new positions array and return t...
const PLMD::Pbc * pbc_
Definition: NeighborList.h:40
unsigned lastupdate_
Definition: NeighborList.h:44
unsigned getLastUpdate() const
Get the last step in which the neighbor list was updated.
NeighborList(const std::vector< PLMD::AtomNumber > &list0, const std::vector< PLMD::AtomNumber > &list1, const bool &do_pair, const bool &do_pbc, const PLMD::Pbc &pbc, const double &distance=1.0e+30, const unsigned &stride=0)
unsigned size() const
Get the size of the neighbor list.