use assemble in tutorial to compute error
It is now possible to replace code like
error2 = dune.fem.function.integrate( df-exact)**2, grid=view, order=5)
with
error2 = dune.fem.assemble( (df-exact)**2 * dx )
Remarks
- this only works if the ufl expression contains a grid function from which we can extract the view. So just integrating an ufl form 'exact*dx' leads to a assert at the moment. In this case one can provide the 'assemble' method with a view argument which makes the call similar to 'integrate'.
- at the moment there is a default order extracted from the available grid functions. That would not be such a great idea here since it would use 'df.order'. There exists an order argument but we could use the ufl algorithms to estimate an order for the expression - that exists.
- a nice thing would be that we could also provide at some points integration over the boundary for example, i.e.,
(df-exact)*ds
. - we could also easily provide
assemble( u*dx + u*conditional*ds)
Questions
- Do we want to keep this?
- If we keep it do we want to remove
integrate
(currentlyassemble
usesintegrate
so it doesn't really matter. - Do we use this in the tutorial as preferred approach?
- Do we simply remove it again since it is not used anywhere and it doesn't add enough
Issue
-
the following does not work
as_vector([ error**2, inner(grad(error),grad(error)) ]) * dx
because ufl does not allow thatufl.log.UFLException: Can only integrate scalar expressions. The integrand is a tensor expression with value shape (2,) and free indices with labels ().
But we need that for efficiency.We could write this as
[ error**2*dx, inner(grad(error),grad(error))*dx ]
but that not quite fit the concept of
assemble
.
Edited by Andreas Dedner