24小时热门版块排行榜    

查看: 528  |  回复: 0
【悬赏金币】回答本帖问题,作者cjc021206将赠送您 5 个金币

cjc021206

新虫 (初入文坛)

[求助] 求助UDF函数问题

我用动网格根据零件位置计算力矩,确定他的运动状态,UDF内容是

int damp_f( real theta, real alpha, real* vol, real* r_m ){
    real x0=-300, y0=137.5, x1=-80, y1=-600;
    real x0r, y0r, dx, dy, d01, ddf;
    x0r = x0 * cos( theta ) - y0 * sin( theta );
    y0r = x0 * sin( theta ) + y0 * cos( theta );
    dx  = x0r - x1;
    dy  = y0r - y1;
    d01 = sqrt( pow(dx, 2) + pow(dy, 2) );
    *vol = d01 * alpha;
    *r_m = fabs( (y1 * x0r - x1 * y0r) / d01 );
    return 0;
}

DEFINE_CG_MOTION( piston_damp_sp0, dt, vel, omega, time, dtime )
{

    face_t f;
    cell_t c;
    real f_glob[3], m_glob[3], domega_z, x_cg[ND_ND], m_damp, v_damp;
    int i, status;

    NV_S(omega, =, 0.0);

    for(i=0;i<=3;i++)
    {
    f_glob=0;
    m_glob=0;
    }
   
    x_cg[0] = 0;
    x_cg[1] = 0;
   
    Domain *domain= Get_Domain (1);
    Thread *tf1 = Lookup_Thread (domain, 3);
    Compute_Force_And_Moment (domain, tf1, x_cg, f_glob, m_glob, TRUE);

    real* vol;
    real* r_m;
    status = damp_f( theta_z0, alpha_z0, vol, r_m );
    v_damp =  4 * (*vol) * (*r_m) ;
   
    m_damp   = 0;
    alpha_z0 = (m_glob[2] - m_damp - v_damp )/INERTIA;
    domega_z = dtime * alpha_z0;
    omega_z0 += domega_z;
    theta_z0 = DT_THETA(dt)[2];
   
    Message ("ntime=%f, tz=%.10lf, oz1=%.10lf, oz2=%.10lf, force_x=%.1f ,force_y=%.1f, moment_z=%f, vol=%.1f, rm=%.1f ", \
        time, DT_THETA(dt)[2], DT_OMEGA_CG(dt)[2], theta_z0, f_glob[0], f_glob[1], m_glob[2], *vol, *r_m );   
   
    omega[2]=omega_z0;

}

用多核计算,开始后直接报错,


Node 0: Process 5204: Received signal SIGSEGV.

==============================================================================

==============================================================================

Node 1: Process 9392: Received signal SIGSEGV.

==============================================================================
MPI Application rank 0 exited before MPI_Finalize() with status 2

把函数 damp_f 取消,内容加到 DEFINE_CG_MOTION 里面就没问题,请教UDF里面加函数应该怎么写,还是说UDF里面不能加函数
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 cjc021206 的主题更新
不应助 确定回帖应助 (注意:应助才可能被奖励,但不允许灌水,必须填写15个字符以上)
信息提示
请填处理意见