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
;}
10 // Initialize the container class to be the unit square, with
11 // non-periodic boundary conditions. Divide it into a 10 by 10 grid,
12 // with an initial memory allocation of 16 particles per grid square.
13 container_2d
con(0,1,0,1,10,10,false,false,16);
15 // Add 1000 random points to the container
22 // Output the particle positions to a file
23 con
.draw_particles("random_points_2d.par");
25 // Output the Voronoi cells to a file, in the gnuplot format
26 con
.draw_cells_gnuplot("random_points_2d.gnu");
28 // Sum the Voronoi cell areas and compare to the container area
29 double carea
=1,varea
=con
.sum_cell_areas();
30 printf("Total container area : %g\n"
31 "Total Voronoi cell area : %g\n"
32 "Difference : %g\n",carea
,varea
,varea
-carea
);