Voro++
unitcell.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 : chr@alum.mit.edu
5 // Date : August 30th 2011
6 
7 /** \file unitcell.hh
8  * \brief Header file for the unitcell class. */
9 
10 #ifndef VOROPP_UNITCELL_HH
11 #define VOROPP_UNITCELL_HH
12 
13 #include <vector>
14 
15 #include "config.hh"
16 #include "cell.hh"
17 
18 namespace voro {
19 
20 /** \brief Class for computation of the unit Voronoi cell associated with
21  * a 3D non-rectangular periodic domain. */
22 class unitcell {
23  public:
24  /** The x coordinate of the first vector defining the periodic
25  * domain. */
26  const double bx;
27  /** The x coordinate of the second vector defining the periodic
28  * domain. */
29  const double bxy;
30  /** The y coordinate of the second vector defining the periodic
31  * domain. */
32  const double by;
33  /** The x coordinate of the third vector defining the periodic
34  * domain. */
35  const double bxz;
36  /** The y coordinate of the third vector defining the periodic
37  * domain. */
38  const double byz;
39  /** The z coordinate of the third vector defining the periodic
40  * domain. */
41  const double bz;
42  /** The computed unit Voronoi cell corresponding the given
43  * 3D non-rectangular periodic domain geometry. */
45  unitcell(double bx_,double bxy_,double by_,double bxz_,double byz_,double bz_);
46  /** Draws an outline of the domain in Gnuplot format.
47  * \param[in] filename the filename to write to. */
48  inline void draw_domain_gnuplot(const char* filename) {
49  FILE *fp(safe_fopen(filename,"w"));
51  fclose(fp);
52  }
53  void draw_domain_gnuplot(FILE *fp=stdout);
54  /** Draws an outline of the domain in Gnuplot format.
55  * \param[in] filename the filename to write to. */
56  inline void draw_domain_pov(const char* filename) {
57  FILE *fp(safe_fopen(filename,"w"));
58  draw_domain_pov(fp);
59  fclose(fp);
60  }
61  void draw_domain_pov(FILE *fp=stdout);
62  bool intersects_image(double dx,double dy,double dz,double &vol);
63  void images(std::vector<int> &vi,std::vector<double> &vd);
64  protected:
65  /** The maximum y-coordinate that could possibly cut the
66  * computed unit Voronoi cell. */
67  double max_uv_y;
68  /** The maximum z-coordinate that could possibly cut the
69  * computed unit Voronoi cell. */
70  double max_uv_z;
71  private:
72  inline void unit_voro_apply(int i,int j,int k);
73  bool unit_voro_intersect(int l);
74  inline bool unit_voro_test(int i,int j,int k);
75 };
76 
77 }
78 
79 #endif