Hi there!

Is it possible to access values of a P1 function at the nodes and put them in an array?

Thank you.

Hi there!

Is it possible to access values of a P1 function at the nodes and put them in an array?

Thank you.

Finite element function can be automatically converted in array, you have to write:

```
fespace Uh(Th, P1);
Uh u = ...;
cout << u[] << endl;
cout << u[][5] << endl;
```

`u[]`

is the array of `u`

, `u[][5]`

is the 6th element of the array.

1 Like

Thank you for the quick answer.

I have another question. Given a mesh Th and a function u in Vh, how do I get the value of u at the node Th[i][j]?

The mesh node is obtained using `Th(i)`

(not `Th[i][j]`

, this is triangle `i`

, vertex `j`

, see documentation).

You have access to the value at node `i`

using `u[][i]`

, or alternatively `u(Th(i).x, Th(i).y)`

(using interpolation).