pyvista-gridder


Namepyvista-gridder JSON
Version 0.4.1 PyPI version JSON
download
home_pageNone
SummaryMesh generation using PyVista
upload_time2025-08-15 07:08:36
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords mesh generation numerical modeling pyvista
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
   <img src="https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/logo/logo.png?raw=true" width=25%>
   <h1 align="center"><b>PyVista Gridder</b></h1>
</p>

[![License](https://img.shields.io/badge/license-BSD--3--Clause-green)](https://github.com/INTERA-Inc/pyvista-gridder/blob/master/LICENSE)
[![Stars](https://img.shields.io/github/stars/INTERA-Inc/pyvista-gridder?style=flat&logo=github)](https://github.com/INTERA-Inc/pyvista-gridder)
[![Pyversions](https://img.shields.io/pypi/pyversions/pyvista-gridder.svg?style=flat)](https://pypi.org/pypi/pyvista-gridder/)
[![Version](https://img.shields.io/pypi/v/pyvista-gridder.svg?style=flat)](https://pypi.org/project/pyvista-gridder)
[![Downloads](https://pepy.tech/badge/pyvista-gridder)](https://pepy.tech/project/pyvista-gridder)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat)](https://github.com/psf/black)

Structured and unstructured mesh generation using PyVista for the Finite-Element (FEM), Finite-Difference (FDM), and Finite-Volume Methods (FVM).

## Features

- **Pre-Meshed Geometric Objects**: Easily create basic geometric objects with pre-defined meshes, using structured grids whenever possible.
- **Line/Polyline Extrusion**: Extrude lines or polylines into 2D structured grids.
- **Surface Extrusion**: Extrude surface meshes into volumetric meshes while preserving their original type.
- **1.5D/2.5D Mesh Creation**: Generate meshes by stacking polylines or surfaces, ideal for geological modeling and similar applications.
- **2D Voronoi Mesh Generation**: Create 2D Voronoi meshes from a background mesh, with support for adding constraint points to define custom shapes.
- **Mesh Merging**: Combine multiple PyVista meshes into a single mesh and assign cell groups, leaving conformity checks to the user.
- **Additional Utility Functions**: Includes tools to manipulate structured and unstructured grids.

## Installation

The recommended way to install **pyvista-gridder** and all its dependencies is through the Python Package Index:

```bash
pip install pyvista-gridder --user
```

Otherwise, clone and extract the package, then run from the package location:

```bash
pip install .[full] --user
```

To test the integrity of the installed package, check out this repository and run:

```bash
pytest
```

## Examples

### 2D structured grid

```python
import numpy as np
import pyvista as pv
import pvgridder as pvg

mesh = (
   pvg.MeshStack2D(pv.Line([-3.14, 0.0, 0.0], [3.14, 0.0, 0.0], resolution=41))
   .add(0.0)
   .add(lambda x, y, z: np.cos(x) + 1.0, 4, group="Layer 1")
   .add(0.5, 2, group="Layer 2")
   .add(0.5, 2, group="Layer 3")
   .add(0.5, 2, group="Layer 4")
   .add(lambda x, y, z: np.full_like(x, 3.4), 4, group="Layer 5")
   .generate_mesh()
)
mesh.plot(show_edges=True, scalars=pvg.get_cell_group(mesh))
```

![anticline](https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/anticline.png?raw=true)

### 2D Voronoi mesh

```python
import numpy as np
import pyvista as pv
import pvgridder as pvg

smile_radius = 0.64
smile_points = [
   (smile_radius * np.cos(theta), smile_radius * np.sin(theta), 0.0)
   for theta in np.deg2rad(np.linspace(200.0, 340.0, 32))
]
mesh = (
   pvg.VoronoiMesh2D(pvg.Annulus(0.0, 1.0, 16, 32), default_group="Face")
   .add_circle(0.16, plain=False, resolution=16, center=(-0.32, 0.32, 0.0), group="Eye")
   .add_circle(0.16, plain=True, resolution=16, center=(0.32, 0.32, 0.0), group="Eye")
   .add_polyline(smile_points, width=0.05, group="Mouth")
   .generate_mesh()
)
mesh.plot(show_edges=True, scalars=pvg.get_cell_group(mesh))
```

![nightmare-fuel](https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/nightmare_fuel.png?raw=true)

### 2.5D geological model

```python
import pyvista as pv
import pvgridder as pvg

terrain = pv.examples.download_crater_topo().extract_subset(
   (500, 900, 400, 800, 0, 0), (10, 10, 1)
)
terrain_delaunay = pvg.Polygon(terrain, celltype="triangle")
terrain = terrain.cast_to_structured_grid().warp_by_scalar("scalar1of1")

mesh = (
   pvg.MeshStack3D(
      pvg.VoronoiMesh2D(terrain_delaunay, preference="point").generate_mesh()
   )
   .add(0.0)
   .add(terrain.translate((0.0, 0.0, -1000.0)), 5, method="log_r", group="Bottom layer")
   .add(500.0, 5, group="Middle layer")
   .add(terrain, 5, method="log", group="Top Layer")
   .generate_mesh()
)
mesh.plot(show_edges=True, scalars=pvg.get_cell_group(mesh))
```

![topographic-terrain](https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/topographic_terrain.png?raw=true)

## Acknowledgements

This project is supported by Nagra (National Cooperative for the Disposal of Radioactive Waste), Switzerland.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pyvista-gridder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "mesh generation, numerical modeling, pyvista",
    "author": null,
    "author_email": "Keurfon Luu <kluu@intera.com>",
    "download_url": "https://files.pythonhosted.org/packages/3d/66/21c509d7813194986d8d855000b57a3bf50080d011c5a5e4039e02162138/pyvista_gridder-0.4.1.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\r\n   <img src=\"https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/logo/logo.png?raw=true\" width=25%>\r\n   <h1 align=\"center\"><b>PyVista Gridder</b></h1>\r\n</p>\r\n\r\n[![License](https://img.shields.io/badge/license-BSD--3--Clause-green)](https://github.com/INTERA-Inc/pyvista-gridder/blob/master/LICENSE)\r\n[![Stars](https://img.shields.io/github/stars/INTERA-Inc/pyvista-gridder?style=flat&logo=github)](https://github.com/INTERA-Inc/pyvista-gridder)\r\n[![Pyversions](https://img.shields.io/pypi/pyversions/pyvista-gridder.svg?style=flat)](https://pypi.org/pypi/pyvista-gridder/)\r\n[![Version](https://img.shields.io/pypi/v/pyvista-gridder.svg?style=flat)](https://pypi.org/project/pyvista-gridder)\r\n[![Downloads](https://pepy.tech/badge/pyvista-gridder)](https://pepy.tech/project/pyvista-gridder)\r\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat)](https://github.com/psf/black)\r\n\r\nStructured and unstructured mesh generation using PyVista for the Finite-Element (FEM), Finite-Difference (FDM), and Finite-Volume Methods (FVM).\r\n\r\n## Features\r\n\r\n- **Pre-Meshed Geometric Objects**: Easily create basic geometric objects with pre-defined meshes, using structured grids whenever possible.\r\n- **Line/Polyline Extrusion**: Extrude lines or polylines into 2D structured grids.\r\n- **Surface Extrusion**: Extrude surface meshes into volumetric meshes while preserving their original type.\r\n- **1.5D/2.5D Mesh Creation**: Generate meshes by stacking polylines or surfaces, ideal for geological modeling and similar applications.\r\n- **2D Voronoi Mesh Generation**: Create 2D Voronoi meshes from a background mesh, with support for adding constraint points to define custom shapes.\r\n- **Mesh Merging**: Combine multiple PyVista meshes into a single mesh and assign cell groups, leaving conformity checks to the user.\r\n- **Additional Utility Functions**: Includes tools to manipulate structured and unstructured grids.\r\n\r\n## Installation\r\n\r\nThe recommended way to install **pyvista-gridder** and all its dependencies is through the Python Package Index:\r\n\r\n```bash\r\npip install pyvista-gridder --user\r\n```\r\n\r\nOtherwise, clone and extract the package, then run from the package location:\r\n\r\n```bash\r\npip install .[full] --user\r\n```\r\n\r\nTo test the integrity of the installed package, check out this repository and run:\r\n\r\n```bash\r\npytest\r\n```\r\n\r\n## Examples\r\n\r\n### 2D structured grid\r\n\r\n```python\r\nimport numpy as np\r\nimport pyvista as pv\r\nimport pvgridder as pvg\r\n\r\nmesh = (\r\n   pvg.MeshStack2D(pv.Line([-3.14, 0.0, 0.0], [3.14, 0.0, 0.0], resolution=41))\r\n   .add(0.0)\r\n   .add(lambda x, y, z: np.cos(x) + 1.0, 4, group=\"Layer 1\")\r\n   .add(0.5, 2, group=\"Layer 2\")\r\n   .add(0.5, 2, group=\"Layer 3\")\r\n   .add(0.5, 2, group=\"Layer 4\")\r\n   .add(lambda x, y, z: np.full_like(x, 3.4), 4, group=\"Layer 5\")\r\n   .generate_mesh()\r\n)\r\nmesh.plot(show_edges=True, scalars=pvg.get_cell_group(mesh))\r\n```\r\n\r\n![anticline](https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/anticline.png?raw=true)\r\n\r\n### 2D Voronoi mesh\r\n\r\n```python\r\nimport numpy as np\r\nimport pyvista as pv\r\nimport pvgridder as pvg\r\n\r\nsmile_radius = 0.64\r\nsmile_points = [\r\n   (smile_radius * np.cos(theta), smile_radius * np.sin(theta), 0.0)\r\n   for theta in np.deg2rad(np.linspace(200.0, 340.0, 32))\r\n]\r\nmesh = (\r\n   pvg.VoronoiMesh2D(pvg.Annulus(0.0, 1.0, 16, 32), default_group=\"Face\")\r\n   .add_circle(0.16, plain=False, resolution=16, center=(-0.32, 0.32, 0.0), group=\"Eye\")\r\n   .add_circle(0.16, plain=True, resolution=16, center=(0.32, 0.32, 0.0), group=\"Eye\")\r\n   .add_polyline(smile_points, width=0.05, group=\"Mouth\")\r\n   .generate_mesh()\r\n)\r\nmesh.plot(show_edges=True, scalars=pvg.get_cell_group(mesh))\r\n```\r\n\r\n![nightmare-fuel](https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/nightmare_fuel.png?raw=true)\r\n\r\n### 2.5D geological model\r\n\r\n```python\r\nimport pyvista as pv\r\nimport pvgridder as pvg\r\n\r\nterrain = pv.examples.download_crater_topo().extract_subset(\r\n   (500, 900, 400, 800, 0, 0), (10, 10, 1)\r\n)\r\nterrain_delaunay = pvg.Polygon(terrain, celltype=\"triangle\")\r\nterrain = terrain.cast_to_structured_grid().warp_by_scalar(\"scalar1of1\")\r\n\r\nmesh = (\r\n   pvg.MeshStack3D(\r\n      pvg.VoronoiMesh2D(terrain_delaunay, preference=\"point\").generate_mesh()\r\n   )\r\n   .add(0.0)\r\n   .add(terrain.translate((0.0, 0.0, -1000.0)), 5, method=\"log_r\", group=\"Bottom layer\")\r\n   .add(500.0, 5, group=\"Middle layer\")\r\n   .add(terrain, 5, method=\"log\", group=\"Top Layer\")\r\n   .generate_mesh()\r\n)\r\nmesh.plot(show_edges=True, scalars=pvg.get_cell_group(mesh))\r\n```\r\n\r\n![topographic-terrain](https://github.com/INTERA-Inc/pyvista-gridder/blob/main/.github/topographic_terrain.png?raw=true)\r\n\r\n## Acknowledgements\r\n\r\nThis project is supported by Nagra (National Cooperative for the Disposal of Radioactive Waste), Switzerland.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Mesh generation using PyVista",
    "version": "0.4.1",
    "project_urls": {
        "Code": "https://github.com/INTERA-Inc/pyvista-gridder",
        "Homepage": "https://github.com/INTERA-Inc/pyvista-gridder",
        "Issues": "https://github.com/INTERA-Inc/pyvista-gridder/issues"
    },
    "split_keywords": [
        "mesh generation",
        " numerical modeling",
        " pyvista"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dce4b69504a387c98cc5ff54d1d317d3ac11d3fe05efa39aba0cf04a18729c9d",
                "md5": "c48d970b564d9ba6bd2f6f344c1a9331",
                "sha256": "f3b5fd16cbd2a570548e25a3d8ef3d3546ee6f91ba74599639a0ffce06e837dd"
            },
            "downloads": -1,
            "filename": "pyvista_gridder-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c48d970b564d9ba6bd2f6f344c1a9331",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 47178,
            "upload_time": "2025-08-15T07:08:35",
            "upload_time_iso_8601": "2025-08-15T07:08:35.125431Z",
            "url": "https://files.pythonhosted.org/packages/dc/e4/b69504a387c98cc5ff54d1d317d3ac11d3fe05efa39aba0cf04a18729c9d/pyvista_gridder-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3d6621c509d7813194986d8d855000b57a3bf50080d011c5a5e4039e02162138",
                "md5": "35567cc9c841c610e69d0c7d09c21f69",
                "sha256": "53b44d94f0404c68eaf27aaa26285d17cc9d1cbd2c5012eeb18b12e2424bda17"
            },
            "downloads": -1,
            "filename": "pyvista_gridder-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "35567cc9c841c610e69d0c7d09c21f69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 52147,
            "upload_time": "2025-08-15T07:08:36",
            "upload_time_iso_8601": "2025-08-15T07:08:36.192698Z",
            "url": "https://files.pythonhosted.org/packages/3d/66/21c509d7813194986d8d855000b57a3bf50080d011c5a5e4039e02162138/pyvista_gridder-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 07:08:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "INTERA-Inc",
    "github_project": "pyvista-gridder",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pyvista-gridder"
}
        
Elapsed time: 1.65639s