CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

problem in gradient of user defined scalar C_UDSI_G(c,t,i) at boundaries

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By AhmedHafez

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2020, 03:02
Default problem in gradient of user defined scalar C_UDSI_G(c,t,i) at boundaries
  #1
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
Hello,

During writing a udf ,I need to compute gradient, so I put the variable in UDS then compute gradient using C_UDSI_G(c,t,i), However the value I get is not logical at boundaries. So as to make sure that everything is going well. I put a variable that have predefined gradient in the uds (say C_UDSI(c,t,0)=C_K(c,t)) and compare its predefined gradient (C_K_G(c,t) [0]) with uds gradient (C_UDSI_G(c,t,0)[0]). I found significant difference at 1st two cells adjacent to all boundaries, then perfect agreement after those 2 cells.
Do any one know where is the problem. Below is extracted part from my udf regarding this issue
-----
#include "udf.h"
#include "mem.h"

DEFINE_ADJUST(adjust_udf, domain)
{
Thread *t;
cell_t c;
thread_loop_c(t,domain)
{
begin_c_loop(c,t)
{
C_UDSI(c,t,0) = C_K(c,t);
C_UDMI(c,t,0) = C_UDSI_G(c,t,0)[0];
C_UDMI(c,t,1) = C_K_G(c,t)[0];
}
end_c_loop(c,t)
}
}
DaveD! likes this.
AhmedHafez is offline   Reply With Quote

Old   April 7, 2020, 03:54
Default Wall Treatment
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
The reason for that is the wall treatment. For momentum, thermal energy, species, turbulence, etc., there is a wall treatment carried out but not for UDS. For UDS, users have to do it themselves.

https://www.afs.enea.it/project/nept.../th/node99.htm

For k, though the boundary condition at wall is 0 flux, but its generation modifies the profile near the wall.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 04:31
Default
  #3
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
Thank you Vinerm for your reply.
However the problem takes place at all boundaries ( velocity inlet, pressure outlet and wall) not walls only so I think it is not an issue of wall treatment.
AhmedHafez is offline   Reply With Quote

Old   April 7, 2020, 05:30
Default Boundary Conditions and Solving
  #4
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Do you have same boundary conditions for UDS as those for k? Furthermore, do you solve for UDS? If yes, then the change is expected since the equations are not the same.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 05:37
Default
  #5
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Do you have same boundary conditions for UDS as those for k? Furthermore, do you solve for UDS? If yes, then the change is expected since the equations are not the same.
yes I use the same boundary condition for k, specified value at inlet which set equal to the inlet k and zero flux at wall and pressure outlet.
For you second question, No, I turned off the uds.
AhmedHafez is offline   Reply With Quote

Old   April 7, 2020, 05:44
Default Reconstructed
  #6
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Did you try using Reconstructed gradient instead of gradient?
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 06:56
Default
  #7
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Did you try using Reconstructed gradient instead of gradient?
I tried it now but unfortunately it did not help. The trend at 1st cell changed significantly (became) worse. While 2nd cell became better.
AhmedHafez is offline   Reply With Quote

Old   April 7, 2020, 07:50
Default Comparison
  #8
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Are you comparing cell values or node values? That may make a difference. Though with same boundary conditions applied, it should not make a difference but it may.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 7, 2020, 10:04
Default
  #9
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Are you comparing cell values or node values? That may make a difference. Though with same boundary conditions applied, it should not make a difference but it may.
When I compare, I use cell values.
Here is an update!!
I repeated the simulation using green gauss node base method for gradient and I got perfect agreement at inlet but not at wall nor outlet, it may be due to zero flux boundary condition for uds, so I looped over all boundary face and assign F_UDSI(f,t,0)=F_K(f,t) similar as in the following link:
https://www.afs.enea.it/project/nept...df/node103.htm

This time I got perfect agreement between C_USDI_G & C_K_G
however when I repeated the same procedure using least square method, there is big enhancement at wall and pressure outlet and no enhancement at inlet and generally I still have significant difference at all boundaries.
Do you have any guess why this happens with least square method?
AhmedHafez is offline   Reply With Quote

Old   April 9, 2020, 05:52
Default Least Square
  #10
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Most likely because least square gradient is based on the assumption that the solution varies linearly. However, the difference you are observing could also be due to the gradient method being used, i.e., cell-to-face and not cell-to-cell. You can try using cell-to-cell as well as trying using differentiable limiter instead of default non-differentiable one.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   April 11, 2020, 17:15
Default
  #11
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Most likely because least square gradient is based on the assumption that the solution varies linearly. However, the difference you are observing could also be due to the gradient method being used, i.e., cell-to-face and not cell-to-cell. You can try using cell-to-cell as well as trying using differentiable limiter instead of default non-differentiable one.
Thank you for your continuous help

I tried differentiable, cell-to-face and not cell-to-cell but the same problem still occur.
AhmedHafez is offline   Reply With Quote

Old   January 8, 2021, 05:10
Default
  #12
New Member
 
Vincenzo Luci
Join Date: Jan 2019
Posts: 9
Rep Power: 7
vincenzolights is on a distinguished road
Hello to everyone, someone has solved this problem?

Thank you,
Vincenzo
vincenzolights is offline   Reply With Quote

Old   January 8, 2021, 08:03
Default
  #13
New Member
 
Ahmed Hafez
Join Date: Jul 2018
Posts: 26
Rep Power: 7
AhmedHafez is on a distinguished road
I used gauss node based instead of least square
method. As gauss node based didn't have the same problem

Quote:
Originally Posted by vincenzolights View Post
Hello to everyone, someone has solved this problem?

Thank you,
Vincenzo
AhmedHafez is offline   Reply With Quote

Old   April 4, 2024, 05:11
Default
  #14
New Member
 
Diogo Martinho
Join Date: Sep 2022
Posts: 6
Rep Power: 3
diogoloureiromartinho is on a distinguished road
Quote:
Originally Posted by vinerm View Post
The reason for that is the wall treatment. For momentum, thermal energy, species, turbulence, etc., there is a wall treatment carried out but not for UDS. For UDS, users have to do it themselves.

https://www.afs.enea.it/project/nept.../th/node99.htm

For k, though the boundary condition at wall is 0 flux, but its generation modifies the profile near the wall.
Hi,

I am facing a problem with the gradient of my UDS. Similar to the one presented on this thread. However, I haven't solved it yet.

I am defining a UDS and this UDS is only defined in certain domains. However, the cells of the domain where the UDS is solved that are neighbours to the cells of the domain where the UDS is not solved, present a wrong gradient.

I already tried set the UDS to be solved in all the domains and then I would set a low diffusion coefficient on the domains where it shouldnt be solved but didnt manage to get it right.

Do you have any alternative to this?
I know boundary_face_thread, however, I am not entirely sure how could I use it to fix this issue.
diogoloureiromartinho 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
whats the cause of error? immortality OpenFOAM Running, Solving & CFD 13 March 24, 2021 07:15
User Defined Scalar Flux SandilyaCFD OpenFOAM Running, Solving & CFD 0 February 15, 2017 15:08
Diverging solution in transonicMRFDyMFoam tsalter OpenFOAM Running, Solving & CFD 30 July 7, 2014 06:20
is internalField(U) equivalent to zeroGradient? immortality OpenFOAM Running, Solving & CFD 7 March 29, 2013 01:27
user defined function in Transient Structural for FSI problem omidiut CFX 5 December 5, 2011 11:19


All times are GMT -4. The time now is 09:30.