Subject: [Bug 768233] Re: PETScUserPreconditioner does not work with PETScKrylovMatrix
** Branch linked: lp:~dolfin-core/dolfin/hake-trunk

--
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/768233

Title:
PETScUserPreconditioner does not work with PETScKrylovMatrix

Status in DOLFIN:
In Progress

Bug description:
There seems to be a problem with passing matrix-free preconditioners
to PETSc: The combination of PETScKrylovMatrix and
PETScUserPreconditioner fails with the following error:

[0]PETSC ERROR: No support for this operation for this object type!
[0]PETSC ERROR: Matrix format shell does not have a built-in PETSc direct
solver!

Here's a minimal example which triggers the error:

from dolfin import *

mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, 'CG', 1)
bc = DirichletBC(V, Constant(0.0), lambda x, on_boundary: on_boundary)
u = TrialFunction(V); v = TestFunction(V);
A, b = assemble_system( inner(grad(u), grad(v))*dx, Constant(1.0)*v*dx, bc)

class KrylovMatrix(PETScKrylovMatrix) :
def __init__(self) :
PETScKrylovMatrix.__init__(self, V.dim(), V.dim())

def mult(self, *args) :
y = PETScVector(V.dim())
A.mult(args[0],y)
args[1].set_local(y.array())

class IdentityPreconditioner(PETScUserPreconditioner) :
def __init__(self) :
PETScUserPreconditioner.__init__(self)

def solve(self, *args) :
args[0].set_local(args[1])

y = Function(V)
solve(A,y.vector(),b)
x_petsc = PETScVector(V.dim())

MyPrecon = IdentityPreconditioner()
KrylovSolver = PETScKrylovSolver("cg", MyPrecon)

KrylovSolver.solve(KrylovMatrix(), x_petsc, down_cast(b)) # fails
KrylovSolver.solve(A, x_petsc, down_cast(b)) # works

To manage notifications about this bug go to:
https://bugs.launchpad.net/dolfin/+bug/768233/+subscriptions

(C)2011 mailinglist-archive.com