1 // Voro++, a 3D cell-based Voronoi library
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
7 /** \file rad_option.hh
8 * \brief Header file for the classes encapsulating functionality for the
9 * regular and radical Voronoi tessellations. */
11 #ifndef VOROPP_RAD_OPTION_HH
12 #define VOROPP_RAD_OPTION_HH
16 /** \brief Class containing all of the routines that are specific to computing
17 * the regular Voronoi tessellation.
19 * The container and container_periodic classes are derived from this class,
20 * and during the Voronoi cell computation, these routines are used to create
21 * the regular Voronoi tessellation. */
24 /** This is called prior to computing a Voronoi cell for a
25 * given particle to initialize any required constants.
26 * \param[in] ijk the block that the particle is within.
27 * \param[in] s the index of the particle within the block. */
28 inline void r_init(int ijk
,int s
) {}
29 /** Sets a required constant to be used when carrying out a
30 * plane bounds check. */
31 inline void r_prime(double rv
) {}
32 /** Carries out a radius bounds check.
33 * \param[in] crs the radius squared to be tested.
34 * \param[in] mrs the current maximum distance to a Voronoi
35 * vertex multiplied by two.
36 * \return True if particles at this radius could not possibly
37 * cut the cell, false otherwise. */
38 inline bool r_ctest(double crs
,double mrs
) {return crs
>mrs
;}
39 /** Scales a plane displacement during a plane bounds check.
40 * \param[in] lrs the plane displacement.
41 * \return The scaled value. */
42 inline double r_cutoff(double lrs
) {return lrs
;}
43 /** Adds the maximum radius squared to a given value.
44 * \param[in] rs the value to consider.
45 * \return The value with the radius squared added. */
46 inline double r_max_add(double rs
) {return rs
;}
47 /** Subtracts the radius squared of a particle from a given
49 * \param[in] rs the value to consider.
50 * \param[in] ijk the block that the particle is within.
51 * \param[in] q the index of the particle within the block.
52 * \return The value with the radius squared subtracted. */
53 inline double r_current_sub(double rs
,int ijk
,int q
) {return rs
;}
54 /** Scales a plane displacement prior to use in the plane cutting
56 * \param[in] rs the initial plane displacement.
57 * \param[in] ijk the block that the particle is within.
58 * \param[in] q the index of the particle within the block.
59 * \return The scaled plane displacement. */
60 inline double r_scale(double rs
,int ijk
,int q
) {return rs
;}
61 /** Scales a plane displacement prior to use in the plane
62 * cutting algorithm, and also checks if it could possibly cut
64 * \param[in,out] rs the plane displacement to be scaled.
65 * \param[in] mrs the current maximum distance to a Voronoi
66 * vertex multiplied by two.
67 * \param[in] ijk the block that the particle is within.
68 * \param[in] q the index of the particle within the block.
69 * \return True if the cell could possibly cut the cell, false
71 inline bool r_scale_check(double &rs
,double mrs
,int ijk
,int q
) {return rs
<mrs
;}
74 /** \brief Class containing all of the routines that are specific to computing
75 * the radical Voronoi tessellation.
77 * The container_poly and container_periodic_poly classes are derived from this
78 * class, and during the Voronoi cell computation, these routines are used to
79 * create the radical Voronoi tessellation. */
82 /** A two-dimensional array holding particle positions and radii. */
84 /** The current maximum radius of any particle, used to
85 * determine when to cut off the radical Voronoi computation.
88 /** The class constructor sets the maximum particle radius to
90 radius_poly() : max_radius(0) {}
92 /** This is called prior to computing a Voronoi cell for a
93 * given particle to initialize any required constants.
94 * \param[in] ijk the block that the particle is within.
95 * \param[in] s the index of the particle within the block. */
96 inline void r_init(int ijk
,int s
) {
97 r_rad
=ppr
[ijk
][3*s
+2]*ppr
[ijk
][3*s
+2];
98 r_mul
=r_rad
-max_radius
*max_radius
;
100 /** Sets a required constant to be used when carrying out a
101 * plane bounds check. */
102 inline void r_prime(double rv
) {r_val
=1+r_mul
/rv
;}
103 /** Carries out a radius bounds check.
104 * \param[in] crs the radius squared to be tested.
105 * \param[in] mrs the current maximum distance to a Voronoi
106 * vertex multiplied by two.
107 * \return True if particles at this radius could not possibly
108 * cut the cell, false otherwise. */
109 inline bool r_ctest(double crs
,double mrs
) {return crs
+r_mul
>sqrt(mrs
*crs
);}
110 /** Scales a plane displacement during a plane bounds check.
111 * \param[in] lrs the plane displacement.
112 * \return The scaled value. */
113 inline double r_cutoff(double lrs
) {return lrs
*r_val
;}
114 /** Adds the maximum radius squared to a given value.
115 * \param[in] rs the value to consider.
116 * \return The value with the radius squared added. */
117 inline double r_max_add(double rs
) {return rs
+max_radius
*max_radius
;}
118 /** Subtracts the radius squared of a particle from a given
120 * \param[in] rs the value to consider.
121 * \param[in] ijk the block that the particle is within.
122 * \param[in] q the index of the particle within the block.
123 * \return The value with the radius squared subtracted. */
124 inline double r_current_sub(double rs
,int ijk
,int q
) {
125 return rs
-ppr
[ijk
][3*q
+2]*ppr
[ijk
][3*q
+2];
127 /** Scales a plane displacement prior to use in the plane cutting
129 * \param[in] rs the initial plane displacement.
130 * \param[in] ijk the block that the particle is within.
131 * \param[in] q the index of the particle within the block.
132 * \return The scaled plane displacement. */
133 inline double r_scale(double rs
,int ijk
,int q
) {
134 return rs
+r_rad
-ppr
[ijk
][3*q
+2]*ppr
[ijk
][3*q
+2];
136 /** Scales a plane displacement prior to use in the plane
137 * cutting algorithm, and also checks if it could possibly cut
139 * \param[in,out] rs the plane displacement to be scaled.
140 * \param[in] mrs the current maximum distance to a Voronoi
141 * vertex multiplied by two.
142 * \param[in] ijk the block that the particle is within.
143 * \param[in] q the index of the particle within the block.
144 * \return True if the cell could possibly cut the cell, false
146 inline bool r_scale_check(double &rs
,double mrs
,int ijk
,int q
) {
148 rs
+=r_rad
-ppr
[ijk
][3*q
+2]*ppr
[ijk
][3*q
+2];
149 return rs
<sqrt(mrs
*trs
);
152 double r_rad
,r_mul
,r_val
;