# Re: [deal.II] Accessing nodal values of a FEM solution

```>
> We need to update function v based on solution u in the following loop.
>
> for ( x in vector_of_nodal_points )
>   v(x) = f(x, u(x))
>
> where v(x) and u(x) are the nodal point value for functions v and u,
> respectively, and f() is some function depending on function u as well as
> the location of the nodal point. So in this case, we need to access nodal
> point coordinates and nodal point values of the solution in the same loop.
>```
```
You can just loop over all degrees of freedom and do

for (unsigned int i=0; i<n_dofs; ++i)
v(i) = f(map_dof_to_support_points[i], u(i))

or loop over the cells yourself and do

FEValues fe_values (..., q, update_q_points);
for (const auto& cell)
...
for (unsigned int i=0; i<n_dofs_per_cell;  ++i)
v(local_dof_indices[i]) = f(points[i],  u(local_dof_indices));

(also see

> Well, the above function calculates the gradients of a finite element at
> the quadrature points of a cell, not at the nodal points of a cell.
> Such a need arises in the following situation.
>
> for ( x in vector_of_nodal_points )
>   v(x) = g(x, u(x), grad u(x))
>

You can do similarly,

FEValues fe_values (..., q, update_q_points);
for (const auto& cell)
...
fe_values.get_function_values(values);
for (unsigned int i=0; i<n_dofs_per_cell;  ++i)

Best,
Daniel

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see