pysdic.create_elements_adjacency_graph#

create_elements_adjacency_graph(connectivity)[source]#

Create the elements adjacency graph from the connectivity of the mesh, where two elements are neighbors if they share at least one vertex in the mesh.

Note that the function is indepedent of the geometry of the element, thus two elements will be considered as neighbors if they share at least one vertex, regardless of the shape of the elements (e.g., triangle, quadrilateral, tetrahedron, hexahedron, …).

Note

  • The input connectivity must be integral-array like.

Warning

No tests are performed to check if the input connectivity is valid (e.g., if the connectivity contains invalid vertex indices, …). The behavior of the function is undefined in that case.

Parameters:

connectivity (ArrayLike) – An array of shape \((N_e, N_{vpe})\) defining the connectivity of the elements in the mesh, where each row contains the indices of the nodes that form an element.

Returns:

A list of sets representing the adjacency list of the graph, where each index corresponds to an element and each set at that index contains the neighboring element indices.

Return type:

List[Set[int]]

See also

create_vertices_adjacency_graph()

Create the vertices adjacency graph from the connectivity of the mesh.

Examples

Create a simple quadrangle 4 mesh with 10 vertices and 4 elements and compute the elements adjacency graph from the connectivity.

../_images/graph_mesh.png

Quadrangle 4 mesh. The neighboring elements of element 3 are elements 1 and 2 since they share at least one vertex in the mesh.#

 1import numpy as np
 2from pysdic import create_elements_adjacency_graph
 3
 4connectivity = np.array([
 5    [0, 1, 4, 5],
 6    [1, 2, 5, 6],
 7    [2, 3, 6, 7],
 8    [6, 7, 8, 9]], dtype=np.int64)
 9n_vertices = 10
10
11adjacency_graph = create_elements_adjacency_graph(connectivity=connectivity)
12
13print(f"elements adjacency graph with length: {len(adjacency_graph)}")
14subset_1 = adjacency_graph[3]
15print(f"elements adjacency graph (neighbors of element 3): {subset_1}")
elements adjacency graph with length: 4
elements adjacency graph (neighbors of element 3): {1, 2}