### Why doesn't the result of dot(u, v) behave like a function?

121
views
0
3 months ago by
I'm just starting out with Fenics and trying to build a mental model for how it works. My understanding so far is that in Fenics we have objects representing scalar or vector valued functions that are elements of certain function spaces. Fine. And if u is such a function, I can plot it with plot(u). Great.

Why can't I (directly) plot dot(u, u), where u is some vector valued function? In particular in my case:

solve(a == L, u, bc)
plot(dot(grad(u), grad(u))) # "Object cannot be plotted directly, projection to piecewise linears."

What exactly is happening here? What sort of an object is the result of dot? Is it not just a scalar valued function on space, like u itself?
Community: FEniCS Project

1
3 months ago by
Hi,

dot(u, u) is the object before the computing on each node. At the moment you write

a = project( dot(u, u), FunctionSpace(...) )

it starts to calculate. Then you can plot(a) as a scalar function represented by the shape functions of a mesh given in FunctionSpace(...).

Best, Emek
Okay, but what *is* dot(u, u)? What sort of an object is it, if not a function?
written 3 months ago by Jack Eiler
1
3 months ago by
FEniCS, as you probably know, is a collection of "packages" that work together to solve your PDE.

The dot() function comes from the package called UFL (unified form language) and creates symbolic expression.
The plot() method comes from DOLFIN which is a backend coupling other packages. It doesn't know (probably up to some trivial linear combinations of functions) how to "interpret" the UFL symbolic expression.
But there is a package, that can "interpret" these UFL expressions, if they are part of finite element form. Its called FFC (fenics form compiler).
That is the reason, why you have to project (i.e. find the closest point in a weak sense = prepare a finite element form, compile it with FFC and solve the problem) to some finite element space and create "pure" DOLFIN's function so plot() understands it.