Automatic Differentiation for step-74 - get_average_of_gradients_from_local_dof_values

45 views
Skip to first unread message

Nik Markus Leuenberger

unread,
Aug 5, 2025, 7:18:13 AMAug 5
to deal.II User Group
Dear all,

I have a question regarding an *extension* of step.74. 

Eventually, I would like to solve a non-linear Poisson equation using DG elements. I would also like to use automatic differentiation to obtain the Jacobian from the Residual as in step-72. 

To start, I wanted to solve the linear problem as if it was non-linear using a single Newton iteration.

For the cell_worker and boundary_worker, I was able to use calls like the following 

std::vector<ADNumberType> old_solution_values(fe_fv.n_quadrature_points);
fe_fv[u_fe].get_function_values_from_local_dof_values(dof_values_ad, old_solution_values);

std::vector<Tensor<1, dim, ADNumberType>> old_solution_gradients(fe_fv.n_quadrature_points);
fe_fv[u_fe].get_function_gradients_from_local_dof_values(dof_values_ad, old_solution_gradients);

to then assemble the residual and automatically compute the Jacobian. The full code is appended.

For the face_worker, however, I think I would need functions like
std::vector<Tensor<1, dim, ADNumberType>> old_average_of_gradients(fe_fv.n_quadrature_points);
fe_iv[u_fe].get_average_of_gradients_from_local_dof_values(dof_values_ad, old_average_of_gradients);

Since I didn't find these functions, I think they might not exist yet.

Therefore my question. 
- If these functions don't exist, what alternative approach do you see to get the desired average of gradients of the old solution vector?

Thank you very much in advance for any help and best regards,
Nik
main.cc

Nik Markus Leuenberger

unread,
Aug 6, 2025, 7:50:33 AMAug 6
to deal.II User Group
Dear all,

I apologize for my question sent once again too early - the requested functions have of course already been implemented (see https://github.com/dealii/dealii/pull/12603 for anyone interested). 

I am currently trying to use this to implement a DG solver for the steady-state Porous medium diffusion equation (https://en.wikipedia.org/wiki/Porous_medium_equation) and will be happy to share the code if I succeed.

Thank you very much for your understanding and best regards,
Nik

Wolfgang Bangerth

unread,
Aug 6, 2025, 2:02:26 PMAug 6
to dea...@googlegroups.com
On 8/6/25 05:50, Nik Markus Leuenberger wrote:
>
> I am currently trying to use this to implement a DG solver for the steady-
> state Porous medium diffusion equation (https://en.wikipedia.org/wiki/
> Porous_medium_equation) and will be happy to share the code if I succeed.

As always, we'd love to take people's code as part of the code gallery if you
were willing!

Best
W.
Reply all
Reply to author
Forward
0 new messages