# To calculate the value of solution variable in the boundary

**URL:** <https://community.freefem.org/t/to-calculate-the-value-of-solution-variable-in-the-boundary/3736>\
**Category:** General Discussion\
**Created:** [February 7, 2025, 5:41pm UTC](https://community.freefem.org/t/to-calculate-the-value-of-solution-variable-in-the-boundary/3736 "2025-02-07T17:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goutham2023](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/goutham2023/32/1759_2.png) [@goutham2023](https://community.freefem.org/u/goutham2023)\
**Post date:** [February 7, 2025, 5:41pm UTC](https://community.freefem.org/t/to-calculate-the-value-of-solution-variable-in-the-boundary/3736/1 "2025-02-07T17:41:15Z")

</div>

Hello everyone,  
I just need to know how the values of solution variables are calculated at the boundary. I used the syntax provided in the examples, but it is not working. Could you please check this and let me know?

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/9/930d03beb07ed4e4ae58f160b90213f4e86ad552.png)

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [February 9, 2025, 11:35am UTC](https://community.freefem.org/t/to-calculate-the-value-of-solution-variable-in-the-boundary/3736/2 "2025-02-09T11:35:12Z")

</div>

Hello,  
you can do as follows:

```auto
int A3=2;//set the label of desired boundary

int vertdone=-1;//initialize the last vertex already treated
for (int ib=0;ib<Th.nbe;ib++){//loop on boundary elements of mesh Th
 if (Th.be(ib).label==A3){// if the boundary element is on A3
  int iv0=Th.be(ib)[0];// vertex of origin of the boundary element
  if (iv0!=vertdone){
   real xx0=Th(iv0).x;
   real yy0=Th(iv0).y;
   real value0=sdot(xx0,yy0);
   cout << " x,y,value " << xx0 << ", " << yy0 << ", " << value0 << endl;
  }
  int iv1=Th.be(ib)[1];// vertex of end of the boundary element
  real xx1=Th(iv1).x;
  real yy1=Th(iv1).y;
  real value1=sdot(xx1,yy1);
  cout << " x,y,value " << xx1 << ", " << yy1 << ", " << value1 << endl;
  vertdone=iv1;// this vertex is done
 }
}

```
