3 // Author : Chris H. Rycroft (Harvard SEAS)
4 // Email : chr@alum.mit.edu
5 // Date : August 30th 2011
10 const double pi
=3.1415926535897932384626433832795;
14 double x
,y
,z
,evol
,vvol
;
16 // Create a container with the geometry given above, and make it
17 // non-periodic in each of the three coordinates. Allocate space for
18 // eight particles within each computational block.
19 container
con(-5,5,-5,5,-5,5,6,6,6,
22 // Add a cylindrical wall to the container
23 wall_sphere
sph(0,0,0,4);
26 // Place particles in a regular grid within the frustum, for points
27 // which are within the wall boundaries
28 for(z
=-4.5;z
<5;z
+=1) for(y
=-4.5;y
<5;y
+=1) for(x
=-4.5;x
<5;x
+=1) {
29 if (con
.point_inside(x
,y
,z
)) {
34 // Output the particle positions and Voronoi cells in Gnuplot format
35 con
.draw_particles("sphere_p.gnu");
36 con
.draw_cells_gnuplot("sphere_v.gnu");
38 // Compute the volume of the Voronoi cells and compare it to the
39 // exact frustum volume
41 vvol
=con
.sum_cell_volumes();
42 printf("Exact sphere volume : %g\n"
43 "Voronoi cell volume : %g\n"
44 "Difference : %g\n",evol
,vvol
,vvol
-evol
);