CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

What is the difference between gradient and reconstruction gradient vectors ?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By hitzhwan
  • 1 Post By sbaffini
  • 1 Post By LuckyTran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 15, 2020, 22:31
Default What is the difference between gradient and reconstruction gradient vectors ?
  #1
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
What is the difference between gradient and reconstruction gradient vectors ?

You can access gradient and reconstruction gradient vectors (and components) for many of the cell variableslisted in Table 3.8: Macros for Cell Flow Variables Defined in mem.h (p. 183). ANSYS FLUENT calculates thegradient of flow in a cell (based on the divergence theory) and stores this value in the variable identifiedby the suffix _G. For example, cell temperature is stored in the variable C_T, and the temperature gradientof the cell is stored in C_T_G. The gradients stored in variables with the _G suffix are non-limited valuesand if used to reconstruct values within the cell (at faces, for example), may potentially result in values thatare higher (or lower) than values in the surrounding cells. Therefore, if your UDF needs to compute facevalues from cell gradients, you should use the reconstruction gradient (RG) values instead of non-limitedgradient (G) values. Reconstruction gradient variables are identified by the suffix _RG, and use the limitingmethod that you have activated in your ANSYS FLUENT model to limit the cell gradient values.
Mary-31 likes this.
hitzhwan is offline   Reply With Quote

Old   November 16, 2020, 06:17
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
You basically wrote the answer to your question, or am I missing something?
FMDenaro likes this.
sbaffini is offline   Reply With Quote

Old   November 16, 2020, 12:23
Default It is directly borrowed from the udf help document, but I cannot understand the foll
  #3
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
You basically wrote the answer to your question, or am I missing something?
It is directly borrowed from the udf help document, but I cannot understand the following sentence, could you explain it to me, thank you.

The gradients stored in variables with the _G suffix are non-limited valuesand if used to reconstruct values within the cell (at faces, for example), may potentially result in values thatare higher (or lower) than values in the surrounding cells.
hitzhwan is offline   Reply With Quote

