pysdic.Mesh.to_meshio#
- Mesh.to_meshio(save_properties=True)[source]#
Convert the
Meshinstance to ameshio.Meshobject (element_typemust 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
Mesh.from_meshio()for the reverse operation.meshio documentation for more information.
- Parameters:
save_properties (
bool, optional) – IfTrue, properties are saved to themeshio.Meshobject, by defaultTrue.- Returns:
A meshio Mesh object created from the Mesh instance.
- Return type:
meshio.Mesh- Raises:
TypeError – If save_properties is not a boolean.
ValueError – If the mesh is empty.
Examples
Create a simple
Meshinstance.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
Meshinstance to ameshio.Meshobject.1mesh = mesh3d.to_meshio() 2print(mesh.points) 3# Output: [[0. 0. 0.] [1. 0. 0.] [0. 1. 0.] [0. 0. 1.]]