Skip to content
Snippets Groups Projects
Commit cbd81007 authored by Max Bonomi's avatar Max Bonomi
Browse files

Moved documentation in .h in doxygen format

parent a33899d7
No related branches found
No related tags found
No related merge requests found
...@@ -31,14 +31,12 @@ NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNum ...@@ -31,14 +31,12 @@ NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNum
initialize(); initialize();
} }
NeighborList::NeighborList(const vector<AtomNumber>& list0, const bool& do_pbc, NeighborList::NeighborList(const vector<AtomNumber>& list0, const bool& do_pbc,
const Pbc& pbc, const double& distance, const Pbc& pbc, const double& distance,
const unsigned& stride): const unsigned& stride):
do_pbc_(do_pbc), pbc_(pbc), do_pbc_(do_pbc), pbc_(pbc),
distance_(distance), stride_(stride) distance_(distance), stride_(stride)
{ {
// store full list of atoms needed
fullatomlist_=list0; fullatomlist_=list0;
nlist0_=list0.size(); nlist0_=list0.size();
twolists_=false; twolists_=false;
...@@ -46,7 +44,6 @@ NeighborList::NeighborList(const vector<AtomNumber>& list0, const bool& do_pbc, ...@@ -46,7 +44,6 @@ NeighborList::NeighborList(const vector<AtomNumber>& list0, const bool& do_pbc,
initialize(); initialize();
} }
// initialize neighborlist with all possible pairs
void NeighborList::initialize() void NeighborList::initialize()
{ {
neighbors_.clear(); neighbors_.clear();
...@@ -55,16 +52,11 @@ void NeighborList::initialize() ...@@ -55,16 +52,11 @@ void NeighborList::initialize()
} }
} }
// this methods returns the list of all atoms
// it should be called at the end of the step
// before the update of the neighbor list or in the prep stage
vector<AtomNumber>& NeighborList::getFullAtomList() vector<AtomNumber>& NeighborList::getFullAtomList()
{ {
return fullatomlist_; return fullatomlist_;
} }
// this method returns the pair of indexes of the positions array
// of pair "ipair" among the list of all possible pairs
pair<unsigned,unsigned> NeighborList::getIndexPair(unsigned ipair) pair<unsigned,unsigned> NeighborList::getIndexPair(unsigned ipair)
{ {
pair<unsigned,unsigned> index; pair<unsigned,unsigned> index;
...@@ -79,18 +71,14 @@ pair<unsigned,unsigned> NeighborList::getIndexPair(unsigned ipair) ...@@ -79,18 +71,14 @@ pair<unsigned,unsigned> NeighborList::getIndexPair(unsigned ipair)
return index; return index;
} }
// this method updates the neighbor list and prepare the new
// list of atoms to request to the MD code
void NeighborList::update(const vector<Vector>& positions) void NeighborList::update(const vector<Vector>& positions)
{ {
// clean neighbors list
neighbors_.clear(); neighbors_.clear();
// check if positions array has the correct length // check if positions array has the correct length
if(positions.size()!=fullatomlist_.size()){ if(positions.size()!=fullatomlist_.size()){
// i need to access to log here. still don't know how to do it // i need to access to log here. still don't know how to do it
//log.printf("ERROR you need to request all the atoms one step before updating the NL\n"); //log.printf("ERROR you need to request all the atoms one step before updating the NL\n");
} }
// update neighbors. cycle on all possible pairs
for(unsigned int i=0;i<nallpairs_;++i){ for(unsigned int i=0;i<nallpairs_;++i){
pair<unsigned,unsigned> index=getIndexPair(i); pair<unsigned,unsigned> index=getIndexPair(i);
unsigned index0=index.first; unsigned index0=index.first;
...@@ -109,7 +97,6 @@ void NeighborList::update(const vector<Vector>& positions) ...@@ -109,7 +97,6 @@ void NeighborList::update(const vector<Vector>& positions)
setRequestList(); setRequestList();
} }
// template to remove duplicates from a list of types <T>
template<typename T> template<typename T>
void NeighborList::removeDuplicates(std::vector<T>& vec) void NeighborList::removeDuplicates(std::vector<T>& vec)
{ {
...@@ -117,7 +104,6 @@ void NeighborList::removeDuplicates(std::vector<T>& vec) ...@@ -117,7 +104,6 @@ void NeighborList::removeDuplicates(std::vector<T>& vec)
vec.erase(std::unique(vec.begin(), vec.end()), vec.end()); vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
} }
// extract the list of atoms from the list of close pairs
void NeighborList::setRequestList() void NeighborList::setRequestList()
{ {
requestlist_.clear(); requestlist_.clear();
...@@ -129,10 +115,6 @@ void NeighborList::setRequestList() ...@@ -129,10 +115,6 @@ void NeighborList::setRequestList()
//removeDuplicates<AtomNumber>(request); //removeDuplicates<AtomNumber>(request);
} }
// this method should be called at the end of the step when nl is updated
// it updates the indexes in the neighbor list to match the new
// ordering in the future positions array at the next iteration
// and returns the new list of atoms to request to the MD code
vector<AtomNumber>& NeighborList::getReducedAtomList() vector<AtomNumber>& NeighborList::getReducedAtomList()
{ {
std::vector< pair<unsigned,unsigned> > newneighbors; std::vector< pair<unsigned,unsigned> > newneighbors;
...@@ -151,28 +133,21 @@ vector<AtomNumber>& NeighborList::getReducedAtomList() ...@@ -151,28 +133,21 @@ vector<AtomNumber>& NeighborList::getReducedAtomList()
return requestlist_; return requestlist_;
} }
// get the update stride of the Neighbor List
unsigned NeighborList::getStride() const unsigned NeighborList::getStride() const
{ {
return stride_; return stride_;
} }
// size of the Neighbor List
unsigned NeighborList::size() const unsigned NeighborList::size() const
{ {
return neighbors_.size(); return neighbors_.size();
} }
// this method returns the pair of indexes in the positions array of
// the close pair "i"
const pair<unsigned,unsigned> & NeighborList::operator[] (unsigned i) const const pair<unsigned,unsigned> & NeighborList::operator[] (unsigned i) const
{ {
return neighbors_[i]; return neighbors_[i];
} }
// this method returns the list of indexes in the positions array of the
// neighbors of the atom "index", where "index" refers to the index in the
// positions array
vector<unsigned> NeighborList::getNeighbors(unsigned index) vector<unsigned> NeighborList::getNeighbors(unsigned index)
{ {
vector<unsigned> neighbors; vector<unsigned> neighbors;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace PLMD{ namespace PLMD{
/// NeighborList /// A class that implements neighbor lists from two lists or a single list of atoms
class NeighborList class NeighborList
{ {
bool do_pair_,do_pbc_,twolists_; bool do_pair_,do_pbc_,twolists_;
...@@ -17,10 +17,15 @@ class NeighborList ...@@ -17,10 +17,15 @@ class NeighborList
std::vector< std::pair<unsigned,unsigned> > neighbors_; std::vector< std::pair<unsigned,unsigned> > neighbors_;
double distance_; double distance_;
unsigned stride_,nlist0_,nlist1_,nallpairs_; unsigned stride_,nlist0_,nlist1_,nallpairs_;
/// Initialize the neighbor list with all possible pairs
void initialize(); void initialize();
std::pair<unsigned,unsigned> getIndexPair(unsigned ipair); /// Return the pair of indexes in the positions array
/// of the two atoms forming the i-th pair among all possible pairs
std::pair<unsigned,unsigned> getIndexPair(unsigned i);
/// Template to remove duplicates from a list of types <T>
template<typename T> template<typename T>
void removeDuplicates(std::vector<T>& vec); void removeDuplicates(std::vector<T>& vec);
/// Extract the list of atoms from the current list of close pairs
void setRequestList(); void setRequestList();
public: public:
NeighborList(const std::vector<PLMD::AtomNumber>& list0, NeighborList(const std::vector<PLMD::AtomNumber>& list0,
...@@ -30,13 +35,24 @@ public: ...@@ -30,13 +35,24 @@ public:
NeighborList(const std::vector<PLMD::AtomNumber>& list0, const bool& do_pbc, NeighborList(const std::vector<PLMD::AtomNumber>& list0, const bool& do_pbc,
const PLMD::Pbc& pbc, const double& distance=1.0e+30, const PLMD::Pbc& pbc, const double& distance=1.0e+30,
const unsigned& stride=0); const unsigned& stride=0);
/// Return the list of all atoms that are needed to rebuild the neighbor list.
/// This method should be called at the end of the step
/// before the update of the neighbor list or in prep stage
std::vector<PLMD::AtomNumber>& getFullAtomList(); std::vector<PLMD::AtomNumber>& getFullAtomList();
/// Update the indexes in the neighbor list to match the
/// ordering in the new positions array
/// and return the new list of atoms that must be requested to the main code
std::vector<PLMD::AtomNumber>& getReducedAtomList(); std::vector<PLMD::AtomNumber>& getReducedAtomList();
/// Update the neighbor list and prepare the new
/// list of atoms that will be requested to the main code
void update(const std::vector<PLMD::Vector>& positions); void update(const std::vector<PLMD::Vector>& positions);
/// Get the update stride of the neighbor list
unsigned getStride() const; unsigned getStride() const;
/// Get the size of the neighbor list
unsigned size() const; unsigned size() const;
/// Get the i-th pair of the neighbor list
const std::pair<unsigned,unsigned> & operator[] (unsigned i)const; const std::pair<unsigned,unsigned> & operator[] (unsigned i)const;
/// Get the list of neighbors of the i-th atom
std::vector<unsigned> getNeighbors(unsigned i); std::vector<unsigned> getNeighbors(unsigned i);
~NeighborList(){}; ~NeighborList(){};
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment