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
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
- it is possible to force compute_gradient to use a PETSc krylov solver (normally if the forward solver uses the black box method of
compute_gradientwill not use a PETSc solver)?
- it is possible change the PETSc solver settings used by compute_gradient without manually editing the source code?