← Back to team overview

dolfin team mailing list archive

Re: [Bug 702372] [NEW] BlockMatrix and deleted matrices

 

It was a while we had the problem of object getting out of scope, especially 
after we got the shared_ptr interface going. It think we are up for some heavy 
coding if we are introducing shared_ptrs (or some other smart_pointer) for the 
linear algebra objects. 

Eventhough your patch fixes the problem in DOLFIN I am not sure we want the 
extra complication od the view flag. I just added a place holder in the python 
interface for the Foo object fixing the out of scope problem. A hack, but a 
quite non intrucive one.

Johan

On Thursday January 13 2011 06:22:26 Joachim Haga wrote:
> Public bug reported:
> 
> The following code crashes, unless "del A" is commented out. I don't
> know the memory handling strategy in dolfin, (boost::shared_ptr is used
> in some places, but not consistently?) but attached is a patch which at
> least removes the crash by making private copies of the matrices (and
> vectors in BlockVectors).
> 
> from dolfin import *
> 
> mesh = UnitSquare(4, 4)
> V = FunctionSpace(mesh, "CG", 1)
> u,v = TrialFunction(V), TestFunction(V)
> 
> a = u*v*dx
> 
> AA = BlockMatrix(1,1)
> 
> A = assemble(a)
> AA[0, 0] = A
> 
> del A
> 
> print AA[0,0]
> 
> ** Affects: dolfin
>      Importance: Undecided
>          Status: New

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

Title:
  BlockMatrix and deleted matrices

Status in DOLFIN:
  New

Bug description:
  The following code crashes, unless "del A" is commented out. I don't
  know the memory handling strategy in dolfin, (boost::shared_ptr is
  used in some places, but not consistently?) but attached is a patch
  which at least removes the crash by making private copies of the
  matrices (and vectors in BlockVectors).

  from dolfin import *

  mesh = UnitSquare(4, 4)
  V = FunctionSpace(mesh, "CG", 1)
  u,v = TrialFunction(V), TestFunction(V)

  a = u*v*dx

  AA = BlockMatrix(1,1)

  A = assemble(a)
  AA[0, 0] = A

  del A

  print AA[0,0]





References