Class for writing geometry files for Gmsh from voro++
This class is intended to export the geometry of Voronoï cells computed using the Voro++ library as a Gmsh-readable file.
See here for how to install the Voro++ library.
The present class needs the AdjacencyMatrix I have developped.
Since the class is intended to generate files for Gmsh, you may install it on your computer.
Import the required library into your project
Depending on the path to the voroGmsh files, you may need something like this:
Check the path to AdjacencyMatrix
In both vorogmsh.cpp and vorogmsh.h, check the path for the
AdjacencyMatrix library (see above). E.g.:
How to use it?
Create an instance of vorogmsh
Once you have defined the Voro++ container and filled it with particles, you can create an object of class
con is the name of the container. The object
gmsh contains all the data needed to create a 3D geometry in Gmsh.
Dump the geometry into a text file
Then, you can write an ASCII file defining the whole geometry:
saveasgeo method automatically computes the maximum element size at each vertex (based on the edge lengths). You can override this value by passing the nominal size as an optional parameter. E.g.:
Note that if the nominal size is smaller than the computed one, the latter will be used instead.
As an example, the
pack_six_cube_poly dataset (provided in Voro++ examples) has been used. Figure below illustrates the meshes with default mesh size (left) and nominal size of 0.1 (right).
I am not a programmer. Thus, this class is probably not optimized in terms of performances or flexibility. Do not hesitate to fork this project in order to improve it.