# Extracting boundary points

I’ve created a 2D disc which has a virtual boundary (h1 etc. are mesh sizes).

geo = SplineGeometry()
geo = Circle(geo, electrode_radius, 1, 0, 1, h1)
geo = Circle(geo, diel_radius,           2, 1, 0, h3)
geo = Circle(geo, electrode_radius, 4, 2, 0, h1)
mesh = geo.GenerateMesh(maxh=h4)
mesh.Save("annular_face.vol")

I would like to extract the points from the virtual boundary then use them to define the exact points along the edge of second disc (that will have a larger mesh in the centre).

How do I do that?

Hi andrew,
You can iterate over the boundary elements and get using their boundary number you can collect the vertex numbers of the boundary:

from netgen.geom2d import unit_square

mesh = unit_square.GenerateMesh(maxh=0.2)

for el in mesh.Elements1D():
# get boundary index
print(el.index)
# get name of boundary condition (one based)
print(mesh.GetBCName(el.index-1))
# get vertex numbers of element
print(el.vertices)
# get vertex coordinates
print([mesh[vert] for vert in el.vertices])

Best
Christopher

Thank you for the help. I can now extract the mesh points from a circular virtual boundary, and create a new meshed circle. My intention is that the mesh points along the perimeter should be at exactly the same locations as those of the original virtual boundary - but the mesh density at the centre of the new circle can be set differently. When I try to do this I find that the perimeter points are not the same.
[attachment=undefined]circles.png[/attachment]

If you have a moment to help me sort this out it would be much appreciated.

# Create concentric circles with virtual boundary

geo = SplineGeometry()

ngmesh = geo.GenerateMesh(maxh=h4)
ngmesh.Save(“annular.vol”)

# Extract points from virtual boundary and create a second mesh

geo2 = SplineGeometry()
nlist = []
for el in ngmesh.Elements1D():
# check boundary index is the right one (circle perimeter)
if el.index != 1: continue
x, y, z = ngmesh[el.vertices[0]]
nlist.append(geo2.AppendPoint(x,y))

nlen = len(nlist)
nlist.append(nlist[0])
for i in range(nlen):
geo2.Append(['line',nlist[i],nlist[i+1]], leftdomain=1, rightdomain=0, bc=1)

ngmesh2 = geo2.GenerateMesh(maxh=h5)
ngmesh2.Save("plane_face.vol")

Hi,