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

UDF Turbulent Viscosity Damping Function

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 25, 2016, 06:25
Default UDF Turbulent Viscosity Damping Function
  #1
New Member
 
Martijn
Join Date: Nov 2016
Posts: 13
Rep Power: 10
Revolver2006 is on a distinguished road
Dear all,

My thesis project is about a CFD analysis of a Wing-in-Ground effect vehicle. In order to improve my results I want to implement a UDF to damp the turbulent viscosity in the buffer region of the boundary layer. The basic idea is described in more detail in: "T. Chitsomboon, C. Thamyhae - Adjustment of k-w SST turbulence model for an improved prediction of stalls on wind turbine blades, Wind Energy Applications, 2011".

Although the procedure is fairly straightforward, I struggle with the implementation. I should note that I have no experience with writing UDF's or programming in C for that matter. Nevertheless, I believe the error (parse error line 36) is because I cant find a way to access the yplus value of the cells. I searched the forums (and Google) but I do not find a solution. This part is giving me headaches:

...

real F3(wall_d_bc, t, i)
{
real yPlus = C_STORAGE_R(f,t,SV_WALL_YPLUS_UTAU);

real A = 10;
real B = 200;

if (A<yPlus<B)
F3 = 0.1+(1-0.1*tanh(pow((0.03*yPlus), 4)))*(0.9+0.1*tanh(pow((0.005*yPlus),8)));
else
{
F3=1;
}

return F3;
}

...

I attached the full code in a separate file. Could anyone help me out to implement this UDF? Your help is much appreciated!
Attached Files
File Type: c Eddy_Visc_Mod_V4.c (1.6 KB, 50 views)
Revolver2006 is offline   Reply With Quote

Old   November 25, 2016, 09:20
Default
  #2
Member
 
KirMaks
Join Date: Aug 2016
Posts: 34
Rep Power: 10
kirmaks is on a distinguished road
Hallo,

I'm not sure, but shouldn't You provide the types of variables in the definition of the function F3 (as You have made it for F2)?

It is also a good praxis to divide the code in small blocks and increase its complexity in small steps to see when exactly the error comes out.

Best regards, Maks
kirmaks is offline   Reply With Quote

Old   November 25, 2016, 10:04
Default
  #3
New Member
 
Martijn
Join Date: Nov 2016
Posts: 13
Rep Power: 10
Revolver2006 is on a distinguished road
Thank you very much for your reply Maks, much appreciated!

You are correct about the input of F3, as I do not need the properties of the walls themselves. It now gives some other errors, but I will try to resolve them first. I'll keep you posted! Thanks again.


P.S. When I comment the F3 part and set it as a constant, the code will run flawlessly
Revolver2006 is offline   Reply With Quote

Old   November 25, 2016, 11:15
Default
  #4
New Member
 
Martijn
Join Date: Nov 2016
Posts: 13
Rep Power: 10
Revolver2006 is on a distinguished road
The UDF can now be interpreted without any errors, however the solver gives the following error when applying the UDF:

"mpi application rank 0 exited before mpi_finalize() with status 2"

If I understand it correctly this has something to do with parallel processing. is that correct? I do run Fluent in parallel mode on a 12 core machine. Do I need to take specific measures to parallel the code?

The updated code is attached. Any suggestions are welcome!
Attached Files
File Type: c Eddy_Visc_Mod_V5.c (1.8 KB, 27 views)
Revolver2006 is offline   Reply With Quote

Old   November 26, 2016, 07:39
Default
  #5
New Member
 
Martijn
Join Date: Nov 2016
Posts: 13
Rep Power: 10
Revolver2006 is on a distinguished road
Another update:

I found out that the problem isn't related to Fluent parallel mode or memory allocation. Instead, it appears that the line:

real yPlus = C_STORAGE_R(c,t,SV_WALL_YPLUS_UTAU);

,is giving me the error. When I replace yplus with a constant value I can run the simulation without any problems. Hence, it appears that I will need to find a different way to access or calculate the yplus of the cell.

However I am not sure how to do this. I have noticed that Fluent only stores the yplus value of the wall adjacent cells, which could be an explanation for the above error. Nevertheless, I need to be able to define a specific range of Yplus where the eddy viscosity is modified by the described damping function. Any suggestions?
Revolver2006 is offline   Reply With Quote

Old   November 28, 2016, 02:59
Default
  #6
Member
 
KirMaks
Join Date: Aug 2016
Posts: 34
Rep Power: 10
kirmaks is on a distinguished road
Hallo,

there may be several things:

1. may be the temporary memory should be keept during iterations: try to set it through /solve/set/expert

2. this variable may not be initialised during the first iteration, so You sould check for it, there are some examples in the forum, I saw several different recently, but couldn't find them, try to put something like:
Code:
if ( NULL != ...here should be check for data availability...)
{
 
}
3. You may try to compute YPlus with the C_WALL_DIST and /solve/set/expert

