Ok, I’ll do that!
Yes, of course I will share my solution. The system matrix and rhs assemble have to look like this:
# assemble system matrix
K = assemble_matrix(jac, dbcs)
K.assemble()
# assemble rhs vector
r = assemble_vector(varform)
apply_lifting(r, [jac], [dbcs], x0=[u.vector], scale=-1.0)
r.ghostUpdate(addv=PETSc.InsertMode.ADD, mode=PETSc.ScatterMode.REVERSE)
set_bc(r, dbcs, x0=u.vector, scale=-1.0)
The apply_lifting and the way to call set_bc like this also work if there are non-homogeneous DBCs present. One does not have to manually create a homogeneous version or call dbc.homogenize.
Solving the linear system then should be called like this:
# solve linearized system
solve(K, del_u.vector, -r)
# update solution
u.vector.axpy(1.0, del_u.vector)
u.vector.ghostUpdate(addv=PETSc.InsertMode.INSERT, mode=PETSc.ScatterMode.FORWARD)
where the ghostUpdate on u is essential for parallel functionality.
Bw,
Marc