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

Function Hooks

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 7, 2020, 17:01
Default Function Hooks
  #1
p.1
New Member
 
Italia
Join Date: Oct 2020
Posts: 19
Rep Power: 5
p.1 is on a distinguished road
Hi. This is my UDF:

#include "udf.h"
#define uinf 1.75
#define d 6

DEFINE_ADJUST(uu, domain)
{
Thread *t;
cell_t c;

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
real mu_t = C_MU_T(c, t); /*Eddy Viscosity*/
real k = C_K(c, t); /*Turbulence Kinetic Energy*/
real ux = C_U_G(c, t)[0]; /*du/dx*/

C_UDSI(c, t, 0) = 2 * mu_t*ux - (2 / 3)*k;

C_UDMI(c, t, 3) = -C_UDSI_G(c, t, 0)[0] / (uinf*uinf*d);
}
end_c_loop(c, t)
}
}


I have to get the contours of the UDM, so I put "uu" in "User-Defined Function Hooks" but Fluent crash. If I don't put "uu" in "User-Defined Function Hooks" Fluent run the calculation but the value of my UDM is 0.
How can I solve it?
p.1 is offline   Reply With Quote

Old   November 9, 2020, 00:21
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you should put "uu" in "User-Defined Function Hooks" to make it executed.
why do you use scalar in your code? C_UDSI(c, t, 0)

most likely, you didn't allocate memories for user defined scalars and/or for user defined memory

also
Quote:
In order to retain the
gradient data (when you want to set up user-defined scalar transport equations, for example), you can
prevent the solver from freeing up memory by issuing the text command solve/set/expert and
then answering yes to the question, “Keep temporary solver memory from being freed?”
you may try this code, allocate 2 memory locations in FLUENT GUI
Code:
#include "udf.h"
#define uinf 1.75
#define d 6

DEFINE_ADJUST(uu, domain)
{
Thread *t;
cell_t c;
real mu_t; /*Eddy Viscosity*/
real k; /*Turbulence Kinetic Energy*/
real ux; /*du/dx*/

thread_loop_c(t, domain)
{
begin_c_loop(c, t)
{
mu_t = C_MU_T(c, t); /*Eddy Viscosity*/
k = C_K(c, t); /*Turbulence Kinetic Energy*/
ux = C_U_G(c, t)[0]; /*du/dx*/

C_UDMI(c, t, 0) = 2 * mu_t*ux - (2 / 3)*k;
C_UDMI(c, t, 1) = (2 * mu_t*ux - (2 / 3)*k) / (uinf*uinf*d);
}
end_c_loop(c, t)
}
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 9, 2020, 03:23
Default
  #3
p.1
New Member
 
Italia
Join Date: Oct 2020
Posts: 19
Rep Power: 5
p.1 is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
why do you use scalar in your code? C_UDSI(c, t, 0)
[/CODE]
Thank you, I use C_UDSI(c,t,0) because I have to get the gradient of this UDS, in fact in C_UDMI I have C_UDSI_G. In your UDF there isn't the gradient, right?
p.1 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 11:04
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 13:06
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 04:37
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


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