Is there some FEniCS function that enables to compute closest distance-to-surface for all elements (tetrahedrons in my case)?
The idea is to make some terms of the variational form depend on the distance-to-surface, for instance the forces.
e.g. with the Poisson equation:
a = dot(grad(u), grad(v))*dx
L = f(distance-to-surface)vdx
You can get every dof-coordinate in your function space by calling V.tabulate_dof_coordinates().
Then for each of these, you can use any library that accepts a numpy array of coordinates to compute the distance from your analytical shape.
You can then pass these in to a function v in V by calling v.vector()[:] = output_of_distance algorithm.