A scalar field f approximated on a triangular mesh using the FEM method can be given as
$f(x,y) \approx \bar{f}(x,y) = \sum_{n=1}^3 \left(\phi_n(x,y) \cdot f_n \right)$
I am of the understanding, then, that the gradient of f can be found inside each triangle with
$\nabla \bar{f}_t = \sum_{n=1}^3 \left(\frac{\partial\phi_n(x,y)}{\partial x} \cdot f_n , \frac{\partial\phi_n(x,y)}{\partial y} \cdot f_n\right)$
Where $f_t$ is the value at the triangle centroids. Since the value at each point $f_n$ is only defined at single points, it acts as a scalar in the derivative.
But, what if we then want to take the gradient of each of the components from the previous solution? One way seems to be to interpolate the gradient results from the triangle centroids back to the given points, and then repeat the process for each component. However, what if this interpolation is unsatisfactory -- is there a way to possibly define the gradient at each point from data at the triangle centroids?
There seems to be a similiar question posed here, but I'm not sure if the solution is relevant -- the answer solution seems to involve going through all the basis functions of adjacent triangles, whereas it seems to me that only one basis function from each adjacent triangle is needed -- the one which has a nonzero value at the observed point.
With this in mind, I've derived the following equation:
$\nabla \bar{f}_i = \sum_{n=1}^{t_i} \left(\left( \frac{\partial\phi_i^n(x,y)}{\partial x}, \frac{\partial\phi_i^n(x,y)}{\partial y} \right) \frac{f_n}{t_i} \right)$
Where i is the observed point, and $t_i$ is the number of triangles which contain the vertex point i.
Unfortunately, it doesn't seem to work, and I'm not sure if averaging over the number of triangles is appropriate. Can someone point me in the right direction?