pysdic.Mesh.from_meshio#
- classmethod Mesh.from_meshio(mesh, *, element_type=None, load_properties=True)[source]#
Create a mesh from a
meshio.Meshwith a single cell block.The following fields are read:
mesh.points→ vertices,mesh.cells[0].data→ connectivity,mesh.point_data→ vertex properties,mesh.cell_data→ element properties.
See also
to_meshio()for the reverse operation.
- Parameters:
mesh (
meshio.Mesh) – The mesh to read. It must contain exactly one cell block.element_type (Optional[str], optional) – The type of the elements. By default, it is inferred from the meshio 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:
- Raises:
TypeError – If
meshis not ameshio.Mesh.ValueError – If the mesh does not contain exactly one cell block, or if
element_typedoes not match the cells.
Examples
1import numpy 2import meshio 3from pysdic import Mesh 4 5points = numpy.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]) 6cells = [("triangle", numpy.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]))] 7 8mesh = Mesh.from_meshio(meshio.Mesh(points=points, cells=cells)) 9print(mesh.element_type) # triangle_3