This page describes how to set install MeshGenC++. If you encounter any difficulties in the installation process, please send e-mail to the discussion group.



The MeshGenC++ code is distributed using the file revisioning system known as Git. Git can be download for free from


The MeshGenC++ code is written in C++. You will need to obtain a C++ compiler. A free C++ compiler is available via the GNU project.


A key step in generating a mesh using MeshGenC++ is to create a delaunay triangulation for a given set of nodes. This is accomplished using the Qhull code, which can be freely downloaded from


The MeshGenC++ distribution includes several MATLAB scripts that can be used to visualize the results. If you wish to run these scripts you will need a valid MATLAB license.


MATLAB is not an open-source software package. For open-source plotting in MeshGenC++ see Python.


Alongside the MATLAB plotting scripts, the MeshGenC++ distribution also includes Python plotting scripts that invoke matplotlib. This provides an open-source alternative to MATLAB. In addition to basic Python, the plotting routines need numpy and matplotlib.


The MeshGenC++ developers recommend the Enthought Python Distribution to obtain a modern Python with several important scientific computing libraries installed "out-of-the-box". The Enthought Python Distribution is freely available for academic use.


In the current release, Python plotting scripts exist only for 2D meshes.


Once all the dependencies have been resolved, the latest version of the MeshGenC++ package can be pulled from the git repository via the following command:

$ git clone

Setting up the environment

The next step is to set the environment variables. The easiest way to do this is to use a script provided in the util subdirectory that produces the appropriate environment variables for MeshGenC++. To run the script, go into your base directory you created above and run

$ python util/

This script should produce two files that contain the shell script for setting the above variables. By default these files are called setenv.bash and setenv.csh. These can be used by running

$ source setenv.bash


$ source setenv.csh

depending on your shell (this can be checked by typing printenv SHELL at your command line). The shell code in these files can be copied to your .bashrc, .cshrc, or .profile file to be run automatically when you open a terminal.


If using MATLAB for plotting, you may need to manually set the path in MATLAB using the MATLAB command window. The correct path is shown in the setenv.bash and setenv.csh files.

Testing the installation

Once the installation is completed, the next step is to make sure that the installation and setup were successful. Do this by entering a particular example and compiling the code by typing:

$ cd $MESHGENCPP/apps/2d/square_circ/
$ make

Once compiled, execute the code by typing:

$ mesh.exe

This should produce some output to the screen that ends with a statement something like:

         Number of Elements:      1984
Number of Physical Elements:      1769
   Number of Ghost Elements:       215
            Number of Nodes:      1207
   Number of Physical Nodes:       992
   Number of Boundary Nodes:       215
            Number of Edges:      2761

       Total Area Covered:    3.3655932192133866e+00
  Area Ratio: small/large:    2.4750281448461017e-01
 Angle Ratio: minAngle/60:    5.9045819270050093e-01

Total elapsed time in seconds = 2.00000e+00

If MATLAB is installed, the resulting mesh can be visualized by executing the following script within a MATLAB command window:

>> plotmesh2


Before executing this command, first open MATLAB, then change directory to the $MESHGENCPP/apps/2d/square_circ directory in the MATLAB command window.

This should result in the following two plots being produced:

_images/meshgen_matlab_1.jpg _images/meshgen_matlab_2.jpg

Otherwise, if matplotlib is installed, the resulting mesh can be visualized by executing the following python script:

$ python $MESHGENCPP/viz/python/

or using the following shortcut (this shortcut is defined in setenv.bash and setenv.csh files):

$ plotmesh2

This should result in the following two plots being produced:

_images/meshgen_python_1.jpg _images/meshgen_python_2.jpg