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

How to write UDF programme inside FLUENT?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Bruno Machado
  • 1 Post By mmunige

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 25, 2009, 23:54
Default How to write an UDF programming inside FLUENT?
  #1
New Member
 
oscar
Join Date: Mar 2009
Posts: 7
Rep Power: 17
coolyihao is on a distinguished road
I have a brick region..the front surface i make it as inlet and i would like to write a UDF programme for the inlet velocity which is parabolic shape.. eg: at the center of the inlet is the highest velociy. (a parabolic shape)

secondly, left, right and behind surface i make it as pressure outlet and write a UDF programme for pressure different. Due to the brick region as a sea. and the lower surface is a seabed.. therefore if from top surface to lower surface(deeper) , the pressure will increase..(a triangle shape)

May I know how to write a UDF programme for this..THX

Last edited by coolyihao; March 26, 2009 at 21:19.
coolyihao is offline   Reply With Quote

Old   March 26, 2009, 05:19
Default
  #2
Senior Member
 
Rami Ben-Zvi
Join Date: Mar 2009
Posts: 155
Rep Power: 17
Rami is on a distinguished road
There is a detailed example of a parabolic velocity profile in the UDF manual (chapter 8). Once you learn how to do it, the pressure BCs would be easy to add.
Rami is offline   Reply With Quote

Old   March 26, 2009, 05:49
Default
  #3
New Member
 
oscar
Join Date: Mar 2009
Posts: 7
Rep Power: 17
coolyihao is on a distinguished road
ya..i saw it be4..but then i got the result that doesnt make sense..for example: i put X=0 , Y=1, Z=0..inside the grapgh, ya i get the parabolic shape which is 'u' shape..OR is it suppose a 'n' shape.

But for the pressure difference is it necessary use this function?F_CENTROID(x,f,thread)

regards
coolyihao is offline   Reply With Quote

Old   March 28, 2009, 20:12
Default
  #4
New Member
 
Andrew Slezak
Join Date: Mar 2009
Posts: 1
Rep Power: 0
Drew is on a distinguished road
yes, probably. f_centroid will return the position vector of the cell in 'x'. The solver should produce the pressure profile throughout your domain given appropriate initial and boundary conditions.
Drew is offline   Reply With Quote

Old   April 1, 2009, 02:07
Default
  #5
Member
 
Buddy
Join Date: Mar 2009
Location: P.R.C.
Posts: 30
Rep Power: 17
zjbwow is on a distinguished road
Quote:
Originally Posted by Drew View Post
yes, probably. f_centroid will return the position vector of the cell in 'x'. The solver should produce the pressure profile throughout your domain given appropriate initial and boundary conditions.
there are two kinds of parallel functions such as begin _c_loop and begin_f_loop, can you tell me the differents bwteen face and cell?

and if the using of the cell will return the vector of it,what will return if we use face instead? O(∩_∩)O~

thx in advance
zjbwow is offline   Reply With Quote

Old   March 8, 2016, 12:24
Default UDF for derivatives if fluctuating velocities
  #6
Member
 
Join Date: May 2013
Posts: 32
Rep Power: 12
maphd is on a distinguished road
Hello,

Does anyone know how to calculate 1st derivatives (partial derivative) of the fluctuating velocities in UDF? Appreciate any help.

Thanks,
maphd is offline   Reply With Quote

Old   March 8, 2016, 13:23
Default
  #7
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by maphd View Post
Hello,

Does anyone know how to calculate 1st derivatives (partial derivative) of the fluctuating velocities in UDF? Appreciate any help.

Thanks,
you gotta define an UDS as the value you want (fluctuating velocities in this case) and then you can calculate the gradient using C_UDSI_G(c,t,i)[0] whereas i is the number of the UDS you define and [0] is in the x direction (1 and 2 for y and z direction respectively).
maphd likes this.
Bruno Machado is offline   Reply With Quote

Old   March 8, 2016, 13:53
Default
  #8
Member
 
Join Date: May 2013
Posts: 32
Rep Power: 12
maphd is on a distinguished road
Bruno Machado,

Thank you for your reply. I really appreciate your help.
I never tried a UDF and UDS before. Could you please give me some more help on this? I have added an image file of the equation that I am trying to define in Fluent.
Thank you,
Attached Images
File Type: jpg strain rate.JPG (36.5 KB, 81 views)
maphd is offline   Reply With Quote

Old   March 11, 2016, 09:02
Default
  #9
Senior Member
 
Bruno Machado
Join Date: May 2014
Posts: 271
Rep Power: 12
Bruno Machado is on a distinguished road
Quote:
Originally Posted by maphd View Post
Bruno Machado,

Thank you for your reply. I really appreciate your help.
I never tried a UDF and UDS before. Could you please give me some more help on this? I have added an image file of the equation that I am trying to define in Fluent.
Thank you,
I recommend you to have a read in the fluent manual, in the UDS (User Define Scalar) section. There you will understand how to setup a scalar in your case.

The macro C_UDSI_G(c,t,i)[0] is the derivative with respect of X, whilst C_UDSI_G(c,t,i)[1] is in the Y direction and C_UDSI_G(c,t,i)[2] is with respect of Z direction.
What you gotta do is to define a UDS (fluctuating velocity) and then using the macros previous mentioned, you can easily reproduce the equation you attached.
Bruno Machado is offline   Reply With Quote

Old   June 5, 2016, 21:08
Default nested if statement in udf
  #10
New Member
 
mm
Join Date: May 2016
Posts: 24
Rep Power: 8
mmunige is an unknown quantity at this point
Respected members

I am using udf for defining transient temperature at inlet boundary of my model in fluent. I am writing nested if statement, but model keeps on using the same equation after 180 seconds, and does not move to the next if else statement. My udf is as follows:

#include"udf.h"

DEFINE_PROFILE(inlet_temperature,thread,position )
{

face_t f;
begin_f_loop(f,thread)

{

real t = RP_Get_Real("flow-time");

if ( t <= 100.0 )

F_PROFILE(f,thread,position) = 379.48 + 0.0004*t;

else if (100.0 < t <= 180.0 )

F_PROFILE(f,thread,position) = 1.0624*t + 352.0;

else if (180.0 < t <= 200.0 )

F_PROFILE(f,thread,position) = 0.2716*t + 494.4;

else if (200.0 < t <= 400.0 )
F_PROFILE(f,thread,position) = 328.14*pow(t,0.097);
else
F_PROFILE(f,thread,position) = 727.82;

}
end_f_loop(f,thread)
}

sorry for my poor knowledge of programming.
please help me on this error.
Thanks.
Tianxu likes this.
mmunige 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
Fluent UDF in CFX CFX User CFX 9 July 25, 2023 09:20
developing FLUENT UDF programs by VC++ 6.0 IDE huang peng FLUENT 2 February 25, 2007 14:58
Parallel UDF data passing causes Fluent to hang Tom FLUENT 2 June 9, 2006 13:17
Trying to Write pitch and Plunge UDF Alex FLUENT 0 March 18, 2006 16:14
How to write UDF for pitching&plunging airfoil? Alex FLUENT 0 March 17, 2006 12:37


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