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

UDF compile error

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 8, 2010, 10:39
Default UDF compile error
  #1
New Member
 
Join Date: Aug 2010
Posts: 8
Rep Power: 15
feupes is on a distinguished road
Hi

When ever I try to compile the UDF file this message appears:
error C2109: subscript requires array or pointer type

What it should do is make a water tank vibrate with the action of a discrete acceleration in time.
Can anyone tell me where's the error and if there is a simpler way of writing this function?

Thanks in advance!

Here is the function:

#include"udf.h"
DEFINE_CG_MOTION(wave, dt, vel, omega, time, dtime)
{
/* these are the accelerations in each time step with deltat=0,02s*/
real a = 0.0580711302903;
real b = 0.0145322051660;
real c = -0.0404236449378;
real d = 0.264406521306;
real e = 0.118997934085;
real f = -0.118836401038;
real g = -0.0401178859565;
real h = -0.106652194087;
real i = -0.364683929085;
real j = -0.323308392979;
real k = -0.0480849265815;
real l = -0.0303855198926;
real m = 0.7425039562890;
real n = 1.83807300038;
real o = 1.40528558499;
real p = -0.171611555011;
real q = -1.24726011302;
real r = -0.934601363045;
real s = -0.760612964632;
real t = -1.35824485418;
real u = -1.68408008553;
real v = -1.19671180747;
real w = 0.188111001925;
real x = -0.450769504904;
real y = -1.40067612412;

real tempo;
tempo = time;

/* change of velocity with each time step */
/* v(i+1) = v(i) + accel*delta t */
if
(tempo <= 0.02)
{v[0] = v[0] + a*dtime;}
if (tempo <= 0.04)
{v[0] = v[0] + b*dtime;}
if (tempo <= 0.06)
{v[0] = v[0] + c*dtime;}
if (tempo <= 0.08)
{v[0] = v[0] + d*dtime;}
if (tempo <= 0.10)
{v[0] = v[0] + e*dtime;}
if (tempo <= 0.12)
{v[0] = v[0] + f*dtime;}
if (tempo <= 0.14)
{v[0] = v[0] + g*dtime;}
if (tempo <= 0.16)
{v[0] = v[0] + h*dtime;}
if (tempo <= 0.18)
{v[0] = v[0] + i*dtime;}
if (tempo <= 0.20)
{v[0] = v[0] + j*dtime;}
if (tempo <= 0.22)
{v[0] = v[0] + k*dtime;}
if (tempo <= 0.24)
{v[0] = v[0] + l*dtime;}
if (tempo <= 0.26)
{v[0] = v[0] + m*dtime;}
if (tempo <= 0.28)
{v[0] = v[0] + n*dtime;}
if (tempo <= 0.30)
{v[0] = v[0] + o*dtime;}
if (tempo <= 0.32)
{v[0] = v[0] + p*dtime;}
if (tempo <= 0.34)
{v[0] = v[0] + q*dtime;}
if (tempo <= 0.36)
{v[0] = v[0] + r*dtime;}
if (tempo <= 0.38)
{v[0] = v[0] + s*dtime;}
if (tempo <= 0.40)
{v[0] = v[0] + t*dtime;}
if (tempo <= 0.42)
{v[0] = v[0] + u*dtime;}
if (tempo <= 0.44)
{v[0] = v[0] + v*dtime;}
if (tempo <= 0.46)
{v[0] = v[0] + w*dtime;}
if (tempo <= 0.48)
{v[0] = v[0] + x*dtime;}
if (tempo <= 0.50)
{v[0] = v[0] + y*dtime;}
}
feupes is offline   Reply With Quote

Old   September 8, 2010, 17:09
Default
  #2
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
If I understand what you try to do, you wrote v[0], but it should be vel[0].

Also, it looks to me that your "if" structure does not do what you expect it to do. As an example, if the statement (tempo <= 0.02) is true, then every statement of other "if" is also true. Hence, they will be all executed sequentially. In such case you get:
v[0] = v[0] + a*dtime + b*dtime + c*dtime + ... + y*dtime
Micael is offline   Reply With Quote

Old   September 9, 2010, 06:42
Default Re
  #3
New Member
 
Join Date: Aug 2010
Posts: 8
Rep Power: 15
feupes is on a distinguished road
Thanks a lot!
It works fine now

Regards feupes
feupes is offline   Reply With Quote

Old   September 13, 2010, 10:52
Default Re
  #4
New Member
 
Join Date: Aug 2010
Posts: 8
Rep Power: 15
feupes is on a distinguished road
The function works fine now but it only executes once every 0,02 seconds!
Does anyone know how to make it execute every fluent time step?

Thanks
feupes
feupes is offline   Reply With Quote

Old   September 13, 2010, 20:04
Default
  #5
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
How does look like the function now?
Micael is offline   Reply With Quote

