This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to apply pointsource to LinearVariationalProblem

+1 vote

Hi all,

How does one apply a pointsource to a LinearVariationalProblem?

problem = LinearVariationalProblem(a, L, u, bc)

Normally I'd assemble L and then pointsource.apply works. But LinearVariationalProblem cannot take assembled version of L as input, so how can it be done int this case?

Thanks

asked Jul 7, 2017 by meron FEniCS User (2,340 points)

1 Answer

+2 votes

As far as I'm aware, there is no functionality to include a Dirac delta function in a variational formulation in ufl/FEniCS.

Consider two approaches:

  1. Form the FE matrix equation and apply the point source as you have
    already.

  2. Use an approximation of the Dirac delta function in the variational
    formulation with a suitably fine mesh

$$ \delta(x) = \text{lim}_{\epsilon \rightarrow 0} \frac{1}{\epsilon \sqrt{\pi}} e^{-\left(\frac{x}{\epsilon}\right)^2} $$

answered Jul 7, 2017 by nate FEniCS Expert (17,050 points)
edited Jul 7, 2017 by nate

Thank you very much for your suggestion! Do you know why it has been implemented when using ps.apply(assemble(L)) but not for ufl?
Furthermore, when trying the two approaches the obtained solutions are not the same, how can this be resolved?

I already tried the solution

f_q= Expression("sqrt((x[0] - x0)(x[0] - x0) + (x[1] - y0)(x[1] - y0) ) < r ? q : 0.0", x0=x0, y0=y0, r=thresh, q = 1, degree=2)

but yours is nicer, thanks!

...