A Lloyd algorithm implementation constructing Centroidal Voronoi Diagram in 2D. It uses the Voronoi_diagram_2 and Nef_Polyhedron_2 package in CGAL and works on arbitrary boundary contraints (i.e. whether it is convex or concave, connected or multi-connected, genus-0 or multi-genuses).
This is a new branch that use Matlab to deal with non-constant density function.
This program uses the following tools:
- CGAL 4.6, which is used to generate Voronoi diagram and execute intersection between Voronoi cells and boundaries;
- Matlab, which is used to calculate the value of the energy function of CVT, and the cetroid of each Voronoi cell. For the const density case, a straight forward way is also used to accelerate the calculatino speed of the above two;
- MS-MPI, which is used to parallelize the updating procedure of the generators.
Since the Nef_polyhedron_2 class in CGAL is currently not thread-safe, it is hard to use OpenMP directly to parallelly compute CVT. Here MPI is used to parallelly process the updating of centroids.
The performance on the disk boundary (approximated by 100 segments) with 1,000 generators and 100 iterations varing along with the number of processes is shown in the following:
# of process | time (sec.) |
---|---|
1 | 3843.4 |
2 | 2128.7 |
4 | 1120.6 |
8 | 595.3 |
16 | 314.4 |
32 | 180.1 |
64 | 169.3 |