NAMD
Public Member Functions | List of all members
LCPONeighborList Class Reference

#include <ComputeLCPO.h>

Public Member Functions

 LCPONeighborList ()
 
 ~LCPONeighborList ()
 
LCPOAtomnewlist (int max_size)
 
LCPOAtomnewlist ()
 
void newsize (int list_size)
 
void reset ()
 
void nextlist (LCPOAtom **list, int *list_size)
 
int getSize ()
 

Detailed Description

Definition at line 27 of file ComputeLCPO.h.

Constructor & Destructor Documentation

LCPONeighborList::LCPONeighborList ( )
inline

Definition at line 38 of file ComputeLCPO.h.

38  :
39  maxNeighbors(initsize), maxAtoms(initsize),
40  curNeighbor(0), curAtom(0) {
41  neighbors = new LCPOAtom[initsize];
42  nnfa = new int[initsize];
43  }
LCPONeighborList::~LCPONeighborList ( )
inline

Definition at line 44 of file ComputeLCPO.h.

44  {
45  delete [] neighbors;
46  delete [] nnfa;
47  }

Member Function Documentation

int LCPONeighborList::getSize ( )
inline

Definition at line 90 of file ComputeLCPO.h.

90 { return maxNeighbors; }
LCPOAtom* LCPONeighborList::newlist ( int  max_size)
inline

Definition at line 48 of file ComputeLCPO.h.

Referenced by ComputeLCPO::doForce().

48  { // get a new list w/ room for max_size
49  //do we need to make room for more neighbors
50  int reqNewSize = curNeighbor + max_size;
51  int newSize = maxNeighbors;
52  while ( newSize < reqNewSize ) { newSize += newSize >> 1; }
53  if ( newSize > maxNeighbors ) {
54  LCPOAtom *newNeighbors = new LCPOAtom[newSize];
55  CmiMemcpy(newNeighbors,neighbors,curNeighbor*sizeof(LCPOAtom));
56  delete [] neighbors;
57  neighbors = newNeighbors;
58  maxNeighbors = newSize;
59  }
60  //do we need to make room for more atoms
61  if (curAtom == maxAtoms) {
62  newSize = maxAtoms + (maxAtoms >> 1);
63  int *newNnfa = new int[newSize];
64  CmiMemcpy(newNnfa,nnfa,curAtom*sizeof(int));
65  delete [] nnfa;
66  nnfa = newNnfa;
67  maxAtoms = newSize;
68  }
69  return &neighbors[curNeighbor];
70  }
LCPOAtom* LCPONeighborList::newlist ( )
inline

Definition at line 72 of file ComputeLCPO.h.

72  { // get a new list assuming already allocated
73  return &neighbors[curNeighbor];
74  }
void LCPONeighborList::newsize ( int  list_size)
inline

Definition at line 75 of file ComputeLCPO.h.

Referenced by ComputeLCPO::doForce().

75  { // set the size of the last list gotten
76  nnfa[curAtom] = list_size;
77  curAtom++;
78  curNeighbor += list_size;
79  }
void LCPONeighborList::nextlist ( LCPOAtom **  list,
int *  list_size 
)
inline

Definition at line 84 of file ComputeLCPO.h.

Referenced by ComputeLCPO::doForce().

84  { // get next list and size
85  *list = &neighbors[curNeighbor];
86  *list_size = nnfa[curAtom];
87  curNeighbor += nnfa[curAtom];
88  curAtom ++;
89  }
void LCPONeighborList::reset ( )
inline

Definition at line 80 of file ComputeLCPO.h.

Referenced by ComputeLCPO::doForce().

80  { // go back to the beginning
81  curNeighbor = 0;
82  curAtom = 0;
83  }

The documentation for this class was generated from the following file: