
[Sponsors] 
October 19, 2010, 23:14 
how can I correct the udf?

#1 
New Member
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 8 
Hi,everyone. My udf has several errors as blow:
..\..\src\adjust.c(3) : error C2061: syntax error : identifier 'DEFINE' ..\..\src\adjust.c(3) : error C2059: syntax error : ';' ..\..\src\adjust.c(3) : error C2143: syntax error : missing '{' before '' ..\..\src\adjust.c(3) : error C2059: syntax error : '' ..\..\src\adjust.c(54) : error C2065: 'thread' : undeclared identifier ..\..\src\adjust.c(54) : error C2223: left of '>storage' must point to struct/union ..\..\src\adjust.c(56) : error C2223: left of '>storage' must point to struct/union ..\..\src\adjust.c(80) : error C2065: 'thread' : undeclared identifier ..\..\src\adjust.c(80) : error C2223: left of '>storage' must point to struct/union ..\..\src\adjust.c(82) : error C2223: left of '>storage' must point to struct/union and the udf itself as below: #include "udf.h" DEFINE_ADJUST(print_f_centroids, domain) real FUDMI(f,thread,0) { Thread *thread; face_t f; real force1=0.,force2=0.; int ID = 13; Thread *t= Lookup_Thread(domain, ID); { begin_f_loop(f, thread) { F_AREA(A,f,thread); force1+=F_P(f, thread)*NV_MAG(A); return force1; } end_f_loop(f, thread) } int ID=16; Thread *thread = Lookup_Thread(domain, ID); { begin_f_loop(f, thread) { F_AREA(A,f,thread); force2+=F_P(f, thread)*NV_MAG(A); return force2; } end_f_loop(f, thread) } F_UDMI(f,thread,0)=force1force2; printf("F_UDMI(f,thread,0) = %f ", F_UDMI(f,thread,0)); } DEFINE_CG_MOTION(moveface,dt,vel,omega,time,dtime) { Thread *t; face_t f; real NV_VEC (A); real dv; static real v_prev=0.0; /* reset velocities */ NV_S(vel,=,0.0); NV_S(omega,=,0.0); if(!Data_Valid_P()) return; /* get the thread pointer for which this motion is defined */ t=DT_THREAD (dt); /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv=dtime*F_UDMI(f,t,0)/0.05; v_prev+=dv; Message("time=%f,x_vel=%f,F_UDMI(f,t,0)=%f\n",time ,v_prev,F_UDMI(f,t,0)); /* set xcomponent of velocity */ vel[0]=v_prev; } DEFINE_CG_MOTION(moveface1,dt,vel,omega,time,dtime ) { Thread *t; face_t f; real NV_VEC (A); real dv; static real v_prev=0.0; /* reset velocities */ NV_S(vel,=,0.0); NV_S(omega,=,0.0); if(!Data_Valid_P()) return; /* get the thread pointer for which this motion is defined */ t=DT_THREAD (dt); /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv=dtime*F_UDMI(f,t,0)/0.05; v_prev+=dv; Message("time=%f,x_vel=%f,F_UDMI(f,t,0)=%f\n",time ,v_prev,F_UDMI(f,t,0)); /* set xcomponent of velocity */ vel[0]=v_prev; } could anyone give me some suggestion ? thanks a lot.
__________________
I want to find a good job, fightting! 

October 20, 2010, 02:32 
the function FUDMI(f,thread,0) is already defined !

#2 
New Member
Laurence Wallian
Join Date: Mar 2009
Posts: 17
Rep Power: 9 
I'm not sure, but try to remove the line real FUDMI(f,thread,0).
P.S. however, I think a ";" is missing in such line : FUDMI(f,thread,0) 

October 20, 2010, 02:44 

#3 
New Member
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 8 
Thanks for your reply.
I use "real F_UDMI(f,thread,0)" to make a subfunction . can not it work? just now,I compiled it again ,the error becomes ..\..\src\adjust.c(3) : error C2059: syntax error : 'type' ..\..\src\adjust.c(34) : fatal error C1903: unable to recover from previous error(s); stopping compilation. can not it work?
__________________
I want to find a good job, fightting! 

October 20, 2010, 02:56 

#4 
New Member
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 8 
what confused me is that for the ID function , the purpose of accessing the force of the wall , is this format write ?
In my model, there are 3 faces need to calculate the force , should I write all of the 3 subfuctions in one bracket like the udf I uploaded ? can you give me some example of the same type? I will appreciate you very much!
__________________
I want to find a good job, fightting! 

October 20, 2010, 03:33 

#5 
New Member
Laurence Wallian
Join Date: Mar 2009
Posts: 17
Rep Power: 9 
sorry but I have never used F_UDMI.
I've juste use DEFINE_ADJUST to sum some variables during unsteady run but what can I say is that I think you make a confusion between "," and ";" real force1=0.,force2=0.; => real force1=0.; force2=0.; In C, all instructions must be closed by a ";" good luck 

October 20, 2010, 03:51 

#6 
New Member
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 8 
Thanks a lot!
I have delete the real F_UDMI,and now it indicates other errors. I think it is allowable to define multiparemeters in a parellel line with ,and a ; at the end of the line. also, the console indicate that the DEFINE_ADJUST could not be used to ruturn a parameter,so I cancle the macro also , instead, put the conmmand to the macro of DEFINE_CG_MOTION.
__________________
I want to find a good job, fightting! 

October 20, 2010, 04:32 

#7 
New Member
Laurence Wallian
Join Date: Mar 2009
Posts: 17
Rep Power: 9 
you can define a variable in your C program.
I don't know if it can help you but in the file joined here, I defined the mean of U,V et P every 10 irerations (it was an unsteady run) :  I defined a variable CMPT and 3 UDM : U, V and P  these variables can then be visibles in casedata 

October 20, 2010, 08:39 

#8 
New Member
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 8 
Thanks ,I get it that use C_UDMI can get the data translating from the DEFINE_ADJUST.but I still feel that the configuration is in babelism,would you give me some suggestion?
__________________
I want to find a good job, fightting! 

October 20, 2010, 10:28 

#9 
New Member
Laurence Wallian
Join Date: Mar 2009
Posts: 17
Rep Power: 9 
sorry but I don't understand your request: if you want to measure forces on faces, you will need F_UDMI instead of C_UDMI ?!


January 28, 2011, 10:50 

#10 
New Member
anonymous
Join Date: Jan 2011
Posts: 12
Rep Power: 7 
did u find ur way to avoid the " left of storage must point to struct/union" ...i am facing similar errors


Tags 
cg_motion, compile error, udf 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Moving mesh  Niklas Wikstrom (Wikstrom)  OpenFOAM Running, Solving & CFD  122  June 15, 2014 06:20 
correct UDF code for unsteady pressure boundary  James W  FLUENT  0  November 2, 2005 12:38 
to correct me an udf program  farida hamadi  FLUENT  0  December 18, 2004 06:54 
Cannot set correct inlet velocity by UDF?!?  Bob  FLUENT  5  March 27, 2003 04:17 
Is this UDF correct?  JJ  FLUENT  3  April 8, 2001 18:54 