找回密码
 注册
查看: 1804|回复: 0

请大家帮我看看我的UDF问题出在什么地方

[复制链接]
发表于 2006-3-20 16:25:05 | 显示全部楼层 |阅读模式

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

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

x
[这个贴子最后由bluesharpe在 2006/03/20 04:37pm 第 1 次编辑]

#include "udf.h"
#include "math.h"
DEFINE_GRID_MOTION(membrane_moving, domain, dt, time, dtime)
{
  Thread *tf=DT_THREAD(dt);
  face_t f;
  Node *v;
  real NV_VEC(origin);
  real sign, x[3], r, a, y, c;
  int n;
  float d=0.0005, fre=50;/* maxim deformation and frequency */
  
  sign=d*cos(2*3.1415926*fre*time);   /* maxim magnitude of arc profile in a specific timestep*/
  if(abs(sign)>0.00000001)               /* ensure the denominator is not 0 */
    {
      r=(sign*sign+0.01*0.01)/abs((2*sign));   /* radius of arc  */
      a=r-abs(sign);           /* the length of y component of center of arc */
    }
  else
    {
      a=0;
      r=0;
    }
  
  begin_f_loop(f,tf)
   {
     f_node_loop(f, tf, n)
       {
         v=F_NODE(f, tf, n);        /* check nodes */
         c=NODE_X(v);
          if(NODE_POS_NEED_UPDATE(v))  /* ensure each node only be used once */
           {   
            NODE_POS_UPDATED(v);   
            if(abs(sign)<0.00000001)
               y=0;
            else if(sign>0.00000001)
                    y=sqrt(r*r-c*c)-a;      /* y component value of nodes on arc that is the new position of nodes  */
                 else y=a-sqrt(r*r-c*c);   
            x[0]=c;
            x[1]=y;
            x[2]=0;
            NV_V(NODE_COORD(v), =, x);     /* return new position to node */
            Message("Node-coordinate x: %g\n", c);
            Message("Node-coordinate y: %g\n", x[1]);
           }
       }
    }
  end_f_loop(f,tf);
}
                 
  基本思路是:边界条件在每个时间步上呈圆弧形变形,但是每个时间圆弧曲线又是变化的,圆弧变化的最高弦高为d0,
每个时间步上的弦高呈余弦规律变化,y是在一个特定时间步上圆弧在各点处的Y坐标,X坐标由节点处查询可得,
最后更新节点新的坐标值.圆弧上各点的坐标算法是:已知三点(0,sign),(-10mm,0),(10mm,0),计算出圆心的坐标,然后计算各点值。
可在我预览网格运动时,都显示y坐标始终为0. 不知道问题出在哪里?请大家帮我看看.         
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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