[petsc-users] petsc4py KSP Question
Gaetan Kenway
kenway at utias.utoronto.ca
Tue Mar 6 17:22:15 CST 2012
Hello
I'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'm now doing the linear solution.
For the non-linear solve, I create the snes and set my user context as
follows:
# Create SNES Object
ASContext = ASNKSolver(self) # Context to hold data
snes = PETSc.SNES().createPython(ASContext, comm=self.gcomm)
snes.setFunction(ASContext.formFunction, resVec)
For the linear part, I'm a little confused. I currently have
# Create Python Context and KSP Object
KSPContext = AdjointKSPSolver(self) # Context to hold data
ksp = PETSc.KSP().createPython(KSPContext, comm=self.gcomm)
What I'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?
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?
Thank you,
Gaetan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120306/01c4a046/attachment.htm>
More information about the petsc-users
mailing list