|
[Sponsors] |
August 26, 2012, 04:36 |
How to transfer a 2D UDF code into 3D?
|
#1 |
New Member
zhuoweili
Join Date: Oct 2011
Posts: 14
Rep Power: 15 |
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. |
|
|
|
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 |