|
[Sponsors] |
January 5, 2011, 03:56 |
Is my UDF correct
|
#1 |
Member
EH
Join Date: Dec 2010
Posts: 61
Rep Power: 15 |
Hi all,
Basically, I am trying to simulate a flow tank where the outflow is pumped back into the tank via eight inlets (front1,front2,back1,back2,right1,right2,left1,lef t2). I am trying to write a UDF such that the average temperature of the outflow is the same as the temperature of each of the eight inlets. My UDF (modified from an existing code) is listed: #include "udf.h" /* Mean temperature at outlet is calculated */ DEFINE_ADJUST(mean_outlet_temp, domain) { #if !RP_HOST /* either serial or compute node process is involved */ face_t f; real sum_temp=0.0; int nfaces=0, i; int ID_out = 67; //out int ID_back1 = 65; //back1 int ID_back2 = 66; //back2 int ID_front1 = 59; //front1 int ID_front2 = 60; //front2 int ID_left1 = 63; //left1 int ID_left2 = 64; //left2 int ID_right1 = 61; //right1 int ID_right2 = 62; //right2 /* Determination of zone IDs */ Thread *thread_out = Lookup_Thread(domain, ID_out); Thread *thread_back1 = Lookup_Thread(domain, ID_back1); Thread *thread_back2 = Lookup_Thread(domain, ID_back2); Thread *thread_front1 = Lookup_Thread(domain, ID_front1); Thread *thread_front2 = Lookup_Thread(domain, ID_front2); Thread *thread_left1 = Lookup_Thread(domain, ID_left1); Thread *thread_left2 = Lookup_Thread(domain, ID_left2); Thread *thread_right1 = Lookup_Thread(domain, ID_right1); Thread *thread_right2 = Lookup_Thread(domain, ID_right2); /* Calculation of average outflow temperature and sending to other nodes. */ /* The thread on which the average temperature is calculated is on node zero. */ if(I_AM_NODE_ZERO_P) { begin_f_loop(f,thread_out) { nfaces = nfaces + 1; sum_temp = sum_temp + F_T(f,thread_out); } end_f_loop(f,thread_out) sum_temp = sum_temp/nfaces; /* Message("Node %d : Average exit temperature = %f\n", myid, sum_temp); */ compute_node_loop_not_zero(i) { PRF_CSEND_DOUBLE(i, &sum_temp, 1, myid); } } /* Reception of average temperature from node zero */ if(! I_AM_NODE_ZERO_P) { PRF_CRECV_DOUBLE(0, &sum_temp, 1, 0); /* Message("Node %d : Average exit temperature = %f\n", myid, sum_temp); */ } /* User defined memory of thread_back1 are filled with sum_temp */ begin_f_loop(f, thread_back1) { F_UDMI(f,thread_back1,1) = sum_temp; } end_f_loop(f,thread_back1) /* User defined memory of thread_back2 are filled with sum_temp */ begin_f_loop(f, thread_back2) { F_UDMI(f,thread_back2,2) = sum_temp; } end_f_loop(f,thread_back2) /* User defined memory of thread_front1 are filled with sum_temp */ begin_f_loop(f, thread_front1) { F_UDMI(f,thread_front1,3) = sum_temp; } end_f_loop(f,thread_front1) /* User defined memory of thread_front2 are filled with sum_temp */ begin_f_loop(f, thread_front2) { F_UDMI(f,thread_front2,4) = sum_temp; } end_f_loop(f,thread_front2) /* User defined memory of thread_left1 are filled with sum_temp */ begin_f_loop(f, thread_left1) { F_UDMI(f,thread_left1,5) = sum_temp; } end_f_loop(f,thread_left1) /* User defined memory of thread_left2 are filled with sum_temp */ begin_f_loop(f, thread_left2) { F_UDMI(f,thread_left2,6) = sum_temp; } end_f_loop(f,thread_left2) /* User defined memory of thread_right1 are filled with sum_temp */ begin_f_loop(f, thread_right1) { F_UDMI(f,thread_right1,7) = sum_temp; } end_f_loop(f,thread_right1) /* User defined memory of thread_right2 are filled with sum_temp */ begin_f_loop(f, thread_right2) { F_UDMI(f,thread_right2,8) = sum_temp; } end_f_loop(f,thread_right2) #endif } /* Boundary conditions are filled from user defined memory locations */ DEFINE_PROFILE(back1,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,1); } end_f_loop(f,t) #endif } DEFINE_PROFILE(back2,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,2); } end_f_loop(f,t) #endif } DEFINE_PROFILE(front1,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,3); } end_f_loop(f,t) #endif } DEFINE_PROFILE(front2,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,4); } end_f_loop(f,t) #endif } DEFINE_PROFILE(left1,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,5); } end_f_loop(f,t) #endif } DEFINE_PROFILE(left2,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,6); } end_f_loop(f,t) #endif } DEFINE_PROFILE(right1,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,7); } end_f_loop(f,t) #endif } DEFINE_PROFILE(right2,t,i) { #if !RP_HOST face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i) = F_UDMI(f,t,8); } end_f_loop(f,t) #endif } I tried compiling this but I have not been able to get the compilation successful message mentioned in the fluent manual. I am running parallel in local machine (Win64) and not in a cluster of machines. Also, I am using FLUENT v12. It may be possible that the error is due to the link between Microsoft Visual Studio 2008 and FLUENT but I want to make sure the code is correct before I go reinstalling Visual Studio. If anyone can help, I will be very grateful. Thank you. EH |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF to record FLUENT Solver variables... | mariachi | Fluent UDF and Scheme Programming | 11 | September 24, 2019 01:07 |
HELP! adding a mass source to VOF eqn. by UDF??? | ROOZBEH | FLUENT | 5 | December 3, 2016 18:53 |
how can I correct the udf? | happyrabbit | FLUENT | 9 | January 28, 2011 10:50 |
UDF to record FLUENT solver variables... | mariachi | FLUENT | 1 | February 3, 2010 23:18 |
difference between udf compiled and udf interprete | chandra sekhar | FLUENT | 2 | April 11, 2006 01:04 |