← Back to team overview

dolfin team mailing list archive

Re: Constructing your own mesh vertices/cells

 

On Monday March 14 2011 04:36:29 Neilen Marais wrote:
> Hi,
> 
> I've started using dolfin in my code. For now I'm only replacing some
> low level routines with dolfin code, particularly the calculation of
> mesh connectivity. Since I already read meshes (i.e. vertice
> coordinates and element vertices) from a simple private format, I've
> taken to constructing a dolfin mesh like this:
> 
> import dolfin as dol
> 
> mesh = dol.Mesh()
> me = dol.MeshEditor()
> # 'tetrahedron' ==
> dol.cpp.CellType.type2string(dol.cpp.CellType.tetrahedron)
> me.open(mesh,'tetrahedron', 3, 3)
> me.init_vertices(4)
> me.init_cells(1)
> mesh.coordinates()[:,:] = [[ 0.,  0.,  0.],
>                            [ 1.,  0.,  0.],
>                            [ 0.,  1.,  0.],
>                            [ 0.,  0.,  2.]]
> mesh.cells()[:,:] = [[0, 1, 2, 3]]
> me.close()
> mesh.init()
> 
> 
> So far it seems to work, but since this doesn't seem to be recommended
> in any of the documentation I'd just like to know if I'm going to run
> into trouble down the line?

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.

Johan

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