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

Mesh optimization/smoothing

Project description


CircleCI codecov 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 cvt-uniform-lloyd2 -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 documented at

optimesh -h

CVT (centroidal Voronoi tesselation)

cvt-uniform-lloyd cvt-uniform-lloyd2 cvt-uniform-qnb
uniform-density fixed-point iteration (Lloyd's algorithm, --method cvt-uniform-lloyd) uniform-density overrelaxed Lloyd's algorithm (factor 2, --method cvt-uniform-lloyd2) uniform-density quasi-Newton iteration (block diagonal Hessian, --method cvt-uniform-qnb)

Centroidal Voronoi tessellation smoothing (Du et al.) is one of the oldest and most reliable approaches. optimesh provides classical Lloyd smoothing as well as several variants that provide faster convergence.

CPT (centroidal patch tesselation)

cpt-cp cpt-uniform-fp cpt-uniform-qn
density-preserving linear solve (Laplacian smoothing, --method cpt-dp) uniform-density fixed-point iteration (--method cpt-uniform-fp) uniform-density quasi-Newton (--method cpt-uniform-qn)

A smoothing 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 Laplacian smoothing, so CPT smoothing can be thought of as a generalization.

The uniform-density variants are implemented classically as a fixed-point iteration and as a quasi-Newton method. The latter typically converges faster.

ODT (optimal Delaunay tesselation)

odt-dp-fp odt-uniform-fp odt-uniform-bfgs
density-preserving fixed-point iteration (--method odt-dp-fp) uniform-density fixed-point iteration (--method odt-uniform-fp) uniform-density BFGS (--method odt-uniform-bfgs)

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.

Which method is best?

From practical experiments, it seems that the CVT smoothing variants give very satisfactory results. Here is a comparison of all uniform-density methods applied to the random circle mesh seen above:

(Mesh quality is twice the ratio of incircle and circumcircle radius, with the maximum being 1.)

Access from Python

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

import optimesh

X, cells = optimesh.odt.fixed_point_uniform(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.3.0
Filename, size File type Python version Upload date Hashes
Filename, size optimesh-0.3.0-py2.py3-none-any.whl (17.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size optimesh-0.3.0.tar.gz (15.7 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