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
8 * \brief Header file for the voro_compute template and related classes. */
10 #ifndef VOROPP_V_COMPUTE_HH
11 #define VOROPP_V_COMPUTE_HH
14 #include "worklist.hh"
19 /** \brief Structure for holding information about a particle.
21 * This small structure holds information about a single particle, and is used
22 * by several of the routines in the voro_compute template for passing
23 * information by reference between functions. */
24 struct particle_record
{
25 /** The index of the block that the particle is within. */
27 /** The number of particle within its block. */
29 /** The x-index of the block. */
31 /** The y-index of the block. */
33 /** The z-index of the block. */
37 /** \brief Template for carrying out Voronoi cell computations. */
38 template <class c_class
>
41 /** A reference to the container class on which to carry out*/
43 /** The size of an internal computational block in the x
46 /** The size of an internal computational block in the y
49 /** The size of an internal computational block in the z
52 /** The inverse box length in the x direction, set to
55 /** The inverse box length in the y direction, set to
58 /** The inverse box length in the z direction, set to
61 /** The number of boxes in the x direction for the searching mask. */
63 /** The number of boxes in the y direction for the searching mask. */
65 /** The number of boxes in the z direction for the searching mask. */
67 /** A constant, set to the value of hx multiplied by hy, which
68 * is used in the routines which step through mask boxes in
71 /** A constant, set to the value of hx*hy*hz, which is used in
72 * the routines which step through mask boxes in sequence. */
74 /** The number of floating point entries to store for each
77 /** This array holds the numerical IDs of each particle in each
78 * computational box. */
80 /** A two dimensional array holding particle positions. For the
81 * derived container_poly class, this also holds particle
84 /** An array holding the number of particles within each
85 * computational box of the container. */
87 voro_compute(c_class
&con_
,int hx_
,int hy_
,int hz_
);
88 /** The class destructor frees the dynamically allocated memory
89 * for the mask and queue. */
94 template<class v_cell
>
95 bool compute_cell(v_cell
&c
,int ijk
,int s
,int ci
,int cj
,int ck
);
96 void find_voronoi_cell(double x
,double y
,double z
,int ci
,int cj
,int ck
,int ijk
,particle_record
&w
,double &mrs
);
98 /** A constant set to boxx*boxx+boxy*boxy+boxz*boxz, which is
99 * frequently used in the computation. */
101 /** This sets the current value being used to mark tested blocks
104 /** The current size of the search list. */
106 /** A pointer to the array of worklists. */
107 const unsigned int *wl
;
108 /** An pointer to the array holding the minimum distances
109 * associated with the worklists. */
111 /** This array is used during the cell computation to determine
112 * which blocks have been considered. */
114 /** An array is used to store the queue of blocks to test
115 * during the Voronoi cell computation. */
117 /** A pointer to the end of the queue array, used to determine
118 * when the queue is full. */
120 template<class v_cell
>
121 bool corner_test(v_cell
&c
,double xl
,double yl
,double zl
,double xh
,double yh
,double zh
);
122 template<class v_cell
>
123 inline bool edge_x_test(v_cell
&c
,double x0
,double yl
,double zl
,double x1
,double yh
,double zh
);
124 template<class v_cell
>
125 inline bool edge_y_test(v_cell
&c
,double xl
,double y0
,double zl
,double xh
,double y1
,double zh
);
126 template<class v_cell
>
127 inline bool edge_z_test(v_cell
&c
,double xl
,double yl
,double z0
,double xh
,double yh
,double z1
);
128 template<class v_cell
>
129 inline bool face_x_test(v_cell
&c
,double xl
,double y0
,double z0
,double y1
,double z1
);
130 template<class v_cell
>
131 inline bool face_y_test(v_cell
&c
,double x0
,double yl
,double z0
,double x1
,double z1
);
132 template<class v_cell
>
133 inline bool face_z_test(v_cell
&c
,double x0
,double y0
,double zl
,double x1
,double y1
);
134 bool compute_min_max_radius(int di
,int dj
,int dk
,double fx
,double fy
,double fz
,double gx
,double gy
,double gz
,double& crs
,double mrs
);
135 bool compute_min_radius(int di
,int dj
,int dk
,double fx
,double fy
,double fz
,double mrs
);
136 inline void add_to_mask(int ei
,int ej
,int ek
,int *&qu_e
);
137 inline void scan_bits_mask_add(unsigned int q
,unsigned int *mijk
,int ei
,int ej
,int ek
,int *&qu_e
);
138 inline void scan_all(int ijk
,double x
,double y
,double z
,int di
,int dj
,int dk
,particle_record
&w
,double &mrs
);
139 void add_list_memory(int*& qu_s
,int*& qu_e
);
140 /** Resets the mask in cases where the mask counter wraps
142 inline void reset_mask() {
143 for(unsigned int *mp(mask
);mp
<mask
+hxyz
;mp
++) *mp
=0;