Initialize mesh from list of vertices, connectivities at once

Issue #845 new
Nico Schlömer created an issue

Since the question on the QA site has received a bunch of upvotes, I thought it might suggest here as an enhancement to initialize a Dolfin mesh from vertex coordinates and connectivity directly.

Two possible workarounds:

Using MeshEditor:

editor = MeshEditor()
mesh = Mesh()
editor.open(mesh, "triangle", 2, 2)
editor.init_vertices(self.points.shape[0])
editor.init_cells(self.cells.shape[0])
for k, point in enumerate(self.points):
    editor.add_vertex(k, point[:2])
for k, cell in enumerate(self.cells):
    editor.add_cell(k, cell)
editor.close()

Using an XML file:

meshio.write('test.xml', points, cells)
mesh = Mesh('test.xml')

but certainly this isn't optimal.

Comments (5)

  1. Log in to comment