Strip extra spaces from code.
[voro++.git] / branches / 2d / examples / boundary / comb.cc
blob8873a7646670b93ec694548c397cdba93766c99b
1 #include "voro++_2d.hh"
2 using namespace voro;
4 // This function returns a random floating point number between 0 and 1
5 double rnd() {return double(rand())/RAND_MAX;}
7 int main() {
8 int i;
9 double x,y;
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
17 con.start_boundary();
18 con.put(0,-0.9,-0.9);
19 con.put(1,0.9,-0.9);
20 con.put(2,0.9,0.9);
21 i=3;
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++;
26 con.end_boundary();
28 // Add random points
29 while(i<200) {
30 x=-1+2*rnd();
31 y=-1+2*rnd();
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");
38 con.setup();
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);