pysdic.Mesh.to_vtk#

Mesh.to_vtk(filename, save_properties=True)[source]#

Write the Mesh instance to a VTK file (Only for 3D embedding dimension meshes \(E=3\)).

The mesh must not be empty.

This method uses meshio to write the Mesh instance to a VTK file.

See also

Parameters:
  • filename (str) – The path to the output VTK file.

  • save_properties (bool, optional) – If True, properties are saved to the VTK file, by default True.

Raises:

ValueError – If the file format is not supported or the mesh is empty.

Return type:

None

Examples

Create a simple Mesh instance.

1import numpy as np
2from pysdic import Mesh, PointCloud
3
4points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
5connectivity = np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]])
6mesh3d = Mesh(PointCloud.from_array(points), connectivity)

Save the Mesh instance to a VTK file.

1mesh3d.to_vtk("simple_mesh.vtk")
2# This will create a file named 'simple_mesh.vtk' in the current directory.