pysdic.Connectivity.remove_elements#

Connectivity.remove_elements(indices, inplace=False)[source]#

Remove elements from the connectivity based on their indices.

This method returns a new Connectivity object with the elements at the specified indices removed. The properties associated with the elements are also updated accordingly.

See also

Parameters:
  • indices (ArrayLike) – A 1D NumPy array of integer indices representing the elements to be removed from the connectivity.

  • inplace (bool, optional) – If True, modifies the current connectivity in place and returns itself. If False, returns a new Connectivity instance (default is False).

Returns:

A new Connectivity object with the elements at the specified indices removed or the modified current instance if inplace is True.

Return type:

Connectivity

Raises:

ValueError – If any index is out of bounds or if the input is not a 1D array of integers.

Examples

Create a Connectivity from a random NumPy array.

1import numpy as np
2from pysdic import Connectivity
3
4# Create a random connectivity with 100 elements
5random_elements = np.random.randint(0, 100, size=(100, 3))  # shape (100, 3)
6connectivity = Connectivity.from_array(random_elements)

Removing elements at indices 1 and 3.

1# Remove elements at indices 1 and 3
2indices_to_remove = np.array([1, 3])
3new_connectivity = connectivity.remove_elements(indices_to_remove)
4print(new_connectivity.elements)
5# Output: A NumPy array of shape (98, 3) with elements at indices 1 and 3 removed