# extract surface from 3d mesh and compute gradient of solution vector

**URL:** https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205
**Category:** ParaView Support
**Created:** [November 8, 2023, 4:58pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205 "2023-11-08T16:58:26Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [November 8, 2023, 4:58pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/1 "2023-11-08T16:58:26Z")

</div>

Dear all,

I have a vtu file which contains a displacement vector on a 3d mesh obtained from a finite element solution.

I interpolated 2d measured displacements on this mesh using the ResampleWithDataset filter:

 ![Screenshot at 2023-11-08 17-45-56](https://discourse.paraview.org/uploads/default/original/2X/7/730546ed50114e30c30a3a8ec106ee1155880436.png)

In this picture, you can see that some of the displacements at the front surface are non-zero, but the displacements at the remaining five surfaces are zero (since these were not measured).

I want to compute the gradient of the displacement vector, but it does not make much sense to do this on the 3d mesh, since the gradient is dominated by the jump to the surfaces with the non-zero values.

That said, is there a way to extract the surface (containing the measured values), thus, having a 2d mesh, and compute the gradient on this surface? The surface is characterized by the points with z-coordinate zero.

Thank you for your help!

Best regards,  
Simon

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 9, 2023, 12:57pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/2 "2023-11-09T12:57:08Z")

</div>

Use ExtractSurface filter ?

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [November 9, 2023, 3:52pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/3 "2023-11-09T15:52:49Z")

</div>

But how can I select the front surface (z=0)?

 ![Screenshot at 2023-11-09 16-51-33](https://discourse.paraview.org/uploads/default/original/2X/e/e7893f2cb6e8a6537caa780cbbfd51ad906bdf8a.png)

If I just press “Apply”, I get again the entire volume

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 9, 2023, 3:57pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/4 "2023-11-09T15:57:44Z")

</div>

I missed that point. You can slice with z=0, or select the surface on z = 0.

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [November 9, 2023, 4:04pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/5 "2023-11-09T16:04:48Z")

</div>

The slice filter works!

But applying the gradient filter to it, still gives 9 components + magnitude. So the displacement is still going to be considered in 3d.

I could ignore some components of the gradient, of course, but is there a way to get only 4 components + magnitude directly?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 9, 2023, 4:07pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/6 "2023-11-09T16:07:29Z")

</div>

A vector will stay in 3D unless you compute a scalar from it ? This is expected. Do you want to compute the magnitude ?

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [November 9, 2023, 4:12pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/7 "2023-11-09T16:12:16Z")

</div>

After the slice filter, the contour plot is a surface with a displacement in x- and y-direction.

What I want is to get the displacement as a vector in 2d rather than in 3d by simply “forgetting” about the z-coordinate. So the gradient has 4 components.  
Can I do this in paraview?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 9, 2023, 4:29pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/8 "2023-11-09T16:29:14Z")

</div>

You could force the Z component to 0 with a calculator but you will not be able top transform it into a two component array easily.

---

<div class="post-metadata">

### Author: ![simonw](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/s/34f0e0/32.png) [@simonw](https://discourse.paraview.org/u/simonw)
#### Post date: [November 9, 2023, 4:36pm UTC](https://discourse.paraview.org/t/extract-surface-from-3d-mesh-and-compute-gradient-of-solution-vector/13205/9 "2023-11-09T16:36:08Z")

</div>

The Z component is already Zero everywhere.

But if I understand you, the best way is to simply ignore components of the gradient in Z-direction, right?
