Different ways to do PointSource

Dear all,

Suppose that there is a point source in the right-hand side of a linear problem, like \int_\Omega \nabla u\nabla\phi dx+\kappa\int_\Gamma u \phi ds=\int_\Omega\delta(x-x')\phi dx as the weak form. The usual way to write this in Fenics using PointSource function is

a=inner(grad(u),grad(v))*dx+kappa*inner(u,v)*ds
L=Constant(0)*v*dx
ps=PointSouce(V, Point(x'), 1)
A,b=assemble_system(a, L)
ps.apply(b)
u = Function(V)
solve(A, u.vector(), b)

Inspired by the example here, can I do something similar like

f = Function(V)
ps = PointSource(V, Point(x’), 1)
ps.apply(f.vector())
a = inner(grad(u), grad(v)) * dx + kappa * inner(u, v) * ds
L = f * v *dx
u = Function(V)
solve(a = = L)

Is the second one a correct way to do point source? Are these two methods the same?

Thanks a lot in advance.

Best regards,
Alice

The second method is not a correct way to apply a point source. The post that you link to is a non-standard (ab)use of the PointSource functionality to assign the value of a Function at a nodal point. The modified Function does not approximate a Dirac delta of the desired magnitude. What PointSource does when applied to a Function is set the i^\text{th} entry of the Function's vector to c\phi_i(\mathbf{x}), where c is the magnitude of the PointSource, \phi_i is the i^\text{th} basis function of the corresponding FunctionSpace, and \mathbf{x} is the location of the PointSource.

2 Likes