File: cell_statistics.cc

package info (click to toggle)
voro%2B%2B 0.5%2Brevert-to-0.4.6%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 1,368 kB
  • sloc: cpp: 6,384; perl: 232; makefile: 164
file content (52 lines) | stat: -rw-r--r-- 1,818 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Simple cell statistics demonstration code
//
// Author   : Chris H. Rycroft (LBL / UC Berkeley)
// Email    : chr@alum.mit.edu
// Date     : August 30th 2011

#include "voro++.hh"
using namespace voro;

// This function returns a random floating point number between 0 and 1
double rnd() {return double(rand())/RAND_MAX;}

int main() {
	double x,y,z;
	voronoicell v;

	// Initialize the Voronoi cell to be a cube of side length 2, centered
	// on the origin
	v.init(-1,1,-1,1,-1,1);

	// Remove one edge of the cell with a single plane cut
	v.plane(1,1,0,2);

	// Output the Voronoi cell to a file in gnuplot format
	v.draw_gnuplot(0,0,0,"simple_cell.gnu");

	// Output vertex-based statistics
	printf("Total vertices      : %d\n",v.p);
	printf("Vertex positions    : ");v.output_vertices();puts("");
	printf("Vertex orders       : ");v.output_vertex_orders();puts("");
	printf("Max rad. sq. vertex : %g\n\n",0.25*v.max_radius_squared());

	// Output edge-based statistics
	printf("Total edges         : %d\n",v.number_of_edges());
	printf("Total edge distance : %g\n",v.total_edge_distance());
	printf("Face perimeters     : ");v.output_face_perimeters();puts("\n");

	// Output face-based statistics
	printf("Total faces         : %d\n",v.number_of_faces());
	printf("Surface area        : %g\n",v.surface_area());
	printf("Face freq. table    : ");v.output_face_freq_table();puts("");
	printf("Face orders         : ");v.output_face_orders();puts("");
	printf("Face areas          : ");v.output_face_areas();puts("");
	printf("Face normals        : ");v.output_normals();puts("");
	printf("Face vertices       : ");v.output_face_vertices();puts("\n");

	// Output volume-based statistics
	v.centroid(x,y,z);
	printf("Volume              : %g\n"
	       "Centroid vector     : (%g,%g,%g)\n",v.volume(),x,y,z);

}