Hi everyone. I had this problem again…
TypeError Traceback (most recent call last)
Cell In[9], line 1
----> 1 x_up,y_up ,ind_up =closest_point(domain,[0.05,0],0.001)
2 print(x_up,y_up,ind_up)
3 x_t,y_t ,ind_t =closest_point(domain,[0.1065,0],0.001)
Cell In[3], line 17, in closest_point(mesh, point, tol)
14 if (np.abs(mesh_geom[j][0]-points[0])< tol and np.abs(mesh_geom[j][1]-points[1])< tol):
15 return points, j
---> 17 geom_dof = dolfinx.cpp.mesh.entities_to_geometry(mesh,tdim,[entity], False)
18 #geom_dof = dolfinx.cpp.mesh.compute_incident_entities(mesh,[entity], 2,1)
19 #print('geom',geom_dof)
20 mesh_nodes = mesh_geom[geom_dof][0]
TypeError: entities_to_geometry(): incompatible function arguments. The following argument types are supported:
1. (mesh: dolfinx.cpp.mesh.Mesh, dim: int, entities: numpy.ndarray[numpy.int32], orient: bool) -> numpy.ndarray[numpy.int32]
Invoked with: <dolfinx.mesh.Mesh object at 0x7f7073db7130>, 2, [array([829543], dtype=int32)], False
The code of the function is:
def closest_point(mesh, point,tol):
points = point
while True:
try:
entity = dolfinx.geometry.compute_closest_entity(tree, mid_tree, mesh, points)
break
except RuntimeError:
print(points)
for j in range(len(mesh.geometry.x)):
if (np.abs(mesh_geom[j][0]-points[0])< tol and np.abs(mesh_geom[j][1]-points[1])< tol):
return points, j
geom_dof = dolfinx.cpp.mesh.entities_to_geometry(mesh,tdim,[entity], False)
#geom_dof = dolfinx.cpp.mesh.compute_incident_entities(mesh,[entity], 2,1)
#print('geom',geom_dof)
mesh_nodes = mesh_geom[geom_dof][0]
#print('mesh_nodes', mesh_nodes)
dis = dolfinx.geometry.compute_distance_gjk(points, mesh_nodes)
index = -100
for i in range(len(mesh_nodes)):
#print(mesh_nodes[i])
if (np.abs(mesh_nodes[i][0]-points[0]+ dis[0]) < tol and np.abs(mesh_nodes[i][1]-points[1]+ dis[1]) < tol):
index = i
if (index == -100):
return point, index
else:
return points[0] - dis[0], points[1] - dis[1] , geom_dof[0][index]
Any suggestions?
Thank you!