matrix-free PETScKrylovMatrix works in 1.0, but is broken in fenics-dev

Bug #922042 reported by Patrick Farrell
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DOLFIN
Fix Released
High
Johan Hake

Bug Description

Consider the following snippet (due to Christian Clason):

#####
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())

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

KrylovSolver = PETScKrylovSolver("cg","none")
KrylovSolver.solve(KrylovMatrix(), x_petsc, down_cast(b))

print (y.vector()-x_petsc).norm("l2")
#####

This code works with Dolfin from the fenics PPA:

[pef@doodson:/tmp]$ dpkg -l python-dolfin
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=====================================================-=====================================================-==========================================================================================================================
ii python-dolfin 1.0.0-2~ppa1~natty1 Python interface for DOLFIN
[pef@doodson:/tmp]$ python testMatrixFreeKrylov.py
1.93697136644e-08

but fails with Dolfin from the fenics-dev PPA:

[pef@caoimhe:/tmp]$ dpkg -l python-dolfin
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Description
+++-=====================================================-=====================================================-==========================================================================================================================
ii python-dolfin 1.0.0-2+bzr6524~ppa1~maverick1 Python interface for DOLFIN
[pef@caoimhe:/tmp]$ python testMatrixFreeKrylov.py
Traceback (most recent call last):
  File "testMatrixFreeKrylov.py", line 23, in <module>
    KrylovSolver.solve(KrylovMatrix(), x_petsc, down_cast(b))
  File "testMatrixFreeKrylov.py", line 15, in mult
    A.mult(args[0],y)
TypeError: in method 'GenericMatrix_mult', argument 2 of type 'dolfin::GenericVector const &'

Johan Hake (johan-hake)
Changed in dolfin:
status: New → Confirmed
milestone: none → trunk
assignee: nobody → Johan Hake (johan-hake)
Johan Hake (johan-hake)
Changed in dolfin:
importance: Undecided → High
status: Confirmed → Fix Committed
Changed in dolfin:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.