I am trying to find the coordinates of an element in netgen.

So far, I found that I can get a list of all elements in a mesh using “mesh.Elements3D()” and each item in the list seems to be the number of points in the element followed by the indices of the points. Each element has two properties “points” and “vertices”, but they are again the indices of the points/vertices.

Is there a way to find the coordinates of the vertices of an element, or the coordinates of a point having a particular point index?

you can get the points of the mesh using “mesh.Points()” and use the indices of the points to get the coordinates.

from netgen.csg import unit_cube
mesh = unit_cube.GenerateMesh(maxh=0.5)
pnts = mesh.Points()
for i,el in enumerate(mesh.Elements3D()):
print("el = ",i)
for v in el.vertices:
print(pnts[v])

you have to loop over the 2D elements. Then you can check the boundary index and you have number and coordinate of the point available.

for i,el in enumerate(mesh.Elements2D()):
print("surface el = ",i)
print("surface index = ",el.index)
for v in el.vertices:
print(pnts[v])

If you are using NGSolve, you can also do this on the NGSolve mesh, which might be handier for you.

from ngsolve import *
mesh = Mesh(mesh) # convert to NGSolve mesh
for el in mesh.Elements(VOL):
print("el = ",el.nr)
for v in el.vertices:
print(mesh[v].point)
for el in mesh.Elements(BND):
print("surface el = ",el.nr)
print("surface index = ",el.index)
for v in el.vertices:
print(mesh[v].point)

When you are solving problems with NGSolve, I would strongly recommend to name you boundaries and use these names when defining your problem. Something about boundaries in the docu.