Convert netgen mesh to numpy arrays?

Is there an efficient way to extract or convert a netgen mesh to numpy arrays in Python. I’m currently using the following

[code]p = mesh.Points()
vertices = np.empty(shape=(len(p), 3), dtype=‘float32’)
for i, p_i in enumerate(p):
vertices[i] = list(p_i)

faceels = mesh.Elements2D()
faces = np.empty(shape=(len(faceels), 3), dtype=‘uint32’)
for i, el in enumerate(faceels):
faces[i] = [ for p in el.points]

which isn’t very efficient. Is there a better way?

Is there anyone who can comment on this (is it possible at all?), or point out something in the documentation (as I couldn’t find anything about this)?

Hm depends what you want to get from python with regards to efficiency, but you could write it more compact and more efficient like this:

from netgen.geom2d import unit_square
mesh = unit_square.GenerateMesh(maxh=0.2)

import numpy as np
# verts = np.array([v.point for v in mesh.vertices])
verts = np.array([list(p) for p in mesh.Points()])
els = np.array([el.vertices for el in mesh.Elements2D()])