# Computing flow through a line

**URL:** <https://community.freefem.org/t/computing-flow-through-a-line/733>\
**Category:** General Discussion\
**Created:** [January 7, 2021, 12:10pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733 "2021-01-07T12:10:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeonardoDipilato](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/leonardodipilato/32/361_2.png) [@LeonardoDipilato](https://community.freefem.org/u/LeonardoDipilato)\
**Post date:** [January 7, 2021, 12:10pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/1 "2021-01-07T12:10:23Z")

</div>

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?

---

<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:** [January 7, 2021, 3:14pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/2 "2021-01-07T15:14:08Z")

</div>

Of coarse yes.

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

---

<div class="post-metadata">

**Author:** ![LeonardoDipilato](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/leonardodipilato/32/361_2.png) [@LeonardoDipilato](https://community.freefem.org/u/LeonardoDipilato)\
**Post date:** [January 7, 2021, 3:24pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/3 "2021-01-07T15:24:55Z")

</div>

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.

---

<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:** [January 7, 2021, 3:40pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/4 "2021-01-07T15:40:22Z")

</div>

you must load “msh3”  
bofere in the script.

---

<div class="post-metadata">

**Author:** ![LeonardoDipilato](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/leonardodipilato/32/361_2.png) [@LeonardoDipilato](https://community.freefem.org/u/LeonardoDipilato)\
**Post date:** [January 7, 2021, 3:43pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/5 "2021-01-07T15:43:43Z")

</div>

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

---

<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:** [January 7, 2021, 4:25pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/6 "2021-01-07T16:25:48Z")

</div>

A TRUE EXAMPLE:

```auto
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]);
plot([u1,u2],ThL,wait=1);
cout << " flux = "<< flux << " == 1/2+1/2" << endl; 

```

---

<div class="post-metadata">

**Author:** ![LeonardoDipilato](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/leonardodipilato/32/361_2.png) [@LeonardoDipilato](https://community.freefem.org/u/LeonardoDipilato)\
**Post date:** [January 7, 2021, 5:16pm UTC](https://community.freefem.org/t/computing-flow-through-a-line/733/7 "2021-01-07T17:16:16Z")

</div>

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.

Thanks!
