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

"Spring" functionals: assembling non-integral functional

+2 votes

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?

asked Feb 20, 2015 by cmaurini FEniCS User (1,130 points)
edited Feb 23, 2015 by cmaurini

1 Answer

+1 vote

Derivative with respect to what?

answered Feb 23, 2015 by martinal FEniCS User (2,800 points)

Directional derivative with respect to u, as a functional.

If you want to get rid of the derivative thing the fundamental question is:

How to assemble a term which is not a integral, and then mathematically speaking, not a differential form, like
f = u(x1)v(x2)
where u is a trial function, v a test function, x1 and x2 two points in the mesh. You may assume that x1 and x2 are vertexes if it simplify the answer. I known how to do it on a piece of paper or on custom finite element code, but I do not see how to do it exploiting the FEniCS assemble function.

You're right, there is no 'apply' operator in UFL, so there's currently no way to represent u(x1).

What's missing is not a purely UFL feature either, the fundamental issue is that apply is not a local operation so it doesn't fit into the "for each cell: compute local contribution && add to global value" assembly framework.

That means this won't be fixed without somebody sitting down doing some serious design and implementation work.

I created an issue in bitbucket to remember about it:

https://bitbucket.org/fenics-project/dolfin/issue/475/assembling-functionals-that-are-not

Martin, I let you select the appropriate priority level and improve the description if you feel it necessary.

...