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_elementsmethod 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
keep_connectivity()to keep only specified elements in the mesh.filter_connectivity()to filter the connectivity of the mesh using a boolean mask.Connectivityfor more information on the connectivity structure and element types.
- 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) – IfTrue, the connectivity will be updated in place, modifying the original connectivity object. IfFalse, a new connectivity object will be created to store the updated connectivity, leaving the original connectivity object unchanged. By defaultFalse.
- Raises:
TypeError – If
element_indicesis not an array-like object or is not an integer array. Ifforce_inplaceis not a boolean.ValueError – If
element_indicesdoes not have the correct shape or contains invalid indices.
- Return type:
None
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]]) 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]]