I am working in FEniCs in a 3D domain with a vector field. My domains corresponds to a very thin box (a plate) and I want to generate my boundary conditions over the top face of the plate (h) in a small circle centered at point xc with radius rs. I have implemented it in the following code:
mf = MeshFunction("size_t",mesh,1)
mf.set_all(0)
g = Expression(("E*(x[0]-x0)/rs","E*(x[1]-y0)/rs","0"), E = E, x0 = xc[0], y0 = xc[1] , rs = rs, degree=2)
class LeftHalf(SubDomain):
def inside(self,x,on_boundary):
tol = 1e-8
return ((x[0]-xc[0])*(x[0]-xc[0]) + (x[1]-xc[1])*(x[1]-xc[1]) - rs*rs) < tol and on_boundary and near(x[2],xc[2],tol)
lefthalf = LeftHalf()
lefthalf.mark(mf,1)
ds = Measure("ds")(subdomain_data=mf)
L = inner(g,v)*ds(1)
l = assemble(self.L)
Nonetheless, when I use this code to generate the force, it is generated in random points of the plate, outisde of the circle of radius rs and of the top face of the plate.
Does anybody know how to solve the code just to generate the force only in the circle indicated?
My point was, can you reproduce the error with a built in mesh, as you are working on a box geometry. This would be a way to identity if it is as mesh issue or not.
Oh, sorry, I did not understand correctly your answer.
I have tried with a BoxMesh generated in Fenics and the error is still similar. With the BoxMesh, the source term L takes value 0 on the whole boundary, while with the original code using the external mesh it took non-zeros values in spurious points on the boundary, but still, with both meshes the condition is not applied.