access higher order derivative of a testfunction


I want to access a second, and third order derivative of a DG testfunction. Is it supported in ngsolve?
Say, I have a third order derivative in the equation,
and this leads to the cell-wise bilinear forms
(u_x, v_xx) or (u, v_xxx)
I tried
ux = u.Deriv()
uxx = ux.Deriv(),
but it seems not working…


Hi Guosheng,

Every finite element space can provide additional differential operators (on top of the evaluation, Deriv() and Trace()). In general there are no higher derivatives, but for H1 we have the DiffOp “hesse” that you can use for second order derivatives with (for v a TestFunction of an H1 FESpace):

hesse_v = CoefficientFunction(v.Operator("hesse"),dims=(mesh.dim,mesh.dim))

The operator gives you a vector of dimension d x d that I wrapped into a matrix.

For L2 it would work the same way, but it wasn’t provided for python so far.
It has just been added to the master. Check out the master branch at or wait for the nightly build.

For higher derivatives we don’t have a standard implementation so far. In that case you have to introduce auxiliary variables to represent higher derivatives or implement the DiffOp yourself.