
PyVista Gridder
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:
pip install pyvista-gridder
Otherwise, clone and extract the package, then run from the package location:
pip install .[full]
To test the integrity of the installed package, check out this repository and run:
pytest
Examples
2D structured grid
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))
2D Voronoi mesh
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))
2.5D geological model
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))
Acknowledgements
This project is supported by Nagra (National Cooperative for the Disposal of Radioactive Waste), Switzerland.
Metadata
Release files for pyvista-gridder 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyvista_gridder-0.6.0.tar.gz | 57.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyvista_gridder-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 110.6 kB
Release files / pyvista_gridder-0.6.0.tar.gz
| Download URL | pyvista_gridder-0.6.0.tar.gz |
|---|---|
| Size | 57.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5adba8954b255c3bfd2b204c215528e85266b8c2edad182571fabba30326eb6a
|
|
BLAKE2b-256 checksum How to use checksums |
3025cf9d414664502489cf95fc85f2222df31aeaa09d3ea65a5215c639694480
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / pyvista_gridder-0.6.0-py3-none-any.whl
| Download URL | pyvista_gridder-0.6.0-py3-none-any.whl |
|---|---|
| Size | 52.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54dc54d0a7b4180d758a5417f62ecdb58e621dc2abc99e82f95f7307b5143f0f
|
|
BLAKE2b-256 checksum How to use checksums |
47a4b4135b85a9c6aee05902cd95f8fda88b27e8ba0a8320c48927b9b336fc58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|