# Confused about the results

**URL:** <https://community.freefem.org/t/confused-about-the-results/2045>\
**Category:** General Discussion\
**Created:** [October 7, 2022, 10:16am UTC](https://community.freefem.org/t/confused-about-the-results/2045 "2022-10-07T10:16:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zese](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zese/32/917_2.png) [@zese](https://community.freefem.org/u/zese)\
**Post date:** [October 7, 2022, 10:16am UTC](https://community.freefem.org/t/confused-about-the-results/2045/1 "2022-10-07T10:16:41Z")

</div>

Dear all

I have written the results at inlet boundary of label 1 and 2 based on the following two methods:

method (1)  
fespace XXXMh(th,[P2,P2,P2,P1]);

```
     XXXMh [u1x,u1r,u1phi,u1p];         
    XXXMh [v1x,v1r,v1phi,v1p];
      XXXMh [xx, xy, xz, xp] = [x,x,x,x];
      XXXMh [yx, yy, yz, yp] = [y,y,y,y];
       ofstream file8("Boundary2.txt");
       varf vBC1([u1x,u1r,u1phi,u1p], [v1x,v1r,v1phi,v1p]) =
          on(1, u1x = 1)+on(2,u1x = 2); 
real[int] bcLab1vec = vBC1(0,XXXMh,tgv=-1);
    cout << "-----1st Method-----" <<endl;
  for(int i=0; i< bcLab1vec .n; i++) {
             if(abs(bcLab1vec[i]-1)<1e-10||abs(bcLab1vec[i]-2)<1e-10)
              {
                     real xx2=xx[][i], yy2=yx[][i];
                    file8 << xx[][i]<< " " << yx[][i] << " " << Cr(xx2,yy2) <<endl;
                   }
 }

```

method (2)  
int Nbtriangle=th.nbe;  
cout \<\< “-----2nd Method-----” \<\<endl;  
for (int k=0; k\<Nbtriangle; k++)  
{  
int L=th.be(k).label;  
if (L==1 || L==2)  
{  
real yy1=th.be(k)[1].y;  
real xx1=th.be(k)[1].x;  
file1 \<\< xx1 \<\< " " \<\< yy1 \<\< " " \<\< Cr(xx1,yy1)\<\< endl;  
}  
}

when I plot the output file in excel there is a difference which confused me.

 ![pic](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/d/d867dd98c876e6f9b6da6541649d7425911ab6bd.jpeg)

I don’t know why there is the difference between them and which one is correct? In addition, one of the trends is correct. For example either the top or the lower trend is acceptable and I don’t know why the orange one is periodically goes and back between these two trends?

BR

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [October 7, 2022, 12:30pm UTC](https://community.freefem.org/t/confused-about-the-results/2045/2 "2022-10-07T12:30:22Z")

</div>

It is hard to say anything since there is neither a mesh nor a function specified in your example. Maybe you should try out the things you want on a simple square mesh and some simple test solution functions (sin, cos, etc).

However, my guess is that the reason for the difference is in the following line:

```auto
real yy1=th.be(k)[1].y;
real xx1=th.be(k)[1].x;

```

here, `th.be(k)[1]` is used only, but not `th.be(k)[0]`, therefore half of the boundary points are omitted compared to the other method.

---

<div class="post-metadata">

**Author:** ![zese](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zese/32/917_2.png) [@zese](https://community.freefem.org/u/zese)\
**Post date:** [October 7, 2022, 12:47pm UTC](https://community.freefem.org/t/confused-about-the-results/2045/3 "2022-10-07T12:47:11Z")

</div>

Thank you. The problem is that one of the trends is right. Let’s define it better. I have a square as the follow:

![Untitled (1)](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/2/2f53e0d8f7d100318491e3029ffaab29216361bf.png)

It is an optimal control method in which Cr is being updated in every loop. Now I need to export the Cr at boundary but in method 1 which I think all data’s are included one trend is acceptable. As you see in the picture the method 1 is like being periodic and zigzag form but it is not right and the trend must be soft. Don’t know why it happens.

---

<div class="post-metadata">

**Author:** ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)\
**Post date:** [October 7, 2022, 3:11pm UTC](https://community.freefem.org/t/confused-about-the-results/2045/4 "2022-10-07T15:11:09Z")

</div>

I do no think I completely understand your approach. It might be the case the you need to change your variational formulation in method 1 since the control is in the radial (?) direction:

```auto
varf vBC1([u1x,u1r,u1phi,u1p], [v1x,v1r,v1phi,v1p]) =
          on(1, u1r = 1)+on(2,u1r = 2); 

```

---

<div class="post-metadata">

**Author:** ![zese](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/zese/32/917_2.png) [@zese](https://community.freefem.org/u/zese)\
**Post date:** [October 7, 2022, 7:26pm UTC](https://community.freefem.org/t/confused-about-the-results/2045/5 "2022-10-07T19:26:50Z")

</div>

Dear aszaboa

Thank you for your responses. I think I found the answer. This happens because in method 1 I used P2 fespace and in method 2 I will export the nodes value which is equal to P1 fespace. when I changed the P2 in method 1 to P1 the results became the same.

BR
