9 #include <util/space/Vector.h> 10 #include <util/space/Dimension.h> 23 invCellWidths_[i] = 0.0;
48 if (cells_.capacity() > 0) {
49 for (i=0; i < cells_.capacity(); ++i) {
55 if (cellTags_.capacity() > 0) {
56 for (i = 0; i < cellTags_.capacity(); ++i) {
66 CellList::setCellsAxis(
int axis,
double cutoff)
68 numCells_[axis] = (int)(lengths_[axis]/cutoff);
69 if (numCells_[axis] < 1) {
72 invCellWidths_[axis] = (double)numCells_[axis];
75 maxCells_[axis] = numCells_[axis]-1;
77 if (numCells_[axis] > 2) {
80 }
else if (numCells_[axis] == 2) {
83 }
else if (numCells_[axis] == 1) {
96 if (atomCapacity <= 0) {
99 atomCapacity_ = atomCapacity;
102 if (cellTags_.capacity() == 0) {
103 cellTags_.allocate(atomCapacity_);
105 if (atomCapacity_ > cellTags_.capacity()) {
106 cellTags_.deallocate();
107 cellTags_.allocate(atomCapacity_);
121 setCellsAxis(0, cutoff);
122 setCellsAxis(1, cutoff);
123 setCellsAxis(2, cutoff);
124 YZCells_ = numCells_[1]*numCells_[2];
125 totCells_ = YZCells_*numCells_[0];
131 if (cells_.capacity() == 0) {
132 cells_.allocate(totCells_);
134 if (totCells_ > cells_.capacity()) {
136 cells_.allocate(totCells_);
140 boundaryPtr_ = &boundary;
153 int jc, jcx, jcy, jcz;
154 int dcx, dcy, dcz, jp;
157 cellCoordFromIndex(ic, icx, icy, icz);
166 cellPtr = &(cells_[ic]);
168 atomPtr = cellPtr->
atomPtr(jp);
170 neighbors.
append(atomPtr);
178 for (dcx = minDel_[0]; dcx <= maxDel_[0]; ++dcx) {
179 jcx = shiftCellCoordAxis(0, icx + dcx);
182 for (dcy = minDel_[1]; dcy <= maxDel_[1]; ++dcy) {
183 jcy = shiftCellCoordAxis(1, icy + dcy);
186 for (dcz = minDel_[2]; dcz <= maxDel_[2]; ++dcz) {
187 jcz = shiftCellCoordAxis(2, icz + dcz);
190 jc = cellIndexFromCoord(jcx, jcy, jcz);
195 cellPtr = &cells_[jc];
197 atomPtr = cellPtr->
atomPtr(jp);
199 neighbors.
append(atomPtr);
217 {
return atomCapacity_; }
225 for (
int icell = 0; icell < totCells_; ++icell) {
226 nAtomSum += cells_[icell].nAtomCell();
242 for (
int icell = 0; icell < totCells_; ++icell) {
243 cells_[icell].isValid(cellTags_, nAtom, icell);
244 nAtomSum += cells_[icell].nAtomCell();
249 if (nAtomSum != nAtom) {
250 UTIL_THROW(
"Number of atoms in all cells != nAtom");
const int Dimension
Dimensionality of space.
bool isValid(int nAtom=-1) const
Return true if valid, or throw Exception.
void clear()
Set logical size to zero.
const Vector & lengths() const
Get Vector of unit cell lengths by const reference.
An orthorhombic periodic unit cell.
void append(const Data &data)
Append data to the end of the array.
int atomCapacity() const
Get the maximum allowed atom index + 1.
void clear()
Sets all Cell objects to empty state (no Atoms).
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
void getCellNeighbors(int ic, NeighborArray &neighbors, int &nInCell) const
Fill an array with pointers to atoms in a cell and neighboring cells.
int nAtom() const
Get total number of atoms in this CellList.
A point particle within a Molecule.
Utility classes for scientific computation.
void setup(const Boundary &boundary, double cutoff)
Setup grid of empty cells.
Atom * atomPtr(int index) const
Get a pointer to Atom (may be null).
virtual ~CellList()
Destructor.
A set of Atoms in a small region.
int firstClearPos() const
Get index of first clear element of atoms_.
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void setAtomCapacity(int atomCapacity)
Set atom capacity.