dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #03778
Re: passing functions
On Thu, Nov 16, 2006 at 12:27:19PM +0100, jjan@xxxxxxxxxxx wrote:
> > I think I know what goes wrong now...
> >
> > The problem is the current design of the DiscreteFunction class. It
> > keeps pointers to a Vector, a Mesh and a FiniteElement and gets
> > confused about who actually owns the data.
> >
> > Here's a simple example to illustrate this:
> >
> > BilinearForm a;
> > Function f(x, mesh, a.trial());
> > // BilinearForm a goes out of scope somehow and deletes its element
> > // Function f tries to use the FiniteElement which is deleted
> >
> > We've discussed using smart pointers for the data in the class
> > DiscreteFunction before and that should do the trick. Does someone
> > have time to look into this?
> >
> > /Anders
> >
>
> The same problem arises in Python when you want this type of concept:
>
> def foo():
>
> x = Vector()
> f = Function(x)
>
> return f
>
> so we do need some general concept of transferring ownership. Smart
> pointers would solve this problem as well as far as I can see. I don't
> have a lot of time, but I can take responsibility for this if nobody else
> volunteers.
>
> Johan
Very good. I'll help out.
/Anders
References