graphlow.TensorMesh#

class graphlow.TensorMesh(points: T, pvmesh: pv.UnstructuredGrid, backend: Backend[T], bcache: BackendCache[T], point_data: dict[str, T] = <factory>, cell_data: dict[str, T] = <factory>, _parent_point_map: ParentPointMap | None = None)#

Differentiable mesh container backed by a PyVista grid.

This class separates the mesh into:

  • Differentiable parts (geometry): points and point_data / cell_data as backend tensors.

  • Non-differentiable parts (topology): pvmesh and cached topology structures derived from it.

Notes

  • Topology is assumed to be fixed (connectivity does not change). Updating points does not invalidate topology caches.

  • pvmesh is used as the source of truth for connectivity.

Attributes

n_cells

Number of cells.

n_points

Number of points.

parent_point_ids

Return the parent point index for each point of this derived mesh.

parent_point_map

Advanced API: Return the parent point map instance for this derived mesh.

points

(n_points, 3) backend tensor; only differentiable part.

pvmesh

PyVista UnstructuredGrid.

backend

Torch or phlower_tensor wrapper.

bcache

Backend-dependent sparse/compiled cache.

point_data

(n_points, ...) backend tensor; data associated with points.

cell_data

(n_cells, ...) backend tensor; data associated with cells.

topology

Topology layer (cached).

geometry

Geometry layer (cached).

Methods

copy_features_from_pyvista([overwrite, ...])

Copy point and cell tensor data from pyvista mesh.

copy_features_to_pyvista([overwrite])

Copy point and cell tensor data to pyvista mesh.

extract_surface(*[, keep_graph])

Extract the boundary surface as a new 2D mesh.

gather_parent_point_data(src_point_data)

Gather parent point data onto this derived mesh.

requires_grad([requires_grad, point_data, ...])

Set requires_grad flags for backend tensors.

save(file_name, *[, binary, remove_time, ...])

Save mesh data.

scatter_add_to_parent_point_data(src_point_data)

Scatter this mesh's point data to the parent point space and add to it.

to([device, non_blocking, dtype])

Move the mesh data to a different device and/or dtype.