pysdic.Mesh.to_meshio#

Mesh.to_meshio(save_properties=True)[source]#

Convert the Mesh instance to a meshio.Mesh object (element_type must be defined). The mesh must not be empty.

Warning

If the mesh does not have a defined element type, this method will raise a ValueError. See Mesh.element_type() to define the element type before conversion.

The following fields are created:

  • vertices → mesh.points

  • connectivity → mesh.cells[0].data

  • vertices properties as arrays of shape (N, A) → mesh.point_data

  • elements properties as arrays of shape (M, B) → mesh.cell_data

See also

Parameters:

save_properties (bool, optional) – If True, properties are saved to the meshio.Mesh object, by default True.

Returns:

A meshio Mesh object created from the Mesh instance.

Return type:

meshio.Mesh

Raises:

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]])
6
7mesh3d = Mesh(points, connectivity, element_type="triangle_3")

Convert the Mesh instance to a meshio.Mesh object.

1mesh = mesh3d.to_meshio()
2print(mesh.points)
3# Output: [[0. 0. 0.] [1. 0. 0.] [0. 1. 0.] [0. 0. 1.]]