# Calculate numerical directional derivative on triangular element

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.

• 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?
– Paul
May 30, 2018 at 5:05
• 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)$ May 30, 2018 at 16:00
• Use Barycentric coordinates. Oct 31, 2018 at 15:31