Strip extra spaces from code.
[voro++.git] / branches / dynamic / examples / walls / tetrahedron.cc
blobcf46f73d86a04447220663714a06ccdc333e0e7b
1 // Voronoi calculation example code
2 //
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : October 19th 2007
7 #include "voro++.cc"
9 // Set up constants for the container geometry
10 const double x_min=-2,x_max=2;
11 const double y_min=-2,y_max=2;
12 const double z_min=-2,z_max=2;
14 // Set up the number of blocks that the container is divided
15 // into
16 const int n_x=7,n_y=7,n_z=14;
18 // Set the number of particles that are going to be randomly
19 // introduced
20 const int particles=64;
22 // This function returns a random double between 0 and 1
23 double rnd() {return double(rand())/RAND_MAX;}
25 int main() {
26 int i=0;
27 double x,y,z;
29 // Create a container with the geometry given above, and make it
30 // non-periodic in each of the three coordinates. Allocate space for
31 // 8 particles within each computational block.
32 container con(x_min,x_max,y_min,y_max,z_min,z_max,n_x,n_y,n_z,
33 false,false,false,8);
35 // Add a cylindrical wall to the container
36 wall_plane p1(1,1,1,1);con.add_wall(p1);
37 wall_plane p2(-1,-1,1,1);con.add_wall(p2);
38 wall_plane p3(1,-1,-1,1);con.add_wall(p3);
39 wall_plane p4(-1,1,-1,1);con.add_wall(p4);
41 while(i<particles) {
42 x=x_min+rnd()*(x_max-x_min);
43 y=y_min+rnd()*(y_max-y_min);
44 z=z_min+rnd()*(z_max-z_min);
45 if (con.point_inside(x,y,z)) {
46 con.put(i,x,y,z);i++;
50 // Output the particle positions and the Voronoi cells in Gnuplot and
51 // POV-Ray formats
52 con.draw_particles("tetrahedron_p.gnu");
53 con.draw_cells_gnuplot("tetrahedron_v.gnu");
54 con.draw_particles_pov("tetrahedron_p.pov");
55 con.draw_cells_pov("tetrahedron_v.pov");