24小时热门版块排行榜    

查看: 1638  |  回复: 0

dongbing1986

金虫 (初入文坛)

[求助] UDF=宏函数含义

NV_V(x[2],=,axis)
NV_S(x[0],/=,R)
N3V_CROSS(x[1],x[2],x[0])
这三个函数式什么意思啊

#include "udf.h"

/* Computation of anisotropic diffusivity matrix for
* cylindrical orthotropic diffusivity */

/* axis definition for cylindrical diffusivity */
static const real origin[3] = {0.0, 0.0, 0.0};
static const real axis[3]   = {0.0, 0.0, 1.0};

/* diffusivities in radial, tangential and axial directions */
static const real diff[3] = {1.0, 0.01, 0.01};

DEFINE_ANISOTROPIC_DIFFUSIVITY(cyl_ortho_diff,c,t,i,dmatrix)
{
    real x[3][3]; /* principal direction matrix for cell in
cartesion coords. */
    real xcent[ND_ND];
    real R;

    C_CENTROID(xcent,c,t);

    NV_VV(x[0],=,xcent,-,origin);
#if RP_3D
    NV_V(x[2],=,axis);
#endif
#if RP_3D
    R = NV_DOT(x[0],x[2]);
    NV_VS(x[0],-=,x[2],*,R);
#endif
    R = NV_MAG(x[0]);
    if (R > 0.0)
      NV_S(x[0],/=,R);
#if RP_3D
    N3V_CROSS(x[1],x[2],x[0]);
#else
    x[1][0] = -x[0][1];
    x[1][1] =  x[0][0];
#endif
   
    /* dmatrix is computed as xT*diff*x */
    dmatrix[0][0] = diff[0]*x[0][0]*x[0][0]
      + diff[1]*x[1][0]*x[1][0]
#if RP_3D
      + diff[2]*x[2][0]*x[2][0]
#endif
      ;
    dmatrix[1][1] = diff[0]*x[0][1]*x[0][1]
      + diff[1]*x[1][1]*x[1][1]
#if RP_3D
      + diff[2]*x[2][1]*x[2][1]
#endif
      ;
    dmatrix[1][0] = diff[0]*x[0][1]*x[0][0]
      + diff[1]*x[1][1]*x[1][0]
#if RP_3D
      + diff[2]*x[2][1]*x[2][0]
#endif
      ;
    dmatrix[0][1] = dmatrix[1][0];

#if RP_3D
    dmatrix[2][2] = diff[0]*x[0][2]*x[0][2]
      + diff[1]*x[1][2]*x[1][2]
      + diff[2]*x[2][2]*x[2][2]
      ;
    dmatrix[0][2] = diff[0]*x[0][0]*x[0][2]
      + diff[1]*x[1][0]*x[1][2]
      + diff[2]*x[2][0]*x[2][2]
      ;
    dmatrix[2][0] = dmatrix[0][2];

    dmatrix[1][2] = diff[0]*x[0][1]*x[0][2]
      + diff[1]*x[1][1]*x[1][2]
      + diff[2]*x[2][1]*x[2][2]
      ;
    dmatrix[2][1] = dmatrix[1][2];
#endif
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 dongbing1986 的主题更新
信息提示
请填处理意见