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

Encountered syntax error when trying to compile udf

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2017, 04:17
Default Encountered syntax error when trying to compile udf
  #1
New Member
 
Join Date: Nov 2016
Posts: 6
Rep Power: 10
dylpeng is on a distinguished road
Hello friends,

This is my first time posting on this forum so please be gentle.

I've been trying to compile my UDF but this error keeps popping up.

Code:
..\..\src\upper.c(48) : error C2143: syntax error : missing ')' before ';'
..\..\src\upper.c(48) : error C2059: syntax error : ')'
..\..\src\upper.c(49) : error C2143: syntax error : missing ')' before ';'
..\..\src\upper.c(49) : error C2059: syntax error : ')'
..\..\src\upper.c(59) : error C2143: syntax error : missing ')' before ';'
..\..\src\upper.c(59) : error C2059: syntax error : ')'
Below is my code to be compiled...

Code:
#include "udf.h"
#include "mem.h"
#include "math.h"

#define domain_ID 1;
#define zone_RPA 7;
#define zone_LPA 6;

real Q_3D_rpa = 0;
real Q_3D_lpa = 0;


DEFINE_EXECUTE_AT_END(massflowrate)
{
	Domain *domain;
	face_t f_RPA;
	face_t f_LPA;
	Thread *f_thread;

	domain = Get_Domain(domain_ID);
	f_thread = Lookup_Thread(domain,zone_RPA);

	begin_f_loop(f_RPA,f_thread)
	{
		Q_3D_rpa += F_FLUX(f_RPA,f_thread);
	}
	end_f_loop(f_RPA, f_thread)

	printf("Mass Flow Rate at RPA: %f\n",Q_3D_rpa);

	f_thread = Lookup_Thread(domain,zone_LPA);
	begin_f_loop(f_LPA,f_thread)
	{
		Q_3D_lpa += F_FLUX(f_LPA,f_thread);
	}
	end_f_loop(f_LPA, f_thread)

	printf("Mass Flow Rate at LPA: %f\n",Q_3D_lpa);

	Q_3D_lpa = 0.;
	Q_3D_rpa = 0.;

}
Any advice is greatly appreciated!!
Thank you!
dylpeng is offline   Reply With Quote

Old   February 8, 2017, 04:50
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The code that you posted here has 43 lines.
The errors that you posted here, indicate that there is a mistake on the 48th line. That line does not exist in the code that you show here.

So for some reason, Fluent is trying to compile a different code than the one you posted here. Can you check if this is really the code that you are asking Fluent to compile? Maybe you looked in the wrong folder?
pakk is offline   Reply With Quote

Old   February 8, 2017, 04:52
Default
  #3
New Member
 
Join Date: Nov 2016
Posts: 6
Rep Power: 10
dylpeng is on a distinguished road
Hi pakk!

I deleted some of my comments before posting onto the forums.Haha! The error occurs at

domain = Get_Domain(domain_ID);
f_thread = Lookup_Thread(domain,zone_RPA);
dylpeng is offline   Reply With Quote

Old   February 8, 2017, 04:59
Default
  #4
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
OK, that makes it clear.

That line is
Code:
domain = Get_Domain(domain_ID);
What is "domain_ID"? You #defined it as "1;". So after replacing that, your code becomes
Code:
domain = Get_Domain(1;);
You see, after the 1 there is a ; but the compiler still needs a ). That explains the error message that you saw.

The real problem is that you added a ";" after your #defines. So make it:
Code:
#define domain_ID 1
#define zone_RPA 7
#define zone_LPA 6
pakk is offline   Reply With Quote

Old   February 8, 2017, 05:00
Default
  #5
New Member
 
Join Date: Nov 2016
Posts: 6
Rep Power: 10
dylpeng is on a distinguished road
Oh gosh, such a silly mistake! Thank you!
dylpeng is offline   Reply With Quote

Old   February 8, 2017, 05:02
Default
  #6
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I expect that every experienced c-programmer at least once made this mistake. So I would not call it silly.
pakk is offline   Reply With Quote

Old   December 25, 2017, 07:27
Default UDF error missing ')'
  #7
Senior Member
 
Arun raj.S
Join Date: Jul 2011
Posts: 210
Rep Power: 16
arunraj is on a distinguished road
#include <stdio.h>
#include "udf.h"
# define UDF_FILENAME "udf_loc_velo_acc"
# define Temp_File "mytemp"

