1 #include "voro++_2d.hh"
4 // This function returns a random floating point number between 0 and 1
5 double rnd() {return double(rand())/RAND_MAX
;}
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
25 con
.put(7,-0.799,-0.6);
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");
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);