pysdic.Mesh.remove_connectivity#

Mesh.remove_connectivity(element_indices, force_inplace=False)[source]#

Remove specified elements from the mesh by specifying their indices in the connectivity array.

This method is an extension of the connectivity.remove_elements method that allows removing specified elements from the mesh while ensuring that the connectivity structure is maintained and validated. This method will ensure that the specified element indices are compatible with the existing mesh structure and will update the mesh’s connectivity accordingly.

Note

The new connectivity will be stored in a new connectivity object (Copy of the original connectivity object with only the remaining elements). The properties of the remaining elements will be updated to keep only the properties of the remaining elements and stored in the new connectivity object.

See also

Parameters:
  • element_indices (ArrayLike) – An array of shape \((R,)\) containing the indices of the elements to remove from the mesh, where \(R\) is the number of elements to remove.

  • force_inplace (bool, optional) – If True, the connectivity will be updated in place, modifying the original connectivity object. If False, a new connectivity object will be created to store the updated connectivity, leaving the original connectivity object unchanged. By default False.

Raises:
  • TypeError – If element_indices is not an array-like object or is not an integer array. If force_inplace is not a boolean.

  • ValueError – If element_indices does not have the correct shape or contains invalid indices.

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

Remove the first and third elements from the mesh.

1element_indices = np.array([0, 2])
2mesh3d.remove_connectivity(element_indices)
3
4print(mesh3d.connectivity)
5# Output: Connectivity with 2 elements [[0, 1, 3], [1, 2, 3]]