Usage of the AD framework for solving a time-dependent equation

19 views
Skip to first unread message

Maxi Miller

unread,
Dec 8, 2019, 11:01:52 AM12/8/19
to deal.II User Group
I tried to use the AD framework in my own codes (mainly for solving nonlinear equations), and therefore wrote a small test program for solving the linear diffusion equation (after I can calculate the jacobian by hand for that equation). Thus, my residual for the AD-jacobian is -0.5 * (\nabla u_1 + \nabla u_0)\cdot\nabla\varphi - \frac{1}{dt}(u_1 - u_0)\cdot\varphi, with u_0 my current solution, and u_1 my solution for the next step. When creating the jacobian by hand, I use the same approach as shown in example 33, and assume that u_1 = u_0 in my first step, resulting in -0.5\cdot(\nabla\varphi_i\cdot\nabla\varphi_j) - \frac{1}{dt}\cdot\varphi_i\cdot\varphi_j, and my right hand side is \nabla u_0\cdot\nabla\varphi.
Solving both systems should give me a value for \delta u, i.e. the update for my current solution, such that u_1 = \delta u + u_0 (after the system is linear).
Though, when running the code in the attachment, I get the correct result (i.e. \delta u) for my hand-assembled system, but the solution I get for the AD-generated jacobian is u_1, not \delta u. Did I misinterpret something, or is there another bug in the code?
Thanks!
main.cpp
Reply all
Reply to author
Forward
0 new messages