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

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

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

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

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.

1 Like

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