I would like to replace FacetFunction by MeshFunction in order to comply with the new version of FEniCS. The old version of my code is
w = 50
L = 100.
mesh = RectangleMesh(Point(0., 0.), Point(L, w), 5, 5, "crossed")
def eps(v):
return sym(grad(v))
mu = Constant(1.0)
lmbda = Constant(0.5)
def sigma(v):
return lmbda*tr(eps(v))*Identity(2) + 2.0*mu*eps(v)
class Right(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], L)
exterior_facet_domains = FacetFunction("size_t", mesh)
exterior_facet_domains.set_all(0)
Right().mark(exterior_facet_domains, 3)
ds = Measure('ds', domain=mesh, subdomain_data=exterior_facet_domains)
s = Constant((1, 0.0))
V = VectorFunctionSpace(mesh, 'Lagrange', degree=2)
du = TrialFunction(V)
u_ = TestFunction(V)
a = inner(sigma(du), eps(u_))*dx
l = inner(s, u_)*ds(3)
def left(x, on_boundary):
return near(x[0], 0.)
def bottom(x, on_boundary):
return near(x[1], 0.)
bcx = DirichletBC(V.sub(0), Constant((0.)), left)
bcy = DirichletBC(V.sub(1), Constant((0.)), bottom)
bc = [bcx, bcy]
u = Function(V)
solve(a == l, u, bc)
Now when I replace
exterior_facet_domains = FacetFunction("size_t", mesh)
by
exterior_facet_domains = MeshFunction("double", mesh, mesh.topology().dim()-1)
I get the following error:
TypeError: set_exterior_facet_domains(): incompatible function arguments. The following argument types are supported:
1. (self: dolfin.cpp.fem.Form, arg0: dolfin.cpp.mesh.MeshFunctionSizet) -> None
Any help would be very welcome!