I saw some old questions on how to access neighbors but they don’t seem working for fenicsx. I simply want to see the indices of adjacent vertices around one particular node. Is there a way to do it?
from dolfin import *
import numpy as np
mesh = UnitCubeMesh(4,4,4)
# Init vertex-edge connectivity
mesh.init(0,1)
for v in vertices(mesh):
idx = v.index()
neighborhood = [Edge(mesh, i).entities(0) for i in v.entities(1)]
neighborhood = np.array(neighborhood).flatten()
# Remove own index from neighborhood
neighborhood = neighborhood[np.where(neighborhood != idx)[0]]
print "Vertex %d neighborhood: " %idx, neighborhood