UDFaccessing fluent variables
I'm writing a UDF in which I need to access the average value of the pressure on a compressor exit area (that have been calculated with 3D simulation). This socalled "area mass average" value is define as: sum(p_i*A_i*_m_i)/sum(A_i*m_i) where p_i is the pressure, A_i the area and m_i the mass flow in each cell of the exit face. I found the function "F_P(f,t)" that records the pressure in each cell of the face but not the average value. Does anybody knows how to compute this average then? Thanks Manu

Re: UDFaccessing fluent variables
//Please check this udf after changing id to the outlet ID
#include "udf.h" DEFINE_ON_DEMAND(average_pressure) { Domain *d; real P_avg; real A[ND_ND]; Thread *t; real m_sum=0.0; real sum=0.0; int id="GIVE YOUR ZONE ID"; face_t f; d = Get_Domain(1); t= Lookup_Thread(d,id) begin_f_loop(f,t) { sum=sum+(F_P(f,t)*NV_MAG(A)*F_FLUX(f,t)); m_sum=NV_MAG(A)*F_FLUX(f,t); } end_f_loop(f,t) P_avg=sum/m_sum; Message("MY AVERAGE PRESSURE=%f\n",P_avg); } 
Re: UDFaccessing fluent variables
Thank you very much, it looks great!!! I didn't try it yet because I have one small problem accessing the area of each cell. I don't exactly understand the syntax of the function: F_AREA(A,f,t). Does it suffice to add: (...) real A[ND_ND]; F_AREA(A,f,t); (...) and then A is assigned with the area vector?? Is it right so?

Re: UDFaccessing fluent variables
F_AREA(A,f,t); is a function which returns the face normal w.r.t to the grobal axis. A> has three components if its 3D or two componnts if 2D. f and t are the face id for the thread 't'. These things are discussed in fluent manual pertaining to UDF. You can find these things from any search engines Typically, http://venus.imp.mx/hilario/SuperCom...tml/node56.htm

All times are GMT 4. The time now is 11:55. 