You can find the vertices on the boundary like this:
from dolfin import *
mesh = UnitSquareMesh(4, 4)
# Mark a CG1 Function with ones on the boundary
V = FunctionSpace(mesh, 'CG', 1)
bc = DirichletBC(V, 1, DomainBoundary())
u = Function(V)
bc.apply(u.vector())
# Get vertices sitting on boundary
d2v = dof_to_vertex_map(V)
vertices_on_boundary = d2v[u.vector() == 1.0]
# Mark VertexFunction to check
vf = VertexFunction('size_t', mesh, 0)
vf.array()[vertices_on_boundary] = 1.
plot(vf)
interactive()
The DirichletBC.markers()
returns a vector (numpy array in python) of the facets on that boundary, at least for development version.