Good Luck and best regards, Maks.
kirmaks is offline   Reply With Quote

Old   February 17, 2017, 11:22
Default
  #7
New Member
 
Martijn
Join Date: Nov 2016
Posts: 13
Rep Power: 10
Revolver2006 is on a distinguished road
Although the UDF function did not improve my results, I will share the final version that I have used.

I decided to bypass the yplus problem by inserting a fixed empirical relation for yplus based on the wall distance y. The relation was obtained by using the Yplus calculator. For a proof of concept, it was good enough as the variation in yplus was very small. Nevertheless, I am very aware that this a rough approximation.

The eddy viscosity function was indeed successfully damped, however it did not improve my results in a significant way. The boundary layer remained fairly insensitive to the adverse pressure gradient, compared to the experimental data.

In the end, the UDF proved to be most useful for explaining an artefact in the velocity profile of the boundary layer in certain cases. The wall distance y is not calculated correctly at the transition between the prism layer and tetrahedral mesh, causing a discontinuity in the blending function F2 of the SST model. This was resolved by increasing the prism layer thickness.
Attached Files
File Type: c Eddy_Visc_Mod_V18.c (2.1 KB, 43 views)
Revolver2006 is offline   Reply With Quote

Old   February 28, 2017, 17:06
Default
  #8
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18
alinik is on a distinguished road
Quote:
Originally Posted by kirmaks View Post
Hallo,

there may be several things:

1. may be the temporary memory should be keept during iterations: try to set it through /solve/set/expert

2. this variable may not be initialised during the first iteration, so You sould check for it, there are some examples in the forum, I saw several different recently, but couldn't find them, try to put something like:
Code:
if ( NULL != ...here should be check for data availability...)
{
 
}
3. You may try to compute YPlus with the C_WALL_DIST and /solve/set/expert

Good Luck and best regards, Maks.
Kirmaks,

I am using C_WALL_DIST(c,t) in fluent 16.2 but I am receiving segmentation error on that.
have you had similar experience? Do you know how to fix this?
alinik is offline   Reply With Quote

Old   February 28, 2017, 17:20
Default
  #9
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18
alinik is on a distinguished road
Quote:
Originally Posted by Revolver2006 View Post
Although the UDF function did not improve my results, I will share the final version that I have used.

I decided to bypass the yplus problem by inserting a fixed empirical relation for yplus based on the wall distance y. The relation was obtained by using the Yplus calculator. For a proof of concept, it was good enough as the variation in yplus was very small. Nevertheless, I am very aware that this a rough approximation.

The eddy viscosity function was indeed successfully damped, however it did not improve my results in a significant way. The boundary layer remained fairly insensitive to the adverse pressure gradient, compared to the experimental data.

In the end, the UDF proved to be most useful for explaining an artefact in the velocity profile of the boundary layer in certain cases. The wall distance y is not calculated correctly at the transition between the prism layer and tetrahedral mesh, causing a discontinuity in the blending function F2 of the SST model. This was resolved by increasing the prism layer thickness.
Martijn,

What version of Fluent are you using? I am using 16.2 and am constantly getting segmentation error whenever I use C_WALL_DIST(c,t).
alinik is offline   Reply With Quote

Old   March 1, 2017, 04:30
Default
  #10
New Member
 
Martijn
Join Date: Nov 2016
Posts: 13
Rep Power: 10
Revolver2006 is on a distinguished road
I have used Fluent 16.1. What is the error message that you get?
Revolver2006 is offline   Reply With Quote

Old   March 1, 2017, 13:17
Default
  #11
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18
alinik is on a distinguished road
I use 16.2
I receive a generic segmentation error whenever I try to use the C_WALL_DIST macro.
If I replace that with some constant value the error will disappear and solver starts solving.
Do I have include some libraries in order to use C_WALL_DIST macro?

Thanks,
Ali
alinik is offline   Reply With Quote

Old   July 12, 2017, 15:40
Default
  #12
Member
 
Vedamt Chittlangia
Join Date: Feb 2016
Posts: 64
Rep Power: 9
vcvedant is an unknown quantity at this point
if you use C_WALL_DIST() then the original model that has to be selected should use yPlus.
So, either select Spalart-Allarmus model or k-e with enhanced wall treatment and then turn off turbulence while solving. This should solve the problem.
vcvedant 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
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
wrong results after use UDF turbulent viscosity lehoanganh07 Fluent UDF and Scheme Programming 0 July 21, 2014 12:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
UDF of Turbulent viscosity justin FLUENT 0 November 24, 2006 07:36
RNG k-e and turbulent viscosity UDF! ROOZBEH FLUENT 0 January 28, 2004 03:56


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