# Integrate Solution over an interior "Slice"

**URL:** <https://community.freefem.org/t/integrate-solution-over-an-interior-slice/1107>\
**Category:** General Discussion\
**Created:** [July 19, 2021, 7:51pm UTC](https://community.freefem.org/t/integrate-solution-over-an-interior-slice/1107 "2021-07-19T19:51:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinmo08](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kevinmo08/32/217_2.png) [@kevinmo08](https://community.freefem.org/u/kevinmo08)\
**Post date:** [July 19, 2021, 7:51pm UTC](https://community.freefem.org/t/integrate-solution-over-an-interior-slice/1107/1 "2021-07-19T19:51:39Z")

</div>

Dear All,

I am interested in finding the average value of a “slice”, where it cuts through the middle of my mesh.  
I am aware that FreeFEM allows you to integrate functions over borders using int2D for a 3D mesh or int1D for a 2D mesh. But this integral would be in the interior of the mesh, and would represent a vertical slice.

I have tried something like this, but the error induced is a bit too much due to gradients in my solution.

```auto
  fespace Ph(Th3, P0);
  Ph2 chi = (x > -0.01 && x < 0.01 ; // I want the 2D average at x = 0, all values of y, all values of z.
  real avgProbAtCenter = int3d(Th3)(chi*uh) / int3d(Th3)(chi) ;

```

If I make the range too small or too large around 0, errors are compounded. Is there a better way to get the 2D integral at just x = 0 instead of a region around it?

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [July 19, 2021, 8:21pm UTC](https://community.freefem.org/t/integrate-solution-over-an-interior-slice/1107/2 "2021-07-19T20:21:40Z")

</div>

Hi wouldn’t the keyword `levelset` would do the job for what you want?  
Something like

> `int2d(Th3, levelset=x)(uh)`

or

> `int3d(Th3, levelset=x)(uh)`

Or something like this… Maybe check the documentation [here](https://doc.freefem.org/documentation/finite-element.html#problem-definition)…

---

<div class="post-metadata">

**Author:** ![kevinmo08](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/kevinmo08/32/217_2.png) [@kevinmo08](https://community.freefem.org/u/kevinmo08)\
**Post date:** [July 19, 2021, 8:41pm UTC](https://community.freefem.org/t/integrate-solution-over-an-interior-slice/1107/3 "2021-07-19T20:41:41Z")

</div>

Hi Julien,

Thank you! That does seem to work well. With using

`int3d(Th3, levelset=x)(uh)`

And I can just change x to x+3 to do the levelset at x = -3 which works great.
