Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Python frontend for Gmsh

Project Description

Gmsh is a powerful mesh generation tool with a scripting language that is notoriously hard to write.

The goal of pygmsh is to combine the power of Gmsh with the versatility of Python and to provide useful abstractions from the Gmsh scripting language so you can create complex geometries more easily.

To create the above mesh, simply do

import pygmsh
import numpy as np

geom = pygmsh.built_in.Geometry()

# Draw a cross.
poly = geom.add_polygon([
    [0.0,   0.5, 0.0],
    [-0.1,  0.1, 0.0],
    [-0.5,  0.0, 0.0],
    [-0.1, -0.1, 0.0],
    [0.0,  -0.5, 0.0],
    [0.1,  -0.1, 0.0],
    [0.5,   0.0, 0.0],
    [0.1,   0.1, 0.0]
    ],
    lcar=0.05
    )

axis = [0, 0, 1]

geom.extrude(
    poly,
    translation_axis=axis,
    rotation_axis=axis,
    point_on_axis=[0, 0, 0],
    angle=2.0 / 6.0 * np.pi
    )

points, cells, point_data, cell_data, field_data = pygmsh.generate_mesh(geom)

to retrieve all points and cells of the mesh for the specified geometry. To store the mesh, you can use meshio; for example

import meshio
meshio.write('test.vtu', points, cells, cell_data=cell_data)

The output file can be visualized with various tools, e.g., ParaView.

You will find the above mesh in the directory `test/ <https://github.com/nschloe/pygmsh/tree/master/test/>`__ along with other small examples.

OpenCASCADE

As of version 3.0, Gmsh supports OpenCASCADE, allowing for a CAD-style geometry specification.

Example:

import pygmsh

geom = pygmsh.opencascade.Geometry(
  characteristic_length_min=0.1,
  characteristic_length_max=0.1,
  )

rectangle = geom.add_rectangle([-1.0, -1.0, 0.0], 2.0, 2.0)
disk1 = geom.add_disk([-1.2, 0.0, 0.0], 0.5)
disk2 = geom.add_disk([+1.2, 0.0, 0.0], 0.5)
union = geom.boolean_union([rectangle, disk1, disk2])

disk3 = geom.add_disk([0.0, -0.9, 0.0], 0.5)
disk4 = geom.add_disk([0.0, +0.9, 0.0], 0.5)
flat = geom.boolean_difference([union], [disk3, disk4])

geom.extrude(flat, [0, 0, 0.3])

points, cells, point_data, cell_data, field_data = pygmsh.generate_mesh(geom)

Installation

pygmsh is available from the Python Package Index, so simply type

pip install -U pygmsh

to install or upgrade.

Usage

Just

import pygmsh as pg

and make use of all the goodies the module provides. The documentation and the examples under `test/ <https://github.com/nschloe/pygmsh/tree/master/test/>`__ might inspire you.

Testing

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

pytest

Building Documentation

Docs are built using Sphinx.

To build run

sphinx-build -b html doc doc/_build

Distribution

To create a new release

  1. bump the __version__ number,

  2. publish to PyPi and GitHub:

    $ make publish
    

License

pygmsh is published under the MIT license.

Release History

Release History

This version
History Node

4.0.4

History Node

4.0.3

History Node

4.0.2

History Node

4.0.1

History Node

4.0.0

History Node

3.2.2

History Node

3.2.1

History Node

3.2.0

History Node

3.1.0

History Node

3.0.18

History Node

3.0.17

History Node

3.0.16

History Node

3.0.15

History Node

3.0.14

History Node

3.0.13

History Node

3.0.12

History Node

3.0.11

History Node

3.0.10

History Node

3.0.9

History Node

3.0.8

History Node

3.0.7

History Node

3.0.6

History Node

3.0.5

History Node

3.0.4

History Node

3.0.3

History Node

3.0.2

History Node

3.0.1

History Node

3.0.0

History Node

2.7.0

History Node

2.6.0

History Node

2.5.1

History Node

2.5.0

History Node

2.4.2

History Node

2.4.1

History Node

2.4.0

History Node

2.3.0

History Node

2.2.0

History Node

2.1.3

History Node

2.1.2

History Node

2.1.1

History Node

2.1.0

History Node

2.0.1

History Node

2.0.0

History Node

1.0.1

History Node

1.0.0

History Node

0.2.1

History Node

0.2.0

History Node

0.1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pygmsh-4.0.4-py2.py3-none-any.whl (30.1 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Nov 12, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting