1 #include "voro++_2d.hh"
3 // This function returns a random floating point number between 0 and 1
4 double rnd() {return double(rand())/RAND_MAX
;}
9 // Initialize the container class to be the unit square, with
10 // non-periodic boundary conditions. Divide it into a 6 by 6 grid, with
11 // an initial memory allocation of 16 particles per grid square.
12 container_2d
con(0,1,0,1,6,6,true,true,false,16);
14 // Add 1000 random points to the container
21 // Output the particle positions to a file
22 con
.draw_particles("test_ctr.par");
24 // Output the Voronoi cells to a file, in the gnuplot format
25 con
.draw_cells_gnuplot("test_ctr.gnu");
27 // Sum the Voronoi cell areas and compare to the container area
28 double carea(1),varea(con
.sum_cell_areas());
29 printf("Total container area : %g\n"
30 "Total Voronoi cell area : %g\n"
31 "Difference : %g\n",carea
,varea
,varea
-carea
);