Repository navigation
Add implementation of Hessian recovery using Clement interpolant - #23
Conversation
stephankramer
left a comment
There was a problem hiding this comment.
Yeah sorry I'm a little unsure about these different cases tbh: for degree 2 and DG1 I'm not sure it's consistent (and for degree>2 it's not doing any Clement in the first place). For degree 2 I would be a bit more confident if the first gradient was done with a L2 projection into CG1 - I might well be wrong about this, is there some literature to compare with?
| # Recover gradient | ||
| if degree <= 1: | ||
| V = fd.VectorFunctionSpace(mesh, "DG", 0) | ||
| g = clement_interpolant(fd.project(ufl.grad(f), V)) |
There was a problem hiding this comment.
I would say with DG1 this is still dubious: you only get a good approximation of the gradient if the discontinuities are neglible - which in general is very hard to guarantee
There was a problem hiding this comment.
Fair point. To be honest, I'm not sure how this ended up going into Animate (although it was likely my fault!). Restricted to P1 in 1d56a17
| g = recover_gradient_l2(f, target_space=V) | ||
|
|
||
| # Recover Hessian | ||
| if degree <= 2: |
There was a problem hiding this comment.
For degree==2 I'm also not entirely convinced this is safe. If f is CG2 but for some reason your numerical scheme doesn't give you a 2nd order accurate, but a 1st order accurate approximation of some analytical continuous truth, i.e. f could just be in CG1 (as a subset of CG2), then g in DG1 would actually be DG0, and thus H=0 - this may sound arbitrary, but I think it means that any arbitrary 2nd order error in the computation of f would make the Hessian inconsistent.
|
Decided to add gradient recovery using Clement here, too. Also grouped the gradient recovery tests in one file since they use some of the same fixtures. |
stephankramer
left a comment
There was a problem hiding this comment.
Nice, all looks good - one suggestion
| :rtype: :class:`firedrake.function.Function` | ||
| """ | ||
| val_err = ( | ||
| "Clement interpolation can only be used to compute gradients of Lagrange" |
There was a problem hiding this comment.
Maybe add the word "continuous" - if you supply a DG1 field it's not immediately obvious what's wrong (especially if you're used to "DG", 1 instead of "Discontinuous Lagrange", 1)
Closes #22.
This PR ports over the Hessian computation functionality from Animate that goes via the Clement interpolant. Boundary case to be handled separately.