Evaluate on lower dimensional submesh

Hello. I have installed the current development version of FEniCS and try to use the Mixed dimensional Function Space feature. However, I am not so sure if it works correctly: If a run the following code, the assembled function should be bigger zero near the boundary (the submesh) on the right hand side the square and zero everywhere else. However, it equals zero on that boundary and is positive somewhere else. Am I doing something wrong or does this feature not work properly? Kind regards, Johannes

from fenics import *
import matplotlib.pyplot as plt
mesh = UnitSquareMesh(8,8)
marker = MeshFunction(“size_t”, mesh, mesh.topology().dim() - 1, 0)
for fac in facets(mesh):
marker[fac] = fac.midpoint().x() > 1 - DOLFIN_EPS
submesh = MeshView.create(marker, 1)
X = FunctionSpace(mesh,‘P’,1)
Y = FunctionSpace(submesh,‘DG’,0)
y = interpolate(Constant(‘1.0’),Y)
LocRes = TestFunction(X)
x_fct = Function(X)
dL = Measure(“dx”, domain=submesh)
assemble(LocResydL, tensor=x_fct.vector())
plt.figure(1)
plot(x_fct)
plt.figure(2)
plot(mesh)
plot(submesh)
plt.show()

Hello,

First of all, I encourage you to encapsulate your code in a code block for your next posts (the code you give is not correctly indented and includes several typos preventing to run it directly).

If I understand correctly, you want to integrate the test function LocRes (defined on the unit cube), on a part of the boundary. You don’t need to build an additional Mesh object (with MeshView) for that.
You could simply use an exterior facet Measure (ds type) and give it the marker tagging the part of the boundary you want to consider :

dL = Measure('ds', domain=mesh, subdomain_data=marker)
assemble(LocRes*dL(1), tensor=x_fct.vector())
2 Likes