Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Mesh optimization/smoothing

Project description


CircleCI codecov Codacy grade Code style: black smooth PyPi Version GitHub stars

Several mesh smoothing/optimization methods with one simple interface. optimesh

  • is fast,
  • preserves submeshes,
  • only works for triangular meshes (for now), and
  • supports all mesh formats that meshio can handle.

Install with

pip install optimesh

Example call:

optimesh in.e out.vtk --method lloyd -n 50

Output: terminal-screenshot

The left hand-side graph shows the distribution of angles (the grid line is at the optimal 60 degrees). The right hand-side graph shows the distribution of simplex quality, where quality is twice the ratio of circumcircle and incircle radius.

All command-line options are viewed with

optimesh -h

Laplacian smoothing

laplace-fp laplace-ls
classical Laplace linear solve (--method laplace)

Classical Laplacian mesh smoothing means moving all (interior) points into the average of their neighbors until an equilibrium has been reached. The method preserves the mesh density (i.e., small simplices are not blown up as part of the smoothing).

Instead of a fixed-point iteration, one can do a few linear solves, interleaved with facet-flipping. This approach converges much faster.

CVT (centroidal Voronoi tesselation)

--method lloyd

Centroidal Voronoi tessellation smoothing, realized by Lloyd's algorithm, i.e., points are iteratively moved into the centroid of their Voronoi cell. If the topological neighbors of any node are also the geometrically closest nodes, this is exactly Lloyd's algorithm. That is fulfilled in many practical cases, but the algorithm can break down if it is not.

CPT (centroidal patch tessalation)

cpt-fp cpt-qn
fixed-point iteration (--method cpt-fp) quasi-Newton (--method cpt-qn)

A smooting method suggested by Chen and Holst, mimicking CVT but much more easily implemented. The density-preserving variant leads to the exact same equation system as Laplace smoothing, so optimesh only contains the the uniform-density variant.

Implemented once classically as a fixed-point iteration, once as a quasi-Newton method. The latter typically leads to better results.

ODT (optimal Delaunay tesselation)

odt-fp odt-no
fixed-point iteration (--method odt-fp) nonlinear optimization (--method odt-no)

Optimal Delaunay Triangulation (ODT) as suggested by Chen and Holst. Typically superior to CPT, but also more expensive to compute.

Implemented once classically as a fixed-point iteration, once as a nonlinear optimization method. The latter typically leads to better results.

Access from Python

All optimesh functions can also be accessed from Python directly, for example:

import optimesh

X, cells = optimesh.odt(X, cells, 1.0e-2, 100, verbosity=1)


optimesh is available from the Python Package Index, so simply do

pip install -U optimesh

to install or upgrade. Use sudo -H to install as root or the --user option of pip to install in $HOME.

Relevant publications


To run the optimesh unit tests, check out this repository and type



To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and tag on GitHub:

    $ make publish


optimesh is published under the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for optimesh, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size optimesh-0.2.0-py2.py3-none-any.whl (15.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size optimesh-0.2.0.tar.gz (13.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page