Line data Source code
1 : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 : Copyright (c) 2014-2018 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_LinkCells_h
23 : #define __PLUMED_tools_LinkCells_h
24 :
25 : #include <vector>
26 : #include "Vector.h"
27 : #include "Pbc.h"
28 :
29 : namespace PLMD {
30 :
31 : class Communicator;
32 :
33 : /// \ingroup TOOLBOX
34 : /// A class for doing link cells
35 528 : class LinkCells {
36 : private:
37 : /// Symbolic link to plumed communicator
38 : Communicator & comm;
39 : /// Check that the link cells were set up correctly
40 : bool cutoffwasset;
41 : /// The cutoff to use for the sizes of the cells
42 : double link_cutoff;
43 : /// The pbc we are using for link cells
44 : Pbc mypbc;
45 : /// The number of cells in each direction
46 : std::vector<unsigned> ncells;
47 : /// The number of cells to stride through to get the link cells
48 : std::vector<unsigned> nstride;
49 : /// The list of cells each atom is inside
50 : std::vector<unsigned> allcells;
51 : /// The start of each block corresponding to each link cell
52 : std::vector<unsigned> lcell_starts;
53 : /// The number of atoms in each link cell
54 : std::vector<unsigned> lcell_tots;
55 : /// The atoms ordered by link cells
56 : std::vector<unsigned> lcell_lists;
57 : /// Find the cell in which this position is contained
58 : std::vector<unsigned> findMyCell( const Vector& pos ) const ;
59 : /// Find the cell in which this position is contained
60 : unsigned findCell( const Vector& pos ) const ;
61 : public:
62 : ///
63 : explicit LinkCells( Communicator& comm );
64 : /// Have the link cells been enabled
65 : bool enabled() const ;
66 : /// Set the value of the cutoff
67 : void setCutoff( const double& lcut );
68 : /// Get the value of the cutoff
69 : double getCutoff() const ;
70 : /// Build the link cell lists
71 : void buildCellLists( const std::vector<Vector>& pos, const std::vector<unsigned>& indices, const Pbc& pbc );
72 : /// Find a list of relevant atoms
73 : void retrieveNeighboringAtoms( const Vector& pos, unsigned& natomsper, std::vector<unsigned>& atoms ) const ;
74 : };
75 :
76 : inline
77 1781 : bool LinkCells::enabled() const {
78 1781 : return cutoffwasset;
79 : }
80 :
81 : }
82 :
83 : #endif
|