dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23270
Re: [Bug 783857] Re: uBLASSparseMatrix data deleted when object goes out of scope
This is inheritly difficult as I do not know of any way to "attach" the
original Matrix to the generated data arrays. We do this other places, like
when we down_cast a Matrix. Then we store a reference on the down_casted
matrix so the latter will not go out of scope when no references are pointing
to the parent matrix.
But it is a bit trickier with this case, as the NumPy arrays are generated in
a C++ layer outside the C++ Matrix class. In this method we do not know
anything about the host Python object. This means that we cannot store a
reference to the host Python object to the generated NumPy arrays. One could
hypothetize that we could attach the host object after the NumPy arrays were
generated, but a NumPy array does not support setting arbitrary attributes.
I do not see any straight forward solution to this.
Johan
--
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/783857
Title:
uBLASSparseMatrix data deleted when object goes out of scope
Status in DOLFIN:
New
Bug description:
This bug is similar to https://bugs.launchpad.net/dolfin/+bug/747273
The following code produces the output:
0.0333333333333
1.8218374251e-316
I.e. after deleting the uBLASSparseMatrix object the data members are
freed even though there are other references to the data.
from dolfin import *
mesh = UnitTetrahedron()
V = FunctionSpace(mesh, "Nedelec 1st kind H(curl)", 1)
u = TrialFunction(V)
v = TestFunction(V)
m = inner(v,u)*dx
M = uBLASSparseMatrix()
assemble(m, tensor=M)
row,col,data = M.data()
print data[0]
del M
import gc
gc.collect()
print data[0]
References