/libdistmesh

libDistMesh: A Simple Mesh Generator in C++

Primary LanguageC++GNU General Public License v2.0GPL-2.0

libDistMesh: A Simple Mesh Generator in C++

libDistMesh is a C++ implementation of the original DistMesh algorithm for generating unstructured triangular and tetrahedral meshes using signed distance functions.

Getting Started

Simply clone the repository, make sure all dependencies are installed and build it.

cp Makefile.config.example Makefile.config
make
make install

Example

  • Uniform Mesh on Unit Circle:
#include <distmesh/distmesh.h>

int main() {
    // create mesh
    auto const mesh = distmesh::distmesh(distmesh::distanceFunction::circular(1.0), 0.2);

    return 0;
}
  • Rectangle with circular hole, refined at circle boundary:
#include <distmesh/distmesh.h>

int main() {
    // fixed points at the corners of domain to guarantee convergence
    Eigen::ArrayXXd fixedPoints(4, 2);
    fixedPoints << -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0;

    // create mesh
    auto const mesh = distmesh::distmesh(
        distmesh::distanceFunction::rectangular(rectangle)
            .max(-distmesh::distanceFunction::circular(0.5)),
        0.05, 0.05 + 0.3 * distmesh::distanceFunction::circular(0.5),
        distmesh::utils::boundingBox(2), fixedPoints);

    return 0;
}

Dependencies

libDistMesh uses some C++11 features and compiles properly with both clang and gcc. For linear algebra operations and the delaunay triangulation two libraries are needed for building and using libDistMesh:

References

The DistMesh algorithm is described in the following two references. If you use the algorithm in a program or publication, please acknowledge its authors by adding a reference to the first paper below.