I'm novice in FEniCS, need some help with below issue.
I create subdomain containing one middle point of the unit interval. So, I want to assemble the given function over that subdomain, but it seems to be not working correctly.
mesh = UnitIntervalMesh(10)
V = FunctionSpace(mesh, 'CG', 1)
boundary_parts = \
MeshFunction('size_t', mesh, mesh.topology().dim() - 1)
left = CompiledSubDomain('near(x[0], 0.)')
right = CompiledSubDomain('near(x[0], 1.)')
middle = CompiledSubDomain('near(x[0], 0.5)')
left.mark(boundary_parts, 0)
right.mark(boundary_parts, 1)
middle.mark(boundary_parts, 2)
ds = Measure('ds', domain = mesh, subdomain_data = boundary_parts)
f = interpolate(Expression('3*x[0]', degree = 1), V)
print assemble(f*ds(0))
print assemble(f*ds(1))
print assemble(f*ds(2))
My output is
0.0
3.0
0.0
The last line should be 1.5.