Recently, I am working on a problem which need to calculate the distance of all the interior points to the boundary. I use the following code:
bmesh = BoundaryMesh(mesh, "exterior") bbtree = BoundingBoxTree() bbtree.build(bmesh) vertex_distance_to_boundary = MeshFunction("double", mesh, 0) for v_idx in xrange(mesh.num_vertices()): v = Vertex(mesh, v_idx) _, distance = bbtree.compute_closest_entity(v.point()) print distance vertex_distance_to_boundary[v_idx] = distance
It works well, but I am wondering how FEniCS computes the distance? What’s the method/algorithm used behind? I can not find any explanation here and there.