# Print the solution at points

**URL:** <https://community.freefem.org/t/print-the-solution-at-points/1643>\
**Category:** General Discussion\
**Created:** [April 3, 2022, 7:13pm UTC](https://community.freefem.org/t/print-the-solution-at-points/1643 "2022-04-03T19:13:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![omar](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/omar/32/1074_2.png) [@omar](https://community.freefem.org/u/omar)\
**Post date:** [April 3, 2022, 7:13pm UTC](https://community.freefem.org/t/print-the-solution-at-points/1643/1 "2022-04-03T19:13:25Z")

</div>

Dear all, I am new to FreeFEM.

I am solving Poisson’s equation. and I want to print the u solution to a text file. The solution printed include the solution at nodes and at cells as well.

How can I print the solutions at the nodes only.  
This is my code to save the solution

{  
ofstream file(“u\_EXACT.txt”);  
for (int j = 0; j \< u[].n; j++)  
file \<\< u[][j]\<\< endl;

}

---

<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:** [April 4, 2022, 3:28pm UTC](https://community.freefem.org/t/print-the-solution-at-points/1643/2 "2022-04-04T15:28:42Z")

</div>

Remark, what is a node for you, if a node as a DoF (degree of freefem++) you print the correct thing, but  
iT depend of the type on your finite element`  
for (P1) your get value a vertex,  
for (P2) the value are Vertex and middle edge with a strange numbering.  
for other you can more complexe stuff.

---

<div class="post-metadata">

**Author:** ![omar](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/omar/32/1074_2.png) [@omar](https://community.freefem.org/u/omar)\
**Post date:** [April 4, 2022, 3:52pm UTC](https://community.freefem.org/t/print-the-solution-at-points/1643/3 "2022-04-04T15:52:52Z")

</div>

Thanks a lot. That solved the issue. I was using P2. When I used P1 I got only vertices with correct numbering.

---

<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:** [April 4, 2022, 4:14pm UTC](https://community.freefem.org/t/print-the-solution-at-points/1643/4 "2022-04-04T16:14:14Z")

</div>

So what you want the value at vertices only, or get the value of the coordinate of middle edge.

if you do this:

```auto
mesh Th=square(3,3);
fespace Vh(Th,P2);
Vh u = x*x+y*y; // just for the test 

int[int] I(Vh.ndof),II(Vh.ndof);
I=-1; 
II=-1; 
for(int k=0; k< Th.nt; ++k)
  for(int j=0; j<6; ++j)
    {
       int dof = Vh(k,j); // dof number of dof j ok k
       // the 3 first dof are 3 vertices
       // the 3 first dof one 3 edges
       if( j <3 ) I[dof] =Th[k][j]; // the vertex number 
       else { //on edge e =j-3 
	       int e = j-3; 
	       int i1 = (e+1)%3,i2=(e+2)%3; // vertex of edeg on triangle
	       int j1= Th[k][i1],j2= Th[k][i2]; // the 2 vertex number of edge 
	       if( j2 < j2) swap(j1,j2); 
	       I[dof] =j1; 
	       II[dof] =j2;
       }
    }
    
    for(int dof =0; dof< I.n;++dof)
    cout << dof << " :: " << I[dof] << " " << II[dof] << endl; 

```

to find the numbering !!!
