|
[Sponsors] |
September 10, 2010, 07:16 |
|
#7 |
New Member
adrian lynch
Join Date: Feb 2010
Posts: 9
Rep Power: 16 |
Hi Kartn
The problem with the previous code that I posted was in getting the value for the variable “flow” from the DEFINE_EXECUTE_AT_END section and using it in the DEFINE_PROFILE. The way it was set as a global variable was okay but what was happening was it was been set to zero after the DEFINE_EXECTUE_AT_END loop so the DEFINE_PROFILE function was seeing a value of flow=0. Sorry if what I am saying is hard to follow, but I have attached the working code below and maybe from comparing the two you will be able to understand. The only real different is in introducing the flow_tot variable as the global variable instead of using the flow variable. #include"udf.h" real flow_tot; real p ; DEFINE_EXECUTE_AT_END(funny) { Domain *d; real flow; cell_t c; Thread *t; face_t f; d = Get_Domain(1); t= Lookup_Thread(d, 12); begin_f_loop(f,t) { flow+=F_FLUX(f,t); } end_f_loop(f,t) p = C_P(c,t); printf("static pressure = %g\n", p); printf("MASS Flow Rate: %g\n",flow); flow_tot =flow; flow=0.; } DEFINE_PROFILE(pressure_out,t,i) { real set_point = 1; real pressure; face_t f; printf("MASS Flow Rate: %g\n",flow_tot); if (flow_tot < set_point) pressure = p - 1; elseif (flow_tot > set_point) pressure = p + 1; else pressure = p; begin_f_loop(f,t) { F_PROFILE(f,t,i) = pressure; } end_f_loop(f,t) printf("Adjusted pressure = %g\n", pressure); } Hope this helps! |
|
Tags |
lookup_thread, mass flow rate, udf |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mass flow rate not conserved in turbomachine, interface defined wrong? | wildli | FLUENT | 3 | September 15, 2022 12:19 |
mass flow rate (CFX post) | sanchezz | CFX | 2 | January 14, 2010 06:54 |
Mass Flow Rate | student87 | CFX | 4 | January 2, 2010 04:45 |
mass flow rate entering and exiting a cell | samir bensaid | FLUENT | 0 | July 4, 2007 05:37 |
User defined function of mass flow rate | Eric | FLUENT | 1 | April 22, 2005 18:15 |