mesh_vtk#

VTK export with original Nastran cells and recoverable tensor metadata.

Classes#

MeshVTKSink

Export volume meshes as VTU/legacy VTK or their boundary surface as VTP.

Functions#

read_vtk_data(→ dict[str, tensordict.TensorDict])

Restore exported tensor fields, nested paths, complex values, and empty shapes.

Module Contents#

class physicsnemo_curator.domains.mesh.sinks.mesh_vtk.MeshVTKSink(
output_dir: str,
file_format: str = 'vtu',
naming_template: str | None = None,
binary: bool = True,
use_original_geometry: bool = True,
)#

Bases: physicsnemo_curator.domains.mesh.sinks.mesh_vtu.MeshVTUSink

Export volume meshes as VTU/legacy VTK or their boundary surface as VTP.

Numeric point/cell arrays retain integer IDs and floating precision. Modal fields become named three-component vectors such as mode_shape_m0001. Nested global tensors (including constraint tables) become VTK field-data arrays. physicsnemo_schema records tensor paths, shapes, dtypes, and empty fields. Complex arrays use real/imaginary pairs. For Nastran sources, original higher-order cells and parent fields are exported by default. VTP carries a boundary subset of point/cell data; the complete global result/source archive remains in Field Data.

Parameters:
  • output_dir (str) – Destination directory.

  • file_format (str) – "vtu" (default), "vtk", or "vtp" (boundary surface).

  • naming_template (str | None) – Output stem template with index/seq and source-backed relpath/stem placeholders. Default "mesh_{index:04d}_{seq}".

  • binary (bool) – Write binary files by default; False writes ASCII. Legacy VTK ASCII rejects NaN/infinity; VTU/VTP ASCII rejects negative infinity.

  • use_original_geometry (bool) – Prefer retained Nastran cells (default True). False exports the native simplicial cells, including transformed cell fields. Original export rejects changed connectivity or cell fields.

Examples

>>> sink = MeshVTKSink(output_dir="./output", file_format="vtu")
>>> paths = sink(mesh_iterator, index=0)

Initialize the VTK sink and validate output naming.

classmethod params() → list[physicsnemo_curator.core.base.Param]#

Declare format, naming, and binary-output parameters.

description: ClassVar[str] = 'Export VTU/VTK volumes or VTP surfaces with modes and metadata'#

Short description shown in the interactive CLI.

property file_format: str#

Return the VTK output format.

name: ClassVar[str] = 'Mesh VTK Writer'#

Human-readable display name for the interactive CLI.

property use_original_geometry: bool#

Return whether retained Nastran cells are preferred.

physicsnemo_curator.domains.mesh.sinks.mesh_vtk.read_vtk_data(path: str) → dict[str, tensordict.TensorDict]#

Restore exported tensor fields, nested paths, complex values, and empty shapes.

This returns point/cell/global TensorDicts rather than constructing a simplicial Mesh: Nastran VTU/VTK preserves original higher-order cells.

Parameters:

path (str) – File produced by MeshVTKSink.

Returns:

Tensor fields keyed by point_data, cell_data, and global_data.

Return type:

dict[str, TensorDict]

Raises:

ValueError – If the file lacks a supported PhysicsNeMo tensor schema.