CFD Online Logo CFD Online URL
Home > Forums > FLUENT

Fluent UDF - Random Noise

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   March 18, 2008, 11:28
Default Fluent UDF - Random Noise
Posts: n/a
I am trying to implement a constant time dependent (step) velocity normal to the boundary at the inlet of my simulation. I would also like to include some random nosie with zero mean. I am not an expert in C but i patched together the script below:

#include "udf.h"

#include "stdlib.h"

DEFINE_PROFILE(Velocity_profile,thread,index) {

face_t f;

double Flow_Time;

double U;

double Random_Number_Array[100000] = {0.0};

double Mean = {0.0};

int Number_of_Face_Nodes;

int i;

int Counter = {0};

//Find number of nodes on face//

Number_of_Face_Nodes = F_NNODES(f,thread);

//Find simulation time//

Flow_Time = RP_GET_REAL("flow-time");

if (Flow_Time < 1.0)

U = 1.0;





//Generate Random numbers for each node on inflow face//

//The range is set to -0.5 to 0.5//

for (i=1 ; i < Number_of_Face_Nodes ; i++)



Random_Number_Array[i] =(((double) rand()/(double) RAND_MAX)-0.5)*((double) 2);

Mean = Mean + Random_Number_Array[i]; }

Mean = Mean/(double) Number_of_Face_Nodes;

//Ensure that mean is zero//

for (i=1 ; i < Number_of_Face_Nodes ; i++)

{Random_Number_Array[i] = Random_Number_Array[i] - Mean;}



Counter = Counter + 1;

//Velocity at each node is U + differenc Random fluctuation//

F_PROFILE(f, thread, index) = U + Random_Number_Array[Counter];


end_f_loop(f,t) }

I think this is a good start though I cannot get fluent (6.3.26) to interpret it. I get the error:

cpp -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/src" -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/cortex/src" -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/client/src" -I"/work/tanner/cx1_Fluent/Fluent.Inc/fluent6.3.26/multiport/src" -I. -DUDFCONFIG_H="<udfconfig.h>" "/work/tanner/LES_Unsteady/OCPS2_Forced/test.c" In file included from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/stdlib.h:33: stddef.h: No such file or directory In file included from /usr/include/sys/types.h:31,

from /usr/include/stdlib.h:433,

from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/bits/types.h:31: stddef.h: No such file or directory In file included from /usr/include/stdlib.h:433,

from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/sys/types.h:147: stddef.h: No such file or directory In file included from /usr/include/stdlib.h:606,

from /work/tanner/LES_Unsteady/OCPS2_Forced/test.c:2: /usr/include/alloca.h:25: stddef.h: No such file or directory Error: /usr/include/stdlib.h: line 108: syntax error. cpp: output pipe has been closed

I would certainly appreciate some help. I'm not sure how to get fluent to find the stdlib.h though it is installed on my computer. Many thanks.

  Reply With Quote

Old   March 19, 2008, 07:38
Default Re: Fluent UDF - Random Noise
Posts: n/a
I have managed to hook the UDF I wanted using the compile function rather than the intrepreted function.

My only concern now is how often the UDF is updated. I want a random profile at each time step NOT iteration.

I have found that including an "if (first_iteration)" statement produces works for unsteady PISO but is this suitable for NITA?

How frequently are profiles updated for NITA? How can I tell it to update at the start of each time step?
  Reply With Quote

Old   May 29, 2014, 03:27
Senior Member
Svetlana Tkachenko
Join Date: Oct 2013
Location: Australia
Posts: 144
Rep Power: 5
Светлана is on a distinguished road
looking at your code, it looks like U is "1.0 + random noise" on the first time step, and "2.0 + random noise" on next time steps. Would you happen to know how to make it "U_old + random noise" instead please?
Светлана is offline   Reply With Quote


Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Injections Lior FLUENT 0 November 8, 2004 04:07
how to call the random function in Fluent Yong FLUENT 3 April 6, 2004 03:52
random number in Fluent Yong FLUENT 0 April 1, 2004 21:13
Could Fluent simulate random process? David FLUENT 0 September 6, 2002 10:49
NEW flow-induced noise module in FLUENT 6?? jon FLUENT 0 March 18, 2002 05:18

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