Hi,
Given a radius r and an element e, I would like to find all the elements whose center-to-center distance from e is smaller than r.
I would like to do this for all the elements of the mesh. What I would like to do is similar to the following example, which, however, implies a double loop on all the cells and is not efficient for large numbers of elements.
from dolfin import *
import dolfin as df
mesh = UnitSquareMesh(20,20)
radius = 0.05
k=0
for cell1 in cells(mesh):
center1 = cell1.midpoint()
j=0
for cell2 in cells(mesh):
center2 = cell2.midpoint()
if center1.distance(center2) < radius:
print ('element %i is in neighborhood of element %i'% (j,k))
j=j+1
k=k+1
Is there a better way to “identify” which elements are inside a neighborhood of a given radius from the center of a given element?
I have already thought about exploiting the numeration of the elements, but I was wondering whether I have to do it manually or there is a command I could use.
Thank you!