# Boundary Edge extremities

**URL:** <https://community.freefem.org/t/boundary-edge-extremities/1428>\
**Category:** General Discussion\
**Created:** [January 13, 2022, 6:45am UTC](https://community.freefem.org/t/boundary-edge-extremities/1428 "2022-01-13T06:45:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [January 13, 2022, 6:45am UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/1 "2022-01-13T06:45:46Z")

</div>

Hello all,

I would like to know how to have access to edge extremities (x1,y1) and (x2,y2) when we calculate for example:

```auto
 int1d(ThK)(u*((x - x1)*(x2 - x1) + (y - y1)*(y2 - y1))/( (x2 - x1)^2 + (y2 – y1)^2 ))

```

The problem reads how to find the two vertices of the current edge.

Thank you in advance for your help,

Best regards,

Loïc,

---

<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 13, 2022, 10:34am UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/2 "2022-01-13T10:34:47Z")

</div>

Idea,

1. ( (x2 - x1)^2 + (y2 – y1)^2 )) = lenEdge^2
2. (x-x1)/(x2-x1) == (y-y1)/(y2=y1) == barycentric coordinate en edge…

```auto
load "Element_PkEdge"
mesh Th=square(2,1);
func Tg = [-N.y,N.x];// Tangente to edge 
macro grad(u) [dx(u),dy(u)]//
fespace Wh(Th,P1edge);
Wh b,bb;
// int_E (b) = 0.5 ; on each e edge
// (grad(b).T) = 1 ; on each e edge T the tangent to E 
verbosity = 10;
solve ComputeB(b,bb) = intalledges(Th,qforder=1)(b*bb+grad(b)'*grad(bb)) - intalledges(Th,qforder=1)(0.5*bb+Tg'*grad(bb));
plot(b,wait=1); 

```

`b` give le barycentric on edge if I a make no mistake.

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [January 13, 2022, 12:34pm UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/3 "2022-01-13T12:34:08Z")

</div>

Hello @frederichecht ,

Thank you for you answer,  
Your method seems to work in this case, but I don’t understand what “ComputeB(b,bb)”  
does. Could you give me more insights about this calculation ?

In more general case, if I do not consider the barycentric coordinate on edge, but I consider

> int1d(ThK)(u\*P(x,y, [x1,y1], [x2, y2]))

where P is a polynomial which depends on the edge extremities [x1,y1], [x2, y2]). Do you have an idea how to have access at this extremities ? Or may be it will be possible to compute P in the say way that in the method you have proposed.

Best regards,

Loïc,

---

<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 13, 2022, 2:05pm UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/4 "2022-01-13T14:05:13Z")

</div>

The method compute a barycentric coordinate on the edge  
so b(x,y) is a such that X = b(X)\*X2 + (1-b(X))\*X1  
so you can easily make the change of variable with a other polynom.

Otherwise you can use Pkedge with k = 0 to 5 to set a polynom on each edge

the degre of freedom are the Quadrature point of the Gauss Legendre formulae on [0,1] with k point

see [Gauss–Legendre quadrature - Wikipedia](https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_quadrature)

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [January 13, 2022, 2:31pm UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/5 "2022-01-13T14:31:01Z")

</div>

Thank you for your clear explanation @frederichecht. It is exactely what I was looking for.

However, I just don’t understand where the formula:

```auto
intalledges(Th,qforder=1)(b*bb+grad(b)'*grad(bb)) - intalledges(Th,qforder=1)(0.5*bb+Tg'*grad(bb))

```

comes from. Could you explain it briefly ?

Best regards,

Loïc,

---

<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 13, 2022, 2:50pm UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/6 "2022-01-13T14:50:58Z")

</div>

This simple the barycentric coordinate verif

b( middle) = 0.5  
and grad(b) . T = 1

qforder = 1 =\> one quadrature point at middle of E  
=\> OK

int\_E (b\*bb+ grad(b)_grad(bb) - =int\_E(0.5_bb + T’\*grad(bb))

because grad(b)) is tangent to the edge E.

---

<div class="post-metadata">

**Author:** ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)\
**Post date:** [January 13, 2022, 3:02pm UTC](https://community.freefem.org/t/boundary-edge-extremities/1428/7 "2022-01-13T15:02:41Z")

</div>

Thank you,  
I understand now,

Best regards,

Loïc,
