mesh.Mesh.adjacency#

Mesh.adjacency(level=0, diflevel=-1, kind='e')#

Create an element adjacency table.

This creates an element adjacency table (kind=’e’) or a node adjacency table (kind=’n’). Two elements are said to be adjacent if they share a lower entity of the specified level. Two nodes are said to be adjacent if they share a higher entity of the specified level.

Parameters#

level: int

Hierarchic level of the geometric items connecting two elements: 0 = node, 1 = edge, 2 = face. Only values of a lower hierarchy than the level of the Mesh itself make sense. Default is to consider nodes as the connection between elements.

diflevel: int, optional

Only used with kind=’e’. If >= level, and smaller than the level of the Mesh itself, elements that have a connection of this level are removed. Thus, in a Mesh with volume elements, self.adjacency(0,1) gives the adjacency of elements by a node but not by an edge.

kind: ‘e’ or ‘n’

Select element (‘e’) or node (n’) adjacency table. Default is element adjacency.

Returns#

adj: Adjacency

An Adjacency table specifying for each element or node its neighbours connected by the specified geometrical subitems.

Examples#

>>> M = Mesh(eltype='quad4').subdivide(2)
>>> print(M.report(full=True))
Mesh: n_nodes: 9, n_elems: 4, plexitude: 4, level: 2, eltype: quad4
  BBox: [0. 0. 0.], [1. 1. 0.]
  Size: [1. 1. 0.]
  Length: 4.0  Area: 1.0
  Coords: [[0.  0.  0. ]
           [0.5 0.  0. ]
           [1.  0.  0. ]
           [0.  0.5 0. ]
           [0.5 0.5 0. ]
           [1.  0.5 0. ]
           [0.  1.  0. ]
           [0.5 1.  0. ]
           [1.  1.  0. ]]
  Elems: [[0 1 4 3]
          [1 2 5 4]
          [3 4 7 6]
          [4 5 8 7]]
>>> print(M.adjacency(level=0, kind='e'))
[[1 2 3]
 [0 2 3]
 [0 1 3]
 [0 1 2]]
>>> print(M.adjacency(level=0, diflevel=1, kind='e'))
[[3]
 [2]
 [1]
 [0]]
>>> print(M.adjacency(level=1, kind='e'))
[[1 2]
 [0 3]
 [0 3]
 [1 2]]
>>> print(M.adjacency(level=1, kind='n'))
[[-1 -1  1  3]
 [-1  0  2  4]
 [-1 -1  1  5]
 [-1  0  4  6]
 [ 1  3  5  7]
 [-1  2  4  8]
 [-1 -1  3  7]
 [-1  4  6  8]
 [-1 -1  5  7]]