LCOV - code coverage report
Current view: top level - tools - NeighborList.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 4 4 100.0 %
Date: 2024-10-11 08:09:47 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2011-2023 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.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       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             : class Communicator;
      34             : 
      35             : /// \ingroup TOOLBOX
      36             : /// A class that implements neighbor lists from two lists or a single list of atoms
      37             : class NeighborList
      38             : {
      39             :   bool reduced;
      40             :   bool serial_;
      41             :   bool do_pair_,do_pbc_,twolists_;
      42             :   const PLMD::Pbc* pbc_;
      43             :   Communicator& comm;
      44             :   std::vector<PLMD::AtomNumber> fullatomlist_,requestlist_;
      45             :   std::vector<std::pair<unsigned,unsigned> > neighbors_;
      46             :   double distance_;
      47             :   unsigned stride_,nlist0_,nlist1_,nallpairs_,lastupdate_;
      48             : /// Initialize the neighbor list with all possible pairs
      49             :   void initialize();
      50             : /// Return the pair of indexes in the positions array
      51             : /// of the two atoms forming the i-th pair among all possible pairs
      52             :   std::pair<unsigned,unsigned> getIndexPair(unsigned i);
      53             : /// Extract the list of atoms from the current list of close pairs
      54             :   void setRequestList();
      55             : public:
      56             :   NeighborList(const std::vector<PLMD::AtomNumber>& list0,
      57             :                const std::vector<PLMD::AtomNumber>& list1,
      58             :                const bool& serial,
      59             :                const bool& do_pair, const bool& do_pbc, const PLMD::Pbc& pbc, Communicator &cm,
      60         388 :                const double& distance=1.0e+30, const unsigned& stride=0);
      61             :   NeighborList(const std::vector<PLMD::AtomNumber>& list0,
      62             :                const bool& serial,
      63             :                const bool& do_pbc,
      64          22 :                const PLMD::Pbc& pbc, Communicator &cm, const double& distance=1.0e+30,
      65          22 :                const unsigned& stride=0);
      66             : /// Return the list of all atoms. These are needed to rebuild the neighbor list.
      67             :   std::vector<PLMD::AtomNumber>& getFullAtomList();
      68             : /// Update the indexes in the neighbor list to match the
      69             : /// ordering in the new positions array
      70             : /// and return the new list of atoms that must be requested to the main code
      71             :   std::vector<PLMD::AtomNumber>& getReducedAtomList();
      72             : /// Update the neighbor list and prepare the new
      73             : /// list of atoms that will be requested to the main code
      74             :   void update(const std::vector<PLMD::Vector>& positions);
      75             : /// Get the update stride of the neighbor list
      76             :   unsigned getStride() const;
      77             : /// Get the last step in which the neighbor list was updated
      78             :   unsigned getLastUpdate() const;
      79             : /// Set the step of the last update
      80             :   void setLastUpdate(unsigned step);
      81             : /// Get the size of the neighbor list
      82             :   unsigned size() const;
      83             : /// Get the i-th pair of the neighbor list
      84             :   std::pair<unsigned,unsigned> getClosePair(unsigned i) const;
      85             : /// Get the list of neighbors of the i-th atom
      86             :   std::vector<unsigned> getNeighbors(unsigned i);
      87         284 :   ~NeighborList() {}
      88             : /// Get the i-th pair of AtomNumbers from the neighbor list
      89             :   std::pair<AtomNumber,AtomNumber> getClosePairAtomNumber(unsigned i) const;
      90             : };
      91             : 
      92             : }
      93             : 
      94             : #endif

Generated by: LCOV version 1.15