error in conditional UDF code
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! |
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 |
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) Thanks a lot! |
Though it's tempting to use, I think the actual function is fmod(), not mod() - http://en.cppreference.com/w/c/numeric/math/fmod.
|
All times are GMT -4. The time now is 23:39. |