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

写udf,动网格DEFINE_CG_MOTION 疑问?

[复制链接]
发表于 2007-4-17 18:13:32 | 显示全部楼层 |阅读模式

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

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

x
写udf,动网格DEFINE_CG_MOTION 疑问?

(1)请问
有谁用udf做动网格
编写DEFINE_CG_MOTION(piston, dt, vel, omega, time, dtime)
成功过的??
给个例子好吗??
如有相关例子请发送到zhangload@163.com
(2)按照目前udf 做的移动移动网格问题的相关例子中的udf  如下,都是帮助文件里自带的例子。见附录,估计做相关的人都看过了这2个例子。有几点疑问:
     1)他们这些力的转换思路 和理论是什么?
     2)这2个例子的力学转换关系有些不同,为什么会这样?哪个是标准的?
     3)他们中给定的常数,比如,50.0 、K_SPRING 150000 、 0.4 * 0.0254  是什么含义?是如何得来? 如果要修改一般要注意哪些?


附  udf例子--------------------------------------
1)#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;
}

+--------------------------------------------------------------------------------
2)DEFINE_CG_MOTION(valve, dt, cg_vel, cg_omega, time, dtime)
{
#if !RP_NODE
  Thread *t = DT_THREAD (dt);
  face_t f;
  real force, loc;
#endif
  real velo;
  /* reset velocities */
  NV_S (cg_vel, =, 0.0);
  NV_S (cg_omega, =, 0.0);
  if (!Data_Valid_P ())
    return;
#if !RP_NODE  
  /* compute force on piston wall */
  force = 0.0;
  begin_f_loop (f, t)
    {
      real *AA;
      AA = F_AREA_CACHE (f, t);
      force += F_P (f, t) * AA[0];
    }
  end_f_loop (f, t)
# if RP_2D
  if (rp_axi)
    force *= 2.0 * M_PI;
# endif
  read_loc_velo_file (&loc, &velo);
  /* add in spring force */
# define K_SPRING 150000
  {
    real init_disp = 0.4 * 0.0254;
    real s_force =  K_SPRING * (loc + init_disp);
    force = force - s_force;
  }
  /* compute change in velocity */
  {
    real dv = dtime * force / 0.01;
    velo += dv;
    loc += velo * dtime;
  }
  Message ("\nUDF valve: time = %f, x_vel = %f, force = %f, loc(m)= %f\n",
           time, velo, force, loc);
  write_loc_velo_file (loc, velo);
#endif /* !RP_NODE */
#if PARALLEL
  host_to_node_real_1 (velo);
#endif
  cg_vel[0] = velo;
}
发表于 2012-1-13 18:07:58 | 显示全部楼层
不知道lz搞懂了没,可不可以指教一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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