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

Defining "Integral*Integral" as new node in UFL Tree?

+4 votes

Dear all,

presently, UFL cannot deal with non-standard bilinear forms such as this one

(v*dx) * (w*dx)

as the product of two forms is not defined. In particular, the error message for the above example is
TypeError: unsupported operand type(s) for *: 'Form' and 'Form'.

I know the numerical value of the above can easily be obtained by

assemble(...)*assemble(...)

but that procedure is not rich enough for my problem.

What is a good starting point, if I wanted to code functionality of the type below?

IntegralInner(integral_a, integral_b)

This should give scalar if integral_a and integral_b assemble into a vector, e.g. a^T*b. And

IntegralOuter(integral_a, integral_b)

should give a rank-1 matrix, e.g. a*b^T

It's easy to just define these two functions, call the assemble and the build the vector or matrix manually, but what I really would need is to add a new node into the UFL-tree, where each of the operands is an integral and can consequently be expressed, traversed and transformed in the UFL-tree such as in https://media.readthedocs.org/pdf/fenics-ufl/latest/fenics-ufl.pdf page 44 and 46.

asked May 30, 2016 by sschmidt FEniCS Novice (490 points)
...