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