Voro++
|
00001 // Voro++, a 3D cell-based Voronoi library 00002 // 00003 // Author : Chris H. Rycroft (LBL / UC Berkeley) 00004 // Email : chr@alum.mit.edu 00005 // Date : August 30th 2011 00006 00007 /** \file v_base.hh 00008 * \brief Header file for the base Voronoi container class. */ 00009 00010 #ifndef VOROPP_V_BASE_HH 00011 #define VOROPP_V_BASE_HH 00012 00013 #include "worklist.hh" 00014 00015 namespace voro { 00016 00017 /** \brief Class containing data structures common across all particle container classes. 00018 * 00019 * This class contains constants and data structures that are common across all 00020 * particle container classes. It contains constants setting the size of the 00021 * underlying subgrid of blocks that forms the basis of the Voronoi cell 00022 * computations. It also constructs bound tables that are used in the Voronoi 00023 * cell computation, and contains a number of routines that are common across 00024 * all container classes. */ 00025 class voro_base { 00026 public: 00027 /** The number of blocks in the x direction. */ 00028 const int nx; 00029 /** The number of blocks in the y direction. */ 00030 const int ny; 00031 /** The number of blocks in the z direction. */ 00032 const int nz; 00033 /** A constant, set to the value of nx multiplied by ny, which 00034 * is used in the routines that step through blocks in 00035 * sequence. */ 00036 const int nxy; 00037 /** A constant, set to the value of nx*ny*nz, which is used in 00038 * the routines that step through blocks in sequence. */ 00039 const int nxyz; 00040 /** The size of a computational block in the x direction. */ 00041 const double boxx; 00042 /** The size of a computational block in the y direction. */ 00043 const double boxy; 00044 /** The size of a computational block in the z direction. */ 00045 const double boxz; 00046 /** The inverse box length in the x direction. */ 00047 const double xsp; 00048 /** The inverse box length in the y direction. */ 00049 const double ysp; 00050 /** The inverse box length in the z direction. */ 00051 const double zsp; 00052 /** An array to hold the minimum distances associated with the 00053 * worklists. This array is initialized during container 00054 * construction, by the initialize_radii() routine. */ 00055 double *mrad; 00056 /** The pre-computed block worklists. */ 00057 static const unsigned int wl[wl_seq_length*wl_hgridcu]; 00058 bool contains_neighbor(const char* format); 00059 voro_base(int nx_,int ny_,int nz_,double boxx_,double boxy_,double boxz_); 00060 ~voro_base() {delete [] mrad;} 00061 protected: 00062 /** A custom int function that returns consistent stepping 00063 * for negative numbers, so that (-1.5, -0.5, 0.5, 1.5) maps 00064 * to (-2,-1,0,1). 00065 * \param[in] a the number to consider. 00066 * \return The value of the custom int operation. */ 00067 inline int step_int(double a) {return a<0?int(a)-1:int(a);} 00068 /** A custom modulo function that returns consistent stepping 00069 * for negative numbers. For example, (-2,-1,0,1,2) step_mod 2 00070 * is (0,1,0,1,0). 00071 * \param[in] (a,b) the input integers. 00072 * \return The value of a modulo b, consistent for negative 00073 * numbers. */ 00074 inline int step_mod(int a,int b) {return a>=0?a%b:b-1-(b-1-a)%b;} 00075 /** A custom integer division function that returns consistent 00076 * stepping for negative numbers. For example, (-2,-1,0,1,2) 00077 * step_div 2 is (-1,-1,0,0,1). 00078 * \param[in] (a,b) the input integers. 00079 * \return The value of a div b, consistent for negative 00080 * numbers. */ 00081 inline int step_div(int a,int b) {return a>=0?a/b:-1+(a+1)/b;} 00082 private: 00083 void compute_minimum(double &minr,double &xlo,double &xhi,double &ylo,double &yhi,double &zlo,double &zhi,int ti,int tj,int tk); 00084 }; 00085 00086 } 00087 00088 #endif