Old   November 16, 2020, 13:31
Default
  #4
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,674
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
The gradients (with suffix _G) are calculated at cell centers and these gradients are unlimited (they're just calculated normally). If you use unlimited gradients to calculate values at cell faces (i.e. reconstruction), you can often end up with cell face values that are non-physical (lower/higher than surrounding cells centers).

To avoid this, you need to limit the amount of the gradient used in the reconstruction and these are called the reconstruction gradients (RG). The reconstruction gradients are limited based on the limiting method you set.

I got done writing this text and realized I just re-worded the udf manual definition.
Mary-31 likes this.
LuckyTran is offline   Reply With Quote

Old   November 16, 2020, 19:05
Default
  #5
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Finite volume (FV) methods are based on the cell average and flux concepts. You know cell average values in cell centers and conservation equations are written, for those cells, that require summing convective and diffusive fluxes over the faces of those cells.

As values are known in the cell centers but needed on the faces, some reconstruction/interpolation is needed which, starting from the former values can give you the latter.

Modern high order (>1) FV methods for unstructured grids do this by computing a Taylor series expansion of the variables in the cell centers. So that, the variable value on a face of a cell for a 2nd order code (like Fluent) can be written like the value in the cell center (the one you know) + gradient in cell center times the distance vector from the cell center to the face center (we use centers because the Taylor series then have 0 odd terms).

So, you need gradients in cell centers and Fluent, as all similar codes, has some methods to compute them. Unfortunately, what happens if you just use those gradients straight into the Taylor expansion is that the resulting face value might be larger/smaller than the maximum/minimum value from the adjacent cell centers. That is, a new extrema is introduced. Now, if a new extrema is introduced at every iteration, I guess you see that things are not going to end well.

In order to avoid this problem, FV codes use, for their Taylor series reconstruction, a limited version of the gradients. Basically, the gradient values are reduced so that no new extrema are introduced when computing face values.

Fluent has both standard (G) and limited (RG) gradients available in UDF.

That's it, very roughly speaking.
sbaffini is offline   Reply With Quote

Old   November 16, 2020, 23:45
Default So you mean if we calculate the cells in the center, we use the G, if the cells are i
  #6
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
The gradients (with suffix _G) are calculated at cell centers and these gradients are unlimited (they're just calculated normally). If you use unlimited gradients to calculate values at cell faces (i.e. reconstruction), you can often end up with cell face values that are non-physical (lower/higher than surrounding cells centers).

To avoid this, you need to limit the amount of the gradient used in the reconstruction and these are called the reconstruction gradients (RG). The reconstruction gradients are limited based on the limiting method you set.

I got done writing this text and realized I just re-worded the udf manual definition.
So you mean if we calculate the cells in the center, we use the G, if the cells are in the outside surface, we use RG,is that right?
hitzhwan is offline   Reply With Quote

Old   November 16, 2020, 23:46
Default Thank you so much for your reply,Could you tell how to calculate the gradient of volu
  #7
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
Finite volume (FV) methods are based on the cell average and flux concepts. You know cell average values in cell centers and conservation equations are written, for those cells, that require summing convective and diffusive fluxes over the faces of those cells.

As values are known in the cell centers but needed on the faces, some reconstruction/interpolation is needed which, starting from the former values can give you the latter.

Modern high order (>1) FV methods for unstructured grids do this by computing a Taylor series expansion of the variables in the cell centers. So that, the variable value on a face of a cell for a 2nd order code (like Fluent) can be written like the value in the cell center (the one you know) + gradient in cell center times the distance vector from the cell center to the face center (we use centers because the Taylor series then have 0 odd terms).

So, you need gradients in cell centers and Fluent, as all similar codes, has some methods to compute them. Unfortunately, what happens if you just use those gradients straight into the Taylor expansion is that the resulting face value might be larger/smaller than the maximum/minimum value from the adjacent cell centers. That is, a new extrema is introduced. Now, if a new extrema is introduced at every iteration, I guess you see that things are not going to end well.

In order to avoid this problem, FV codes use, for their Taylor series reconstruction, a limited version of the gradients. Basically, the gradient values are reduced so that no new extrema are introduced when computing face values.

Fluent has both standard (G) and limited (RG) gradients available in UDF.

That's it, very roughly speaking.


Thank you so much for your reply. As you can see in the image, I need to the gradient of volume fraction \nabla\alpha, Could you tell how to calculate the gradient of volume fraction on the cells?
Attached Images
File Type: jpg qa.jpg (2.9 KB, 30 views)

Last edited by hitzhwan; November 17, 2020 at 11:07.
hitzhwan is offline   Reply With Quote

Old   November 18, 2020, 17:14
Default
  #8
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Fluent computes the gradient for all the user defined scalars, and probably the limited gradients as well. You could copy the variable whose gradient is needed into an uds and let Fluent compute its gradient. You need to be careful on the bc side (because bc enter the gradient computation) and the order of the steps (when you copy your field into an uds, has the uds gradient already been computed?), but seems doable to me.

Still, you might want to check if Fluent already has the model you want (or something similar that can be adapted), because the task is not for the faint of heart, and volume fractions (with related models) are bitches
sbaffini is offline   Reply With Quote

Old   November 19, 2020, 09:15
Default Hi,thank you for your kindful help, because I am not familar with udf, could you show
  #9
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
Fluent computes the gradient for all the user defined scalars, and probably the limited gradients as well. You could copy the variable whose gradient is needed into an uds and let Fluent compute its gradient. You need to be careful on the bc side (because bc enter the gradient computation) and the order of the steps (when you copy your field into an uds, has the uds gradient already been computed?), but seems doable to me.

Still, you might want to check if Fluent already has the model you want (or something similar that can be adapted), because the task is not for the faint of heart, and volume fractions (with related models) are bitches
Hi,thank you for your kindful help, because I am not familar with udf, could you show me the relative codes about the gradient of volume fraction to me ,thank you so much.
hitzhwan is offline   Reply With Quote

Old   November 19, 2020, 09:22
Default
  #10
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
I can't as I have no more access to Fluent since several years, so I couldn't even try to put it down.

Also, this matter is not going to be solved like that. This sort of UDF use requires a much more disciplined approach, knowledge of how stuff works both at the theory and practice level. Are you sure the model you want to code, or even the gradient you are looking for, isn't already present? That would be a much better route.
sbaffini is offline   Reply With Quote

Old   November 19, 2020, 09:29
Default Yes,sbaffini,I am quite sure,this is what I see in the published paper, they also udf
  #11
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
I can't as I have no more access to Fluent since several years, so I couldn't even try to put it down.

Also, this matter is not going to be solved like that. This sort of UDF use requires a much more disciplined approach, knowledge of how stuff works both at the theory and practice level. Are you sure the model you want to code, or even the gradient you are looking for, isn't already present? That would be a much better route.
Yes,sbaffini,I am quite sure,this is what I see in the published paper, they also udf, the only problem is the gradient of volume fraction, so could you tell me what should I do to solve it,thank you so much.
hitzhwan is offline   Reply With Quote

Old   November 19, 2020, 09:58
Default
  #12
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
I can only point to this https://forum.ansys.com/discussion/4...ng-error-crash

It seems that reconstruction gradients might be present (which totally makes sense).

Otherwise there is a lot of material out there on computing gradients of scalars by previously copying them into UDS.
sbaffini is offline   Reply With Quote

Old   November 19, 2020, 13:19
Default
  #13
Senior Member
 
Join Date: Dec 2017
Posts: 384
Rep Power: 9
hitzhwan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
I can only point to this https://forum.ansys.com/discussion/4...ng-error-crash

It seems that reconstruction gradients might be present (which totally makes sense).

Otherwise there is a lot of material out there on computing gradients of scalars by previously copying them into UDS.
Hi,sbaffini,thank you, have you used C_VOF_G directly before?
hitzhwan is offline   Reply With Quote

Old   November 19, 2020, 14:04
Default
  #14
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,151
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
No, but note that the take home message from the previous link is that, if any, only C_VOF_RG will be available. I noted in my previous post that this would make sense because a non limited vof gradient is going to give you volume fractions outside the 0-1 range if used for reconstructions
sbaffini is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
RECONSTRUCTION GRADIENT dirk FLUENT 4 July 10, 2019 13:03
gradient reconstruction in ghost cells Joachim Main CFD Forum 1 February 1, 2014 23:45
reconstruction gradient of a UDS gemini Fluent UDF and Scheme Programming 0 June 7, 2009 16:03
limiter for gradient reconstruction FVM harry Main CFD Forum 0 September 18, 2008 03:59
reconstruction gradient richie Siemens 0 May 31, 2007 15:13


All times are GMT -4. The time now is 15:32.