求C语言大神详细解释一下的程序

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;
}

求教,多谢

DEFINE_CG_MOTION(piston,dt,vel,omega,time,dtime)
{
Thread *t;定义thread
face_t f;定义一面符号
real NV_VEC(A);定义面积
real force, dv;定义力
/* reset velocities */
NV_S(vel, =, 0.0);三个方向线速度为0
NV_S(omega, =, 0.0);三个方向角速度为0
if (!Data_Valid_P())如果非流体
return;返回
/* get the thread pointer for which this motion is defined */
t = DT_THREAD(dt);读取thread位置指针赋给t
/* compute pressure force on body by looping through all faces */
force = 0.0;初始化力为0
begin_f_loop(f,t)遍历所此thread中所有面
{
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; 速度的微分等于时间微分成立力除以质量(我赌5毛钱,质量是50.0kg)
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;吧速度赋给x方向速度
}
同样在学udf,刚开始学,上面的各种宏都是一条一条百度的。望采纳
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-07-25
有一个很好的回答,另补充一下,计算力和力矩有一个函数很好用:Compute_Force_And_Moment
相似回答