Old   September 14, 2010, 05:26
Default Re
  #6
New Member
 
Join Date: Aug 2010
Posts: 8
Rep Power: 15
feupes is on a distinguished road
This is the one I used:

#include"udf.h"
DEFINE_CG_MOTION(wave, dt, vel, omega, time, dtime)
{

real a = 0.0580711302903;
real b = 0.0145322051660;
real c = -0.0404236449378;
real d = 0.264406521306;
real e = 0.118997934085;
real f = -0.118836401038;
real g = -0.0401178859565;
real h = -0.106652194087;
real i = -0.364683929085;
real j = -0.323308392979;
real k = -0.0480849265815;
real l = -0.0303855198926;
real m = 0.7425039562890;
real n = 1.83807300038;
real o = 1.40528558499;
real p = -0.171611555011;
real q = -1.24726011302;
real r = -0.934601363045;
real s = -0.760612964632;
real t = -1.35824485418;
real u = -1.68408008553;
real v = -1.19671180747;
real w = 0.188111001925;
real x = -0.450769504904;
real y = -1.40067612412;

real tempo;
tempo = time;


if (tempo <= 0.02)
{vel[0] = vel[0] + a*dtime;}
if (0,02 < tempo <= 0.04)
{vel[0] = vel[0] + b*dtime;}
if (0,04 < tempo <= 0.06)
{vel[0] = vel[0] + c*dtime;}
if (0,06 < tempo <= 0.08)
{vel[0] = vel[0] + d*dtime;}
if (0,08 < tempo <= 0.10)
{vel[0] = vel[0] + e*dtime;}
if (0,10 < tempo <= 0.12)
{vel[0] = vel[0] + f*dtime;}
if (0,12 < tempo <= 0.14)
{vel[0] = vel[0] + g*dtime;}
if (0,14 < tempo <= 0.16)
{vel[0] = vel[0] + h*dtime;}
if (0,16 < tempo <= 0.18)
{vel[0] = vel[0] + i*dtime;}
if (0,18 < tempo <= 0.20)
{vel[0] = vel[0] + j*dtime;}
if (0,20 < tempo <= 0.22)
{vel[0] = vel[0] + k*dtime;}
if (0,22 < tempo <= 0.24)
{vel[0] = vel[0] + l*dtime;}
if (0,24 < tempo <= 0.26)
{vel[0] = vel[0] + m*dtime;}
if (0,26 < tempo <= 0.28)
{vel[0] = vel[0] + n*dtime;}
if (0,28 < tempo <= 0.30)
{vel[0] = vel[0] + o*dtime;}
if (0,30 < tempo <= 0.32)
{vel[0] = vel[0] + p*dtime;}
if (0,32 < tempo <= 0.34)
{vel[0] = vel[0] + q*dtime;}
if (0,34 < tempo <= 0.36)
{vel[0] = vel[0] + r*dtime;}
if (0,36 < tempo <= 0.38)
{vel[0] = vel[0] + s*dtime;}
if (0,38 < tempo <= 0.40)
{vel[0] = vel[0] + t*dtime;}
if (0,40 < tempo <= 0.42)
{vel[0] = vel[0] + u*dtime;}
if (0,42 < tempo <= 0.44)
{vel[0] = vel[0] + v*dtime;}
if (0,44 < tempo <= 0.46)
{vel[0] = vel[0] + w*dtime;}
if (0,46 < tempo <= 0.48)
{vel[0] = vel[0] + x*dtime;}
if (0,48 < tempo <= 0.50)
{vel[0] = vel[0] + y*dtime;}
}


I also came up with this one for the first 12 accelerations but it doesn't work at all..

#include "udf.h"

DEFINE_CG_MOTION(wave, dt, vel, omega, time, dtime)

{
int i;

real a [12] = { 0.145322051660, -0.404236449378, 2.64406521306, 1.18997934085, -1.18836401038, -0.401178859565, -1.06652194087, -3.64683929085, -3.23308392979, -0.480849265815, -0.303855198926, 7.425039562890 };


for (i = 1 ; i <= 12 ; i++)
{vel[0]= vel[0] + dtime*a[i-1];
if (time <= 0,02*i)
{i=i-1;}
}

}

Thanks for your help!
feupes is offline   Reply With Quote

Old   September 14, 2010, 10:36
Default
  #7
Senior Member
 
Micael
Join Date: Mar 2009
Location: Canada
Posts: 156
Rep Power: 18
Micael is on a distinguished road
First of all, there is some confusion in your code with decimal point and decimal comma. Only use decimal point.

Well, if I understand what you try to do, I would do this:

