← Back to team overview

dolfin team mailing list archive

Constructing your own mesh vertices/cells

 

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?

Thanks
Neilen



Follow ups