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

请教linyufeng

[复制链接]
发表于 2004-4-7 23:31:17 | 显示全部楼层 |阅读模式

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

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

x
这是帮助里面的一个例子,程序中定义的这些量如何能和网格中的相对应起来,也就是说,如果有了网格,如何在程序中对它进行操作,下面这个例子希望您能讲解一下:
例如:考察一下例子,从简单x方向力平衡来计算线速度。

V是速度,F是力,m是物体质量,用explicit欧拉公式计算t时刻的速度

/************************************************************
*
* 1-degree of freedom equation of motion (x-direction)
* compiled UDF
*
************************************************************/
#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, i.e., 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;
}
发表于 2004-4-12 17:11:05 | 显示全部楼层

请教linyufeng

这其实就是个简单的C程序,很容易明白的,多看看帮助文件 
我把我做的例子帖上了,希望能有用。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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