pyFM.mesh.geometry.grad_mat

pyFM.mesh.geometry.grad_mat(vertices, faces, normals=None, face_areas=None, order_style='C')

Return the gradient operator as a (3 * m, n) matrix G.

This is a ‘flattened’ version of the gradient. Given a function f of shape (n,), the gradient is given by (G @ f).reshape(order=order_style).

Parameters:
  • vertices ((n, 3) np.ndarray) – Coordinates of the vertices.

  • faces ((m, 3) np.ndarray) – Vertex indices for each face.

  • normals ((m, 3) np.ndarray, optional) – Normal coordinates for each face. Computed from the mesh if not provided.

  • face_areas ((m,) np.ndarray, optional) – Per-face areas, for faster computation. Computed from the mesh if not provided.

  • order_style (str, optional) – Order style to use for reshape, either ‘C’ or ‘F’.

Returns:

G – Gradient matrix.

Return type:

(3 * m, n) scipy.sparse.csr_matrix