CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

how can I correct the udf?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2010, 00:14
Exclamation how can I correct the udf?
  #1
New Member
 
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 16
happyrabbit is on a distinguished road
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 F-UDMI(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)=force1-force2;
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 x-component 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 x-component of velocity */
vel[0]=v_prev;
}
could anyone give me some suggestion ? thanks a lot.
__________________
I want to find a good job, fightting!
happyrabbit is offline   Reply With Quote

Old   October 20, 2010, 03:32
Default the function F-UDMI(f,thread,0) is already defined !
  #2
New Member
 
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17
Laurence Wallian is on a distinguished road
I'm not sure, but try to remove the line real F-UDMI(f,thread,0).

P.S. however, I think a ";" is missing in such line : F-UDMI(f,thread,0)
Laurence Wallian is offline   Reply With Quote

Old   October 20, 2010, 03:44
Default
  #3
New Member
 
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 16
happyrabbit is on a distinguished road
Thanks for your reply.
I use "real F_UDMI(f,thread,0)" to make a sub-function .
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!
happyrabbit is offline   Reply With Quote

Old   October 20, 2010, 03:56
Default
  #4
New Member
 
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 16
happyrabbit is on a distinguished road
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 sub-fuctions 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!
happyrabbit is offline   Reply With Quote

Old   October 20, 2010, 04:33
Default
  #5
New Member
 
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17
Laurence Wallian is on a distinguished road
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
Laurence Wallian is offline   Reply With Quote

Old   October 20, 2010, 04:51
Default
  #6
New Member
 
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 16
happyrabbit is on a distinguished road
Thanks a lot!
I have delete the real F_UDMI,and now it indicates other errors.
I think it is allowable to define multi-paremeters 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!
happyrabbit is offline   Reply With Quote

Old   October 20, 2010, 05:32
Default
  #7
New Member
 
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17
Laurence Wallian is on a distinguished road
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 case-data
Attached Files
File Type: c Example_DEFINE_ADJUST.c (4.1 KB, 53 views)
Laurence Wallian is offline   Reply With Quote

Old   October 20, 2010, 09:39
Default
  #8
New Member
 
jiahongshu
Join Date: Oct 2010
Location: china
Posts: 6
Rep Power: 16
happyrabbit is on a distinguished road
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!
happyrabbit is offline   Reply With Quote

Old   October 20, 2010, 11:28
Default
  #9
New Member
 
Laurence Wallian
Join Date: Mar 2009
Posts: 19
Rep Power: 17
Laurence Wallian is on a distinguished road
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 ?!
Laurence Wallian is offline   Reply With Quote

Old   January 28, 2011, 10:50
Default
  #10
New Member
 
anonymous
Join Date: Jan 2011
Posts: 12
Rep Power: 15
calvin is on a distinguished road
did u find ur way to avoid the " left of storage must point to struct/union" ...i am facing similar errors
calvin is offline   Reply With Quote

Reply

Tags
cg_motion, compile error, udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07: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 19:54


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