I hope this python code example can help you - let's say you want to "submesh" the upper and lower half of the UnitCube (SubMesh only works in serial):
class Dom1(SubDomain):
def inside(self, x, on_boundary):
return x[2] < 0.5 + DOLFIN_EPS
class Dom2(SubDomain):
def inside(self, x, on_boundary):
return x[2] > 0.5 - DOLFIN_EPS
mesh = UnitCubeMesh(6, 6, 6)
dom1 = Dom1()
dom2 = Dom2()
domains = CellFunction("size_t", mesh)
domains.set_all(0)
dom1.mark(domains, 1)
dom2.mark(domains, 2)
submesh1 = SubMesh(mesh, domains, 1)
submesh2 = SubMesh(mesh, domains, 2)
df.File('submesh1.xml') << submesh1 # export if needed
df.File('submesh2.xml') << submesh2 # -- "" --