Given a triangle with nodes 0, 1, and 2 where each node is located at $r_i = x_i,y_i,z_i$ for $i = 0:2$ and has an associated scalar value $\phi_i$ at the node, how would I evaluate the directional derivative $\nabla_u \phi$ at the centroid of the triangle at the centroid of the triangular element given the direction $u$.

I've figured out how to evaluate $\nabla_u \phi$ on each edge separately but not sure how to get the value at the centroid.

  • 2
    $\begingroup$ If its a lagrange element, then the solution is linear inside each triangle. The gradient of a linear function is constant. The gradient at the edges is not unique since FEM computes a piecewise linear solution in each element. How did you compute the edge gradients? $\endgroup$
    – Paul
    May 30, 2018 at 5:05
  • $\begingroup$ I just used the values at each node over the distance between the nodes for the edges: $(\phi_1 - \phi_0) / (r_1 - r_0)$ $\endgroup$
    – nrabbit
    May 30, 2018 at 16:00
  • $\begingroup$ Use Barycentric coordinates. $\endgroup$
    – joojaa
    Oct 31, 2018 at 15:31

1 Answer 1


The easiest way is to fit a linear function a + b x + c y. To find a, b and c solve the system of equations:

a + bx0 + cy0 = phi0 a + bx1 + cy1 = phi1 a + bx2 + cy2 = phi2

If (u1,u2) is the unit vector in the direction u, the the directional derivative is: bu1 + cu2

  • $\begingroup$ Thats by intuition. Not a numerical method $\endgroup$
    – Fennekin
    Jun 3, 2018 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.