pysdic.Mesh.from_vtk#

classmethod Mesh.from_vtk(dataset, *, element_type=None, load_properties=True)[source]#

Create a mesh from a VTK dataset with a single cell type (vtkUnstructuredGrid, vtkPolyData, …, i.e. any vtkPointSet).

A dataset which is not a vtkUnstructuredGrid is first converted with vtkAppendFilter. The following fields are read:

  • the points → vertices (always 3D, \(E = 3\)),

  • the cells → connectivity,

  • the point data → vertex properties,

  • the cell data → element properties.

Note

Requires VTK 9 or later (new layout of vtkCellArray).

Parameters:
  • dataset (vtkPointSet) – The VTK dataset to read. All its cells must have the same type.

  • element_type (Optional[str], optional) – The type of the elements. By default, it is inferred from the VTK cell type when this type is implemented (otherwise the mesh has no element type).

  • load_properties (bool, optional (default: True)) – If False, the point and cell data are ignored.

Returns:

The new mesh.

Return type:

pysdic.Mesh

Raises:
  • TypeError – If dataset is not a vtkPointSet, or if a data array is not numeric (use load_properties=False to ignore the data).

  • ValueError – If the dataset has no points, if the cells do not have exactly one type, if a data array has no name, or if element_type does not match the cells.