See for instance: Stokes equations with Mini elements — DOLFIN documentation
Where the MeshFunction sub_domains
is used to apply boundary conditions.
For using meshfunctions in integration measures, see: Two ways to use MeshFunction to mark domain boundaries - #2 by dokken