LUSolver assumes repeated use of a single matrix

Bug #1043715 reported by James Maddison
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dolfin-adjoint
Fix Committed
Undecided
Unassigned

Bug Description

The dolfin-adjoint LUSolver assumes that a single matrix is used repeatedly. The following example:

#!/usr/bin/env python
from dolfin import *
from dolfin_adjoint import *
mesh = Rectangle(0.0, 0.0, 1.0, 1.0, 10, 10)
space = FunctionSpace(mesh, "CG", 1)
mass = assemble(inner(TestFunction(space), TrialFunction(space)) * dx)
rhs = assemble(inner(TestFunction(space), Constant(1.0)) * dx)
F = Function(space)
solver = LUSolver()
solver.solve(mass, F.vector(), rhs)
print assemble(F * dx)

leads to the error:

Original exception was:
Traceback (most recent call last):
  File "./dolfin-adjoint_bug_lusolver", line 9, in <module>
    solver = LUSolver()
  File "/usr/lib/python2.7/dist-packages/dolfin_adjoint/lusolver.py", line 57, in __init__
    self.operator = args[0].form
IndexError: tuple index out of range

while:

#!/usr/bin/env python
from dolfin import *
from dolfin_adjoint import *
mesh = Rectangle(0.0, 0.0, 1.0, 1.0, 10, 10)
space = FunctionSpace(mesh, "CG", 1)
mass = assemble(inner(TestFunction(space), TrialFunction(space)) * dx)
rhs = assemble(inner(TestFunction(space), Constant(1.0)) * dx)
F = Function(space)
solver = LUSolver(mass)
solver.solve(mass, F.vector(), rhs)
print assemble(F * dx)

leads to the error:

Original exception was:
Traceback (most recent call last):
  File "./dolfin-adjoint_bug_lusolver", line 10, in <module>
    solver.solve(mass, F.vector(), rhs)
  File "/usr/lib/python2.7/dist-packages/dolfin_adjoint/lusolver.py", line 84, in solve
    raise libadjoint.exceptions.LibadjointErrorInvalidInputs("The annotated LUSolver.solve must be called like solve(x, b).")
libadjoint.exceptions.LibadjointErrorInvalidInputs: The annotated LUSolver.solve must be called like solve(x, b).

Each of these is valid when used with dolfin.

Changed in dolfin-adjoint:
status: New → Fix Committed
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.