strange caching bug when importing blocks

Issue #733 invalid
Florian Bruckner created an issue

I recently noticed a strange problem, where the results of my calculations changed if a added a line to the code which only creates a new Function. I tried to locate the problem and came up with the following testcode:

from dolfin import *
from block import * # BUG vanishes if block is not included

mesh = UnitCubeMesh(2,2,2)

V = VectorFunctionSpace(mesh, "CG", 1)
u = TrialFunction(V)
v = TestFunction(V)
A = assemble(2.*inner(u,v)*dP)

v1 = Function(V).vector()
v2 = Function(V).vector()

v1[0] = 123
v2[0] = 234

res1 = Function(V, A*v1) # BUG vanishes if A* is removed
res2 = Function(V, A*v2) # BUG vanishes if A* is removed

print res1.vector()[0]
print res2.vector()[0]

res1.vector()[0] = 1234
print res1.vector()[0]
print res2.vector()[0]

The output should be 123 and 234 at first and then 1234 and 234, but I always get the same value in both vectors. It somehow seems to use the same data array. The problem disappears if is comment out the 'import blocks' statement, or if I don't do the matrix vector multiplication.

greetings FloB

Comments (1)

  1. Log in to comment