# Second Order Derivative

**URL:** https://discourse.paraview.org/t/second-order-derivative/10874
**Category:** ParaView Support
**Created:** [November 28, 2022, 5:31pm UTC](https://discourse.paraview.org/t/second-order-derivative/10874 "2022-11-28T17:31:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aishwaryavyas2995](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/e79b87/32.png) [@aishwaryavyas2995](https://discourse.paraview.org/u/aishwaryavyas2995)
#### Post date: [November 28, 2022, 5:31pm UTC](https://discourse.paraview.org/t/second-order-derivative/10874/1 "2022-11-28T17:31:25Z")

</div>

Hi,

Does anybody know the convention for the output we get when we use the second-order derivative on the gradient of a velocity? I got a total of 27 outputs, but I am unsure what the order is.

Please let me know.

---

<div class="post-metadata">

### Author: ![jfausty](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jfausty/32/9405_2.png) [@jfausty](https://discourse.paraview.org/u/jfausty)
#### Post date: [November 28, 2022, 6:24pm UTC](https://discourse.paraview.org/t/second-order-derivative/10874/2 "2022-11-28T18:24:51Z")

</div>

Hi @aishwaryavyas2995,

Thanks for posting!

I have to admit that it would benefit to have a little context.

Depending on your mesh, your initial data, your numerical gradient calculation, etc. the answer can be quite different. For example: if you have data described on your points on an unstructured grid, ParaView automatically linearly interpolates inside cells. A gradient should therefore be a cell data field being constant inside cells leaving a second derivative null.

By default ParaView does things differently and provides gradient data on points which should lead to non-null second order derivative tensor field.

Are you looking for the order (i.e. row or column first) of the tensor you get after performing a gradient on a vector field?

Best regards,

Julien

---

<div class="post-metadata">

### Author: ![aishwaryavyas2995](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/e79b87/32.png) [@aishwaryavyas2995](https://discourse.paraview.org/u/aishwaryavyas2995)
#### Post date: [November 28, 2022, 6:30pm UTC](https://discourse.paraview.org/t/second-order-derivative/10874/3 "2022-11-28T18:30:12Z")

</div>

Hi,

Thank you for the reply.

So I am doing a CFD simulation postprocessing of an OpenFOAM case in paraview.

I want to use the calculated velocity field to further calculate the second order derivative of velocity.

For example , using the gradient function for velocity in paraview we get 9 components . du/dx,du/dy,du/dz, etc.

But I want to find the derivatives d2u/dx2 and d2w/dz2. For this when I use the gradient function again on the output I got for velocity gradient, now I obtain a result with 27 components. But the problem is it is not mentioned which is which. Like, whether the component , say, 2 is d2u/dx2 or d2w/dx.dy.

I wanted to know what this convention is.  
I am aware of the convention for the first order derivative, that is the 9 components. But for 27 components what is the assignment /naming?

---

<div class="post-metadata">

### Author: ![jfausty](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jfausty/32/9405_2.png) [@jfausty](https://discourse.paraview.org/u/jfausty)
#### Post date: [November 29, 2022, 9:22am UTC](https://discourse.paraview.org/t/second-order-derivative/10874/4 "2022-11-29T09:22:13Z")

</div>

Hi @aishwaryavyas2995,

Thanks for the context. I think I have a better sense of your question now.

The documentation in the `vtkGradientFilter` states:

```auto
The output gradient array has 3*number of components of the input data array. 
The ordering for the output gradient tuple will be 

{du/dx, du/dy, du/dz, dv/dx, dv/dy, dv/dz, dw/dx, dw/dy, dw/dz} 

for an input array {u, v, w}.

```

This leads me to believe that for the double gradient case, starting from a `{u, v, w}` case you will get something along the lines of:

```auto
{d(du/dx)/dx, d(du/dx)/dy, d(du/dx)/dz, d(du/dy)/dx, d(du/dy)/dy, ..., d(dw/dz)/dx, d(dw/dz)/dy, d(dw/dz)/dz}

```

Essentially repeating the gradient operation on each component individually and storing them in order.

I hope that helps and answers your question!

Regards,

Julien

---

<div class="post-metadata">

### Author: ![todoooo](https://discourse.paraview.org/user_avatar/discourse.paraview.org/todoooo/32/2819_2.png) [@todoooo](https://discourse.paraview.org/u/todoooo)
#### Post date: [November 29, 2022, 11:38pm UTC](https://discourse.paraview.org/t/second-order-derivative/10874/5 "2022-11-29T23:38:10Z")

</div>

I would have though you could answer that question yourself by generating some input data with known first and second derivative values.

---

<div class="post-metadata">

### Author: ![aishwaryavyas2995](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/e79b87/32.png) [@aishwaryavyas2995](https://discourse.paraview.org/u/aishwaryavyas2995)
#### Post date: [November 30, 2022, 11:07am UTC](https://discourse.paraview.org/t/second-order-derivative/10874/6 "2022-11-30T11:07:23Z")

</div>

Thank you for the answer.  
I assumed that this would be the convention, just wanted to know if there is an actual definition in ParaView handbook for this.
