Skip to content

dec_d0

dec_d0(F, E=None, n=None)

Builds the DEC d0 operator as described, for example, in Crane et al. 2013. "Digital Geometry Processing with Discrete Exterior Calculus".

The edge labeling in E follows the convention from Gpytoolbox's halfedge_edge_map.

The input mesh must be a manifold mesh.

Parameters:

Name Type Description Default
F (m,3) numpy int array

face index list of a triangle mesh

required
E (e,2) numpy int array, optional (default None)

edge index list of a triangle mesh. If absent, will be computed using halfedge_edge_map

None
n int, optional (default None)

number of vertices in the mesh. If absent, will try to infer from F.

None

Returns:

Name Type Description
d0 (e,n) scipy csr_matrix

DEC operator d0

Examples:

# Mesh in V,F
d0 = gpy.dec_d0(F)
Source code in src/gpytoolbox/dec_d0.py
 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
48
49
50
51
52
53
def dec_d0(F,E=None,n=None):
    """Builds the DEC d0 operator as described, for example, in Crane et al.
    2013. "Digital Geometry Processing with Discrete Exterior Calculus".

    The edge labeling in E follows the convention from Gpytoolbox's
    `halfedge_edge_map`.

    The input mesh _must_ be a manifold mesh.

    Parameters
    ----------
    F : (m,3) numpy int array
        face index list of a triangle mesh
    E : (e,2) numpy int array, optional (default None)
        edge index list of a triangle mesh.
        If absent, will be computed using `halfedge_edge_map`
    n : int, optional (default None)
        number of vertices in the mesh.
        If absent, will try to infer from F.

    Returns
    -------
    d0 : (e,n) scipy csr_matrix
        DEC operator d0

    Examples
    --------
    ```python
    # Mesh in V,F
    d0 = gpy.dec_d0(F)
    ```

    """

    assert F.shape[1] == 3

    if n is None:
        n = np.max(F)+1

    if E is None:
        _,E,_,_ = halfedge_edge_map(F, assume_manifold=True)

    i = np.concatenate((np.arange(E.shape[0]), np.arange(E.shape[0])), axis=0)
    j = np.concatenate((E[:,0], E[:,1]), axis=0)
    k = np.concatenate((np.ones(E.shape[0], dtype=float),
        -np.ones(E.shape[0], dtype=float)))
    d0 = sp.sparse.csr_matrix((k, (i,j)), shape=(E.shape[0],n))

    return d0