pysdic.Connectivity.to_array#
- Connectivity.to_array()[source]#
Convert the connectivity to a NumPy array of shape \((N_e, N_vpe)\).
Note
The returned array is a copy of the internal elements array. Modifying it will not affect the original connectivity.
See also
elements()property for accessing and modifying the elements of the connectivity.from_array()class method for creating a Connectivity object from a NumPy array.
- Returns:
A NumPy array of shape \((N_e, N_vpe)\) containing the elements of the connectivity.
- Return type:
Examples
Creating a
Connectivityobject 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, 4)) # shape (100, 4) 6connectivity = Connectivity.from_array(random_elements)
Convert back to a NumPy array using the to_array method.
1# Convert the connectivity back to a NumPy array 2elements_array = connectivity.to_array() 3print(elements_array) 4# Output: A NumPy array of shape (100, 4) containing the elements of the connectivity.