I'd like to precondition a linear solve $Ax=b$ with the inverse of another linear operator $B$. Is there a way to define preconditioning objects in Python with FEniCS?
Yes, look at the class KrylovSolver and in particular the function
set_operators(A, P)
Check stokes-iterative demo for example.
stokes-iterative
The documentation of KrylovSolver is a bit unclear here. With the preconditioner P, are we solving $PAx=Pb$, $P^{-1}Ax = P^{-1}b$, or are we talking about a right preconditioner altogether? How are the systems $P^{-1}$ solved/approximated, and how can I influence the solution parameters?
KrylovSolver
P
I think this works differently. By set_operators(A, P) you just supply $A$ and $P\approx A$ or (typically $P=A$) which is used in a construction of actual preconditioning $Q^{-1}Ax=Q^{-1}b$ or $AQ^{-1}Qx=b$. Operator $Q\approx P$ is constructed by actual preconditioning algorithm outside of DOLFIN.
Use PETScUserPreconditioner. You just supply method for calculation of values of mapping $b\rightarrow B^{-1}b$.
PETScUserPreconditioner