pysdic.Connectivity.concatenate#

Connectivity.concatenate(other, inplace=False)[source]#

Concatenate the current connectivity with another Connectivity instance.

This method combines the elements from both connectivities into a new Connectivity object.

Note

The properties in common between the two connectivities are also concatenated. If a property exists in only one of the connectivities, it will be filled with numpy.nan values for the points from the other connectivity.

Parameters:
Returns:

A new Connectivity object containing the concatenated elements from both connectivities or the modified current instance if inplace is True

Return type:

Connectivity

Raises:

ValueError – If the input is not an instance of Connectivity. If the two connectivities have different dimensions.

Examples

Creating two Connectivity objects.

1import numpy as np
2from pysdic import Connectivity
3
4# Create two random NumPy arrays of shape (100, 3)
5random_elements1 = np.random.randint(0, 100, size=(100, 4))  # shape (100, 4)
6random_elements2 = np.random.randint(0, 100, size=(50, 4))   # shape (50, 4)
7
8connectivity1 = Connectivity.from_array(random_elements1)
9connectivity2 = Connectivity.from_array(random_elements2)

Concatenate the two connectivities using the concatenate() method.

1# Concatenate the two connectivities
2concatenated_connectivity = connectivity1.concatenate(connectivity2)
3
4print(concatenated_connectivity.elements)
5# Output: A NumPy array of shape (150, 4) containing the concatenated elements