Skip to content

momentum_leaking_matrix

momentum_leaking_matrix(V, T, dt=None, pow=1)

Constructs the momentum leaking matrix, that fudges the CD constraint to allow momentum to leak from the rig to the mesh. This is a diagonal matrix with entries ranging from 0 (full momentum leak), to 1 (no momentum leak). This leaking matrix is computed via a surface diffusion, where values at the surface have momentum leaking value set to 0, and smoothly increases to 1 at the interior.

Parameters:

Name Type Description Default
V (n, 3) float numpy array

Vertex positions

required
T (t, 4) int numpy array

Tet indices

required
dt float

Used in diffusion (default 1/l^2 where l is the mean edge lengths)

None
pow float

Power to raise the diffusion weights to (default 1)

1

Returns:

Name Type Description
D (n, n) scipy sparse matrix

Diagonal sparse matrix with entries varying from 0 (momentum-fully leaking) to 1 (momentum not leaking) for each vertex.

Source code in src\fast_cody\momentum_leaking_matrix.py
 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 momentum_leaking_matrix(V, T, dt=None, pow=1):
    """
    Constructs the momentum leaking matrix, that fudges the CD constraint to allow momentum to leak from
    the rig to the mesh. This is a diagonal matrix with entries ranging from 0 (full momentum leak), to 1 (no momentum leak).
    This leaking matrix is computed via a surface diffusion, where values at the surface have momentum leaking value set to 0,
    and smoothly increases to 1 at the interior.


    Parameters
    ----------
    V : (n, 3) float numpy array
        Vertex positions
    T : (t, 4) int numpy array
        Tet indices
    dt : float
        Used in diffusion (default 1/l^2 where l is the mean edge lengths)
    pow : float
        Power to raise the diffusion weights to (default 1)

    Returns
    -------
    D : (n, n) scipy sparse matrix
        Diagonal sparse matrix with entries varying from 0 (momentum-fully leaking) to 1 (momentum not leaking) for each vertex.
    """
    F = igl.boundary_facets(T)
    M = igl.massmatrix(V, T)
    Me = sp.sparse.kron(sp.sparse.identity(3), M)
    bI = np.unique(F)
    phi = np.ones((bI.shape[0], 1))
    d = 1 - np.power(diffuse_weights(V, T, phi, bI, dt=dt), pow)

    # import polyscope as ps
    # ps.init()
    # m = ps.register_volume_mesh("mesh", V, T)
    # m.add_scalar_quantity("d", d[:, 0], enabled=True)
    # ps.show()
    D = sp.sparse.kron(sp.sparse.identity(3), sp.sparse.diags(d[:, 0]))


    return D