# how to use vtkGradientFilter to get the gradient of each point in an unstructured grid in codes

**URL:** https://discourse.vtk.org/t/how-to-use-vtkgradientfilter-to-get-the-gradient-of-each-point-in-an-unstructured-grid-in-codes/10514
**Category:** Support
**Created:** [January 20, 2023, 9:40pm UTC](https://discourse.vtk.org/t/how-to-use-vtkgradientfilter-to-get-the-gradient-of-each-point-in-an-unstructured-grid-in-codes/10514 "2023-01-20T21:40:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![FanWang10](https://discourse.vtk.org/user_avatar/discourse.vtk.org/fanwang10/32/6394_2.png) [@FanWang10](https://discourse.vtk.org/u/FanWang10)
#### Post date: [January 20, 2023, 9:40pm UTC](https://discourse.vtk.org/t/how-to-use-vtkgradientfilter-to-get-the-gradient-of-each-point-in-an-unstructured-grid-in-codes/10514/1 "2023-01-20T21:40:22Z")

</div>

Hello,

I am trying to use vtkGradientFilter to calculate the gradient at each point. However I didn’t find an example that fits my need.

What I have is a .vtu file. It is an unstructured grid with 5 triangle cells. What I’d like to do is to get the gradient of each triangle vertex as something like vtkDataSet that I can access the gradient vector value.  
[testInput.vtu](https://discourse.vtk.org/uploads/short-url/xg8GIMbWpCpjdXKxpknhherjU5V.vtu) (1.0 KB)

I followed the example here: ([https://kitware.github.io/vtk-examples/site/Cxx/PolyData/GradientFilter/](https://kitware.github.io/vtk-examples/site/Cxx/PolyData/GradientFilter/)) but cannot find a way to print or read the gradient.

Any help would be appreciated! Thank you!
