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 // Create comb-like domain
22 for(x
=0.8;x
>-0.9;x
-=0.2) {
23 con
.put(i
,x
,-0.7);i
++;
24 con
.put(i
,x
-0.1,0.9);i
++;
32 if(con
.point_inside(x
,y
)) {con
.put(i
,x
,y
);i
++;}
35 con
.draw_boundary_gnuplot("comb.bd");
36 con
.draw_particles("comb.par");
39 con
.draw_cells_gnuplot("comb.gnu");
41 // Sum the Voronoi cell areas and compare to the container area
42 // double carea=1,varea=con.sum_cell_areas();
43 // printf("Total container area : %g\n"
44 // "Total Voronoi cell area : %g\n"
45 // "Difference : %g\n",carea,varea,varea-carea);