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 rad_option.hh 00008 * \brief Header file for the classes encapsulating functionality for the 00009 * regular and radical Voronoi tessellations. */ 00010 00011 #ifndef VOROPP_RAD_OPTION_HH 00012 #define VOROPP_RAD_OPTION_HH 00013 00014 namespace voro { 00015 00016 /** \brief Class containing all of the routines that are specific to computing 00017 * the regular Voronoi tessellation. 00018 * 00019 * The container and container_periodic classes are derived from this class, 00020 * and during the Voronoi cell computation, these routines are used to create 00021 * the regular Voronoi tessellation. */ 00022 class radius_mono { 00023 protected: 00024 /** This is called prior to computing a Voronoi cell for a 00025 * given particle to initialize any required constants. 00026 * \param[in] ijk the block that the particle is within. 00027 * \param[in] s the index of the particle within the block. */ 00028 inline void r_init(int ijk,int s) {} 00029 /** Sets a required constant to be used when carrying out a 00030 * plane bounds check. */ 00031 inline void r_prime(double rv) {} 00032 /** Carries out a radius bounds check. 00033 * \param[in] crs the radius squared to be tested. 00034 * \param[in] mrs the current maximum distance to a Voronoi 00035 * vertex multiplied by two. 00036 * \return True if particles at this radius could not possibly 00037 * cut the cell, false otherwise. */ 00038 inline bool r_ctest(double crs,double mrs) {return crs>mrs;} 00039 /** Scales a plane displacement during a plane bounds check. 00040 * \param[in] lrs the plane displacement. 00041 * \return The scaled value. */ 00042 inline double r_cutoff(double lrs) {return lrs;} 00043 /** Adds the maximum radius squared to a given value. 00044 * \param[in] rs the value to consider. 00045 * \return The value with the radius squared added. */ 00046 inline double r_max_add(double rs) {return rs;} 00047 /** Subtracts the radius squared of a particle from a given 00048 * value. 00049 * \param[in] rs the value to consider. 00050 * \param[in] ijk the block that the particle is within. 00051 * \param[in] q the index of the particle within the block. 00052 * \return The value with the radius squared subtracted. */ 00053 inline double r_current_sub(double rs,int ijk,int q) {return rs;} 00054 /** Scales a plane displacement prior to use in the plane cutting 00055 * algorithm. 00056 * \param[in] rs the initial plane displacement. 00057 * \param[in] ijk the block that the particle is within. 00058 * \param[in] q the index of the particle within the block. 00059 * \return The scaled plane displacement. */ 00060 inline double r_scale(double rs,int ijk,int q) {return rs;} 00061 /** Scales a plane displacement prior to use in the plane 00062 * cutting algorithm, and also checks if it could possibly cut 00063 * the cell. 00064 * \param[in,out] rs the plane displacement to be scaled. 00065 * \param[in] mrs the current maximum distance to a Voronoi 00066 * vertex multiplied by two. 00067 * \param[in] ijk the block that the particle is within. 00068 * \param[in] q the index of the particle within the block. 00069 * \return True if the cell could possibly cut the cell, false 00070 * otherwise. */ 00071 inline bool r_scale_check(double &rs,double mrs,int ijk,int q) {return rs<mrs;} 00072 }; 00073 00074 /** \brief Class containing all of the routines that are specific to computing 00075 * the radical Voronoi tessellation. 00076 * 00077 * The container_poly and container_periodic_poly classes are derived from this 00078 * class, and during the Voronoi cell computation, these routines are used to 00079 * create the radical Voronoi tessellation. */ 00080 class radius_poly { 00081 public: 00082 /** A two-dimensional array holding particle positions and radii. */ 00083 double **ppr; 00084 /** The current maximum radius of any particle, used to 00085 * determine when to cut off the radical Voronoi computation. 00086 * */ 00087 double max_radius; 00088 /** The class constructor sets the maximum particle radius to 00089 * be zero. */ 00090 radius_poly() : max_radius(0) {} 00091 protected: 00092 /** This is called prior to computing a Voronoi cell for a 00093 * given particle to initialize any required constants. 00094 * \param[in] ijk the block that the particle is within. 00095 * \param[in] s the index of the particle within the block. */ 00096 inline void r_init(int ijk,int s) { 00097 r_rad=ppr[ijk][4*s+3]*ppr[ijk][4*s+3]; 00098 r_mul=r_rad-max_radius*max_radius; 00099 } 00100 /** Sets a required constant to be used when carrying out a 00101 * plane bounds check. */ 00102 inline void r_prime(double rv) {r_val=1+r_mul/rv;} 00103 /** Carries out a radius bounds check. 00104 * \param[in] crs the radius squared to be tested. 00105 * \param[in] mrs the current maximum distance to a Voronoi 00106 * vertex multiplied by two. 00107 * \return True if particles at this radius could not possibly 00108 * cut the cell, false otherwise. */ 00109 inline bool r_ctest(double crs,double mrs) {return crs+r_mul>sqrt(mrs*crs);} 00110 /** Scales a plane displacement during a plane bounds check. 00111 * \param[in] lrs the plane displacement. 00112 * \return The scaled value. */ 00113 inline double r_cutoff(double lrs) {return lrs*r_val;} 00114 /** Adds the maximum radius squared to a given value. 00115 * \param[in] rs the value to consider. 00116 * \return The value with the radius squared added. */ 00117 inline double r_max_add(double rs) {return rs+max_radius*max_radius;} 00118 /** Subtracts the radius squared of a particle from a given 00119 * value. 00120 * \param[in] rs the value to consider. 00121 * \param[in] ijk the block that the particle is within. 00122 * \param[in] q the index of the particle within the block. 00123 * \return The value with the radius squared subtracted. */ 00124 inline double r_current_sub(double rs,int ijk,int q) { 00125 return rs-ppr[ijk][4*q+3]*ppr[ijk][4*q+3]; 00126 } 00127 /** Scales a plane displacement prior to use in the plane cutting 00128 * algorithm. 00129 * \param[in] rs the initial plane displacement. 00130 * \param[in] ijk the block that the particle is within. 00131 * \param[in] q the index of the particle within the block. 00132 * \return The scaled plane displacement. */ 00133 inline double r_scale(double rs,int ijk,int q) { 00134 return rs+r_rad-ppr[ijk][4*q+3]*ppr[ijk][4*q+3]; 00135 } 00136 /** Scales a plane displacement prior to use in the plane 00137 * cutting algorithm, and also checks if it could possibly cut 00138 * the cell. 00139 * \param[in,out] rs the plane displacement to be scaled. 00140 * \param[in] mrs the current maximum distance to a Voronoi 00141 * vertex multiplied by two. 00142 * \param[in] ijk the block that the particle is within. 00143 * \param[in] q the index of the particle within the block. 00144 * \return True if the cell could possibly cut the cell, false 00145 * otherwise. */ 00146 inline bool r_scale_check(double &rs,double mrs,int ijk,int q) { 00147 double trs=rs; 00148 rs+=r_rad-ppr[ijk][4*q+3]*ppr[ijk][4*q+3]; 00149 return rs<sqrt(mrs*trs); 00150 } 00151 private: 00152 double r_rad,r_mul,r_val; 00153 }; 00154 00155 } 00156 #endif