← Back to team overview

dolfin team mailing list archive

Re: mesh entities in python

 

On Thursday 11 December 2008 19:28:23 Bartosz Sawicki wrote:
> Hi,
>
> I'm new in Swing and python bindings, so maybe answer to my question
> will be trivial. Could you please tell me, if it is possible to access
> into mesh entities from python. For example:
>
> c = Cell(mesh, 111)
> print c.numEntities(0)
> ent = c.entities()
> print ent
>
> gives output:
>
> 4
> <Swig Object of type 'dolfin::uint *' at 0x3a26fb8>
>
> According to the documentation I expect that entities method "Return
> array of indices ". 'dolfin::uint *' is propably pointer to array, but
> ent[0] fails with "'int' object is unsubscriptable" error.
> So how can I get elements for this array?

Hello Bartek!

Not all of the DOLFIN interface is mapped correctly to PyDOLFIN. For example 
are there, as you correctly observed, some issues with pointers to C-arrays.

To access what vertices are included in a particular cell you can look at

  cells = mesh.cells()

For a tetrahedral mesh, this will return a numpy.array with 

  shape = (mesh.numCells(),4)

What I would like to map to the PyDOLFIN interface includes the topological 
connection information. This would be feasable but has not yet been done.

Johan

> regrd.
> BArtek
>
>
>
>
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev




Follow ups

References