Custom Newton Solver problem with Dirichlet conditions

Or use this with a PETScSNESSolver where you can get access to the underlying SNES (which I assume is what you want).