I would like to define a function that's zero everywhere except on the boundary of my mesh. How do I do this? What I have so far is:
mesh = Mesh('mesh.xml')
bmesh = BoundaryMesh(mesh, 'exterior')
my_function = FacetFunction('int', mesh)
my_function.set_all(0)
for facet in facets(mesh):
if facet in bmesh: # What's the proper check here?
my_function[facet] = 42
Not surprisingly, the "facet in bmesh" expression doesn't work. But what do I have to use instead?