Skip to content

tetrahedron_edge_map

tetrahedron_edge_map(T)

Computes unique edges of a tetrahedral mesh and a map from each tetrahedron local edges to the unique edge list

Edge ordering convention is: [(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)]

Input

T : (m,4) numpy int array m = number of tetrahedra 4 vertices

Returns:

Name Type Description
E (e,2) numpy int array

Unique unoriented edges of the tetrahedral mesh

T_to_E (m,6) numpy int array

For each tetrahedron, index into E corresponding to its six local edges

Source code in src/gpytoolbox/tetrahedron_edge_map.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def tetrahedron_edge_map(T):
    """Computes unique edges of a tetrahedral mesh and a map from each tetrahedron local edges to the unique edge list

    Edge ordering convention is: [(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)]

    Input
    ----------
    T : (m,4) numpy int array
        m = number of tetrahedra
        4 vertices

    Returns
    -------
    E : (e,2) numpy int array
        Unique unoriented edges of the tetrahedral mesh

    T_to_E : (m,6) numpy int array
        For each tetrahedron, index into E corresponding to its six local edges
    """

    assert T.shape[0] > 0
    assert T.shape[1] == 4

    local_edges = np.array([
        [0, 1],
        [0, 2],
        [0, 3],
        [1, 2],
        [1, 3],
        [2, 3],
    ])

    all_edges = T[:, local_edges].reshape(-1, 2)
    all_edges = np.sort(all_edges, axis=1)

    E, inverse = np.unique(
        all_edges,
        axis=0,
        return_inverse=True
    )

    T_to_E = inverse.reshape(T.shape[0], 6)

    return E, T_to_E