Connectivity structures#
Connectivity class#
- class Connectivity(elements, properties=None, element_type=None)[source]#
A class representing the connectivity information of a mesh.
Connectivity can store any scalar/vector properties associated with each element in the mesh.
If
element_typeis provided, the mesh will enforce that all elements are of the specified type. This allow to use the predefined shape functions and properties associated with that element type. The implemented types are:Element Type
Description
“segment_2”
2-node line element
“segment_3”
3-node line element
“triangle_3”
3-node triangular element
“triangle_6”
6-node triangular element
“quadrangle_4”
4-node quadrilateral element
“quadrangle_8”
8-node quadrilateral element
Note
The number of vertices per element of the connectivity is not designed to change after connectivity creation.
Note
The connections and the properties of the elements are stored as copy-on-write (cow) NumPy arrays of type
numpy.int64(connectivity) andnumpy.float64(properties). Accesing these arrays directly will return unwritable views to prevent accidental modifications.- Parameters:
elements (ArrayLike) – A NumPy array of shape \((N_{e}, N_{vpe})\) representing the connectivity of the mesh, where \(N_{e}\) is the number of elements and \(N_{vpe}\) is the number of vertices per element.
properties (Optional[Dict[
str, ArrayLike]], optional) – A dictionary of additional properties to associate with the connectivity. Keys are property names, and values are NumPy arrays of property data of shape \((N_{e}, A)\) where \(A\) is the number of attributes per element for the given property. Default isNone, meaning no additional properties are set.element_type (Optional[
str], optional) – The expected type of elements in the connectivity. If provided, the connectivity will enforce that all elements are of the specified type. Default isNone.
- Raises:
TypeError – If the input elements is not a NumPy array. If the given dimension is not an integer. If the properties is not a dictionary of string keys and NumPy array values. If the element type is not a string.
ValueError – If the input array does not have the correct shape. If the given dimension is not a strictly positive integer. If the properties arrays do not have the correct shape. If the element type is not one of the implemented types.
Instantiate and export Connectivity object#
To Instantiate a Connectivity object, use one of the following class methods:
|
Create a |
|
Create a |
The Connectivity can then be exported to different formats using the following methods:
Convert the connectivity to a NumPy array of shape \((N_e, N_vpe)\). |
|
|
Save the connectivity to a NumPy NPZ file. |
Accessing Connectivity attributes#
The public attributes of a Connectivity object can be accessed using the following properties:
[Get or Set] An numpy array of shape \((N_e, N_{vpe})\) representing the connectivity of the mesh. |
|
[Get or Set] The expected type of elements in the connectivity. |
|
[Get] The number of elements \(N_e\) in the mesh. |
|
[Get] The topological dimension \(K\) of the elements in the connectivity, if |
|
[Get] The number of vertices per element \(N_{vpe}\) in the mesh. |
|
[Get] The shape of the elements array (\(N_e\), \(N_{vpe}\)). |
Add and manage Connectivity elements properties#
The properties of the elements in a Connectivity object can be managed using the following methods:
Note
Elements properties are stored as named NumPy arrays of shape \((N_e, A)\) where \(N_e\) is the number of elements and \(A\) is the number of property components (e.g., 3 for RGB color).
All the element properties must have the same number of elements as the Connectivity object and are stored as numpy.float64 arrays.
|
Set a property for the connectivity as a NumPy array of shape \((N_e, A)\) where \(A\) is the number of attributes per element for the given property. |
Get a property of the connectivity by its key/name. |
|
Check if the connectivity has a property with the given key/name. |
|
Delete a property of the connectivity by its key/name. |
|
List all property keys/names associated with the connectivity. |
|
Create a copy of all properties of the connectivity. |
|
Remove all properties from the connectivity. |
Add, remove or modify points in Connectivity objects#
The elements of a Connectivity object can be manipulated using the following methods:
|
Concatenate the current connectivity with another |
|
Create a copy of the current |
|
Filter elements in the connectivity based on a boolean mask. |
|
Keep only the elements at the specified indices in the connectivity. |
|
Remove elements from the connectivity based on their indices. |