Hello <div><br></div><div>I&#39;m in the process of using petsc4py to solve a large multidisciplinary, non-linear system and its adjoint. I have the non-linear solution with snes() working correctly and I&#39;m now doing the linear solution. </div>
<div><br></div><div>For the non-linear solve, I create the snes and set my user context as follows:</div><div>   # Create SNES Object</div><div><div>  ASContext = ASNKSolver(self) # Context to hold data</div><div>  snes = PETSc.SNES().createPython(ASContext, comm=self.gcomm)</div>
</div><div>  snes.setFunction(ASContext.formFunction, resVec)</div><div><br></div><div>For the linear part, I&#39;m a little confused. I currently have</div><div><br></div><div><div>    # Create Python Context and KSP Object</div>
<div>    KSPContext = AdjointKSPSolver(self) # Context to hold data</div><div>    ksp = PETSc.KSP().createPython(KSPContext, comm=self.gcomm)</div><div><br></div><div>What I&#39;m not sure of is how to specify the operator for the KSP solver in the KSPContext object. Is this possible? Is there something like def apply() you must do?</div>
</div><div><br></div><div>The petsc4py poisson2d.py example, first creates a Mat, then sets a context for that, and then uses ksp.setOperators() to use that matrix. Is this the only way to do it? If, so, what is the use of the  PETSc.KSP().createPython() command?</div>
<div><br></div><div>Thank you,</div><div><br></div><div>Gaetan</div>