pygmsh


Namepygmsh JSON
Version 7.1.17 PyPI version JSON
download
home_page
SummaryPython frontend for Gmsh
upload_time2022-01-28 13:15:43
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords mesh gmsh mesh generation mathematics engineering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <a href="https://github.com/nschloe/pygmsh"><img alt="pygmsh" src="https://nschloe.github.io/pygmsh/logo-with-text.svg" width="60%"></a>
  <p align="center">Gmsh for Python.</p>
</p>

[![PyPi Version](https://img.shields.io/pypi/v/pygmsh.svg?style=flat-square)](https://pypi.org/project/pygmsh/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pygmsh.svg?style=flat-square)](https://pypi.org/project/pygmsh/)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1173105.svg?style=flat-square)](https://doi.org/10.5281/zenodo.1173105)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/pygmsh.svg?style=flat-square&logo=github&label=Stars&logoColor=white)](https://github.com/nschloe/pygmsh)
[![PyPi downloads](https://img.shields.io/pypi/dm/pygmsh.svg?style=flat-square)](https://pypistats.org/packages/pygmsh)

[![Discord](https://img.shields.io/static/v1?logo=discord&label=chat&message=on%20discord&color=7289da&style=flat-square)](https://discord.gg/hnTJ5MRX2Y)
[![Documentation Status](https://readthedocs.org/projects/pygmsh/badge/?version=latest&style=flat-square)](https://pygmsh.readthedocs.io/en/latest/?badge=latest)

[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/pygmsh/ci?style=flat-square)](https://github.com/nschloe/pygmsh/actions?query=workflow%3Aci)
[![codecov](https://img.shields.io/codecov/c/github/nschloe/pygmsh.svg?style=flat-square)](https://codecov.io/gh/nschloe/pygmsh)
[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/pygmsh.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/pygmsh)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)

pygmsh combines the power of [Gmsh](https://gmsh.info/) with the versatility of Python.
It provides useful abstractions from Gmsh's own Python interface so you can create
complex geometries more easily.

To use, install Gmsh itself and pygmsh from [pypi](https://pypi.org/project/pygmsh/):

```
[sudo] apt install python3-gmsh
pip install pygmsh
```

This document and the [`tests/`](https://github.com/nschloe/pygmsh/tree/main/tests/)
directory contain many small examples. See
[here](https://pygmsh.readthedocs.io/en/latest/index.html) for the full documentation.

#### Flat shapes

| <img src="https://nschloe.github.io/pygmsh/polygon.svg" width="100%"> | <img src="https://nschloe.github.io/pygmsh/circle.svg" width="100%"> | <img src="https://nschloe.github.io/pygmsh/splines.svg" width="100%"> |
| :-------------------------------------------------------------------: | :------------------------------------------------------------------: | :-------------------------------------------------------------------: |
|                                Polygon                                |                                Circle                                |                              (B-)Splines                              |

Codes:

```python
import pygmsh

with pygmsh.geo.Geometry() as geom:
    geom.add_polygon(
        [
            [0.0, 0.0],
            [1.0, -0.2],
            [1.1, 1.2],
            [0.1, 0.7],
        ],
        mesh_size=0.1,
    )
    mesh = geom.generate_mesh()

# mesh.points, mesh.cells, ...
# mesh.write("out.vtk")
```

```python
import pygmsh

with pygmsh.geo.Geometry() as geom:
    geom.add_circle([0.0, 0.0], 1.0, mesh_size=0.2)
    mesh = geom.generate_mesh()
```

```python
import pygmsh

with pygmsh.geo.Geometry() as geom:
    lcar = 0.1
    p1 = geom.add_point([0.0, 0.0], lcar)
    p2 = geom.add_point([1.0, 0.0], lcar)
    p3 = geom.add_point([1.0, 0.5], lcar)
    p4 = geom.add_point([1.0, 1.0], lcar)
    s1 = geom.add_bspline([p1, p2, p3, p4])

    p2 = geom.add_point([0.0, 1.0], lcar)
    p3 = geom.add_point([0.5, 1.0], lcar)
    s2 = geom.add_spline([p4, p3, p2, p1])

    ll = geom.add_curve_loop([s1, s2])
    pl = geom.add_plane_surface(ll)

    mesh = geom.generate_mesh()
```

The return value is always a [meshio](https://pypi.org/project/meshio/) mesh, so to
store it to a file you can

<!--pytest-codeblocks:skip-->

```python
mesh.write("test.vtk")
```

The output file can be visualized with various tools, e.g.,
[ParaView](https://www.paraview.org/).

With

<!--pytest-codeblocks:skip-->

```python
pygmsh.write("test.msh")
```

you can access Gmsh's native file writer.

#### Extrusions

| <img src="https://nschloe.github.io/pygmsh/extrude.png" width="100%"> | <img src="https://nschloe.github.io/pygmsh/revolve.png" width="100%"> | <img src="https://nschloe.github.io/pygmsh/twist.png" width="100%"> |
| :-------------------------------------------------------------------: | :-------------------------------------------------------------------: | :-----------------------------------------------------------------: |
|                               `extrude`                               |                               `revolve`                               |                               `twist`                               |

```python
import pygmsh

with pygmsh.geo.Geometry() as geom:
    poly = geom.add_polygon(
        [
            [0.0, 0.0],
            [1.0, -0.2],
            [1.1, 1.2],
            [0.1, 0.7],
        ],
        mesh_size=0.1,
    )
    geom.extrude(poly, [0.0, 0.3, 1.0], num_layers=5)
    mesh = geom.generate_mesh()
```

```python
from math import pi
import pygmsh

with pygmsh.geo.Geometry() as geom:
    poly = geom.add_polygon(
        [
            [0.0, 0.2, 0.0],
            [0.0, 1.2, 0.0],
            [0.0, 1.2, 1.0],
        ],
        mesh_size=0.1,
    )
    geom.revolve(poly, [0.0, 0.0, 1.0], [0.0, 0.0, 0.0], 0.8 * pi)
    mesh = geom.generate_mesh()
```

```python
from math import pi
import pygmsh

with pygmsh.geo.Geometry() as geom:
    poly = geom.add_polygon(
        [
            [+0.0, +0.5],
            [-0.1, +0.1],
            [-0.5, +0.0],
            [-0.1, -0.1],
            [+0.0, -0.5],
            [+0.1, -0.1],
            [+0.5, +0.0],
            [+0.1, +0.1],
        ],
        mesh_size=0.05,
    )

    geom.twist(
        poly,
        translation_axis=[0, 0, 1],
        rotation_axis=[0, 0, 1],
        point_on_axis=[0, 0, 0],
        angle=pi / 3,
    )

    mesh = geom.generate_mesh()
```

#### OpenCASCADE

| <img src="https://nschloe.github.io/pygmsh/intersection.png" width="100%"> | <img src="https://nschloe.github.io/pygmsh/ellipsoid-holes.png" width="100%"> | <img src="https://nschloe.github.io/pygmsh/puzzle.png" width="100%"> |
| :------------------------------------------------------------------------: | :---------------------------------------------------------------------------: | :------------------------------------------------------------------: |
|                                                                            |                                                                               |

Gmsh also supports OpenCASCADE (`occ`), allowing for a CAD-style geometry specification.

```python
from math import pi, cos
import pygmsh

with pygmsh.occ.Geometry() as geom:
    geom.characteristic_length_max = 0.1
    r = 0.5
    disks = [
        geom.add_disk([-0.5 * cos(7 / 6 * pi), -0.25], 1.0),
        geom.add_disk([+0.5 * cos(7 / 6 * pi), -0.25], 1.0),
        geom.add_disk([0.0, 0.5], 1.0),
    ]
    geom.boolean_intersection(disks)

    mesh = geom.generate_mesh()
```

```python
# ellpsoid with holes
import pygmsh

with pygmsh.occ.Geometry() as geom:
    geom.characteristic_length_max = 0.1
    ellipsoid = geom.add_ellipsoid([0.0, 0.0, 0.0], [1.0, 0.7, 0.5])

    cylinders = [
        geom.add_cylinder([-1.0, 0.0, 0.0], [2.0, 0.0, 0.0], 0.3),
        geom.add_cylinder([0.0, -1.0, 0.0], [0.0, 2.0, 0.0], 0.3),
        geom.add_cylinder([0.0, 0.0, -1.0], [0.0, 0.0, 2.0], 0.3),
    ]
    geom.boolean_difference(ellipsoid, geom.boolean_union(cylinders))

    mesh = geom.generate_mesh()
```

```python
# puzzle piece
import pygmsh

with pygmsh.occ.Geometry() as geom:
    geom.characteristic_length_min = 0.1
    geom.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)

    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(
        geom.boolean_union([rectangle, disk1, disk2]),
        geom.boolean_union([disk3, disk4]),
    )

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

    mesh = geom.generate_mesh()
```

#### Mesh refinement/boundary layers

| <img src="https://nschloe.github.io/pygmsh/boundary0.svg" width="100%"> | <img src="https://nschloe.github.io/pygmsh/mesh-refinement-2d.svg" width="100%"> | <img src="https://nschloe.github.io/pygmsh/ball-mesh-refinement.png" width="70%"> |
| :---------------------------------------------------------------------: | :------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |
|                                                                         |                                                                                  |

```python
# boundary refinement
import pygmsh

with pygmsh.geo.Geometry() as geom:
    poly = geom.add_polygon(
        [
            [0.0, 0.0],
            [2.0, 0.0],
            [3.0, 1.0],
            [1.0, 2.0],
            [0.0, 1.0],
        ],
        mesh_size=0.3,
    )

    field0 = geom.add_boundary_layer(
        edges_list=[poly.curves[0]],
        lcmin=0.05,
        lcmax=0.2,
        distmin=0.0,
        distmax=0.2,
    )
    field1 = geom.add_boundary_layer(
        nodes_list=[poly.points[2]],
        lcmin=0.05,
        lcmax=0.2,
        distmin=0.1,
        distmax=0.4,
    )
    geom.set_background_mesh([field0, field1], operator="Min")

    mesh = geom.generate_mesh()
```

<!--pytest-codeblocks:skip-->

```python
# mesh refinement with callback
import pygmsh

with pygmsh.geo.Geometry() as geom:
    geom.add_polygon(
        [
            [-1.0, -1.0],
            [+1.0, -1.0],
            [+1.0, +1.0],
            [-1.0, +1.0],
        ]
    )
    geom.set_mesh_size_callback(
        lambda dim, tag, x, y, z: 6.0e-2 + 2.0e-1 * (x ** 2 + y ** 2)
    )

    mesh = geom.generate_mesh()
```

<!--pytest-codeblocks:skip-->

```python
# ball with mesh refinement
from math import sqrt
import pygmsh


with pygmsh.occ.Geometry() as geom:
    geom.add_ball([0.0, 0.0, 0.0], 1.0)

    geom.set_mesh_size_callback(
        lambda dim, tag, x, y, z: abs(sqrt(x ** 2 + y ** 2 + z ** 2) - 0.5) + 0.1
    )
    mesh = geom.generate_mesh()
```

#### Optimization

pygmsh can optimize existing meshes, too.

<!--pytest-codeblocks:skip-->

```python
import meshio

mesh = meshio.read("mymesh.vtk")
optimized_mesh = pygmsh.optimize(mesh, method="")
```

You can also use the command-line utility

```
pygmsh-optimize input.vtk output.xdmf
```

where input and output can be any format supported by
[meshio](https://pypi.org/project/meshio/).

### Testing

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

```
pytest
```

### Building Documentation

Docs are built using [Sphinx](http://www.sphinx-doc.org/en/stable/).

To build, run

```
sphinx-build -b html doc doc/_build
```

### License

This software is published under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "pygmsh",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "mesh,gmsh,mesh generation,mathematics,engineering",
    "author": "",
    "author_email": "Nico Schl\u00f6mer <nico.schloemer@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b8/13/3604dcd79e73e5d76d8f06fe80506b7ab8087597191440437bbf70699ab6/pygmsh-7.1.17.tar.gz",
    "platform": "",
    "description": "<p align=\"center\">\n  <a href=\"https://github.com/nschloe/pygmsh\"><img alt=\"pygmsh\" src=\"https://nschloe.github.io/pygmsh/logo-with-text.svg\" width=\"60%\"></a>\n  <p align=\"center\">Gmsh for Python.</p>\n</p>\n\n[![PyPi Version](https://img.shields.io/pypi/v/pygmsh.svg?style=flat-square)](https://pypi.org/project/pygmsh/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/pygmsh.svg?style=flat-square)](https://pypi.org/project/pygmsh/)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1173105.svg?style=flat-square)](https://doi.org/10.5281/zenodo.1173105)\n[![GitHub stars](https://img.shields.io/github/stars/nschloe/pygmsh.svg?style=flat-square&logo=github&label=Stars&logoColor=white)](https://github.com/nschloe/pygmsh)\n[![PyPi downloads](https://img.shields.io/pypi/dm/pygmsh.svg?style=flat-square)](https://pypistats.org/packages/pygmsh)\n\n[![Discord](https://img.shields.io/static/v1?logo=discord&label=chat&message=on%20discord&color=7289da&style=flat-square)](https://discord.gg/hnTJ5MRX2Y)\n[![Documentation Status](https://readthedocs.org/projects/pygmsh/badge/?version=latest&style=flat-square)](https://pygmsh.readthedocs.io/en/latest/?badge=latest)\n\n[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/pygmsh/ci?style=flat-square)](https://github.com/nschloe/pygmsh/actions?query=workflow%3Aci)\n[![codecov](https://img.shields.io/codecov/c/github/nschloe/pygmsh.svg?style=flat-square)](https://codecov.io/gh/nschloe/pygmsh)\n[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/pygmsh.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/pygmsh)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)\n\npygmsh combines the power of [Gmsh](https://gmsh.info/) with the versatility of Python.\nIt provides useful abstractions from Gmsh's own Python interface so you can create\ncomplex geometries more easily.\n\nTo use, install Gmsh itself and pygmsh from [pypi](https://pypi.org/project/pygmsh/):\n\n```\n[sudo] apt install python3-gmsh\npip install pygmsh\n```\n\nThis document and the [`tests/`](https://github.com/nschloe/pygmsh/tree/main/tests/)\ndirectory contain many small examples. See\n[here](https://pygmsh.readthedocs.io/en/latest/index.html) for the full documentation.\n\n#### Flat shapes\n\n| <img src=\"https://nschloe.github.io/pygmsh/polygon.svg\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/circle.svg\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/splines.svg\" width=\"100%\"> |\n| :-------------------------------------------------------------------: | :------------------------------------------------------------------: | :-------------------------------------------------------------------: |\n|                                Polygon                                |                                Circle                                |                              (B-)Splines                              |\n\nCodes:\n\n```python\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    geom.add_polygon(\n        [\n            [0.0, 0.0],\n            [1.0, -0.2],\n            [1.1, 1.2],\n            [0.1, 0.7],\n        ],\n        mesh_size=0.1,\n    )\n    mesh = geom.generate_mesh()\n\n# mesh.points, mesh.cells, ...\n# mesh.write(\"out.vtk\")\n```\n\n```python\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    geom.add_circle([0.0, 0.0], 1.0, mesh_size=0.2)\n    mesh = geom.generate_mesh()\n```\n\n```python\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    lcar = 0.1\n    p1 = geom.add_point([0.0, 0.0], lcar)\n    p2 = geom.add_point([1.0, 0.0], lcar)\n    p3 = geom.add_point([1.0, 0.5], lcar)\n    p4 = geom.add_point([1.0, 1.0], lcar)\n    s1 = geom.add_bspline([p1, p2, p3, p4])\n\n    p2 = geom.add_point([0.0, 1.0], lcar)\n    p3 = geom.add_point([0.5, 1.0], lcar)\n    s2 = geom.add_spline([p4, p3, p2, p1])\n\n    ll = geom.add_curve_loop([s1, s2])\n    pl = geom.add_plane_surface(ll)\n\n    mesh = geom.generate_mesh()\n```\n\nThe return value is always a [meshio](https://pypi.org/project/meshio/) mesh, so to\nstore it to a file you can\n\n<!--pytest-codeblocks:skip-->\n\n```python\nmesh.write(\"test.vtk\")\n```\n\nThe output file can be visualized with various tools, e.g.,\n[ParaView](https://www.paraview.org/).\n\nWith\n\n<!--pytest-codeblocks:skip-->\n\n```python\npygmsh.write(\"test.msh\")\n```\n\nyou can access Gmsh's native file writer.\n\n#### Extrusions\n\n| <img src=\"https://nschloe.github.io/pygmsh/extrude.png\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/revolve.png\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/twist.png\" width=\"100%\"> |\n| :-------------------------------------------------------------------: | :-------------------------------------------------------------------: | :-----------------------------------------------------------------: |\n|                               `extrude`                               |                               `revolve`                               |                               `twist`                               |\n\n```python\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    poly = geom.add_polygon(\n        [\n            [0.0, 0.0],\n            [1.0, -0.2],\n            [1.1, 1.2],\n            [0.1, 0.7],\n        ],\n        mesh_size=0.1,\n    )\n    geom.extrude(poly, [0.0, 0.3, 1.0], num_layers=5)\n    mesh = geom.generate_mesh()\n```\n\n```python\nfrom math import pi\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    poly = geom.add_polygon(\n        [\n            [0.0, 0.2, 0.0],\n            [0.0, 1.2, 0.0],\n            [0.0, 1.2, 1.0],\n        ],\n        mesh_size=0.1,\n    )\n    geom.revolve(poly, [0.0, 0.0, 1.0], [0.0, 0.0, 0.0], 0.8 * pi)\n    mesh = geom.generate_mesh()\n```\n\n```python\nfrom math import pi\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    poly = geom.add_polygon(\n        [\n            [+0.0, +0.5],\n            [-0.1, +0.1],\n            [-0.5, +0.0],\n            [-0.1, -0.1],\n            [+0.0, -0.5],\n            [+0.1, -0.1],\n            [+0.5, +0.0],\n            [+0.1, +0.1],\n        ],\n        mesh_size=0.05,\n    )\n\n    geom.twist(\n        poly,\n        translation_axis=[0, 0, 1],\n        rotation_axis=[0, 0, 1],\n        point_on_axis=[0, 0, 0],\n        angle=pi / 3,\n    )\n\n    mesh = geom.generate_mesh()\n```\n\n#### OpenCASCADE\n\n| <img src=\"https://nschloe.github.io/pygmsh/intersection.png\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/ellipsoid-holes.png\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/puzzle.png\" width=\"100%\"> |\n| :------------------------------------------------------------------------: | :---------------------------------------------------------------------------: | :------------------------------------------------------------------: |\n|                                                                            |                                                                               |\n\nGmsh also supports OpenCASCADE (`occ`), allowing for a CAD-style geometry specification.\n\n```python\nfrom math import pi, cos\nimport pygmsh\n\nwith pygmsh.occ.Geometry() as geom:\n    geom.characteristic_length_max = 0.1\n    r = 0.5\n    disks = [\n        geom.add_disk([-0.5 * cos(7 / 6 * pi), -0.25], 1.0),\n        geom.add_disk([+0.5 * cos(7 / 6 * pi), -0.25], 1.0),\n        geom.add_disk([0.0, 0.5], 1.0),\n    ]\n    geom.boolean_intersection(disks)\n\n    mesh = geom.generate_mesh()\n```\n\n```python\n# ellpsoid with holes\nimport pygmsh\n\nwith pygmsh.occ.Geometry() as geom:\n    geom.characteristic_length_max = 0.1\n    ellipsoid = geom.add_ellipsoid([0.0, 0.0, 0.0], [1.0, 0.7, 0.5])\n\n    cylinders = [\n        geom.add_cylinder([-1.0, 0.0, 0.0], [2.0, 0.0, 0.0], 0.3),\n        geom.add_cylinder([0.0, -1.0, 0.0], [0.0, 2.0, 0.0], 0.3),\n        geom.add_cylinder([0.0, 0.0, -1.0], [0.0, 0.0, 2.0], 0.3),\n    ]\n    geom.boolean_difference(ellipsoid, geom.boolean_union(cylinders))\n\n    mesh = geom.generate_mesh()\n```\n\n```python\n# puzzle piece\nimport pygmsh\n\nwith pygmsh.occ.Geometry() as geom:\n    geom.characteristic_length_min = 0.1\n    geom.characteristic_length_max = 0.1\n\n    rectangle = geom.add_rectangle([-1.0, -1.0, 0.0], 2.0, 2.0)\n    disk1 = geom.add_disk([-1.2, 0.0, 0.0], 0.5)\n    disk2 = geom.add_disk([+1.2, 0.0, 0.0], 0.5)\n\n    disk3 = geom.add_disk([0.0, -0.9, 0.0], 0.5)\n    disk4 = geom.add_disk([0.0, +0.9, 0.0], 0.5)\n    flat = geom.boolean_difference(\n        geom.boolean_union([rectangle, disk1, disk2]),\n        geom.boolean_union([disk3, disk4]),\n    )\n\n    geom.extrude(flat, [0, 0, 0.3])\n\n    mesh = geom.generate_mesh()\n```\n\n#### Mesh refinement/boundary layers\n\n| <img src=\"https://nschloe.github.io/pygmsh/boundary0.svg\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/mesh-refinement-2d.svg\" width=\"100%\"> | <img src=\"https://nschloe.github.io/pygmsh/ball-mesh-refinement.png\" width=\"70%\"> |\n| :---------------------------------------------------------------------: | :------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |\n|                                                                         |                                                                                  |\n\n```python\n# boundary refinement\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    poly = geom.add_polygon(\n        [\n            [0.0, 0.0],\n            [2.0, 0.0],\n            [3.0, 1.0],\n            [1.0, 2.0],\n            [0.0, 1.0],\n        ],\n        mesh_size=0.3,\n    )\n\n    field0 = geom.add_boundary_layer(\n        edges_list=[poly.curves[0]],\n        lcmin=0.05,\n        lcmax=0.2,\n        distmin=0.0,\n        distmax=0.2,\n    )\n    field1 = geom.add_boundary_layer(\n        nodes_list=[poly.points[2]],\n        lcmin=0.05,\n        lcmax=0.2,\n        distmin=0.1,\n        distmax=0.4,\n    )\n    geom.set_background_mesh([field0, field1], operator=\"Min\")\n\n    mesh = geom.generate_mesh()\n```\n\n<!--pytest-codeblocks:skip-->\n\n```python\n# mesh refinement with callback\nimport pygmsh\n\nwith pygmsh.geo.Geometry() as geom:\n    geom.add_polygon(\n        [\n            [-1.0, -1.0],\n            [+1.0, -1.0],\n            [+1.0, +1.0],\n            [-1.0, +1.0],\n        ]\n    )\n    geom.set_mesh_size_callback(\n        lambda dim, tag, x, y, z: 6.0e-2 + 2.0e-1 * (x ** 2 + y ** 2)\n    )\n\n    mesh = geom.generate_mesh()\n```\n\n<!--pytest-codeblocks:skip-->\n\n```python\n# ball with mesh refinement\nfrom math import sqrt\nimport pygmsh\n\n\nwith pygmsh.occ.Geometry() as geom:\n    geom.add_ball([0.0, 0.0, 0.0], 1.0)\n\n    geom.set_mesh_size_callback(\n        lambda dim, tag, x, y, z: abs(sqrt(x ** 2 + y ** 2 + z ** 2) - 0.5) + 0.1\n    )\n    mesh = geom.generate_mesh()\n```\n\n#### Optimization\n\npygmsh can optimize existing meshes, too.\n\n<!--pytest-codeblocks:skip-->\n\n```python\nimport meshio\n\nmesh = meshio.read(\"mymesh.vtk\")\noptimized_mesh = pygmsh.optimize(mesh, method=\"\")\n```\n\nYou can also use the command-line utility\n\n```\npygmsh-optimize input.vtk output.xdmf\n```\n\nwhere input and output can be any format supported by\n[meshio](https://pypi.org/project/meshio/).\n\n### Testing\n\nTo run the pygmsh unit tests, check out this repository and type\n\n```\npytest\n```\n\n### Building Documentation\n\nDocs are built using [Sphinx](http://www.sphinx-doc.org/en/stable/).\n\nTo build, run\n\n```\nsphinx-build -b html doc doc/_build\n```\n\n### License\n\nThis software is published under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html).\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python frontend for Gmsh",
    "version": "7.1.17",
    "split_keywords": [
        "mesh",
        "gmsh",
        "mesh generation",
        "mathematics",
        "engineering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "ce4ee5cdb239acba7707381769b09c54",
                "sha256": "3b3da976a4da5070eaf1b0d2c5eec3fc4902524580c6d256c32a390f720e86d4"
            },
            "downloads": -1,
            "filename": "pygmsh-7.1.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ce4ee5cdb239acba7707381769b09c54",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 45435,
            "upload_time": "2022-01-28T13:15:39",
            "upload_time_iso_8601": "2022-01-28T13:15:39.376960Z",
            "url": "https://files.pythonhosted.org/packages/6e/67/9d4ac4b0d683aaa4170da59a1980740b281fd38fc253e1830fde4dac3d4f/pygmsh-7.1.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "c09975c4bd3aa74cd9188cf2e7e032b0",
                "sha256": "563724abff4f8517598d3354b9c795feddbe0675786145bfeaf20cbee6691c1d"
            },
            "downloads": -1,
            "filename": "pygmsh-7.1.17.tar.gz",
            "has_sig": false,
            "md5_digest": "c09975c4bd3aa74cd9188cf2e7e032b0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 61707,
            "upload_time": "2022-01-28T13:15:43",
            "upload_time_iso_8601": "2022-01-28T13:15:43.628401Z",
            "url": "https://files.pythonhosted.org/packages/b8/13/3604dcd79e73e5d76d8f06fe80506b7ab8087597191440437bbf70699ab6/pygmsh-7.1.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-01-28 13:15:43",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "pygmsh"
}
        
Elapsed time: 0.15510s