|
[Sponsors] |
October 4, 2013, 08:44 |
error in conditional UDF code
|
#1 |
Senior Member
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15 |
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! |
|
October 6, 2013, 04:39 |
|
#2 |
New Member
Join Date: Jun 2013
Posts: 15
Rep Power: 13 |
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 |
|
October 7, 2013, 05:36 |
|
#3 |
Senior Member
Francisco
Join Date: Mar 2012
Location: Spain
Posts: 273
Rep Power: 15 |
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; } Thanks a lot! |
|
October 7, 2013, 13:01 |
|
#4 |
New Member
Join Date: Jun 2013
Posts: 15
Rep Power: 13 |
Though it's tempting to use, I think the actual function is fmod(), not mod() - http://en.cppreference.com/w/c/numeric/math/fmod.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Brownian Motion UDF Code | Confuser | FLUENT | 3 | August 13, 2021 02:14 |
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 01:09 |
UDF code | yahya_azizi | Fluent UDF and Scheme Programming | 4 | August 6, 2012 09:06 |
UDF Scalar Code: HT 1 | Greg Perkins | FLUENT | 8 | October 20, 2000 13:40 |