### Forms involving reals

164
views
0
4 months ago by
Is there an easy way to construct a form involving 'functions' from a space of real numbers? To be precise, I would like to assemble the form
$a\big( (u,\lambda), (v, \mu) \big) = \int_\Omega u \, v \, \mathrm{d}x + \lambda \, \mu.$
Here, $u$, $v$ are functions and $\lambda$, $\mu$ are real numbers.
Note that the very last addend does not need an integral since it only involves real numbers.

What I have tried:
from dolfin import *

mesh = UnitSquareMesh(4,4)

CG_el = FiniteElement("CG", triangle, 1)
R_el = FiniteElement("Real", triangle, 0)
U = FunctionSpace(mesh, CG_el * R_el)

[u,l] = TestFunctions(U)
[v,m] = TrialFunctions(U)

a = u*v*dx + l*m​

However, I do not know how to convert "l*m" to a "Form".

Community: FEniCS Project

2
4 months ago by
l*m*dx will do the job.
No, this will assemble $|\Omega| \, \lambda \, \mu$, where $|\Omega|$ is the measure of $\Omega$.
written 4 months ago by gerw
Is it a problem to divide by volume of the domain?
written 4 months ago by Jan Blechta
No, but something like
area = assemble(1*dx)
a = ... + Constant(1./area) * l * m * dx​
seems to be overkill. There should be no need to integrate over $\Omega$ in order to realize the multiplication of two real numbers.
written 4 months ago by gerw
* dP(1) defining as dP(1) a domain made by only one vertex ?
written 4 months ago by Marco Morandini
I would rather avoid using the point measure. It is rather fragile and might be removed from FEniCS X.
written 4 months ago by Jan Blechta
But principally I agree - the point measure is the right abstraction.
written 4 months ago by Jan Blechta
I wouldn't be scared of performance implications of this. Jacobian code is generated and called on every cell anyway and adding l*m*dx contributions probably has negligible performance impact.

If you really want to chase performance then don't handle the term by DOLFIN assemble. Use DOLFIN assembler to assemble just integral and set appropriate matrix entry by yourself manually.
written 4 months ago by Jan Blechta