To calculate the value of solution variable in the boundary

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?

Hello,
you can do as follows:

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
 }
}
1 Like