# Gradient of a vector on a triangulated lattice

Suppose I have a triangulated mesh and I have solved a differential equation problem and have a solution phi. From phi I can construct a vector field, how would I go about computing the gradient of this vector field?

The mesh looks something like this. phi is solved for at the center of all of the cells in the picture. I'm not sure how to handle the spatial discretization for a triangulated lattice. Any references would be appreciated.

## 2 Answers

You can use a least squares method to calculate the gradient on unstructured meshes. Here's a presentation on the method. least squares gradient

• Does this method by itself work for computing the gradient of a vector? – wgwz Dec 24 '14 at 14:45
• The url doesn't exist anymore. – johnbaltis Jun 18 '18 at 16:55

The gradient of a vector field is simply a matrix where each row is the gradient of one of the (scalar) components of your vector field. In other words, if you know how to compute the gradient of a scalar solution, you also know how to compute the gradient of a vector field.

Of course, on a triangular mesh with piecewise linear elements, the gradient is then simply a constant on every cell.

• What are piecewise linear elements? – wgwz Dec 29 '14 at 16:53
• Err, the most elementary elements, with the usual hat functions as shape functions. – Wolfgang Bangerth Dec 29 '14 at 23:32
• Here's some stuff on shape functions for those like myself who have never heard of these before. Basic explanation of shape functions.. @WolfgangBangerth I plan to check out Lecture 4 of yours. Thanks for the pointers. – wgwz Dec 30 '14 at 0:06