I want to interpolate from a piecewise constant function (DG0) to piecewise linear (DG1)
in such a way that the total integral remains the same, but the new function has a
gradient (which could just be the average difference between neighbouring DG0 cells).
i.e.
DG0 = FunctionSpace(mesh, "DG", 0)
DG1 = FunctionSpace(mesh, "DG", 1)
F0 = Function(DG0)
F0.interpolate(Expression("x[0]"))
will produce a piecewise constant function, F0. Now if I do:
F1.interpolate(F0)
or
F1 = project(F0, DG1)
the resulting function F1 is still piecewise constant. How can I make it incorporate the local gradient information. I realise it may involve solving an equation, but I don't know how to do it...