How to define boundary conditions on an irregular geometry?

Then you need to load a MeshFunction. As shown in Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio you load the mesh function mf And use that In the DirichletBC, As shown in the Stokes demo