Skip to main content
Join the official 2020 Python Developers Survey

Mesh optimization/smoothing

# optimesh

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:

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

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)

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)

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)
```

### Installation

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`.

### Testing

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

``````pytest
``````

### Distribution

To create a new release

1. bump the `__version__` number,

2. publish to PyPi and tag on GitHub:

``````\$ make publish
``````

### License

optimesh is published under the MIT license.

## 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
Filename, size optimesh-0.2.0.tar.gz (13.1 kB) File type Source Python version None Upload date Hashes