We would like to add "springs" in an elastic bar model, but we are blocked figuring out how to assemble efficiently and simply the corresponding stiffness matrix with UFL forms.
The key problem can be formulated as follow:
Let u
be a scalar function on a mesh and x0 and x1 two point in the mesh.
Consider the energy functional (potential energy)
F = 1/2 * k* (u(x1) - u(x0))**2
How can we assemble the matrix corresponding to the second derivative of F ?
The problem for me is that the energy is a functional, but not an 'integral' functional. Hence it is not a UFL
form. And I cannot see the syntax to use in FEniCS to assemble its derivatives. (Of course the matrix is 'trivial' to be assembled using a user assembling code).
I tryied to investigate the use of FunctionalExpressions proposed here by Martin: https://bitbucket.org/fenics-project/dolfin/issue/413/add-a-demo-of-global-operators-with-semi .
But it seems to me far too complex (and maybe not sufficient) to solve this theoretically trivial problem.
Any suggestions?