pyFM.mesh.geometry.grad_f

pyFM.mesh.geometry.grad_f(f, vertices, faces, normals, face_areas=None, use_sym=False, grads=None)

Compute the gradient of one or multiple functions on a mesh.

Takes a function defined on each vertex and returns a per-face gradient.

Parameters:
  • f ((n, p) or (n,) np.ndarray) – Function values on each vertex.

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

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

  • normals ((m, 3) np.ndarray) – Normal coordinates for each face.

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

  • use_sym (bool, optional) – If True, uses the (slower but) symmetric expression of the gradient.

  • grads (iterable, optional) – Iterable of size 3 containing arrays of size (m, 3) giving gradient directions for all faces (see function _get_grad_dir).

Returns:

gradient – Gradient of f on the mesh.

Return type:

(m, 3) or (m, p, 3) np.ndarray