I/O#
Conversion between PhysicsNeMo Mesh objects and
PyVista meshes. Because PyVista supports a wide range of
file formats (VTK, STL, PLY, OBJ, and many others), this module serves as the
primary I/O gateway for PhysicsNeMo-Mesh.
from_pyvista()Convert a
pyvista.PolyDataorpyvista.UnstructuredGridto aMesh. Point data and cell data arrays are carried over.to_pyvista()Convert a
Meshto apyvista.PolyData(for surface meshes) orpyvista.UnstructuredGrid(for volume meshes).
import pyvista as pv
from physicsnemo.mesh.io import from_pyvista, to_pyvista
# Load any format PyVista supports
pv_mesh = pv.read("geometry.stl")
mesh = from_pyvista(pv_mesh)
# Work with the mesh in PhysicsNeMo...
mesh = mesh.subdivide(levels=1, filter="loop")
# Export back to PyVista for saving or visualization
pv_out = to_pyvista(mesh)
pv_out.save("refined.vtk")
API Reference#
I/O utilities for PhysicsNeMo Mesh.
This module provides functions to convert between PhysicsNeMo Mesh and other mesh formats, particularly PyVista.
Submodules that depend on optional packages are loaded lazily via the
module-level __getattr__ (PEP 562) so that import physicsnemo.mesh.io
succeeds without those packages installed; the import only fails when the
attribute is actually accessed.