找回密码
 注册
查看: 1217|回复: 1

UDF中如何定义一个Y方向的单位向量呢?

[复制链接]
发表于 2014-3-6 11:02:17 | 显示全部楼层 |阅读模式

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

您需要 登录 才可以下载或查看,没有账号?注册

x
RT,如何定义一个全局变量的单位向量呢,要放在下面程序的那个位置呢?
#include "udf.h"
static real v_prev = 0.0;

DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
    Thread *t;
    face_t f;
    real NV_VEC(A);
    real force, dv;
    /* reset velocities */
    NV_S(vel, =, 0.0);
    NV_S(omega, =, 0.0);
    if (!Data_Valid_P())
      return;
    /* get the thread pointer for which this motion is defined */
    t = DT_THREAD(dt);
    /* compute pressure force on body by looping through all faces */
    force = 0.0;
    begin_f_loop(f,t)
      {
         F_AREA(A,f,t);
         force += F_P(f,t) * NV_MAG(A);
      }
    end_f_loop(f,t)
    /* compute change in velocity, that is, dv = F * dt / mass  velocity update using explicit Euler formula */


    dv = dtime * force / 50.0;
    v_prev += dv;
    Message ("time = %f, x_vel = %f, force = %f\n", time, v_prev,
      force);
    /* set x-component of velocity */
    vel[0] = v_prev;
}
发表于 2014-3-6 16:26:22 | 显示全部楼层
放在static real v_prev = 0.0;之后,DEFINE_CG_MOTION之前。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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