vtk#
VTK file source for mesh pipelines.
Reads VTK-format files (.vtk, .vtp, .vtu, .vts, .vtm)
from a local directory and converts each to a
physicsnemo.mesh.Mesh using physicsnemo.mesh.io.from_pyvista().
File discovery uses pathlib.Path.glob() with an optional pattern,
filtering to recognised VTK extensions.
The conversion supports multiple manifold dimensions (point clouds, lines,
surfaces, volumes) and two point-source modes (vertices or cell centroids).
See physicsnemo.mesh.io.from_pyvista() for full details.
Attributes#
Classes#
Read local VTK files and yield |
Module Contents#
- class physicsnemo_curator.domains.mesh.sources.vtk.VTKSource(
- input_path: str,
- file_pattern: str = '**/*',
- *,
- manifold_dim: int | Literal['auto'] = 'auto',
- point_source: Literal['vertices', 'cell_centroids'] = 'vertices',
- warn_on_lost_data: bool = True,
- backend: Backend = 'pyvista',
Bases:
physicsnemo_curator.core.base.Source[physicsnemo.mesh.Mesh]Read local VTK files and yield
Meshobjects.File discovery uses
pathlib.Path.glob()with an optional file_pattern, filtering to recognised VTK extensions. Only local paths are supported; for remote datasets use a domain-specific source such asDrivAerMLSource.- Parameters:
input_path (str) – Path to a local directory containing VTK files, or a single VTK file.
file_pattern (str) – Glob pattern for filtering files inside a directory. Defaults to
"**/*"which recursively discovers all VTK files. Use"*"for flat (non-recursive) discovery, or a custom pattern such as"timestep_*"for selective matching.manifold_dim (int or {"auto"}) –
Target manifold dimension passed to
from_pyvista:"auto"(default): detect from cell types.0: point cloud (vertices only, no cells).1: line mesh (edge cells).2: surface mesh (triangulated).3: volume mesh (tetrahedralized).
point_source ({"vertices", "cell_centroids"}) –
Controls what becomes the Mesh points:
"vertices"(default): mesh vertices become points,point_datais preserved."cell_centroids": cell centroids become points,cell_datais mapped topoint_data. Onlymanifold_dim0 and 1 are valid in this mode.
warn_on_lost_data (bool) – If True (default), emit a warning when the conversion discards non-empty data arrays (e.g. cell data lost during dimension reduction).
backend ({"pyvista", "rust"}) –
VTK reading backend:
"pyvista"(default): use PyVista for full-featured reading."rust": use the native Rust backend for faster reading. Note: The Rust backend only supports ASCII VTU/VTP files and does not supportmanifold_dimorpoint_sourceoptions.
Examples
Local directory:
>>> source = VTKSource("./cfd_results/") >>> len(source) 42 >>> mesh = next(source[0])
Custom glob pattern:
>>> source = VTKSource("./data/", file_pattern="timestep_*")
Using the fast Rust backend:
>>> source = VTKSource("./cfd_results/", backend="rust")
Note
VTK format: VTK File Formats
PyVista: PyVista documentation
- classmethod params() list[physicsnemo_curator.core.base.Param]#
Return parameter descriptors for the VTK source.
- relative_path(index: int) str#
Return the path of the index-th file relative to the root.
This is used by sinks (e.g.
MeshSink) to resolve{relpath}and{stem}naming placeholders.
- description: ClassVar[str] = 'Read VTK files (.vtk, .vtp, .vtu, .vts, .vtm) and convert to physicsnemo Mesh'#
- property root: pathlib.Path#
Return the root directory of this source.
- Returns:
The root directory containing the discovered VTK files.
- Return type:
- physicsnemo_curator.domains.mesh.sources.vtk.Backend#