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 interpreting UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 10, 2015, 18:03
Default Parse error interpreting UDF
  #1
New Member
 
Mario Alberto
Join Date: Sep 2015
Location: Russian Federation
Posts: 10
Rep Power: 11
mrwts is on a distinguished road
Hi guys!
I am new learner of FlUENT and UDF and I have been having some problems creating an energy source whose position changes respect to time. The coordinates of the energy source are saved in a extra text file. I have been looking for a while and I haven't found the mistake anywhere.
Trying to interpret the code I am getting the following mistake:

cpp -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/cortex/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/client/src" -I"C:\PROGRA~1\ANSYSI~1\v150\fluent\fluent15.0.7/multiport/src" -I. -DUDF
ONFIG_H="<udfconfig.h>" "C:\Users\Mendez\Desktop\energy source\Airfoil source - arrays with modulus.c"
Error: C:\\Users\\Mendez\\Desktop\\energy source\\Airfoil source - arrays with modulus.c: line 10: parse error.

I add the beginning of code so you can examine the part of the problem:

#include "udf.h"
#define V 1;
#define vel 2;
#define power 1000;
FILE *fp;
int i;
int j;

real a[1021][1021];
fp = fopen("values.txt","r");
for (i=0; i<1022; i++) {
for (j=0; j<1022; j++) {
fscanf(fp,"@d",&a[i][j]);
}
}
real t;
t = CURRENT_TIME; // line of the error
real s;
s = t*vel;

DEFINE_SOURCE(energ_source, cell, thread, dS, eqn)
{
real z[ND_ND];
real source;
real SOURCE_X_POSITION;
real SOURCE_Y_POSITION;
C_CENTROID(z,cell,thread);
...

Thanks in advance.
mrwts is offline   Reply With Quote

Old   September 14, 2015, 04:51
Default
  #2
Member
 
Join Date: Jul 2013
Posts: 80
Rep Power: 13
upeksa is on a distinguished road
You must declare the variables at the beginning of the code.

FILE *fp;
int i;
int j;
real t;
real a[1021][1021];
real s;

fp = fopen("values.txt","r");
for (i=0; i<1021; i++) {
for (j=0; j<1021; j++) {
fscanf(fp,"@d",&a[i][j]);
}
}

t = CURRENT_TIME;

s = t*vel;

You must use this code in a DEFINE_ON_DEMAND macro.

Check the size of the arrays.

That should be enough. Cheers.
upeksa is offline   Reply With Quote

Old   September 14, 2015, 17:45
Default Source code, new error
  #3
New Member
 
Mario Alberto
Join Date: Sep 2015
Location: Russian Federation
Posts: 10
Rep Power: 11
mrwts is on a distinguished road
Thanks, It solved one of the problems. But, after declaring the variables at the beginning and adding the DEFINE_ON_COMAND marcro, an error comes up regarding two lines

DEFINE_SOURCE(energ_source, c, t, dS, eqn) // showing parse error and in the source line saying that the variable source hasn't been declared.

It seems really unusual for me, let me add the that part of the code so you can give your opinion.

DEFINE_SOURCE(energ_source,c,t,dS,eqn)
{
real source;
if (t_m % 2 != 0)
{
....

}
}

source = power/V;
dS[eqn] = 0;

return source;
}
}

I was thinking about the source name maybe, because the rest seems normal to me.
Should the name of the source,in my case energ_source, match with the names written in the macros DEFINE_SOURCE, DEFINE_ON_COMAND and the name of the UDF file?

Thanks again
mrwts is offline   Reply With Quote

Reply

Tags
airfoil 2d, energy source, udf and programming


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
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
PARSE ERROR Message when interpreting UDF in FLUENT dhimans FLUENT 0 May 24, 2009 12:40
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 19:11.