dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #17746
Re: Passing arrays from Python
On Sat, Feb 27, 2010 at 06:32:12PM +0000, Garth N. Wells wrote:
> How do I pass the pointer to the first element of an array from the
> Python interface to a wrapped C++ function? I would like to tabulate the
> dofs of a cell, so I tried
>
> local_facet = cell.index(facet)
> dofs = numpy.array(9, dtype=numpy.uint32)
> dof_map.tabulate_facet_dofs(dofs, local_facet)
>
> but I get a bunch of memory errors. I don't know to correctly allocate
> 'dofs' such that I can pass it to tabulate_facet_dofs.
Try this:
cell_dofs = numpy.zeros(n, dtype='I')
It has worked for me before. Also note that there are dolfin::Cell
functions for some (but not all) of the functions in DofMap which
allows access from Python without needing to create a ufc::cell.
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References