Simpatico  v1.10
List of all members | Public Types | Public Member Functions | Static Public Attributes
Tools::Cell Class Reference

Detailed Description

A single cell in a CellList.

An initialized Cell has an array of CellAtom objects, a pointer to the next Cell in a linked list, and a pointer to an array of integer offsets to neighboring cells.

A linked list of cells is created by a parent CellList. The method CellList::begin() returns a pointer to the first Cell in the list.

The method Cell::getNeighbors() returns an array containing pointers to atoms in this cell and all neighboring cells, with the atoms in in this cell listed first.

Here is an example of code to iterate over all local cells in a CellList, and over all pairs of neighboring atoms:

CellList cellList; // parent CellList
Cell::NeighborArray neighbors; // array of CellAtom* pointers
const Cell* cellPtr; // pointer to Cell in linked list
Atom* atom1Ptr; // pointer to Atom in this cell.
Atom* atom2Ptr; // pointer to neighbor Atom
// Iterate over cells in list.
cellPtr = cellList.begin();
while (cellPtr) {
cellPtr->getNeighbors(neighbors);
// Iterate over atoms in this cell.
for (i = 0; i < cellPtr->nAtom(); ++i) {
atom1Ptr = neighbors[i];
// Iterate over neighbor atoms.
for (j = 0; j < neighbors.size(); ++j) {
atom2Ptr = neighbors[j];
}
}
}

Definition at line 70 of file tools/neighbor/Cell.h.

#include <Cell.h>

Public Types

typedef FSArray< std::pair< int, int >, Dimension > OffsetArray
 An array of offsets to the neighboring cells surrounding this cell. More...
 
typedef FSArray< CellAtom *, MaxNeighborAtomNeighborArray
 Static array for holding neighbors in a cell list. More...
 

Public Member Functions

 Cell ()
 Constructor. More...
 
 ~Cell ()
 Destructor. More...
 
void setNextCell (Cell &nextCell)
 Set the pointer to the next cell in the list. More...
 
void setLastCell ()
 Set this to be the last cell in the list. More...
 
const CellnextCellPtr () const
 Return a pointer to neighbor cell i. More...
 
void setId (int id)
 Set id for this Cell. More...
 
void setOffsetArray (OffsetArray &offsets)
 Set the pointer to an array of integer offsets. More...
 
void clear ()
 Reset to empty before incrementing capacity. More...
 
void incrementCapacity ()
 Increment the capacity counter. More...
 
CellAtominitialize (CellAtom *begin)
 Associate the Cell with an array of CellAtom objects. More...
 
void append (Atom *atomPtr)
 Append an Atom to an initialized cell. More...
 
int id () const
 Get identifier for this Cell. More...
 
int nAtom () const
 Number of atoms in cell. More...
 
int atomCapacity () const
 Capacity of array segment. More...
 
CellAtomatomPtr (int i) const
 Return a pointer to atom i. More...
 
void getNeighbors (NeighborArray &neighbors) const
 Fill an array with pointers to atoms in a cell and neighboring cells. More...
 

Static Public Attributes

static const int MaxNeighborAtom = 2000
 Maximum possible number of atoms in this an neighboring cells. More...
 

Member Typedef Documentation

typedef FSArray< std::pair<int,int>, Dimension> Tools::Cell::OffsetArray

An array of offsets to the neighboring cells surrounding this cell.

Every cell has a pointer to an OffsetArray, which uses relative cell indices (offsets relative to the cell id of the primary cell) to identify neighboring cells. There are a maximum of 3 pairs, one for each dimension. The pair.first contains the offset to move in the positive direction while pair.second contains the offset to move in the negative direction. The contents of the OffsetArray are calculated in the CellList::makeGrid() function.

Definition at line 93 of file tools/neighbor/Cell.h.

Static array for holding neighbors in a cell list.

Definition at line 98 of file tools/neighbor/Cell.h.

Constructor & Destructor Documentation

Tools::Cell::Cell ( )

