Hi!
I have these two functions, one in DG0 and one in CG1, e.g.
DG0 = FunctionSpace(mesh, "DG", 0)
CG1 = FunctionSpace(mesh, "CG", 1)
f1 = Function(DG0)
f2 = Function(CG1)
# Assign some values to f1 and f2
...
# Multiply f1 and f2
...
Now my question is, what would be the best and most natural way to manually multiply these functions (without solving a linear system)? As of now I have interpolated the DG0-funcion to CG1 as this
ll = LagrangeInterpolator()
f3 = Function(CG1)
ll.interpolate(f3, f1)
# Do multiplication
f2.vector()[:] = f2.vector()*f3.vector()
This works ok, but instead of using this piecewise "smooth" DG0 field the interpolated field may be be oscillating a lot. This is not critical since the oscillations are controlled, that is they are in the range of the DG0-function, however a better solution would absolutely be preferred! The multiplication should be more "element wise".
Any tips?
Thanks!