Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

grad vs Grad

More
4 years 5 months ago #1983 by Guosheng Fu
grad vs Grad was created by Guosheng Fu
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
Code:
Grad
instead of
Code:
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
More
4 years 5 months ago #1984 by Guosheng Fu
Replied by Guosheng Fu on topic grad vs Grad
Alright, it looks like that Grad is simply grad.trans....
More
4 years 5 months ago #1985 by christopher
Replied by christopher on topic grad vs Grad
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
More
4 years 5 months ago #1986 by Guosheng Fu
Replied by Guosheng Fu on topic grad vs Grad
Thanks for the clarification!
More
11 months 3 weeks ago - 11 months 3 weeks ago #4780 by psalasiya
Replied by psalasiya on topic grad vs Grad
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
Last edit: 11 months 3 weeks ago by psalasiya.
More
11 months 3 weeks ago #4781 by joachim
Replied by joachim on topic grad vs Grad
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

 
The following user(s) said Thank You: psalasiya
Time to create page: 0.177 seconds