I would like to assemble a right-hand side (a vector) over a subdomain. The code
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)
r = Expression('x[0]', domain=mesh)
# This works:
#V = FunctionSpace(mesh, 'CG', 1)
# This doesn't:
V = FunctionSpace(submesh, 'CG', 1)
v = TestFunction(V)
a = assemble(r * v * dx(1))
however yields the error
AssertionError: Expecting a completed form with domains at this point.
How to work around the issue?