Rhyno466 |
May 5, 2012 20:59 |
I cannot figure out for the life of me what is wrong with the UDF's with respect to linux. Again, they work absolutely fine on windows but fail on linux. I think the error is due to the calculation of B (beta angle). I get a bunch of unused variable warnings including fp1, P1, T1, I1, r1, Rt1, Rl1, TFY1, TFX1, LFY1, and LFX1.
Here is the UDF. If anyone has any insight into what might be causing these problems that I'm having, I am open to try anything to get this working!!
Code:
#include "udf.h"
double B1 = 0;
double Bdeg1 = 0;
double w1 = 0;
double LVX1 = 0;
double LVY1 = 0;
double LX1 = -0.7366;
double LY1 = 0;
double V1 = 0;
double alpha1 = -0.087266;
double adeg1 = -5;
double s1 = 0;
double st1 = 0;
double lim1 = 0.252;
double aa1 = 0.087266;
double da1 = 1.74533;
DEFINE_CG_MOTION(leading,dt,vel,omega,time,dtime)
{
double flx1 = 0;
double flvx1 = 0;
double flvy1 = 0;
double fly1 = 0;
double ftx1 = 0;
double fty1 = 0;
double ftvx1 = 0;
double ftvy1 = 0;
double LFX1 = 0;
double LFY1 = 0;
double TFX1 = 0;
double TFY1 = 0;
double Rl1 = 0;
double Rt1 = 0;
double r1 = .7366;
double I1 = 1;
double T1 = 0;
double ad1 = 0;
double P1 = 0;
FILE *fp1;
#if !RP_HOST
Domain *d = Get_Domain(1);
Thread *t1 = Lookup_Thread(d,5);
Thread *t2 = Lookup_Thread(d,6);
face_t f;
real NV_VEC(A);
#endif
#if !RP_HOST
begin_f_loop(f,t1)
{
if PRINCIPAL_FACE_P(f,t1)
{
F_AREA(A,f,t1);
flx1 += F_P(f,t1) * A[0];
fly1 += F_P(f,t1) * A[1];
flvx1 += -F_STORAGE_R_N3V(f,t1,SV_WALL_SHEAR)[0];
flvy1 += -F_STORAGE_R_N3V(f,t1,SV_WALL_SHEAR)[1];
}
}
end_f_loop(f,t1)
begin_f_loop(f,t2)
{
if PRINCIPAL_FACE_P(f,t2)
{
F_AREA(A,f,t2);
ftx1 += F_P(f,t2) * A[0];
fty1 += F_P(f,t2) * A[1];
ftvx1 += -F_STORAGE_R_N3V(f,t2,SV_WALL_SHEAR)[0];
ftvy1 += -F_STORAGE_R_N3V(f,t2,SV_WALL_SHEAR)[1];
}
}
end_f_loop(f,t2)
# if RP_NODE
flx1 = PRF_GRSUM1(flx1);
fly1 = PRF_GRSUM1(fly1);
flvx1 = PRF_GRSUM1(flvx1);
flvy1 = PRF_GRSUM1(flvy1);
ftx1 = PRF_GRSUM1(ftx1);
fty1 = PRF_GRSUM1(fty1);
ftvx1 = PRF_GRSUM1(ftvx1);
ftvy1 = PRF_GRSUM1(ftvy1);
# endif
# endif
node_to_host_double_4(ftx1,fty1,ftvx1,ftvy1);
node_to_host_double_4(flx1,fly1,flvx1,flvy1);
#if !RP_NODE
LFX1 = flx1+flvx1;
LFY1 = fly1+flvy1;
TFX1 = ftx1+ftvx1;
TFY1 = fty1+ftvy1;
Rl1 = LFY1*cos(B1) + LFX1*sin(B1);
Rt1 = TFY1*cos(B1) + TFX1*sin(B1);
st1 = s1 * B1;
T1 = (Rl1*r1) + (Rt1*-r1) - st1;
w1 += dtime * T1 / I1;
P1 = T1 * w1;
V1 = w1*r1;
LVX1 = V1 * sin(B1);
LVY1 = V1 * cos(B1);
LX1 += LVX1 * dtime;
LY1 += LVY1 * dtime;
B1 = asin(LY1/r1) * (3.141592654/180);
Bdeg1 = B1 * (180 / 3.141592654);
if (LY1 <= -lim1 && alpha1 <= aa1)
{
ad1 = -da1;
}
if (LY1 >= lim1 && alpha1 >= -aa1)
{
ad1 = da1;
}
alpha1 += -ad1 * dtime;
adeg1 = alpha1 * (180 / 3.141592654);
if (time < 2*dtime)
{
fp1 = fopen("data.txt","a");
fprintf(fp1,"%s\t\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s\n","Time","Lead X P","Lead Y P","Lead X V","Lead Y V","Trail X P","Trail Y P","Trail X V","Trail Y V","Lead X","Lead Y","Trail X","Trail Y","Beta","Omega","LVX","LVY","LX","LY","Alpha1","AD1","RAD1","Torque","Power","Spring T");
fclose(fp1);
}
fp1 = fopen("data.txt","a");
fprintf(fp1,"%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n",time,flx1,fly1,flvx1,flvy1,ftx1,fty1,ftvx1,ftvy1,LFX1,LFY1,TFX1,TFY1,Bdeg1,w1,LVX1,LVY1,LX1,LY1,adeg1,ad1,alpha1,T1,P1,st1);
fclose(fp1);
# endif
host_to_node_double_3(LVX1,LVY1,ad1);
vel[0] = LVX1;
vel[1] = LVY1;
omega[2] = ad1;
}
|