On Thu, Dec 11, 2008 at 08:08:46PM +0100, Johan Hake wrote: > 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
Correct.
Until this has been fixed, one needs to work with the iterators which
are mapped correctly to Python. So you may for example to
for cell in cells(mesh):
for vertex in vertices(cell):
for edge in edges(vertex):
print edge.index()
etc.
--
Anders
signature.asc
Description: Digital signature
_______________________________________________ DOLFIN-dev mailing list [email protected] http://www.fenics.org/mailman/listinfo/dolfin-dev
