How to use and set petsc options for compute_gradient?

Hi,

I have noticed that when I use a custom PETSc solver in my forward solver, for example:

solver = PETScKrylovSolver("cg", "jacobi") 
solver.set_from_options() 
solver.solve(A, u.vector(), b) #Solve forward problem

subsequent compute_gradient calls using the solution of my forward solve uses a petsc_krylov solver. Having looked at the source code within fenics_adjoint/petsc_krylov_solver.py I have been able to edit the solver settings manually. However I would like to know if there if

  1. it is possible to force compute_gradient to use a PETSc krylov solver (normally if the forward solver uses the black box method of solve(a==L,.....), compute_gradient will not use a PETSc solver)?
  2. it is possible change the PETSc solver settings used by compute_gradient without manually editing the source code?

Cheers,
Kiri