DOF = 50
# Create mesh and define function space
L=4
mesh = IntervalMesh(DOF, 0, L)
degree = 1
U = VectorFunctionSpace(mesh, 'CG', degree, dim=3)
u = TrialFunction(U)
v = TestFunction(U)
# Dirichlet on left boundary
def l_boundary(x, on_boundary):
return on_boundary and near(x[0], 0.0)
zero = Constant((0.0, 0.0, 0.0))
bc = DirichletBC(U, zero, l_boundary)
# Variational formulation
A = inner(grad(u), grad(v))*dx
# I want the following load f to be a point load on the endpoint L=4
L = inner(f, v)*dx
# Solution to the problem
u_h = Function(U)
solve(A == L,u_h,bc)

From the post related above, a suggested solution was that an approximation of the Dirac delta function can do the work, but I have no idea on how to do this on FEniCS. I tried the solution from Mirok but get an Maximum recursion depth exceeded error.

I missed to point out in my question that I’m trying NOT to use the PointSource class in order to avoid the assemble() and apply() part. That will mess up my code…

Hello @MiroK Mirok, what is the magnitude of the force and location in this code?
I want to add a point load at the free end of a cantilever, is this code useful for that?
Thanks.

Hi Mirok, I have a question to ask you. When I run this code, it returns this error. Is this a problem with my “fenics_adjoint”, or is it something else?

Dear MiroK, I think I have a new question. The example is applying a load to a single node, how can I load multiple nodes at different locations at the same time? Thank you very much for your answer.