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

UDF error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 25, 2017, 06:58
Default UDF error
  #1
Senior Member
 
Arun raj.S
Join Date: Jul 2011
Posts: 194
Rep Power: 14
arunraj is on a distinguished road
Hello everyone,

I am trying to load this UDF (https://www.cfd online.com/Forums/fluent/88129-vortex-induced-vibration.html) for my problem. But I am getting this error while loading "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   December 25, 2017, 06:58
Default UDF is given here
  #2
Senior Member
 
Arun raj.S
Join Date: Jul 2011
Posts: 194
Rep Power: 14
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;
}
arunraj is offline   Reply With Quote

Old   December 26, 2017, 15:06
Default
  #3
Member
 
mohamed
Join Date: Apr 2016
Posts: 34
Rep Power: 10
moh_zain is on a distinguished road
hi check this line
reff=force[1]+MASS*(a0*loc1+a2*vel1+a3*acc1)+CC*(a1*loc1+a4*vel 1+a5*acc1);

the last part a4*vel 1+a25 their is space between vel and 1
moh_zain is offline   Reply With Quote

Old   December 26, 2017, 20:33
Default
  #4
Senior Member
 
Arun raj.S
Join Date: Jul 2011
Posts: 194
Rep Power: 14
arunraj is on a distinguished road
Thank you guys.. it helped..
arunraj is offline   Reply With Quote

Old   December 21, 2018, 16:48
Default
  #5
New Member
 
Join Date: Mar 2018
Posts: 7
Rep Power: 8
yomnag is on a distinguished road
Quote:
Originally Posted by arunraj View Post
Thank you guys.. it helped..
can you post your final UDF or email it to me yomnagobran@yahoo.com

thanks
yomnag 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
UDF for DPM particle deposition modelingpa haghshenasfard Fluent UDF and Scheme Programming 10 September 15, 2019 02:03
Undeclared Identifier Errof UDF SteveGoat Fluent UDF and Scheme Programming 7 October 15, 2014 07:11
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 06:42
Installation OF1.5-dev ttdtud OpenFOAM Installation 46 May 5, 2009 02:32
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


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