Initialize mesh from list of vertices, connectivities at once
Issue #845
new
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)
-
-
-
assigned issue to
-
assigned issue to
-
- changed milestone to 2017.2
-
- changed milestone to 2018.1
- changed title to Initialize mesh from list of vertices, connectivities at once
Pushing this back to 2018.1 since it will be a lot easier with pybind11 than with SWIG (due to pybind11 support for NumPy).
-
reporter - edited description
- Log in to comment
It would be relatively easy to do this, at least in serial.