graphlow.from_pyvista#

graphlow.from_pyvista(grid: DataSet, backend: Literal['torch'], dtype: dtype = torch.float32, *, dimension_collection: dict[str, dict[str, float]] | None = None, device: device | str | None = None, validate_mesh: bool = False) TensorMesh[Tensor]#
graphlow.from_pyvista(grid: DataSet, backend: Literal['phlower'], dtype: dtype = torch.float32, *, dimension_collection: dict[str, dict[str, float]] | None = None, device: device | str | None = None, validate_mesh: bool = False, disable_dimensions: bool = False) TensorMesh[pt.PhlowerTensor]

Build a TensorMesh from a PyVista mesh.

Parameters:
gridpyvista.DataSet

Input mesh. Will be converted to an UnstructuredGrid.

backend{“torch”, “phlower”}, default=”torch”

Backend used for tensors in the returned mesh.

dtypetorch.dtype, default=torch.float32

Floating-point dtype used by the backend tensors.

dimension_collectiondict[str, dict[str, float]] or None, optional

Optional per-array dimension metadata (for phlower_tensor). Keys correspond to grid.point_data / grid.cell_data names.

devicetorch.device or str or None, optional

Target device. Interpretation depends on the backend.

validate_mesh: bool, default=False

If True, validate the mesh using PyVista’s validate_mesh method.

disable_dimensions: bool, default=False

If True, ignore all dimensions and treat all data as dimensionless.

Returns:
TensorMesh[torch.Tensor] or TensorMesh[pt.PhlowerTensor]

Mesh with backend tensors for points and data arrays, and connectivity stored in pvmesh.

Notes

The returned mesh eagerly attaches MeshTopology and MeshGeometry instances.

Examples

>>> mesh = from_pyvista(grid, backend="torch")