声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 4163|回复: 2

[UDF专题] 6dof'中last_call含义及编译问题

[复制链接]
发表于 2008-10-5 20:32 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
本人见了一篇6dof资料,但对里面的last_call代表什么意思不能理解,还有在编译时出错是怎么回事?好像不认识boolean这个..\..\src\6dof.c(195) : error C2146: syntax 运算符  ,我算的是单刚体,是否可以把last_call去掉
下面是compiled时出现的错误
error : missing ';' before identifier 'last_call'
..\..\src\6dof.c(195) : error C2065: 'last_call' : undeclared identifier
望大虾不吝赐教
程序如下:
  1. #include "udf.h"
  2. #define  ZONE_ID1   8            /* face ID of the moving object */
  3.                                  /* properties of moving object: */
  4. #define  MASS       907.185      /* mass of object, kg */
  5. #define  IXX        27.116       /* moment of intertia, Nms^2 */
  6. #define  IYY        488.094      /* moment of intertia, Nms^2*/
  7. #define  IZZ        488.094      /* moment of intertia, Nms^2 */
  8. #define  IXZ        0.0          /* moment of intertia, Nms^2 */
  9. #define  IXY        0.0          /* moment of intertia, Nms^2 */
  10. #define  IYZ        0.0          /* moment of intertia, Nms^2 */
  11. #define  NUM_CALLS  2            /* number of times routine called
  12.                                     (number of moving zones) */
  13. #define  R2D        180./M_PI
  14. /*******************************************************
  15. * Read/write velocites file
  16. *******************************************************/
  17. #if !RP_NODE
  18. static void
  19. write_velocities (real *v_old, real *om_old, real *euler)
  20. {
  21.   FILE *file_velo;
  22.   register int i;
  23.   if ((file_velo = fopen ("velocities_3d", "w")) == NULL)
  24.     Message ("\nCannot open velocities_3d file");
  25.   for (i = 0; i < ND_ND; i++)
  26.     fprintf (file_velo, "%e ", v_old);
  27.   for (i = 0; i < 3; i++)
  28.     fprintf (file_velo, "%e ", om_old);
  29.   for (i = 0; i < 3; i++)
  30.     fprintf (file_velo, "%e ", euler);
  31.   fclose(file_velo);
  32. }
  33. #endif
  34. static void
  35. read_velocities (real *v_old, real *om_old, real *euler)
  36. {
  37.   float read_v_old[3], read_om_old[3], read_euler[3];
  38.   register int i;
  39. #if !RP_NODE
  40.   FILE *file_velo;
  41.   if ((file_velo = fopen ("velocities_3d", "r")) == NULL)
  42.     {
  43.       Message ("\nCannot open velocities_3d file...creating one!");
  44.       if ((file_velo = fopen ("velocities_3d", "w")) == NULL)
  45.         Message ("\nCannot create velocities_3d file...dying!");
  46.       else
  47.         {
  48.           for (i = 0; i < 9; i++)
  49.             fprintf (file_velo, "%e ", 0.0);
  50.           fclose (file_velo);
  51.           file_velo = fopen ("velocities_3d", "r");
  52.         }
  53.     }
  54.   for (i = 0; i < ND_ND; i++)
  55.     fscanf(file_velo, "%e", &read_v_old);
  56. # if RP_2D
  57.   read_v_old[2] = 0.0;
  58. # endif
  59.   for (i = 0; i < 3; i++)
  60.     fscanf(file_velo, "%e", &read_om_old);
  61.   for (i = 0; i < 3; i++)
  62.     fscanf(file_velo, "%e", &read_euler);
  63.   fclose(file_velo);
  64. #endif
  65. #if PARALLEL
  66.   {
  67.     real exchange[9];
  68. # if RP_HOST
  69.     for (i = 0; i < 3; i++)
  70.       {
  71.         exchange = (real)read_v_old;
  72.         exchange[i + 3] = (real)read_om_old;
  73.         exchange[i + 6] = (real)read_euler;
  74.       }
  75. # endif
  76.     host_to_node_real (exchange, 9);
  77. # if RP_NODE
  78.     for (i = 0; i < 3; i++)
  79.       {
  80.         read_v_old = (float)exchange;
  81.         read_om_old = (float)exchange[i + 3];
  82.         read_euler = (float)exchange[i + 6];
  83.       }
  84. # endif
  85.   }
  86. #endif /* PARALLEL */
  87.   for (i = 0; i < 3; i++)
  88.     {
  89.       v_old = (real)read_v_old;
  90.       om_old = (real)read_om_old;
  91.       euler = (real)read_euler;
  92.     }
  93. }
  94. /*******************************************************
  95. * Main 6DOF UDF
  96. *******************************************************/
  97. DEFINE_CG_MOTION(six_dof, dt, cg_vel, cg_omega, time, dtime)
  98. /* six_dof  = name shown in Fluent GUI
  99.    dt       = thread
  100.    cg_vel   = old/updated cg velocity (global)
  101.    cg_omega = old/updated angular velocity (global)
  102.    time     = current time
  103.    dtime    = time step
  104. */
  105. {
  106.   real        f_glob[3];      /* Total forces (global) */
  107.   real        af_glob[3];     /* Aerodynamic forces (global) */
  108.   real        af_body[3];     /* Aerodynamic forces (body) */
  109.   real        m_glob[3];      /* Moment (global) */
  110.   real        m_body[3];      /* Moment (body) */
  111.   real        v_old_glob[3];  /* Velocity at previous time (global) */
  112.   real        om_old_body[3]; /* Angular velocity at previous time, rad/sec (body) */
  113.   real        om_body[3];     /* Updated angular velocity, rad/sec (body) */
  114.   real        al_body[3];     /* angular acceleration, rad/sec/sec (body) */
  115.   real        x_cg[3];        /* CG location */
  116.   real        euler_angle[3]; /* Euler angles:
  117.                                    [0] = phi   = roll  = about x
  118.                                    [1] = theta = pitch = about y
  119.                                    [2] = psi   = yaw   = about z (radians)*/
  120.   real        euler_angle_old[3];
  121.   real        euler_rate[3];  /* time derivative of euler_angle */
  122.   real        grav_acc[3];    /* gravitational acceleration (global) */
  123.   real        cf, ct, cs;     /* cosines of Euler angles */
  124.   real        sf, st, ss;     /* sines of Euler angles   */
  125.   real        RC[3][3];       /* coordinate rotation matrix (body -> global) */
  126.   real        RD[3][3];       /* derivative rotation matrix (body -> global) */

  127.   real        wx, wy, wz;
  128.   real        r1, r2, r3;
  129.   real        s1, s2, s3;
  130.   real        D;
  131.   real        a11, a21, a31, a12, a22, a32, a13, a23, a33;
  132.   register int       i;
  133.   Domain *domain = Get_Domain (1);
  134.   Thread *tf1 = Lookup_Thread (domain, ZONE_ID1);
  135.   static int calls = 0;
  136.   static boolean last_call = FALSE;
  137. /*
  138. * Initialize gravity acceleration */
  139.   grav_acc[0] = 0.0;
  140.   grav_acc[1] = 0.0;
  141.   grav_acc[2] = 9.81;
  142. /*
  143. * Read data previous time step
  144. */
  145.   read_velocities (v_old_glob, om_old_body, euler_angle);
  146. /*
  147. * Get CG position
  148. */
  149.   for (i = 0; i < ND_ND; i++)
  150.     x_cg = DT_CG(dt);
  151. /*
  152. * Count number of calls done
  153. */
  154.   if ((++calls) == NUM_CALLS)
  155.     last_call = TRUE;
  156. /*
  157. * Get aerodynamic forces and moments
  158. */
  159.   Compute_Force_And_Moment (domain, tf1, x_cg, f_glob, m_glob, TRUE);
  160.   for (i = 0; i < ND_ND; i++)
  161.     af_glob = f_glob;
  162. /*
  163. * Add gravity force
  164. */
  165.   for (i = 0; i < ND_ND; i++)
  166.     f_glob += grav_acc*MASS;
  167.   add_injector_forces (x_cg, euler_angle, f_glob, m_glob);
  168. /*
  169. * Calculate the velocity of the CG in the global system
  170. */
  171.   for (i = 0; i < ND_ND; i++)
  172.     cg_vel = f_glob * dtime / MASS + v_old_glob;
  173. /*
  174. * Calculate the new CG position
  175. */
  176.   for (i = 0; i < ND_ND; i++)
  177.     x_cg = x_cg + cg_vel * dtime;
  178. /*
  179. * Calculate the angular velocity in global csys
  180. */
  181. /* create transformation matrices (body -> global) for coords and derivs */
  182.   cf = cos(euler_angle[0]);  /* cosine(phi)   */
  183.   ct = cos(euler_angle[1]);  /* cosine(theta) */
  184.   cs = cos(euler_angle[2]);  /* cosine(psi)   */
  185.   sf = sin(euler_angle[0]);  /* sine(phi)     */
  186.   st = sin(euler_angle[1]);  /* sine(theta)   */
  187.   ss = sin(euler_angle[2]);  /* sine(psi)     */
  188.   RC[0][0] = ct*cs;
  189.   RC[0][1] = sf*st*cs-cf*ss;
  190.   RC[0][2] = cf*st*cs+sf*ss;
  191.   RC[1][0] = ct*ss;
  192.   RC[1][1] = sf*st*ss+cf*cs;
  193.   RC[1][2] = cf*st*ss-sf*cs;
  194.   RC[2][0] = -st;
  195.   RC[2][1] = sf*ct;
  196.   RC[2][2] = cf*ct;
  197.   RD[0][0] = 1.0;
  198.   RD[0][1] = sf*st/ct;
  199.   RD[0][2] = cf*st/ct;
  200.   RD[1][0] = 0.0;
  201.   RD[1][1] = cf;
  202.   RD[1][2] = -sf;
  203.   RD[2][0] = 0.0;
  204.   RD[2][1] = sf/ct;
  205.   RD[2][2] = cf/ct;
  206. /* transform m_glob to body csys (multiply with transpose of RC)*/
  207.    NV_ROTN_V (m_body, = , m_glob, RC);
  208.    NV_ROTN_V (af_body, = , af_glob, RC);
  209. /* calculate angular accelarations in body csys */
  210.   wx = om_old_body[0];
  211.   wy = om_old_body[1];
  212.   wz = om_old_body[2];
  213.   r1 =  IXX * wx - IXY * wy - IXZ * wz;
  214.   r2 = -IXY * wx + IYY * wy - IYZ * wz;
  215.   r3 = -IXZ * wx - IYZ * wy + IZZ * wz;
  216.   s1 = m_body[0] - (wy*r3-wz*r2);
  217.   s2 = m_body[1] - (wz*r1-wx*r3);
  218.   s3 = m_body[2] - (wx*r2-wy*r1);
  219.   D = IXX * IYY * IZZ - IXX * IYZ * IYZ -
  220.       IYY * IXZ * IXZ - IZZ * IXY * IXY -
  221.       2.* IXY * IXZ * IYZ;
  222.   a11 = IYY * IZZ - IYZ * IYZ;
  223.   a12 = IXY * IZZ + IYZ * IXZ;
  224.   a13 = IXY * IYZ + IXZ * IYY;
  225.   a21 = IXY * IZZ + IYZ * IXZ;
  226.   a22 = IXX * IZZ - IXZ * IXZ;
  227.   a23 = IXX * IYZ + IXZ * IXY;
  228.   a31 = IXY * IYZ + IXZ * IYY;
  229.   a32 = IXX * IYZ + IXZ * IXY;
  230.   a33 = IXX * IYY - IXY * IXY;

  231.   al_body[0] = (a11 * s1 + a12 * s2 + a13 * s3) / D;
  232.   al_body[1] = (a21 * s1 + a22 * s2 + a23 * s3) / D;
  233.   al_body[2] = (a31 * s1 + a32 * s2 + a33 * s3) / D;

  234. /* calculate the new angular velocity in body csys */
  235.   for (i = 0; i < 3; i++)
  236.     om_body = om_old_body + al_body * dtime;

  237. /* transform angular velocity from body to global for return to Fluent */
  238.    NV_ROTP_V (cg_omega, = ,om_body, RC);

  239. /*
  240. * calculate the new Euler angles
  241. */
  242.   for (i = 0; i < 3; i++)
  243.     euler_angle_old = euler_angle;
  244.   NV_ROTP_V (euler_rate, =, om_body, RD);
  245.   N3V_S (euler_rate, *=, dtime);
  246.   N3V_V (euler_angle, +=, euler_rate);

  247. #if !RP_NODE
  248. /*
  249. * Write protocol files: velocities, omegas, and Euler angles
  250. */
  251.   if (last_call)
  252.     {
  253.       FILE *file_diag;

  254.       if ((file_diag = fopen ("diagnostics_3d", "a")) == NULL)
  255.         Message ("\nCannot open output file");
  256.       fprintf (file_diag, "%f\t"        , time);
  257.       fprintf (file_diag, "%f\t%f\t%f\t", x_cg[0], x_cg[1], x_cg[2]);
  258.       fprintf (file_diag, "%f\t%f\t%f\t", cg_vel[0], cg_vel[1], cg_vel[2]);
  259.       fprintf (file_diag, "%f\t%f\t%f\t", om_body[0], om_body[1], om_body[2]);
  260.       fprintf (file_diag, "%f\t%f\t%f\t",
  261.                euler_angle[0], euler_angle[1], euler_angle[2]);
  262.       fprintf (file_diag, "%f\t%f\t%f\t", af_body[0], af_body[1], af_body[2]);
  263.       fprintf (file_diag, "%f\t%f\t%f\n", m_body[0], m_body[1], m_body[2]);
  264.       fclose(file_diag);

  265.       write_velocities (cg_vel, om_body, euler_angle);

  266.       calls = 0;
  267.       last_call = FALSE;
  268.   }
  269. #endif
  270. }
