|
[Sponsors] |
August 3, 2019, 20:26 |
discrepancy in fvc::grad(U)
|
#1 |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
HI all,
Recently I noticed that in openfoam, gradient of a vector is computed as the outer product of the gradient operator and the vector. Page 25 (bottom) of the programmer's guide defines the gradient of velocity field as: which is transpose of what we exactly mean by grad(U) as: I checked the computed values of gradient of velocity field near the wall (where wall normal component is expected to be dominant) and I can confirm that it outputs the transpose of what we actually want. To my surprise, I have seen people use the grad(U) without taking its transpose in openfoam that would actually give the correct tensor. Has anybody encountered this issue before? OpenFOAM Version: 2.4.0 |
|
August 3, 2019, 22:11 |
|
#2 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
Hello,
The result is correct however the notation of the manual is confusing (wrong). The problem is due to the nabla operator (). because by convention [Ref. 1] (look carefuly to the position of the indices): Why? because in this context, will not make sense (remember that the operator nabla must act on the vector so it must be at the left). Conclusion: The gradient is calculated correctly (matrix form), but the notation () given in the manual for the gradient is wrong (it is for the transpose of the gradient). [Ref. 1]: See page 7 of this document: http://web.iitd.ac.in/~pmvs/courses/mcl702/notation.pdf |
|
August 3, 2019, 22:31 |
|
#3 |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
Quote:
The computed velocity gradient tensor computed by grad() operator for channel flow (near wall) is below: (0.017149094 -0.00010358519 -0.016898076 29.161076 0.0014569992 1.2603341 0.040551971 -0.00023234273 0.013089031) As you can see, the fourth component (YX) in red is very clearly the wall normal component as it is the dominant term which should actually be the second (XY) component. I guess whatever is presented in the guide is correct. So if the gradient computed is correct, shouldn't the dominant (dU/dy) term be second in the above tensor? |
|
August 3, 2019, 22:41 |
|
#4 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
||
August 3, 2019, 22:55 |
|
#5 | |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
Quote:
This is what we actually need (the common agreed upon definition of velocity gradient in all textbooks on fluid mechanics): Code:
U1,1 U1,2 U1,3 U2,1 U2,2 U2,3 U3,1 U3,2 U3,3 Code:
U1,1 U2,1 U3,1 U1,2 U2,2 U3,2 U1,3 U2,3 U3,3 |
||
August 3, 2019, 23:21 |
|
#6 | |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
This is a matter of layout convention. You can take a look to this detailed section on wikipedia.
Your notation: Quote:
|
||
August 3, 2019, 23:31 |
|
#7 | |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
Quote:
The issue was just to make it very known that with using fvc::grad(U) in foam, as I said, we are not computing the gradient as the textbook definition used for gradient of velocity is written. I have seen people use it right away in calculations when they actually were meant to use its transpose. So care must be taken! Thanks for your time!! I am pretty sure that this discussion will help a lot of people! |
||
August 4, 2019, 00:07 |
|
#8 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
||
August 4, 2019, 00:25 |
|
#9 |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
||
June 8, 2021, 05:35 |
|
#10 |
New Member
Join Date: Feb 2016
Posts: 13
Rep Power: 10 |
Hello,
I also encountered this issue. In my opinion, fvc::grad computes the transpose of the gradient... It is well documented in the programmers' guide - p25 eq2.3. |
|
June 10, 2021, 14:05 |
|
#11 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14 |
No, I think that the OpenFOAM notation does hold up, and makes more sense to me.
For example, the outer product of two vectors, , can be written in terms of matrix multiplication as . Now apply that to the grad operation, which is the outer product of nabla and the vector: which on multiplying out gives: and hey presto you get the convention that OpenFOAM uses. Just as a reminder, the middle term on the top row is component . You just need to remember that the nabla operator comes before the thing it operates on, and so its index comes first. Last edited by Tobermory; June 14, 2021 at 07:50. Reason: Tidying up the wording. |
|
November 23, 2021, 00:38 |
|
#12 |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
Also, we are not much bothered about the convention. We are more concerned about the correct implementation of the terms that arise in FD equations. I think the best practice to address this is to be careful what the term that you are trying to implement involves -- whether you want [U1,1 U1,2 U1,3; U2,1 U2,2 U2,3; U3,1 U3,2 U3,3 ] to be implemented or its transpose. The implementation of gradient in FOAM is technically its transpose but in most of the fluid dynamic equations the tensor I just wrote above is more common representation of (del/del_xj U_i).
|
|
November 23, 2021, 00:47 |
|
#13 |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
||
November 24, 2021, 19:06 |
|
#14 | |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14 |
Quote:
As for your Reynolds stress production terms, see the attached image for the OpenFOAM notation way of writing this (I ran out of patience with trying to do the notation in this editor!). Hope that helps ... Note: some of the terms in the last matrix are wrong - see the corrected version below Last edited by Tobermory; November 25, 2021 at 10:38. Reason: Clarifying a mistake |
||
November 24, 2021, 19:25 |
|
#15 | |
Member
Anonymous
Join Date: Aug 2016
Posts: 75
Rep Power: 10 |
Quote:
Correct, that is how I would implement the first term. Would the second term implementation be any different? I would write the second term as: (with the velcoity gradient getting pre-multiplied) with the stress tensor and your velocity gradient tensor transposed as: Do you agree? |
||
November 25, 2021, 10:37 |
|
#16 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 736
Rep Power: 14 |
Yes - exactly right. The second Re stress production term is just the transpose of the first - check out the attached figure (I also corrected the first term from my earlier post).
|
|
November 27, 2021, 09:01 |
|
#17 |
Member
Join Date: Jun 2019
Posts: 41
Rep Power: 7 |
According to my own test. I confirm that OpenFoam uses the transpose of the jacobian matrix for the gradient of a vector.
I think that it should be written somewhere because when you derive your own equation using the classical jacobian matrix it can be a source of error very hard to catch if you code it without knowing it.
__________________
« Debugging is what CFD is about. 5 minutes to modify your code, 5 months to find why it does not work anymore. » |
|
March 23, 2022, 05:17 |
|
#18 |
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13 |
The treatment on the grad is confusing in my opinion.
Just imagine you compute "skew(gradU)" by assuming the traditional notation.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki-1/Wiki-2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESI-OpenCFD-Trademark) Bugs/Features: FOAM-Extend (Wikki-FSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror Last edited by HPE; March 23, 2022 at 07:37. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how can I do dot product of U and fvc::grad(U) where U is an volVectorFiled ? | mechy | OpenFOAM | 3 | February 24, 2023 12:17 |
Acoustic Power Discrepancy | Time4Tea | FLUENT | 0 | August 21, 2018 10:46 |
implicit - (fvc::grad(U) & fvc::grad(muEff)) | Kareem Abdelshafy | OpenFOAM Programming & Development | 1 | August 20, 2016 21:57 |
strange behaviour of fvc::grad(U) and NonlinearKEShih turbmod - analitical comparison | ancsa | OpenFOAM Verification & Validation | 1 | January 20, 2015 12:00 |
FLUENT Version Mis-Match Discrepancy | asd | Main CFD Forum | 0 | April 19, 2007 05:58 |