Constructor.

Definition at line 15 of file tools/neighbor/Cell.cpp.

Tools::Cell::~Cell ( )

Destructor.

Definition at line 23 of file tools/neighbor/Cell.cpp.

Member Function Documentation

void Tools::Cell::setNextCell ( Cell nextCell)

Set the pointer to the next cell in the list.

Definition at line 31 of file tools/neighbor/Cell.cpp.

Referenced by Tools::CellList::allocate().

void Tools::Cell::setLastCell ( )

Set this to be the last cell in the list.

Definition at line 34 of file tools/neighbor/Cell.cpp.

Referenced by Tools::CellList::allocate().

const Cell * Tools::Cell::nextCellPtr ( ) const
inline

Return a pointer to neighbor cell i.

Definition at line 290 of file tools/neighbor/Cell.h.

Referenced by Tools::PairEnergy::sample().

void Tools::Cell::setId ( int  id)
inline

Set id for this Cell.

Parameters
idinteger identifier for this Cell

Definition at line 231 of file tools/neighbor/Cell.h.

void Tools::Cell::setOffsetArray ( Cell::OffsetArray offsets)

Set the pointer to an array of integer offsets.

Definition at line 28 of file tools/neighbor/Cell.cpp.

void Tools::Cell::clear ( )
inline

Reset to empty before incrementing capacity.

Definition at line 240 of file tools/neighbor/Cell.h.

void Tools::Cell::incrementCapacity ( )
inline

Increment the capacity counter.

This must be called within a loop over atoms, once per atom that belongs in this cell. This loop must completed before initialize is called.

Definition at line 234 of file tools/neighbor/Cell.h.

CellAtom * Tools::Cell::initialize ( CellAtom begin)
inline

Associate the Cell with an array of CellAtom objects.

The final capacity of the cell must be known when this method is called. It associate the Cell with a C array of capacity Atom* pointers, starting at position begin. It returns a pointer to an element one past the end of this array segment.

Parameters
beginfirst element in associated array segment.
Returns
end of array segment (element one past the end)

Definition at line 247 of file tools/neighbor/Cell.h.

void Tools::Cell::append ( Atom atomPtr)
inline

Append an Atom to an initialized cell.

Definition at line 257 of file tools/neighbor/Cell.h.

int Tools::Cell::id ( ) const
inline

Get identifier for this Cell.

Definition at line 268 of file tools/neighbor/Cell.h.

int Tools::Cell::nAtom ( ) const
inline

Number of atoms in cell.

Definition at line 274 of file tools/neighbor/Cell.h.

Referenced by Tools::CellList::isValid(), and Tools::PairEnergy::sample().

int Tools::Cell::atomCapacity ( ) const
inline

Capacity of array segment.

Definition at line 296 of file tools/neighbor/Cell.h.

Referenced by Tools::CellList::isValid().

CellAtom * Tools::Cell::atomPtr ( int  i) const
inline

Return a pointer to atom i.

Definition at line 280 of file tools/neighbor/Cell.h.

Referenced by Tools::CellList::isValid().

void Tools::Cell::getNeighbors ( NeighborArray neighbors) const

Fill an array with pointers to atoms in a cell and neighboring cells.

Upon return, the FSArray neighbors contains pointers to all of the atoms in this cell and neighboring cells. The first nAtom() elements contain pointers to atoms in this cell.

To avoid double counting of pairs, the method only returns atoms from neighboring local cells with a cell id greater than this->id().

Parameters
neighborsArray of pointers to neighbor Atoms

Definition at line 44 of file tools/neighbor/Cell.cpp.

References Util::FSArray< Data, Capacity >::append(), and Util::FSArray< Data, Capacity >::clear().

Referenced by Tools::PairEnergy::sample().

Member Data Documentation

const int Tools::Cell::MaxNeighborAtom = 2000
static

Maximum possible number of atoms in this an neighboring cells.

Definition at line 80 of file tools/neighbor/Cell.h.


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