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 transfer a 2D UDF code into 3D?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 26, 2012, 04:36
Default How to transfer a 2D UDF code into 3D?
  #1
New Member
 
zhuoweili
Join Date: Oct 2011
Posts: 14
Rep Power: 15
Jo_vivian_lee is on a distinguished road
Hi there, I am simulating a 2D case using FLUENT with a 2D UDF. The code is attached below:

#include "udf.h"
DEFINE_PROFILE(unsteady_velocity,thread,index)
{
real pos[2];
real x;
face_t f;
real t=RP_Get_Real("flow-time");
begin_f_loop(f, thread)
{
F_CENTROID(pos, f, thread);
x=pos[0];
if (x>0)
{
F_PROFILE(f,thread,index) =15.2*pow((1.0-x/0.003125), 1.0/6.0)+0.3*15.2*sin(1600*3.1415926*t);

}
else
{
F_PROFILE(f,thread,index) =15.2*pow((1.0+x/0.003125), 1.0/6.0)+0.3*15.2*sin(1600*3.1415926*t);

}
}
end_f_loop(f, thread)
}


Now I want to use a 3D mesh to do the same simulation. I wonder that how can I revise this 2D code and make it be suitable for a 3D case?
I have revised something, however, I don`t know whether it is correct or not. the revised code is as below, could you please check it and tell me whether it is ok or not?

#include "udf.h"
DEFINE_PROFILE(unsteady_velocity,thread,index)
{
real pos[ND_ND];
real x, t;
face_t f;
begin_f_loop(f, thread)
{
F_CENTROID(pos, f, thread);
x=pos[0];
t=CURRENT_TIME;
if (x>0)
{
F_PROFILE(f,thread,index) =15.2*pow((1.0-x/0.003125), 1.0/6.0)+0.3*15.2*sin(1600*3.1415926*t);

}
else
{
F_PROFILE(f,thread,index) =15.2*pow((1.0+x/0.003125), 1.0/6.0)+0.3*15.2*sin(1600*3.1415926*t);

}
}
end_f_loop(f, thread)
}


I look forward to your reply.
Thank you in advance.
Jo_vivian_lee 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
udf code for anisotropy turbulence model- square duct Eliasjal Fluent UDF and Scheme Programming 1 August 29, 2012 11:26
UDF code for concentration distribution szw_china Fluent UDF and Scheme Programming 0 July 22, 2012 22:35
code in dynamic meshing udf wlt_1985 FLUENT 3 April 21, 2011 15:33
correct UDF code for unsteady pressure boundary James W FLUENT 0 November 2, 2005 12:38
udf of heat transfer coefficient me FLUENT 1 June 24, 2005 15:05


All times are GMT -4. The time now is 14:40.