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.


> 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.

Johan
_______________________________________________
fenics mailing list
[email protected]
http://fenicsproject.org/mailman/listinfo/fenics

Reply via email to