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.
Depending on the path to the voroGmsh files, you may need something like this:
#include "voroGmsh.git/trunk/vorogmsh.h"
In both vorogmsh.cpp and vorogmsh.h, check the path for the AdjacencyMatrix
library (see above). E.g.:
#include "adjacencyMatrix.git/trunk/adjacencyMatrix.h"
Once you have defined the Voro++ container and filled it with particles, you can create an object of class vorogmsh
:
vorogmsh gmsh(con);
where con
is the name of the container. The object gmsh
contains all the data needed to create a 3D geometry in Gmsh.
Then, you can write an ASCII file defining the whole geometry:
gmsh.saveasgeo("Geometry.geo");
The 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.:
gmsh.saveasgeo("Geometry.geo",0.5);
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.