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

Parse error in UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 9, 2013, 12:14
Default Parse error in UDF
  #1
New Member
 
taha khademi
Join Date: Mar 2013
Posts: 4
Rep Power: 13
taha is on a distinguished road
hey guys,

i am trying to write a code for trapping particles in a cross flow over a cylinder. but i get parse error in line 17 and it doesn't matter what is in line 17! even it may be an "Enter" or other routine loops. my code is as follow:

//#include "udf.h"
#include "dpm.h"

DEFINE_DPM_BC(trap,p,t,f,f_normal,dim)
{
real normal[2];
real ds=0.01;


#if RP_2D

if (rp_axi)
{

real dp=P_DIAM(p);
real x=P_POS(p)[0];
real y=P_POS(p)[1];

R=sqrt(x*x+y*y);

normal[0]=-f_normal[0];
normal[1]=-f_normal[1];

if(R<=0.5*(ds+dp))
{
P_VEL(p)[0]=P_VEL(p)[0]*normal[0];
P_VEL(p)[1]=P_VEL(p)[1]*normal[1];
}
}
else
#endif

}//end of define

it is noticeable that when i activate the #include "udf.h" header, i get "P_POS: undeclared variable" error!
my code is also where my case and data files are. and also the folder doesn't contain "space" in it.

thanks in advance.
taha is offline   Reply With Quote

Old   March 13, 2013, 06:29
Default
  #2
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
Did compiling or did you interpret the code?

I tried compiling your code and nothing seems to be wrong with it. The fluent manual suggest that UDF with DEFINE_DPM_BC works only after compiling.
vasava is offline   Reply With Quote

Old   March 14, 2013, 03:53
Default
  #3
New Member
 
taha khademi
Join Date: Mar 2013
Posts: 4
Rep Power: 13
taha is on a distinguished road
hey vasava
i tried to interpret the code, but i repeatedly get the parse error
could you please give me some tips about compiling the code
tanx in advance
taha is offline   Reply With Quote

Old   March 14, 2013, 04:16
Default
  #4
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
What is the exact error? Can you copy the text here.

Also try to compile some other code and verify that there is no problem with the compiler.

I am no expert myself but lets try to fix it.
vasava is offline   Reply With Quote

Old   March 14, 2013, 04:22
Default
  #5
New Member
 
taha khademi
Join Date: Mar 2013
Posts: 4
Rep Power: 13
taha is on a distinguished road
this the exact error:
cpp -I"C:\Fluent.Inc\fluent6.3.26/src" -I"C:\Fluent.Inc\fluent6.3.26/cortex/src" -I"C:\Fluent.Inc\fluent6.3.26/client/src" -I"C:\Fluent.Inc\fluent6.3.26/multiport/src" -I. -DUDFCONFIG_H="<udfconfig.h>" "C:\Users\Taha\Desktop\trap.c"
Error: C:\Fluent.Inc\fluent6.3.26/src/dpm.h: line 17: parse error.
taha is offline   Reply With Quote

Old   March 14, 2013, 04:58
Default
  #6
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
1. Put UDF in the same folder as the case. It seems that your udf is on your desktop.
2. Remove the comment on line-1. I think you will need udf.h file.
3. The macros you are using will give you real numbers so you dont have to declare them as real
4. You can try ‘double R=sqrt(x*x+y*y);’ instead of just ‘R=sqrt(x*x+y*y);’
5. To me ‘R=sqrt(x*x+y*y);’ does not make sense. You are not using R for anything. You can try after removing that line.

That’s the only help I can do now.
vasava is offline   Reply With Quote

Old   March 14, 2013, 05:05
Default
  #7
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Edit: should have read the answers too...

Apparently, the macros you are using only work in compiled mode

Last edited by flotus1; March 14, 2013 at 05:32.
flotus1 is offline   Reply With Quote

Old   March 14, 2013, 05:18
Default
  #8
New Member
 
taha khademi
Join Date: Mar 2013
Posts: 4
Rep Power: 13
taha is on a distinguished road
well thank you vasava
i declared R variable as Double, and moved my .C file into the case folder, but still getting the same parse error!
and about udf.h, when i remove comment from udf.h, i get the "line 16: P_POS: undeclared variable" error.
taha is offline   Reply With Quote

Old   March 14, 2013, 06:10
Default
  #9
Senior Member
 
Paritosh Vasava
Join Date: Oct 2012
Location: Lappeenranta, Finland
Posts: 732
Rep Power: 23
vasava will become famous soon enough
I am no expert with DPM but may be studying this (http://jullio.pe.kr/fluent6.1/help/html/udf/node90.htm) would/might help you.

All the best.
vasava is offline   Reply With Quote

Old   November 2, 2016, 17:06
Default I am having the same error/ It does not seem to be UDF related though
  #10
Senior Member
 
ali
Join Date: Oct 2009
Posts: 318
Rep Power: 18
alinik is on a distinguished road
Quote:
Originally Posted by taha View Post
hey guys,

i am trying to write a code for trapping particles in a cross flow over a cylinder. but i get parse error in line 17 and it doesn't matter what is in line 17! even it may be an "Enter" or other routine loops. my code is as follow:

//#include "udf.h"
#include "dpm.h"

DEFINE_DPM_BC(trap,p,t,f,f_normal,dim)
{
real normal[2];
real ds=0.01;


#if RP_2D

if (rp_axi)
{

real dp=P_DIAM(p);
real x=P_POS(p)[0];
real y=P_POS(p)[1];

R=sqrt(x*x+y*y);

normal[0]=-f_normal[0];
normal[1]=-f_normal[1];

if(R<=0.5*(ds+dp))
{
P_VEL(p)[0]=P_VEL(p)[0]*normal[0];
P_VEL(p)[1]=P_VEL(p)[1]*normal[1];
}
}
else
#endif

}//end of define

it is noticeable that when i activate the #include "udf.h" header, i get "P_POS: undeclared variable" error!
my code is also where my case and data files are. and also the folder doesn't contain "space" in it.

thanks in advance.
Hi Taha,

I am having the same error as you are having. It seems that the UDF is not wrong. The origin of the error has to be something else.
I was wondering if you could ever solve this issue?

Your help is much appreciated.

Thanks,

Ali
alinik is offline   Reply With Quote

Reply

Tags
parse error, trapping, udf error


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
A Problem of Fluent Interpreted UDF: parse error knight Fluent UDF and Scheme Programming 25 August 16, 2018 11:26
parse error while interpreting udf Kristin Fluent UDF and Scheme Programming 3 March 15, 2012 07:43
parse error in transient udf spring FLUENT 1 July 6, 2010 07:26
UDF parse error at profile function line Wiggy Fluent UDF and Scheme Programming 1 July 27, 2009 16:59
UDF parse error on line 1 ..... (Unusual) Amit Maha FLUENT 4 June 30, 2006 13:15


All times are GMT -4. The time now is 17:41.