1 /* -*- c++ -*- */
2 #ifndef CUBICCELLMANAGER_H
3 #define CUBICCELLMANAGER_H
4 
5 #include "ArrayCellListStructure.h"
6 #include "Parameter.h"
7 #include "Vector3D.h"
8 
9 #include <vector>
10 
11 namespace ProtoMol {
12 
13   //_________________________________________________________________ CubicCellManager
14   /**
15    * The cell manager for equal-sized (cubic) cells. For optimization reasons
16    * in case of periodic boundary conditions the cells are not cubic any more
17    * in order to fit the system by multiples of the cell dimensions.
18    */
19   class CubicCellManager {
20   public:
21     /// topology and cell location structure of the cell
22     typedef CubicCellLocation Cell;
23     /// implementation of the cell list
24     typedef ArrayCellListStructure CellListStructure;
25 
26     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27     // Constructors, destructors, assignment
28     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29   public:
CubicCellManager()30     CubicCellManager():myCellSize(0.0){}
31     CubicCellManager(Real r);
32 
33     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34     // New methods of class CubicCellManager
35     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36   public:
37     /// Set the size of each cell.
38     void setCellSize(Real newSize);
39 
getCellSize(void)40     Real getCellSize(void) const {return myCellSize;}
getRealCellSize(void)41     Vector3D getRealCellSize(void) const {return myRealCellSize;}
42     /// Get the volume of the cell.
getCellVolume(void)43     Real getCellVolume(void) const {return myRealCellSize.x*myRealCellSize.y*myRealCellSize.z;}
44 
45     /// Find the cell that one atom belongs to.
findCell(const Vector3D & position)46     Cell findCell(const Vector3D &position) const {
47       return Cell((int)floor(position.x*myRealRCellSize.x),(int)floor(position.y*myRealRCellSize.y),(int)floor(position.z*myRealRCellSize.z));
48     }
49 
50     void initialize(CellListStructure& cellList,const Vector3D& min, const Vector3D& max, bool pbc) const;
51     void updateCache(CellListStructure& cellList) const;
52 
getKeyword()53     const std::string& getKeyword() const {return keyword;}
54 
55     void getParameters(std::vector<Parameter>& parameters) const;
getParameterSize()56     unsigned int getParameterSize() const{return 1;}
57     static CubicCellManager make(std::string& errMsg, std::vector<Value> values);
58 
59     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60     // My data members
61     //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62   public:
63     static const std::string keyword;
64   private:
65     Real myCellSize;
66     mutable Vector3D myRealCellSize;
67     mutable Vector3D myRealRCellSize;
68   };
69 
70   //______________________________________________________________________ INLINES
71 }
72 #endif /* CUBICCELLMANAGER_H */
73