In the below MWE, I have an annulus with inner radius 1 and outer radius 2. I introduced a mesh on the annulus. I want to extract the coordinates of the nodes that lie on the inner circle. But
BoundaryMesh(mesh, "interior", True)
is returning an empty set. According to me, the above command must return the nodal coordinates on the inner circle.
MWE:
from __future__ import print_function
from fenics import *
import matplotlib.pyplot as plt
from dolfin import *
from mshr import Circle, generate_mesh
from dolfin import Mesh, File, MeshFunction, Point, BoundaryMesh, SubDomain, plot, File
C1 = Circle(Point(0, 0),1)
C2 = Circle(Point(0, 0),2)
C_1 = C2 - C1
class b1(SubDomain):
def inside(self, x, on_boundary):
return near(x[0]**2 + x[1]**2, 1, eps=1e-3) and on_boundary
class b2(SubDomain):
def inside(self, x, on_boundary):
return near(x[0]**2 + x[1]**2, 4, eps=1e-3) and on_boundary
class s1(SubDomain):
def inside(self, x, on_boundary):
return x[0]**2 + x[1]**2 > 1 and x[0]**2 + x[1]**2 < 4
mesh = generate_mesh(C_1, 5)
boundary_markers = MeshFunction("size_t", mesh, mesh.topology().dim()-1, 0)
surface_markers = MeshFunction("size_t", mesh, mesh.topology().dim(), 0)
b1().mark(boundary_markers, 1)
b2().mark(boundary_markers, 2)
s1().mark(surface_markers, 5)
ds = Measure('ds', domain=mesh, subdomain_data=boundary_markers)
dx = Measure('dx', domain=mesh, subdomain_data=surface_markers)
inner_nodes = BoundaryMesh(mesh, "interior", True)
boundary_coordinates = inner_nodes.coordinates()
print(len(boundary_coordinates))
print(boundary_coordinates)
I also tried the commands BoundaryMesh(mesh, "local", True)
. This returns all the coordinates of the nodes both on the inner and the outer boundaries of the annulus. So how can I extract the nodal coordinates of just the nodes on the inner circle?
Any suggestions would be very helpful.