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

Added two new methods to get all the close pairs (not checking for duplicates at this time).

getClosePairs to get the indexes in the positions array, getClosePairsAtomicIndex to get the atomic indexes instead
parent 489c1ed2
No related branches found
No related tags found
No related merge requests found
......@@ -118,6 +118,30 @@ vector<unsigned> NeighborList::getNeighborsAtomicIndex(unsigned iatom)
return neigh;
}
vector<pair <unsigned, unsigned> > NeighborList::getClosePairs()
{
vector<pair <unsigned, unsigned> > pairs;
for(unsigned int i=0;i<getNumberOfAtoms();++i){
for(unsigned int j=0;j<getNumberOfNeighbors(i);++j){
unsigned jatom=neighbors_[i][j];
pairs.push_back(pair <unsigned,unsigned> (i,indexes_[jatom]));
}
}
return pairs;
}
vector<pair <unsigned, unsigned> > NeighborList::getClosePairsAtomicIndex()
{
vector<pair <unsigned, unsigned> > pairs;
for(unsigned int i=0;i<getNumberOfAtoms();++i){
unsigned iatom=list0_[i];
for(unsigned int j=0;j<getNumberOfNeighbors(i);++j){
pairs.push_back(pair <unsigned,unsigned> (iatom,neighbors_[i][j]));
}
}
return pairs;
}
unsigned NeighborList::getNumberOfNeighbors(unsigned index)
{
return neighbors_[index].size();
......@@ -125,5 +149,5 @@ unsigned NeighborList::getNumberOfNeighbors(unsigned index)
unsigned NeighborList::getNumberOfAtoms() const
{
return neighbors_.size();
return list0_.size();
}
......@@ -22,6 +22,8 @@ public:
void update();
std::vector<unsigned> getNeighbors(unsigned index);
std::vector<unsigned> getNeighborsAtomicIndex(unsigned iatom);
std::vector<std::pair <unsigned, unsigned> > getClosePairs();
std::vector<std::pair <unsigned, unsigned> > getClosePairsAtomicIndex();
unsigned getStride() const;
unsigned getNumberOfAtoms() const;
unsigned getNumberOfNeighbors(unsigned index);
......
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