Is it possible to access nodal point values of a solution in deal.ii? And is it possible to revise nodal values of a solution pointwise?
The tutorial examples show only how to access values of the solution at the quadrature points within each cell.
On 7/19/20 6:28 PM, Daniel Arndt wrote:
>
> The tutorial examples show only how to access values of the solution at
> the quadrature points within each cell.
>
> https://github.com/dealii/dealii/wiki/Frequently-Asked-Questions#how-to-get-the-mapped-position-of-support-points-of-my-element
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdealii%2Fdealii%2Fwiki%2FFrequently-Asked-Questions%23how-to-get-the-mapped-position-of-support-points-of-my-element&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cc61491e1703e46c5be0f08d82c43defe%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637308017305040965&sdata=TM3AYA4IqcrckUMqRTWfCJWUz3MGrUx%2FRFGvRrsg40Y%3D&reserved=0>
> might also be helpful.
You might also be interested in looking at the do_half_phase_step() function
of step-58:
https://dealii.org/developer/doxygen/deal.II/step_58.html#ImplementingtheStrangsplittingsteps
Best
W.
However, I have two more related questions. BTW, I am a newbie in C++ programming. So my questions may seem absurd.
- Now that we have a vector holding all nodal point coordinates, and another vector holding all nodal point values of the solution. How do we access every nodal point coordinates, and at the same time, the associated nodal point value within the same loop?
- In addition to nodal point values of a solution, are the partial derivatives (or gradient) of the solution at each nodal point available in deal.ii?
However, I have two more related questions. BTW, I am a newbie in C++ programming. So my questions may seem absurd.
- Now that we have a vector holding all nodal point coordinates, and another vector holding all nodal point values of the solution. How do we access every nodal point coordinates, and at the same time, the associated nodal point value within the same loop?
Can you clarify in a short pseudocode example what you are trying to achieve?
- In addition to nodal point values of a solution, are the partial derivatives (or gradient) of the solution at each nodal point available in deal.ii?
That's basically what DataPostprocessor is doing. In general, you can loop over all cells and calculate the derivatives locally. Have a look at FEValuesBase::get_function_gradients (https://www.dealii.org/current/doxygen/deal.II/classFEValuesBase.html#ad1f4e0deb5d982e8172d82141c634a67).
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.
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,Quadrature q(fe.get_unit_support_points());
FEValues fe_values (..., q, update_q_points);for (const auto& cell)...points = fe_values.get_quadrature_points();fe_values.get_function_values(values);fe_values.get_function_gradients(gradients);for (unsigned int i=0; i<n_dofs_per_cell; ++i)v(local_dof_indices[i]) = f(points[i], values(i), gradients(i));
On 7/23/20 12:07 PM, Xuefeng Li wrote:
>
> 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))
It's worth pointing out, however, that for the common FE_Q elements, the
function values u(x) are continuous and so it doesn't matter how exactly you
compute u(x) at node points. On the other hand, grad u(x) is in general
discontinuous and so trying to evaluate it at node points is not actually
possible: You will either get the values from one adjacent cell or the value
from another.
In other words, if you want to compute a function that depends on 'grad u',
you need to think about what exactly you mean by that. In the formulation
above, v(x) will in general be a discontinuous function, and you need to think
about whether using FE_Q (a continuous finite element space) is really what
you want to do.
Best
W.