复制代码
回复
分享到:

使用道具 举报

 楼主| 发表于 2008-10-6 11:36 | 显示全部楼层
把last_call定义为整型变量,false用0代替,true用1代替,程序却是通过了 但是又出来新的错误
已复制   1个文件
(system "copy D:\software\°&sup2;×°&Egrave;í&frac14;&thorn;\fluent\fluent\Fluent.Inc\fluent6.2.16\src\makefile_nt.udf libudf\ntx86\2d\makefile")
0
(chdir "libudf")()
(chdir "ntx86\2d")()
6dof.c
..\..\src\6dof.c(264) : warning C4700: local variable 'm_body' used without having been initialized
..\..\src\6dof.c(297) : warning C4700: local variable 'euler_rate' used without having been initialized
..\..\src\6dof.c(316) : warning C4700: local variable 'af_body' used without having been initialized
# Generating udf_names.c because of makefile 6dof.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj 6dof.obj
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
   Creating library libudf.lib and object libudf.exp
6dof.obj : error LNK2001: unresolved external symbol _add_injector_forces
libudf.dll : fatal error LNK1120: 1 unresolved externals
我该怎么办呢?
发表于 2008-10-8 01:20 | 显示全部楼层
这个例子好像是fluent官方给出的例子

你把'last_call'的声名移到前面看看
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-12-25 22:10 , Processed in 0.079774 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表