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
18 /** \brief Class containing all of the routines that are specific to computing
19 * the regular Voronoi tessellation.
21 * The container and container_periodic classes are derived from this class,
22 * and during the Voronoi cell computation, these routines are used to create
23 * the regular Voronoi tessellation. */
26 /** This is called prior to computing a Voronoi cell for a
27 * given particle to initialize any required constants.
28 * \param[in] ijk the block that the particle is within.
29 * \param[in] s the index of the particle within the block. */
30 inline void r_init(int ijk
,int s
) {}
31 /** Sets a required constant to be used when carrying out a
32 * plane bounds check. */
33 inline void r_prime(double rv
) {}
34 /** Carries out a radius bounds check.
35 * \param[in] crs the radius squared to be tested.
36 * \param[in] mrs the current maximum distance to a Voronoi
37 * vertex multiplied by two.
38 * \return True if particles at this radius could not possibly
39 * cut the cell, false otherwise. */
40 inline bool r_ctest(double crs
,double mrs
) {return crs
>mrs
;}
41 /** Scales a plane displacement during a plane bounds check.
42 * \param[in] lrs the plane displacement.
43 * \return The scaled value. */
44 inline double r_cutoff(double lrs
) {return lrs
;}
45 /** Adds the maximum radius squared to a given value.
46 * \param[in] rs the value to consider.
47 * \return The value with the radius squared added. */
48 inline double r_max_add(double rs
) {return rs
;}
49 /** Subtracts the radius squared of a particle from a given
51 * \param[in] rs the value to consider.
52 * \param[in] ijk the block that the particle is within.
53 * \param[in] q the index of the particle within the block.
54 * \return The value with the radius squared subtracted. */
55 inline double r_current_sub(double rs
,int ijk
,int q
) {return rs
;}
56 /** Scales a plane displacement prior to use in the plane cutting
58 * \param[in] rs the initial plane displacement.
59 * \param[in] ijk the block that the particle is within.
60 * \param[in] q the index of the particle within the block.
61 * \return The scaled plane displacement. */
62 inline double r_scale(double rs
,int ijk
,int q
) {return rs
;}
63 /** Scales a plane displacement prior to use in the plane
64 * cutting algorithm, and also checks if it could possibly cut
66 * \param[in,out] rs the plane displacement to be scaled.
67 * \param[in] mrs the current maximum distance to a Voronoi
68 * vertex multiplied by two.
69 * \param[in] ijk the block that the particle is within.
70 * \param[in] q the index of the particle within the block.
71 * \return True if the cell could possibly cut the cell, false
73 inline bool r_scale_check(double &rs
,double mrs
,int ijk
,int q
) {return rs
<mrs
;}
76 /** \brief Class containing all of the routines that are specific to computing
77 * the radical Voronoi tessellation.
79 * The container_poly and container_periodic_poly classes are derived from this
80 * class, and during the Voronoi cell computation, these routines are used to
81 * create the radical Voronoi tessellation. */
84 /** A two-dimensional array holding particle positions and radii. */
86 /** The current maximum radius of any particle, used to
87 * determine when to cut off the radical Voronoi computation.
90 /** The class constructor sets the maximum particle radius to
92 radius_poly() : max_radius(0) {}
94 /** This is called prior to computing a Voronoi cell for a
95 * given particle to initialize any required constants.
96 * \param[in] ijk the block that the particle is within.
97 * \param[in] s the index of the particle within the block. */
98 inline void r_init(int ijk
,int s
) {
99 r_rad
=ppr
[ijk
][4*s
+3]*ppr
[ijk
][4*s
+3];
100 r_mul
=r_rad
-max_radius
*max_radius
;
102 /** Sets a required constant to be used when carrying out a
103 * plane bounds check. */
104 inline void r_prime(double rv
) {r_val
=1+r_mul
/rv
;}
105 /** Carries out a radius bounds check.
106 * \param[in] crs the radius squared to be tested.
107 * \param[in] mrs the current maximum distance to a Voronoi
108 * vertex multiplied by two.
109 * \return True if particles at this radius could not possibly
110 * cut the cell, false otherwise. */
111 inline bool r_ctest(double crs
,double mrs
) {return crs
+r_mul
>sqrt(mrs
*crs
);}
112 /** Scales a plane displacement during a plane bounds check.
113 * \param[in] lrs the plane displacement.
114 * \return The scaled value. */
115 inline double r_cutoff(double lrs
) {return lrs
*r_val
;}
116 /** Adds the maximum radius squared to a given value.
117 * \param[in] rs the value to consider.
118 * \return The value with the radius squared added. */
119 inline double r_max_add(double rs
) {return rs
+max_radius
*max_radius
;}
120 /** Subtracts the radius squared of a particle from a given
122 * \param[in] rs the value to consider.
123 * \param[in] ijk the block that the particle is within.
124 * \param[in] q the index of the particle within the block.
125 * \return The value with the radius squared subtracted. */
126 inline double r_current_sub(double rs
,int ijk
,int q
) {
127 return rs
-ppr
[ijk
][4*q
+3]*ppr
[ijk
][4*q
+3];
129 /** Scales a plane displacement prior to use in the plane cutting
131 * \param[in] rs the initial plane displacement.
132 * \param[in] ijk the block that the particle is within.
133 * \param[in] q the index of the particle within the block.
134 * \return The scaled plane displacement. */
135 inline double r_scale(double rs
,int ijk
,int q
) {
136 return rs
+r_rad
-ppr
[ijk
][4*q
+3]*ppr
[ijk
][4*q
+3];
138 /** Scales a plane displacement prior to use in the plane
139 * cutting algorithm, and also checks if it could possibly cut
141 * \param[in,out] rs the plane displacement to be scaled.
142 * \param[in] mrs the current maximum distance to a Voronoi
143 * vertex multiplied by two.
144 * \param[in] ijk the block that the particle is within.
145 * \param[in] q the index of the particle within the block.
146 * \return True if the cell could possibly cut the cell, false
148 inline bool r_scale_check(double &rs
,double mrs
,int ijk
,int q
) {
150 rs
+=r_rad
-ppr
[ijk
][4*q
+3]*ppr
[ijk
][4*q
+3];
151 return rs
<sqrt(mrs
*trs
);
154 double r_rad
,r_mul
,r_val
;