/* read current location,velocity and accelerator from file */
static void
read_loc_vel_acc_file (real *loc1, real *vel1,real *acc1)
{
FILE *fp = fopen(Temp_File, "r");
if (fp != NULL)
{
float read_loc1, read_vel1, read_acc1;
fscanf (fp, "%e %e %e", &read_loc1, &read_vel1, &read_acc1);
fclose (fp);
*loc1 = (real) read_loc1;
*vel1 = (real) read_vel1;
*acc1=(real) read_acc1;
Message ("\nUDF read viv: y_vel = %f, acc = %f, loc(m)= %f\n",
*vel1, *acc1, *loc1);
}
else
{
*loc1 = 0.0;
*vel1 = 0.0;
*acc1 = 0.0;
Message("\nThe first reading of udf_loc_vel_acc_file\n");
}
}
/* write current location, velocity and acceleration into file */
static void
write_loc_vel_acc_file (real loc, real vel, real acc)
{
FILE *fp = fopen(UDF_FILENAME, "a");
if (fp != NULL)
{
fprintf (fp, "%e %e %e\n", loc, vel, acc);
fclose (fp);
}
else
Message ("\nWarning: cannot write %s file", UDF_FILENAME);
}
/* write current location,velocity and acceleration into temp_file */
static void
write_loc_vel_acc_file2 (real loc, real vel, real acc)
{
FILE *fp = fopen(Temp_File, "w");
if (fp != NULL)
{
fprintf (fp, "%e %e %e\n", loc, vel, acc);
fclose (fp);
}
else
Message ("\nWarning: cannot write %s file", Temp_File);
}
DEFINE_CG_MOTION(viv, dt, cg_vel, cg_omega, time, dtime)
{
#define DELTA 0.5
#define BETA 0.25
#define K_SPRING 22.406
#define MASS 4.864
#define xi 0.0054
real wn=sqrt(K_SPRING/MASS);
real CC=2*xi*wn*MASS;
/*fn=2.92745*/
/*mass ratio equaul 2.4*/
real loc,vel,acc,loc1,vel1,acc1;
real a0,a1,a2,a3,a4,a5,a6,a7,keff,reff;
static int id1=5; /* Face ID of the cylinder */
static real f_glob[3]; /* Total forces (global) */
static real m_glob[3]; /* Moment (global) */
static real x_cg[3]; /* CG location */
static real force[3];
int i=0;
Thread *tf1;
Domain *domain = Get_Domain(1);
tf1 = Lookup_Thread(domain, id1);
a0=1/(BETA*dtime*dtime);
a1=DELTA/(BETA*dtime);
a2=1/(BETA*dtime);
a3=0.5/BETA-1;
a4=DELTA/BETA-1;
a5=0.5*dtime*(DELTA/BETA-2);
a6=dtime*(1-DELTA);
a7=DELTA*dtime;
keff=a0*MASS+a1*CC+K_SPRING;
/* reset velocities */
NV_S (cg_vel, =, 0.0);
NV_S (cg_omega, =, 0.0);
if (!Data_Valid_P ())
return;

/* Get CG position */
for (i=0; i<ND_ND; i++) x_cg[i] = DT_CG(dt)[i];
/* compute force on cylinder */
force[1] = 0.0;
Compute_Force_And_Moment(domain, tf1, x_cg, f_glob, m_glob, TRUE);
for (i=0; i<ND_ND; i++)
{
force[i] = f_glob[i];
}

/*read data calculated in the former step*/
read_loc_vel_acc_file (&loc1, &vel1, &acc1);
/* compute response of cylinder by newmark method*/

reff=force[1]+MASS*(a0*loc1+a2*vel1+a3*acc1)+CC*(a1*loc1+a4*vel 1+a5*acc1);
loc=reff/keff;
acc=a0*(loc-loc1)-a2*vel1-a3*acc1;
vel=vel1+a6*acc1+a7*acc;

Message ("\nUDF of viv: time = %f, y_vel = %f, acc = %f, loc(m)= %f\n",
time, vel, acc, loc);
write_loc_vel_acc_file (loc, vel, acc);
write_loc_vel_acc_file2 (loc, vel, acc);
cg_vel[1] = vel;
}


this is the udf i am trying to load and I am getting this message from fluent. Kindly help me

"Copied E:\Arun\Tandem\Tandem fluent\free oscillations\Naturally oscillating cylinder zhang/E:\Arun\Tandem\Tandem fluent\free oscillations\Naturally oscillating cylinder zhang\udf_loc_velo_acc.c to libudf\src
udf_names.c and user_nt.udf files in 2ddp are upto date.
(system "copy "C:\PROGRA~1\ANSYSI~1\v180\fluent"\fluent18.0.0\sr c\udf\makefile_nt.udf "libudf\win64\2ddp\makefile" ")
1 file(s) copied.
(chdir "libudf")(chdir "win64\2ddp")# Generating ud_io1.h
udf_loc_velo_acc.c
..\..\src\udf_loc_velo_acc.c(107) : error C2143: syntax error : missing ')' before 'constant'
..\..\src\udf_loc_velo_acc.c(107) : error C2059: syntax error : ')'"
arunraj is offline   Reply With Quote

Old   January 2, 2018, 11:37
Default
  #8
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
The compiler indicates that that the error is on line 107.
If I counted correctly, this line is:
Code:
reff=force[1]+MASS*(a0*loc1+a2*vel1+a3*acc1)+CC*(a1*loc1+a4*vel 1+a5*acc1);
I see one mistake there. One thing looks different than the rest. Can you see it?
pakk is offline   Reply With Quote

Old   January 2, 2018, 11:42
Default
  #9
Senior Member
 
Arun raj.S
Join Date: Jul 2011
Posts: 210
Rep Power: 16
arunraj is on a distinguished road
Yes mate.. space must be removed.. thank you for your reply..

Last edited by arunraj; January 2, 2018 at 21:29.
arunraj is offline   Reply With Quote

Reply


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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 40 March 18, 2018 07:05
Syntax error UDF Fluent13 SteveGoat ANSYS 0 May 17, 2012 05:13
Error compile file udf czfluent Fluent UDF and Scheme Programming 24 September 26, 2009 14:24
udf compile in parallel system tahereh FLUENT 1 December 9, 2008 10:48
Compile UDF with a C++ compiler Luca FLUENT 7 December 27, 2005 00:05


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