Skip to main content

adaptmesh

PyPI PyPI - License ci DOI

Create triangular meshes by the adaptive process.

The user feeds in a polygon and a low quality mesh is created. Then the low quality mesh gets improved by adaptive finite elements and mesh smoothing. The approach is detailed in the following paper:

@article{adaptmesh,
    title={A simple technique for unstructured mesh generation via adaptive finite elements},
    author={Gustafsson, Tom},
    volume={54},
    doi={10.23998/rm.99648},
    number={2},
    journal={Rakenteiden Mekaniikka},
    year={2021},
    pages={69--79}
}

adaptmesh ships with customized versions of the following packages:

  • tri v0.3.1.dev0 (ported to Python 3; Copyright (c) 2015 Martijn Meijers; MIT; source)
  • optimesh v0.6.3 (trimmed down version with minor changes to the edge flipping; Copyright (c) 2018-2020 Nico Schlömer; the last version with MIT; source)
  • meshplex v0.12.3 (trimmed down version with minor changes, i.e. removal of unnecessary imports; Copyright (c) 2017-2020 Nico Schlömer; the last version with MIT; source)

Installation

pip install adaptmesh

Dependencies

  • numpy
  • scipy
  • matplotlib
  • scikit-fem

Examples

The mesh generator is called through the function adaptmesh.triangulate.

Square with default settings

from adaptmesh import triangulate

m = triangulate([(0., 0.),
                 (1., 0.),
                 (1., 1.),
                 (0., 1.),])
                 
# m.p are the points
# m.t are the elements

Example mesh 1

Non-convex shape

from adaptmesh import triangulate

m = triangulate([(0.0, 0.0),
                 (1.1, 0.0),
                 (1.2, 0.5),
                 (0.7, 0.6),
                 (2.0, 1.0),
                 (1.0, 2.0),
                 (0.5, 1.5),], quality=0.95)  # default: 0.9

Example mesh 2

Holes

m = triangulate([(0., 0.),
                 (1., 0.),
                 (1., 1.),
                 (0., 1.),],
                holes=[[(.25, .25),
                        (.75, .25),
                        (.75, .75),
                        (.25, .75)]])

Example mesh 3

Subdomains

m1 = triangulate([(0., 0.),
                  (1., 0.),
                  (.7, 1.),
                  (0., 1.),],
                 split=[(1, 8),
                        (2, 6)],
                 quality=0.91)

m2 = triangulate([(0., 2.),
                  (2., 2.),
                  (2., 0.),
                  (1., 0.),
                  (.7, 1.),
                  (0., 1.)],
                 split=[(3, 8),
                        (4, 6)],
                 quality=0.91)

m = m1 + m2

Multiple meshes can be joined to emulate subdomains. However, the nodes must match. Above, segments are splitted to facilitate the matching, e.g., [(1, 8), (2, 6)] means that the second and the third segments are split using eight and six equispaced extra nodes, respectively.

Example mesh 4

Licensing

The main source code of adaptmesh is distributed under the MIT License.

The licenses of the included packages can be found also in LICENSE.md and the respective subdirectories, i.e. ./adaptmesh/*/LICENSE. See LICENSE.md for more information.

Changelog

Unreleased

[0.3.3] - 2022-02-04

  • Fixed: Properly respect segments in the initial triangulation.

[0.3.2] - 2021-09-28

  • Fixed: Rendering of README in pypi.

[0.3.1] - 2021-09-28

  • Fixed: Support for scikit-fem>=4.

[0.3.0] - 2021-06-22

  • Fixed: Support for scikit-fem>=3. Dependency update broke the mesh refinement.

[0.2.0] - 2021-01-20

  • Added: keyword argument split of triangulate allows further splitting the provided segments. This is useful because the segment endpoints are always preserved in the final mesh.
  • Added: keyword argument holes of triangulate allows specifying additional polygonal areas inside the domain that will be free of triangles in the final mesh.

Metadata

Release files for adaptmesh 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adaptmesh 0.3.3
File Size Uploaded
adaptmesh-0.3.3.tar.gz 43.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for adaptmesh 0.3.3
File Interpreter ABI Platform
adaptmesh-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 90.0 kB

Release files / adaptmesh-0.3.3.tar.gz

Download URL adaptmesh-0.3.3.tar.gz
Size 43.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7d4c256077eb1dff7ccc7a1ccc1d08dc58e5ab5596cf31e7504107e267954b4c
BLAKE2b-256 checksum
How to use checksums
4d27d2067e4c292e1e3d91a1edf7f31c2dc131b07677a6fcbd25ad482222e334
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/57.4.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Release files / adaptmesh-0.3.3-py3-none-any.whl

Download URL adaptmesh-0.3.3-py3-none-any.whl
Size 46.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b03db9a18ee7b91d984bfd2f24d08f91a20914b9ef3e5ec98470a710319fb22
BLAKE2b-256 checksum
How to use checksums
f2db2d3e7e4eaa7c3f325a236175eb9943cce083081c9b2cb5f1096f642e1d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/57.4.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page