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

error in conditional UDF code

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread 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: 273
Rep Power: 15
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: 12
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: 273
Rep Power: 15
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: 12
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


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
Brownian Motion UDF Code Confuser FLUENT 3 August 13, 2021 01:14
The FOAM Documentation Project - SHUT-DOWN holger_marschall OpenFOAM 242 March 7, 2013 12: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
UDF Scalar Code: HT 1 Greg Perkins FLUENT 8 October 20, 2000 12:40


All times are GMT -4. The time now is 07:09.