#include "udf.h"
DEFINE_CG_MOTION(wave, dt, vel, omega, time, dtime)
{
real a[25] = {0.0580711302903, 0.0145322051660, -0.0404236449378, 0.264406521306, 0.118997934085, -0.118836401038, -0.0401178859565, -0.106652194087, -0.364683929085, -0.323308392979, -0.0480849265815, -0.0303855198926, 0.7425039562890, 1.83807300038, 1.40528558499, -0.171611555011, -1.24726011302, -0.934601363045, -0.760612964632, -1.35824485418, -1.68408008553, -1.19671180747, 0.188111001925, -0.450769504904, -1.40067612412};

int i;
i = floor(time/0.02);
vel[0] += a[i]*dtime;
}
Micael is offline   Reply With Quote

Old   September 15, 2010, 01:17
Default udf problem
  #8
New Member
 
krishna
Join Date: Sep 2010
Posts: 6
Rep Power: 15
krishnaprasad is on a distinguished road
i have a program to generate stock's second order waves. but after loading in fluent the file name is not showing in the DYNAMIC ZONE WINDOW...and an error is showing that no moving zone selected!!...

what is Error: Divergence detected in AMG solver: x-momentum?

can u please help me.. i am including the udf.
thank u in adv

#include "udf.h"
#define PI 3.14159265
#define GRAV 9.81
#define H 1.5
#define D 10.0
#define T 6
#define L 20

DEFINE_PROFILE(x_velocity, thread, position)
{
real x[ND_ND];
real y;
real AA,BB,CC,DD,EE,FF,GG,LL,ZZ,K;
face_t f;
begin_f_loop(f, thread)
{
real t = RP_Get_Real("flow-time");
F_CENTROID(x,f,thread);
y = x[1];
ZZ= y - D;
K = 2*PI/L;
AA= cosh (K*(ZZ + D));
BB= cosh (K* D);
CC = sinh (K*D);
DD= cos (PI/2.0 -2.0 *PI*(t/T));
EE= cos (2.0*(PI/2.0 -2.0 *PI*(t/T)));
FF= cosh (2.0*K*D);
GG= cosh (2.0*(K*(ZZ + D)));
LL= D+(H*DD/2.0)+(PI*H*H/(8.0*L))*(BB/pow (CC,3.0))*(2.0+FF)*EE;

if (y <= D)
F_PROFILE(f,thread,position)=H/2.0*(GRAV*T/L)*AA*DD/BB+0.75*PI*PI*H*H/(L*T)*GG*EE/pow(CC,4.0);
else if (y <= LL)
F_PROFILE(f,thread,position)=H/2.0*(GRAV*T/L)*BB*DD/BB+0.75*PI*PI*H*H/(L*T)*FF*EE/pow(CC,4.0);
else
F_PROFILE(f, thread, position) = 0;
}
end_f_loop(f, thread)
}
DEFINE_PROFILE(y_velocity, thread, position)
{
real x[ND_ND];
real y;
real K,MM,NN,OO,PP,QQ,RR,SS,TT,UU,VV,WW,ZZZ;
face_t f;
begin_f_loop(f, thread)
{
real t = RP_Get_Real("flow-time");
F_CENTROID(x,f,thread);
y = x[1];
ZZZ= y - D;
K = 2*PI/L;
MM= sinh (K*(ZZZ + D));
NN= cosh (K* D);
OO= cos (PI/2.0 - (2.0 *PI* t/T));
WW= cos (2.0*(PI/2.0 -2.0 *PI*(t/T)));
VV= sin (PI/2.0 - (2.0 *PI* t/T));
QQ= sin (2.0*(PI/2.0 -2.0 *PI*(t/T)));
RR= sinh (K*D);
SS= cosh (2.0*K*D);
TT= sinh (2.0*(K*(ZZZ + D)));
UU= sinh (2.0*K*D);
PP= D+(H*OO/2.0)+(PI*H*H/(8.0*L))*(NN/pow (RR,3.0))*(2.0+SS)*WW;
if (y <= D)
F_PROFILE(f,thread,position)=H/2.0*(GRAV*T/L)*MM*VV/NN+0.75*PI*PI*H*H/(L*T)*TT*QQ/pow(RR,4.0);
else if (y <= PP)
F_PROFILE(f,thread,position)=H/2.0*(GRAV*T/L)*RR*VV/NN+0.75*PI*PI*H*H/(L*T)*UU*QQ/pow(RR,4.0);
else
F_PROFILE(f, thread, position) = 0;
}
end_f_loop(f, thread)
}
krishnaprasad is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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: DEFINE_CG_MOTION for vertical jump motion of an electrode! alban Fluent UDF and Scheme Programming 2 June 8, 2010 18:54
compile errors of boundary condition "expDirectionMixed" liying02ts OpenFOAM Bugs 2 February 1, 2010 20:11
[Netgen] Installation of Netgen in SuSE Linux 92 edvardsenpriv OpenFOAM Meshing & Mesh Conversion 23 January 16, 2009 06:12
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 05:07
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 02:49.