Voro++
rad_option.hh
Go to the documentation of this file.
1 // Voro++, a 3D cell-based Voronoi library
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : [email protected]
5 // Date : August 30th 2011
6 
7 /** \file rad_option.hh
8  * \brief Header file for the classes encapsulating functionality for the
9  * regular and radical Voronoi tessellations. */
10 
11 #ifndef VOROPP_RAD_OPTION_HH
12 #define VOROPP_RAD_OPTION_HH
13 
14 #include <cmath>
15 
16 namespace voro {
17 
18 /** \brief Class containing all of the routines that are specific to computing
19  * the regular Voronoi tessellation.
20  *
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. */
24 class radius_mono {
25  protected:
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
50  * value.
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
57  * algorithm.
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
65  * the cell.
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
72  * otherwise. */
73  inline bool r_scale_check(double &rs,double mrs,int ijk,int q) {return rs<mrs;}
74 };
75 
76 /** \brief Class containing all of the routines that are specific to computing
77  * the radical Voronoi tessellation.
78  *
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. */
82 class radius_poly {
83  public:
84  /** A two-dimensional array holding particle positions and radii. */
85  double **ppr;
86  /** The current maximum radius of any particle, used to
87  * determine when to cut off the radical Voronoi computation.
88  * */
89  double max_radius;
90  /** The class constructor sets the maximum particle radius to
91  * be zero. */
93  protected:
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;
101  }
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
121  * value.
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];
128  }
129  /** Scales a plane displacement prior to use in the plane cutting
130  * algorithm.
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];
137  }
138  /** Scales a plane displacement prior to use in the plane
139  * cutting algorithm, and also checks if it could possibly cut
140  * the cell.
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
147  * otherwise. */
148  inline bool r_scale_check(double &rs,double mrs,int ijk,int q) {
149  double trs=rs;
150  rs+=r_rad-ppr[ijk][4*q+3]*ppr[ijk][4*q+3];
151  return rs<sqrt(mrs*trs);
152  }
153  private:
154  double r_rad,r_mul,r_val;
155 };
156 
157 }
158 #endif
bool r_scale_check(double &rs, double mrs, int ijk, int q)
Definition: rad_option.hh:73
void r_init(int ijk, int s)
Definition: rad_option.hh:98
double r_cutoff(double lrs)
Definition: rad_option.hh:44
Class containing all of the routines that are specific to computing the radical Voronoi tessellation...
Definition: rad_option.hh:82
bool r_scale_check(double &rs, double mrs, int ijk, int q)
Definition: rad_option.hh:148
double r_cutoff(double lrs)
Definition: rad_option.hh:115
void r_prime(double rv)
Definition: rad_option.hh:104
void r_prime(double rv)
Definition: rad_option.hh:33
double r_scale(double rs, int ijk, int q)
Definition: rad_option.hh:62
double r_current_sub(double rs, int ijk, int q)
Definition: rad_option.hh:126
void r_init(int ijk, int s)
Definition: rad_option.hh:30
double r_scale(double rs, int ijk, int q)
Definition: rad_option.hh:135
double r_max_add(double rs)
Definition: rad_option.hh:48
double r_max_add(double rs)
Definition: rad_option.hh:119
double r_current_sub(double rs, int ijk, int q)
Definition: rad_option.hh:55
bool r_ctest(double crs, double mrs)
Definition: rad_option.hh:111
bool r_ctest(double crs, double mrs)
Definition: rad_option.hh:40
Class containing all of the routines that are specific to computing the regular Voronoi tessellation...
Definition: rad_option.hh:24