Hi Nik,
> My question is: for boundary_worker. What am I missing that the calculated residual contributions
don’t show up in the global RHS of the system?
I think that I might have an idea as to what's going on here. I feel that the problem likely lies with what these lines
Vector<double> &cell_rhs = copy_data.cell_rhs;
...
ad_helper.compute_residual(cell_rhs);
do in unison, versus the
that you have in the hand written assembly code. Normally you'd be accumulating into the cell RHS/matrix (as you've demonstrated), but the compute_residual/linearization functions don't do this. Instead, they overwrite the local matrix/vector (although its a little deep into the AD framework, you can see this here
https://github.com/dealii/dealii/blob/master/source/differentiation/ad/ad_drivers.cc#L1836-L1854). This is incompatible with the meshloop() framework as it reuses the same local matrices and vectors on a cell and its faces before scattering their contributions to the global linear system.
What you could do as a workaround is to simply create an intermediate local matrix and RHS vector in each of the workers, have the ADHelper write into those, and then accumulate the result into the data structures in copy_data.
I hope that my thoughts were on the right track, and that this helps. If it does, then this would motivate the addition of a set of functions along the lines of
ad_helper.accumulate_residual(copy_data.cell_rhs, -1.0 /* factor */);
ad_helper.accumulate_linearization(copy_data.cell_matrix);
that would work better with mesh_loop(). We'd be happy to accept any patches that help to realize this functionality!
Best,
Jean-Paul