• Fluent动网格【3】:DEFINE_CG_MOTION宏


    除了利用Profile进行运动指定之外,Fluent中还可以使用UDF宏来指定部件的运动。其中用于运动指定的宏主要有三个:

    • DEFINE_CG_MOTION
    • DEFINE_GEOM
    • DEFINE_GRID_MOTION

    今天主要看第一个UDF宏DEFINE_CG_MOTION。

    用途

    DEFINE_CG_MOTION宏主要用于描述刚体的运动。所谓“刚体”,指的是在运动过程中部件几何形状不会发生任何改变,只是其质心位置发生改变。

    在定义刚体的运动时,通常以速度方式进行显式定义。

    形式

    DEFINE_CG_MOTION宏的结构很简单。

    DEFINE_CG_MOTION(name,dt,vel,omega,time,dtime)
    

    其中:

    name:为宏的名称,可以随意定义

    dt:一个指针Dynamic_Thread *dt,存储动网格属性,通常不需要用户干预。

    vel:平动速度,为一个数组,其中vel[0]为x方向速度,vel[1]为y方向速度,vel[2]为z方向速度。

    omega:转动速度,omega[0]为x方向角速度,omega[1]为y方向角速度,omega[2]为z方向角速度。

    time:当前时间。

    dtime:时间步长。

    DEFINE_CG_MOTION宏实际上是要返回数据vel或omega。__

    实例

    实例1:利用DEFINE_CG_MOTION宏定义速度:

    [u_x = 2 sin(3t) ]

    可以写成:

    #include "udf.h"
    DEFINE_CG_MOTION(velocity,dt,vel,omega,time,dtime)
    {
      vel[0] = 2* sin(3*time); 
    }
    

    很简单,对不对?

    再来个复杂点的例子。

    实例2:已知作用在部件上的力F,计算部件在力F作用下的运动。

    可以采用牛顿第二定律:

    [int_{t_0}^{t}{dv}=int_{t_0}^{t}{(F/m)}dt ]

    则速度可写为:

    [v_t = v_{t-Delta t}+(F/m)Delta t ]

    可写UDF宏为:

    /************************************************************
    * 1-degree of freedom equation of motion (x-direction)
    * compiled UDF
    ************************************************************/
    #include "udf.h"
     
    static real v_prev = 0.0;
    static real time_prev = 0.0;
     
    DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
    {
      Thread *t;
      face_t f;
      real NV_VEC(A);
      real force_x, 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_x = 0.0;
      begin_f_loop(f,t)
        {
          F_AREA(A,f,t);
          force_x += F_P(f,t) * A[0];
        }
      end_f_loop(f,t)
      /* compute change in velocity, dv = F*dt/mass */
      dv = dtime * force_x / 50.0;
      /* motion UDFs can be called multiple times and should not cause
         false velocity updates */
      if (time > (time_prev + EPSILON))
        {
          v_prev += dv;
          time_prev = time;
        }
      Message("time = %f, x_vel = %f, x_force = %f
    ", time, v_prev, force_x);
      /* set x-component of velocity */
      vel[0] = v_prev;
    }
    
  • 相关阅读:
    用数据泵技术实现逻辑备份Oracle 11g R2 数据泵技术详解(expdp impdp)
    用mysql实现类似于oracle dblink的功能
    统计1的个数
    转置字符串,其中单词内的字符需要正常
    经典排序之归并排序
    公共子序列与公共子串问题
    placement new (转)
    数组排序组合最小数字
    实现两个数相加不用四则运算
    操作系统中作业、线程、进程、内存管理、垃圾回收以及缓存等概念
  • 原文地址:https://www.cnblogs.com/LSCAX/p/7011242.html
Copyright © 2020-2023  润新知