Strip extra spaces from code.
[voro++.git] / branches / 2d / examples / boundary / container_bd.cc
blob867b94ec534f4069357ec27e8f38bd2eef841ee6
1 #include "voro++_2d.hh"
2 using namespace voro;
4 // This function returns a random floating point number between 0 and 1
5 double rnd() {return double(rand())/RAND_MAX;}
7 int main() {
8 int i;
9 double x,y;
11 // Initialize the container class to be the unit square, with
12 // non-periodic boundary conditions. Divide it into a 6 by 6 grid, with
13 // an initial memory allocation of 16 particles per grid square.
14 container_boundary_2d con(-1,1,-1,1,6,6,false,false,8);
16 // Add 1000 random points to the container
17 con.start_boundary();
18 con.put(0,-0.8,-0.8);
19 con.put(1,0.8,-0.8);
20 con.put(2,0.8,0.8);
21 con.put(3,0.1,0.75);
22 con.put(4,0,-0.3);
23 con.put(5,-0.1,0.95);
24 con.put(6,-0.8,0.8);
25 con.put(7,-0.799,-0.6);
26 con.end_boundary();
28 for(i=0;i<100;i++) {
29 x=-1+2*rnd();
30 y=-1+2*rnd();
31 if(con.point_inside(x,y)) con.put(i+8,x,y);
34 con.draw_boundary_gnuplot("container_bd.gnu");
35 con.draw_particles("container_bd.par");
37 con.setup();
38 con.draw_cells_gnuplot("container_bd_v.gnu");
40 // Sum the Voronoi cell areas and compare to the container area
41 // double carea=1,varea=con.sum_cell_areas();
42 // printf("Total container area : %g\n"
43 // "Total Voronoi cell area : %g\n"
44 // "Difference : %g\n",carea,varea,varea-carea);