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

error in conditional UDF code

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 4, 2013, 07:44
Default error in conditional UDF code
  #1
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 270
Rep Power: 6
Bollonga is on a distinguished road
Hi guys,

I'm working on a dynamic mesh UDF, it is quite simple but when I try to compile my c code for the DEFINE_CG_MOTION I encounter an error in a line:

error c2100 illegal indirection

I post the code here:

DEFINE_CG_MOTION(wall, dt, cg_vel, cg_omega, time, dtime)
{

real vel, w, omega, T;

#define AMP 0.4;
#define FREQ 1

w = 2.0*M_PI*FREQ;
T=1/FREQ;

vel = AMP*sin(w*time);
omega = 0.5*M_PI*M_PI*sin(w*time);

if (mod(time,T) > T/4 && mod(time,T) < 3*T/4)
{
omega=-omega;
}

cg_vel[0] = vel; /* x-velocity*/
cg_vel[1] = 0.0;
cg_vel[2] = 0.0;

cg_omega[0]=0.0;
cg_omega[1]=0.0;
cg_omega[2]=omega;

}

The error is in the if line. (14 line)

I have tried several ways to write this conditional but I haven't found the way.

Does anybody know what's wrong there?

Thanks a lot!
Bollonga is offline   Reply With Quote

Old   October 6, 2013, 03:39
Default
  #2
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 4
kornetka is on a distinguished road
Hi
I think all #defines should be placed outside DEFINE_CG_MOTION. Try putting them at the beginning of your udf, right after #includes.
Pzdr,
kornetkta
kornetka is offline   Reply With Quote

Old   October 7, 2013, 04:36
Default
  #3
Senior Member
 
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 270
Rep Power: 6
Bollonga is on a distinguished road
Hi Kornetka,

Yes, I modified that and changed a little bit the code. Now the error is in the use of the function mod():

error LNK2019: unresolved external symbol mod referenced in function sheld

I post the new code:
Code:
DEFINE_CG_MOTION(wall, dt, cg_vel, cg_omega, time, dtime)
{

    real amp, freq, vel, w, omega, T, b;
  
    amp = 0.4;
    freq = 1;

    w = 2.0*M_PI*freq;
    T=1/freq;

    vel = amp*sin(w*time);
    omega = 0.5*M_PI*M_PI*sin(w*time);

    b=mod(time,T);

    if(b>T/4 && b<3*T/4)
       {
        omega=-omega;
      }

    cg_vel[0] = vel; /* x-velocity*/
    cg_vel[1] = 0.0;
    cg_vel[2] = 0.0;

    cg_omega[0]=0.0;
    cg_omega[1]=0.0;
    cg_omega[2]=omega;

}
Any ideas?

Thanks a lot!
Bollonga is offline   Reply With Quote

Old   October 7, 2013, 12:01
Default
  #4
New Member
 
kornetka's Avatar
 
Join Date: Jun 2013
Posts: 15
Rep Power: 4
kornetka is on a distinguished road
Though it's tempting to use, I think the actual function is fmod(), not mod() - http://en.cppreference.com/w/c/numeric/math/fmod.
kornetka is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 13:30
Sos!!! Udf code Jo_vivian_lee Fluent UDF and Scheme Programming 1 August 16, 2012 00:09
UDF code yahya_azizi Fluent UDF and Scheme Programming 4 August 6, 2012 08:06
Brownian Motion UDF Code Confuser FLUENT 1 November 1, 2005 11:37
UDF Scalar Code: HT 1 Greg Perkins FLUENT 8 October 20, 2000 12:40


All times are GMT -4. The time now is 15:53.