How to transfer a 2D UDF code into 3D?
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. |
All times are GMT -4. The time now is 17:13. |