Reset platonic code.
[voro++.git] / branches / 2d / src / v_connect / v_base_2d.hh
blobd78c8580fe3b92adecd3d1b4e4e0d82367f02a54
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
7 /** \file v_base.hh
8 * \brief Header file for the base 2D Voronoi container class. */
10 #ifndef VOROPP_V_BASE_2D_HH
11 #define VOROPP_V_BASE_2D_HH
13 #include "worklist_2d.hh"
14 #include <stdio.h>
15 #include <iostream>
16 #include <stdlib.h>
17 namespace voro {
19 /** \brief Class containing data structures common across all particle container classes.
21 * This class contains constants and data structures that are common across all
22 * particle container classes. It contains constants setting the size of the
23 * underlying subgrid of blocks that forms the basis of the Voronoi cell
24 * computations. It also constructs bound tables that are used in the Voronoi
25 * cell computation, and contains a number of routines that are common across
26 * all container classes. */
27 class voro_base_2d {
28 public:
29 // /** total number of particles. */
30 // int totpar;
31 /** The number of blocks in the x direction. */
32 const int nx;
33 /** The number of blocks in the y direction. */
34 const int ny;
35 /** A constant, set to the value of nx multiplied by ny, which
36 * is used in the routines that step through blocks in
37 * sequence. */
38 const int nxy;
39 /** The size of a computational block in the x direction. */
40 const double boxx;
41 /** The size of a computational block in the y direction. */
42 const double boxy;
43 /** The inverse box length in the x direction. */
44 const double xsp;
45 /** The inverse box length in the y direction. */
46 const double ysp;
47 /** An array to hold the minimum distances associated with the
48 * worklists. This array is initialized during container
49 * construction, by the initialize_radii() routine. */
50 double *mrad;
51 bool full_connect;
52 // /** The pre-computed block worklists. */
54 // unsigned int *globne;
55 // /** global neighbor information */
56 // inline void init_globne(){
57 // globne = new unsigned int[((totpar*totpar)/32)+1];
58 // for(int i=0;i<((totpar*totpar)/32);i++){
59 // globne[i] = 0;
60 // }
61 // }
62 // void add_globne_info(int pid, int *nel, int length);
63 // void print_globne(FILE *fp);
64 inline void full_connect_on(){
65 full_connect=true;
69 bool connected(int a,int b);
70 static const unsigned int wl[wl_seq_length_2d*wl_hgridsq_2d];
71 bool contains_neighbor(const char* format);
72 // bool contains_neighbor_global(const char* format);
73 voro_base_2d(int nx_,int ny_,double boxx_,double boxy_);
74 ~voro_base_2d() {delete [] mrad;}
75 protected:
76 /** A custom int function that returns consistent stepping
77 * for negative numbers, so that (-1.5, -0.5, 0.5, 1.5) maps
78 * to (-2,-1,0,1).
79 * \param[in] a the number to consider.
80 * \return The value of the custom int operation. */
81 inline int step_int(double a) {return a<0?int(a)-1:int(a);}
82 /** A custom modulo function that returns consistent stepping
83 * for negative numbers. For example, (-2,-1,0,1,2) step_mod 2
84 * is (0,1,0,1,0).
85 * \param[in] (a,b) the input integers.
86 * \return The value of a modulo b, consistent for negative
87 * numbers. */
88 inline int step_mod(int a,int b) {return a>=0?a%b:b-1-(b-1-a)%b;}
89 /** A custom integer division function that returns consistent
90 * stepping for negative numbers. For example, (-2,-1,0,1,2)
91 * step_div 2 is (-1,-1,0,0,1).
92 * \param[in] (a,b) the input integers.
93 * \return The value of a div b, consistent for negative
94 * numbers. */
95 inline int step_div(int a,int b) {return a>=0?a/b:-1+(a+1)/b;}
96 private:
97 void compute_minimum(double &minr,double &xlo,double &xhi,double &ylo,double &yhi,int ti,int tj);
102 #endif