.Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
CellListFast.h
1 #ifndef __CELL_LIST_CELL_LIST_FAST_H__
2 #define __CELL_LIST_CELL_LIST_FAST_H__
3 
4 #include <boost/multi_array.hpp>
5 
6 #include "../Vector/Vector.hpp"
7 
8 namespace MDSimulation
9 {
20  class CellList
21  {
22  private:
23 
24  typedef boost::multi_array<int, 3> CellData;
25  typedef boost::multi_array<int, 1> LinkedList;
26  typedef boost::multi_array<IntVector, 1> CellIndex;
27 
28  int Particles; // The number of particles in the system
29  IntVector Size;
30 
31  CellData Cells; // 3D array of cell contents.
32  CellIndex Index; // An index of which cell each particle is in.
33  LinkedList Neighbors; // A list of the neighbors in each cell.
34 
49  int FindListPosition(int start, const int ps);
50 
51  public:
52 
54  {
55  private:
56 
57  IntVector LowBounds;
58  IntVector HighBounds;
59 
60  CellList& Parent; // Reference to the current cell list
61 
62  const IntVector Cell; // Cell to find neighbors for
63  IntVector CurrentCell;
64  int CurrentParticle;
65 
66  public:
67 
68  // Constructor for the inner cell
69  NeighborCellIterator(CellList& parent, const IntVector& cell,
70  const IntVector& low, const IntVector& high);
71 
72  // De-reference Operation
73  int operator*() const;
74 
75  // Have we exhaused the iterator?
76  bool HasNext() const;
77 
78  // Increment the iterator
80  };
81 
85  CellList(const int ps, const int xs, const int ys, const int zs);
86 
90  const IntVector& ParticlePosition(const int ps) const;
91 
95  void ParticlePosition(const int ps, IntVector& v) const;
96 
103  void MoveParticle(const int ps, const IntVector& mv);
104 
113  void SetParticle(const int ps, const int x, const int y, const int z);
114 
115 
124  void SetParticle(const int particle, const IntVector& v);
125 
136  NeighborCellIterator BeginNeighborCell(const int particle,
137  const IntVector& low,
138  const IntVector& high);
139 
150  void Resize(const int ps, const IntVector& ex);
151 
156  void Clear();
157 
164  inline unsigned long Dims(const int i) const
165  {
166  assert(i >= 0);
167  assert((unsigned) i < Cells.num_dimensions());
168  return Cells.shape()[i];
169  }
170  };
171 }
172 
173 #endif /* __CELL_LIST_H__ */
NeighborCellIterator BeginNeighborCell(const int particle, const IntVector &low, const IntVector &high)
Create an iterator into the neighboring cells of a given particle.
Definition: CellListFast.cpp:109
This class provides the functionality of a three dimensional cell list.
Definition: CellListFast.h:20
int operator*() const
Definition: CellListFast.cpp:269
CellList(const int ps, const int xs, const int ys, const int zs)
Constructor.
Definition: CellListFast.cpp:59
bool HasNext() const
Definition: CellListFast.cpp:278
void SetParticle(const int ps, const int x, const int y, const int z)
Sets the position of the current particle.
Definition: CellListFast.cpp:125
NeighborCellIterator(CellList &parent, const IntVector &cell, const IntVector &low, const IntVector &high)
Create an iterator into the cells adjacent to the current one (the current one is treated as triviall...
Definition: CellListFast.cpp:185
void Clear()
Clear out the contents of the CellList.
Definition: CellListFast.cpp:315
const IntVector & ParticlePosition(const int ps) const
Get the particle&#39;s position in the grid space.
Definition: CellListFast.cpp:81
unsigned long Dims(const int i) const
Get the number of partitions along each dimension.
Definition: CellListFast.h:164
void MoveParticle(const int ps, const IntVector &mv)
Moves a particle the set number of cells in each direction.
Definition: CellListFast.cpp:93
void Resize(const int ps, const IntVector &ex)
Resize the cell list to a new volume.
Definition: CellListFast.cpp:286
tvmet::Vector< int, 3UL > IntVector
A vector of integer values to hold a particle&#39;s position in the grid of cells.
Definition: Vector.hpp:29
NeighborCellIterator & operator++()
Advances the iterator one position.
Definition: CellListFast.cpp:233