Computing flow through a line

Is there any way to measure the flow through an arbitrary line?

My domain is a duct with one inlet, which then separates into two channels which later merge together and go to the outlet. Is there any way to find out the flow through each of those channels?

Of coarse yes.

  1. build a meshL of segment [a,b] of your line, call ThL for exemple.

     real a1=0,a2=0,b1=1,b2=1;
     meshL Th2 = segment(100,[a1+(b1-a1-*x , a2+(b2-a2)*x ,0 ]); // 100 points 
     real flux = int1d(ThL)([u1,u2]'*[-Tl.y,Tl,x]);

This doesn’t seem to work for me on 4.7
I get an error on the line meshL is on, as if it didn’t recognize the type.
I also tried defining it via buildmesh, but I get the same error.

EDIT: while this still doesn’t work, knowing that I can use a secondary mesh to calculate stuff that was computed on a primary mesh, I just made a very thin rectangle and used just one surface of it to compute the flow. This is a trick, so if I could make the meshL stuff work it would be better, but otherwise the main problem has been solved.

you must load “msh3”
bofere in the script.

I read that in the documentation, so I used load "msh3", but to no avail.


load "msh3"
mesh Th=square(10,10); 
fespace Vh2(Th,P2);
Vh2 u1=-(y),u2=(x);
real a1=0,a2=0,b1=1,b2=1;
meshL ThL = segment(100,[a1+(b1-a1)*x , a2+(b2-a2)*x ,0 ]); // 100 points 
real flux = int1d(ThL)([u1,u2]'*[-Tl.y,Tl.x]);
cout << " flux = "<< flux << " == 1/2+1/2" << endl; 

This works. I yet have to figure out what the difference is between this code and the one I have, but I’m sure it’s some minor error.