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