pysdic.Mesh.from_npz#
- classmethod Mesh.from_npz(filename, element_type=None, load_properties=True)[source]#
Create a Mesh instance from a NPZ file.
This method uses numpy to read the NPZ file and then converts it to a
Meshinstance.See also
Mesh.to_npz()for the reverse operation.numpy documentation for more information.
Meshfor more information on the Mesh class and element types.
- Parameters:
- Returns:
A
Meshinstance created from the NPZ file.- Return type:
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the file format is not supported or the mesh structure is invalid.
Examples
Create a simple
meshio.Meshobject.1import numpy as np 2from pysdic import Mesh 3 4points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]) 5cells = np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]) 6mesh = Mesh(vertices=points, connectivity=cells, element_type="triangle_3") 7mesh.save_npz("simple_mesh.npz")
Create a
Meshinstance from the NPZ file.1mesh3d = Mesh.from_npz("simple_mesh.npz") 2print(mesh3d.vertices) 3# Output: PointCloud with 4 points [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]