On Mon, 10 Mar 2014 09:55:57 +0100 Johan Hake <[email protected]> wrote:
> On Mon, Mar 10, 2014 at 9:27 AM, Jan Blechta > <[email protected]>wrote: > > > On Mon, 10 Mar 2014 08:11:10 +0100 > > Johan Hake <[email protected]> wrote: > > > > > There are no way of passing the data without copying the values > > > from the NumPy array to the std containers. The reason is that > > > there are AFAIK not way of initializing these structures with > > > external data and that is why we have added our own Array<Foo> > > > wrapper of a contiguous array. > > > > Are data copied when initializing dolfin::Array<Foo> from numpy > > array? If so, who owns the pointer Foo*? When is it destroyed? > > > > It is pretty clear by reading the code. Array comes with two > constructors one that owes (and creates its data) and one that takes > an external data pointer and does not take ownership. Yeah, I understand Array.h. Not so much the typemaps. > > > > If data are not copied and Foo* points to data within numpy array, > > user must take care for numpy array not to be garbage collect, > > mustn't he? > > > > Yes, but Array is mostly used to pass data in or out of methods. It > is not used to store any data, which means that once the Array with > the NumPy data is passed to DOLFIN it is destroyed. This all happens > inside the Array<Foo>& typemap. As far as I understand it, IN typemap works without copying but care must be taken not to destroy numpy array with data prematurely (if dolfin::Array is to be stored). On the other hand, OUT typemap copies the data. Am I correct? Thanks, Jan > > Johan _______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
