Simpatico
v1.10
|
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:
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 *, MaxNeighborAtom > | NeighborArray |
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 Cell * | nextCellPtr () 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... | |
CellAtom * | initialize (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... | |
CellAtom * | atomPtr (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... | |
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.
typedef FSArray<CellAtom*, MaxNeighborAtom> Tools::Cell::NeighborArray |
Static array for holding neighbors in a cell list.
Definition at line 98 of file tools/neighbor/Cell.h.
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.
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().
|
inline |
Return a pointer to neighbor cell i.
Definition at line 290 of file tools/neighbor/Cell.h.
Referenced by Tools::PairEnergy::sample().
|
inline |
Set id for this Cell.
id | integer 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.
|
inline |
Reset to empty before incrementing capacity.
Definition at line 240 of file tools/neighbor/Cell.h.
|
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.
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.
begin | first element in associated array segment. |
Definition at line 247 of file tools/neighbor/Cell.h.
|
inline |
Append an Atom to an initialized cell.
Definition at line 257 of file tools/neighbor/Cell.h.
|
inline |
Get identifier for this Cell.
Definition at line 268 of file tools/neighbor/Cell.h.
|
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().
|
inline |
Capacity of array segment.
Definition at line 296 of file tools/neighbor/Cell.h.
Referenced by Tools::CellList::isValid().
|
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().
neighbors | Array 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().
|
static |
Maximum possible number of atoms in this an neighboring cells.
Definition at line 80 of file tools/neighbor/Cell.h.