# How to 1d intergrate along x/y direction in 2d mesh

**URL:** https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986
**Category:** General Discussion
**Created:** [May 20, 2021, 12:15pm UTC](https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986 "2021-05-20T12:15:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![xlzheng](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@xlzheng](https://community.freefem.org/u/xlzheng)
#### Post date: [May 20, 2021, 12:15pm UTC](https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986/1 "2021-05-20T12:15:54Z")

</div>

Now I have a mesh Th defined in the square from x = 0 to 1, y = 0 to 1.  
I solve a PDE on this mesh, getting solution u.  
Then I want to know the line integral of u along y to get ∫𝑢𝑑𝑦,  
but I don’t know how to implement

---

<div class="post-metadata">

### Author: ![Daoudi](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@Daoudi](https://community.freefem.org/u/Daoudi)
#### Post date: [May 20, 2021, 2:08pm UTC](https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986/2 "2021-05-20T14:08:54Z")

</div>

Int1d(Th,label)(u); // label of boundary ( 1 or 2 …)

---

<div class="post-metadata">

### Author: ![xlzheng](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@xlzheng](https://community.freefem.org/u/xlzheng)
#### Post date: [May 21, 2021, 12:45am UTC](https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986/3 "2021-05-21T00:45:26Z")

</div>

thanks, but I want all the value of ∫𝑢𝑑𝑦 on every discrete points in x direction, there isn’t label.

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [May 25, 2021, 9:48am UTC](https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986/4 "2021-05-25T09:48:08Z")

</div>

This is a other story,

One idea : use the levelest integral

```
load "msh3"
mesh Th=square(10,10);
meshL Lyh=segment(10,[0,x,0]);
fespace Vh(Th,P1);
fespace Lh(Lyh,P1);
Vh u =y+x; // 
Lh yy=y; 
Lh v ;
for [i,vi:v[]] {
	vi = int1d(Th,levelset=y-yy[][i])(u); // integral on y = yy[][i] of u ..
}
cout << v[] << endl; 

```

remark, we miss the last line y= 1 due to roundoff error.

---

<div class="post-metadata">

### Author: ![xlzheng](https://avatars.discourse-cdn.com/v4/letter/x/2acd7d/32.png) [@xlzheng](https://community.freefem.org/u/xlzheng)
#### Post date: [July 18, 2021, 2:26pm UTC](https://community.freefem.org/t/how-to-1d-intergrate-along-x-y-direction-in-2d-mesh/986/5 "2021-07-18T14:26:28Z")

</div>

I really appreciate your help very much, and my problem has been solved
