vti#

Structured-grid (VTK ImageData / .vti) source for mesh pipelines.

VTK ImageData describes a uniform rectilinear grid that is fully determined by origin, spacing, and dimensions — there is no explicit point list or connectivity. Forcing such data through the unstructured physicsnemo.mesh.Mesh model would materialise redundant coordinates and discard the regular lattice that grid models (CNN/U-Net/FNO) rely on.

Instead, this source reads each .vti file into a tensordict.TensorDict of dense N-D field tensors:

  • point_data — a sub-TensorDict with batch_size = [Nz, Ny, Nx]; each scalar field has shape (Nz, Ny, Nx) and each vector field (Nz, Ny, Nx, C) (VTK x-fastest ordering).

  • cell_data — a sub-TensorDict with batch_size = [Cz, Cy, Cx] where Ci = max(dim_i - 1, 1).

  • grid — a non-batched sub-TensorDict carrying origin (3,), spacing (3,), dimensions (3,, point counts), and direction (3, 3).

The result is written as a tensordict memmap sidecar beside the mesh outputs via GridSidecarSink.

Classes#

VTISource

Read local VTK ImageData (.vti) files as structured-grid TensorDicts.

Functions#

imagedata_to_griddict(→ tensordict.TensorDict)

Convert a PyVista ImageData object to a structured-grid TensorDict.

Module Contents#

class physicsnemo_curator.domains.mesh.sources.vti.VTISource(
input_path: str,
file_pattern: str = '**/*',
*,
fp32: bool = False,
)#

Bases: physicsnemo_curator.core.base.Source[tensordict.TensorDict]

Read local VTK ImageData (.vti) files as structured-grid TensorDicts.

Each discovered .vti file is converted (via imagedata_to_griddict()) into a tensordict.TensorDict of dense N-D field tensors plus grid metadata, suitable for memmap storage as a sidecar alongside mesh outputs.

Parameters:
  • input_path (str) – Path to a local directory containing .vti files, or a single .vti file.

  • file_pattern (str) – Glob pattern for filtering files inside a directory. Defaults to "**/*" (recursive).

  • fp32 (bool) – If True, downcast float64 arrays to float32.

Examples

>>> source = VTISource("./grids/")
>>> grid = next(source[0])
>>> grid["point_data"].batch_size
torch.Size([64, 64, 64])
classmethod params() list[physicsnemo_curator.core.base.Param]#

Return parameter descriptors for the VTI source.

Returns:

The input_path, file_pattern, and fp32 parameters.

Return type:

list[Param]

relative_path(index: int) str#

Return the index-th file path relative to the root (POSIX style).

description: ClassVar[str] = 'Read VTK ImageData (.vti) as dense structured-grid TensorDicts'#
name: ClassVar[str] = 'VTI Reader'#
property root: pathlib.Path#

Return the root directory of this source.

physicsnemo_curator.domains.mesh.sources.vti.imagedata_to_griddict(
image: Any,
*,
fp32: bool = False,
) tensordict.TensorDict#

Convert a PyVista ImageData object to a structured-grid TensorDict.

Parameters:
  • image (pyvista.ImageData) – The loaded ImageData (uniform grid).

  • fp32 (bool) – If True, downcast float64 field/geometry arrays to float32.

Returns:

A scalar-batch TensorDict with grid metadata and (when present) point_data / cell_data sub-TensorDicts of dense field tensors.

Return type:

TensorDict