How can I integrate a Constant()
function over a submesh?
The following fails:
from dolfin import *
mesh = RectangleMesh(0.0, 0.0, 1.0, 1.0, 100, 100)
class Obstacle(SubDomain):
def inside(self, x, on_boundary):
return (between(x[1], (0.5, 0.7)) and between(x[0], (0.2,
1.0)))
obstacle = Obstacle()
subdomains = CellFunction('size_t', mesh)
subdomains.set_all(0)
obstacle.mark(subdomains, 1)
dx = Measure('dx')[subdomains]
submesh = SubMesh(mesh, subdomains, 1)
# Works:
assemble(Constant(1.0) * dx(mesh))
# Fails:
assemble(Constant(1.0) * dx(submesh))
Non-matching meshes for function spaces and/or measures.