← Back to team overview

dolfin team mailing list archive

Re: Constructing your own mesh vertices/cells

 

On Monday March 14 2011 08:44:19 Neilen Marais wrote:
> Johan,
> 
> On Mon, Mar 14, 2011 at 5:21 PM, Johan Hake <johan.hake@xxxxxxxxx> wrote:
> > On Monday March 14 2011 04:36:29 Neilen Marais wrote:
> > If you have an already tetrahedralized structure, typically given by a
> > coordinate array and an array of conductivities between cells and
> > vertices, you can use MeshEditor. That is what MeshEditor really is for.
> > 
> > 
> > I think the advice of not using MeshEditor is when you use it to
> > construct the vertices and connectivities by hand.
> 
> I guess I'm just worrying about performance in python, since I would
> have to do one method call for each vertex and one for each tet. I may
> be prematurely optimising here, but IIRC even method calls to SWIG
> wrapped C++ classes have a fair amount of overhead. Since I already
> have the vertex coordinates and cell -> vertex connectivity data in
> arrays, it is obviously much faster to just stuff them directly into
> the dolfin structures?

Sure you are right that it might come with some overhead. Not sure it will be 
significant though, as this would probably be a one time thing?

But after reading your post one more time I realize what you asked for :P, and 
the answer is yes! You can perfectly do what you did. mesh.cells() and 
mesh.coordinates() each return a NumPy array view of the actuall data. Your 
syntax works because NumPy allows it.

I would do this in a separate script once for each mesh, and then save it to 
file so you do not have to do this each time you read in a mesh.

Johan

> > Johan
> 
> Best regards
> Neilen
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References