Hello,

I am chasing a bug for my Navier-Stokes solver using Hdiv-HDG for a more than a week, and finally found out that for Hdiv-space, the correct way to calculate the gradient is using

`Grad`

instead of `grad`

This is a bit odd, as I am always using the lower-case grad operator… lol

So what’s the difference???

Is there any documentation I can found on the source code on the implementation of differential operators?

This kind of bugs are extremely hard find as the lower case grad operator is also stable, but produce inaccurate results…

Best,

Guosheng

Alright, it looks like that Grad is simply grad.trans…

Hi, there was an inconsistency in the grad, for example in the VectorH1 and H1(…, dim=3) once it is the jacobin and once the transpose.

To not break old code we introduced the Grad as a consistent version over all spaces.

Best

Christopher

Thanks for the clarification!

Hi Christopher,

I cannot understand when you say grad is transpose? Do you mean that grad(u) is the row vector when u is a scalar field? Thank you.

Best,

Prasanna

You can do

print (Grad(u).dims)

to get the vector/matrix/tensor shape of the expression.

grad(u) of a scalar is a vector (i.e. a first order tensor), and we do not distinguish between row or col vector.

A simple method to figure out the ordering of the matrix (tensor) is drawing:

u = GridFunction(VectorH1( … ))

u.Set( (x+2*y, 0) )

Draw (Grad(u)[0,1], mesh)

Recommendation: use grad(u) for scalar, and Grad(u) for vectorial functions.

Joachim