pysdic.fem.assemble_elements_adjacency_graph#
- assemble_elements_adjacency_graph(connectivity_array)[source]#
Assemble the elements adjacency graph of a mesh, where two elements are neighbors if they share at least one vertex.
The function is independent of the geometry of the elements: two elements sharing only a corner vertex are neighbors.
Note
Input
connectivity_arraywill be converted tonumpy.int64.
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_array (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 vertices that form an element.
- Returns:
graph – A symmetric boolean sparse matrix of shape \((N_{e}, N_{e})\) with an empty diagonal, where
graph[i, j]is True if elements \(i\) and \(j\) are neighbors. The neighbors of element \(i\) aregraph[i].indices.- Return type:
Notes
Let \(B \in \{0, 1\}^{N_{e} \times N_{v}}\) be the incidence matrix of the mesh (\(B_{e,v} = 1\) if vertex \(v\) belongs to element \(e\)). The elements \(i \neq j\) are neighbors if \((B B^{T})_{i,j} > 0\).
See also
pysdic.fem.assemble_vertices_adjacency_graphVertices adjacency graph of a mesh.
Examples
Create a simple
'quadrangle_4'mesh with 10 vertices and 4 elements and assemble the elements adjacency graph.
'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 2from pysdic.fem import assemble_elements_adjacency_graph 3 4connectivity_array = numpy.array([ 5 [0, 1, 4, 5], 6 [1, 2, 5, 6], 7 [2, 3, 6, 7], 8 [6, 7, 8, 9]]) 9 10graph = assemble_elements_adjacency_graph(connectivity_array) 11 12print(f"elements adjacency graph (shape={graph.shape})") 13print(f"neighbors of element 3: {graph[3].indices}")
elements adjacency graph (shape=(4, 4)) neighbors of element 3: [1 2]