# The Gradient filter produces ugly results

**URL:** https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068
**Category:** ParaView Support
**Created:** [July 17, 2024, 3:35am UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068 "2024-07-17T03:35:26Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![svetlanatkachenko](https://discourse.paraview.org/user_avatar/discourse.paraview.org/svetlanatkachenko/32/4765_2.png) [@svetlanatkachenko](https://discourse.paraview.org/u/svetlanatkachenko)
#### Post date: [July 17, 2024, 3:35am UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/1 "2024-07-17T03:35:26Z")

</div>

Vorticity shows the following:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/3/35cafb7e7e6123cbccea1dd568cac5359ec9749b.jpeg)

Y-velocity is much better:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/b/baf9af2ee3d0492c7a44c9e874120092980e9e42.jpeg)

Context: Flow near two parallel inlined heated plates

Same data zoomed out, Vorticity:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/6/61b648d61214ff669354ad41b8996ca73c2dfe37.jpeg)

Y-Velocity:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/a/a16c8aae47bb16bd129bed00292f88a9d3b0c912.jpeg)

Is there something that I can do to make the result look smoother and make sense?

Related topics

> [@QCriterion in Paraview](https://discourse.paraview.org/t/qcriterion-in-paraview/2355):
>
> Hi, I’m working on a turbulent duct flow. I used Gradient of Unstructured Data set filter on velocity vector then I checked the Compute QCriterion option and Compute Vorticity option. (as you can see below) [image] Finally, I used Contour to visualize the QCriterion. (as you can see) [image] The result can be seen in the following image ,but I think it’s not correct. Where is the problem? Did I follow wrong procedures?

> [@How to compute vorticity in Paraview](https://discourse.paraview.org/t/how-to-compute-vorticity-in-paraview/4474):
>
> I’ve opened the results of a simulation (Velocity field and Pressure) in Paraview. I know that the vorticity is by definition the curl of the velocity. How can I proceed to to compute the vorticity in Paraview? I can’t find a clear answer to this after searching. Could you please give a detailed answer for someone beginner? P.S: I am using a structured mesh for my domain, if that matters. I appreciate your help.

> [@Q-Criterion using the Gradient filter](https://discourse.paraview.org/t/q-criterion-using-the-gradient-filter/9149):
>
> Dear all, I am trying to visualize the Q-Criterion as one would normally do with the GradientOfUnstructuredGrid filter. Unfortunately it appears to be integrated in the Gradient filter in 5.10 and I can’t find the old options to calculate the Q-Criterion anymore… Is there a way to do it?

I’m using ParaView 5.11.2 on Windows 11.

Thanks in advance for your advice.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [July 18, 2024, 4:17pm UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/2 "2024-07-18T16:17:47Z")

</div>

Hi,

please share some data to reproduce.

Also you may want to try the 5.12 version or even the 5.13 release candidate ([https://www.paraview.org/download/](https://www.paraview.org/download/))

---

<div class="post-metadata">

### Author: ![svetlanatkachenko](https://discourse.paraview.org/user_avatar/discourse.paraview.org/svetlanatkachenko/32/4765_2.png) [@svetlanatkachenko](https://discourse.paraview.org/u/svetlanatkachenko)
#### Post date: [July 18, 2024, 9:28pm UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/3 "2024-07-18T21:28:24Z")

</div>

Hi @nicolas.vuaille

Thank you for your note.

Attached example data.

[a1.vtm](https://discourse.paraview.org/uploads/short-url/vlPFtFbKL6pUVG1cqWpMCd8DL7V.vtm) (493 Bytes)

Vorticity:

![image](https://discourse.paraview.org/uploads/default/original/2X/6/61380c5e88cc51804a63efcc87c7e7d37f352bc5.png)

Velocity:

 ![image](https://discourse.paraview.org/uploads/default/original/2X/c/ca4983ed8a697f8e29c5a30eb7aedc00a4231e8f.png)

I will check the other paraview versions soon.

How does vorticity work in your version? Could you please check?

---

<div class="post-metadata">

### Author: ![svetlanatkachenko](https://discourse.paraview.org/user_avatar/discourse.paraview.org/svetlanatkachenko/32/4765_2.png) [@svetlanatkachenko](https://discourse.paraview.org/u/svetlanatkachenko)
#### Post date: [July 18, 2024, 11:55pm UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/4 "2024-07-18T23:55:43Z")

</div>

![image](https://discourse.paraview.org/uploads/default/original/2X/3/3a3e70644cce1555fa36b436e10c2a247174b661.png)

What does this mean? This pops up when calculating vorticity in the file attached above, in paraview 5.13 RC.

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [July 19, 2024, 7:43am UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/5 "2024-07-19T07:43:16Z")

</div>

Hi @svetlanatkachenko ,

The `vtm` is a multi-file file format, you send only the root, so actual data is missing (`a1/a1_2_0.vtu`).

Concerning the error, it means that your data is a composite data, and some subpart does not have the requested array. Looks at the `Information` panel (and try the `Extract Block` filter).

Also please prefer copy-paste error message directly over screenshot: it is easier to read and helps other people find this post in the future 🙂

---

<div class="post-metadata">

### Author: ![Kenneth\_Moreland](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kenneth_moreland/32/15033_2.png) [@Kenneth\_Moreland](https://discourse.paraview.org/u/Kenneth_Moreland)
#### Post date: [July 19, 2024, 1:00pm UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/6 "2024-07-19T13:00:41Z")

</div>

> [@nicolas.vuaille](#):
>
> Also please prefer copy-paste error message directly over screenshot: it is easier to read and helps other people find this post in the future 🙂

BTW, the `Output Messages` box has a `Copy to Clipboard` button to make this copy-paste easier. It’s easy to miss that.

---

<div class="post-metadata">

### Author: ![svetlanatkachenko](https://discourse.paraview.org/user_avatar/discourse.paraview.org/svetlanatkachenko/32/4765_2.png) [@svetlanatkachenko](https://discourse.paraview.org/u/svetlanatkachenko)
#### Post date: [July 19, 2024, 11:43pm UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/7 "2024-07-19T23:43:39Z")

</div>

[a1\_2\_0.vtu](https://discourse.paraview.org/uploads/short-url/34Ruraf4hs4yaSfYriSSGHAzmZi.vtu) (66.7 KB)

---

<div class="post-metadata">

### Author: ![Kenichiro-Yoshimi](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/ecc23a/32.png) [@Kenichiro-Yoshimi](https://discourse.paraview.org/u/Kenichiro-Yoshimi)
#### Post date: [July 20, 2024, 3:30am UTC](https://discourse.paraview.org/t/the-gradient-filter-produces-ugly-results/15068/8 "2024-07-20T03:30:06Z")

</div>

The poor aspect ratio of the triangular elements in the cross-section may be causing inaccuracies in the numerical differentiation. Indeed, interpolating the velocity vector on a Cartesian grid using the `Resample To Image` filter and then calculating the vorticity with the `Gradient` filter improves the contours.

 ![vort](https://discourse.paraview.org/uploads/default/original/2X/8/8079d439fbdb6aae9c3c04471cccdb8ed0da0722.png)

If the accuracy of the numerical differentiation for the polyhedral cells is not significantly compromised, calculating the vorticity for the polyhedral cells before cutting may improve the contour.
