CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   parse error with interpreting UDF (http://www.cfd-online.com/Forums/fluent-udf/67406-parse-error-interpreting-udf.html)

ivanbuz August 13, 2009 17:40

parse error with interpreting UDF
 
This is my first UDF, and I am having trouble to interpret it into Fluent. Fluent shows the following error, but I don't know what is wrong.

Error: H:\airfoil_flow\setup_test9_UDF\time_average_press ure_coeff.c: line 23: parse error.
Error: H:\airfoil_flow\setup_test9_UDF\time_average_press ure_coeff.c: line 23: f_loop_last: undeclared variable

See below for the UDF. I am doing unsteady flow around a 3D airfoil, and want to use this UDF to calculate the time-averaged pressure coefficient on the airfoil surface.

/************************************************** **************************/
/* UDF to compute time-averaged pressure coefficient */
/************************************************** **************************/

/* be sure to allocate at least two UDM*/

#include "udf.h"

int n=0; /* number of time-step */
int zone_ID=5; /* zone ID of airfoil surface */

DEFINE_EXECUTE_AT_END(time_avr_PC)
{

Domain *domain = Get_Domain(1);
Thread *t = Lookup_Thread(domain, zone_ID);
real p_ref=0, den_ref=1.225, u_ref=21.911; /* reference pressue, reference density and reference velocity */
real q_ref=1/2*den_ref*u_ref*u_ref; /* reference dynamic pressure */
face_t f;

n++

begin_f_loop(f,t)
{
F_UMDI(f,t,0)+= F_P(f,t);
F_UDMI(f,t,1)=(F_UMDI(f,t,0)/n - p_ref)/(q_ref);
}
end_f_loop(f,t)
}




Thanks for any suggestion!

ivanbuz August 13, 2009 17:53

I got it. I miss the ; behind n++.

and I also fix the typo in line 25 and 26: F_UMDI to F_UDMI.

This is the new version of it.


/************************************************** **************************/
/* UDF to compute time-averaged pressure coefficient */
/************************************************** **************************/

/* be sure to allocate at least two UDM*/

#include "udf.h"

int n=0; /* number of time-step */
int zone_ID=5; /* zone ID of airfoil surface */

DEFINE_EXECUTE_AT_END(time_avr_PC)
{

Domain *domain = Get_Domain(1);
Thread *t = Lookup_Thread(domain, zone_ID);
real p_ref=0, den_ref=1.225, u_ref=21.911; /* reference pressue, reference density and reference velocity */
real q_ref=1/2*den_ref*u_ref*u_ref; /* reference dynamic pressure */
face_t f;

n++;

begin_f_loop(f, t)
{
F_UDMI(f,t,0) += F_P(f,t);
F_UDMI(f,t,1) = (F_UDMI(f,t,0)/n - p_ref)/(q_ref);
}
end_f_loop(f, t)
}


But I still have problem. Fluent shows error as following while interpreting. Anyone knows what it means?

Error: Set_Thread_Variables: wta(real)
Error Object: ((constant . 1) (profile "" ""))

ivanbuz August 13, 2009 18:29

I got it. it is bacause I read the case and data files into older version of fluent.


All times are GMT -4. The time now is 00:44.