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

求助!!!将UDF改为单机多核并行运算以及三维运算!!!

[复制链接]
发表于 2015-2-5 10:41:38 | 显示全部楼层 |阅读模式

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

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

x
我的UDF是为了使桥梁产生涡振现象,这个UDF是用于二维的。
现在想把它改成能适用于三维计算,并且能用单机多核计算,应该怎么修改呢?
在每段程序前加 #if !RP_HOST,段尾加#endif,就行吗?但是这个每段程序是指什么呢,每一行?
谢谢帮助!

#include "udf.h"
#define body_mass   50.61  //the mass of the body
#define body_im   11.548  //质量惯矩Im
static real body_inertial[3]={0.0,0.07336,0.00659};  //moments of inertia in 3D,here you can change the initial value
static real body_vel_prev[3]={0.0,0.0,0.0};// velocity of the body,here you can change the initial value
static real body_omega_prev[3]={0.0,0.0,0.0};// angular velocity of the body,here you can change the initial value
static real body_centroid[3]={0.0,0.0,0.0};//centroid of the body,here you can change the initial value
static real cc[3]={0.0,8.926,17.849};//阻尼-假设为0.5%*2mw
static real accel[3]={0.0,0.0,0.0};//加速度
static real n_body_centroid[3]={0.0,0.0,0.0};//新坐标
static real n_accel[3]={0.0,0.0,0.0};//新加速度

DEFINE_CG_MOTION(yundong,dt,vel,omega,time,dtime)
{
  
  Thread *tread;
  Domain *domin;
  FILE *fd;
  face_t  f;
  real force[ND_ND];//the total force on the body.  
  real moment[ND_ND];//the total momentum on the body.  
  real d_vel[ND_ND];
  real d_omega[ND_ND];
  int i=0;
  int j=0;
  int k=0;
  real ai[8];
  real eq_body_inertial[3];//等效刚度
  real eq_force[3];//等效荷载
  real eq_moment[3];//等效扭矩
  

  tread=DT_THREAD(dt);
  domin = THREAD_DOMAIN (tread);
  NV_S(vel, =, 0.0);
  
  if (time>5)
{
  Compute_Force_And_Moment(domin, tread, body_centroid, force, moment, TRUE);
          ai[0]=4/dtime/dtime;
          ai[1]=2/dtime;
          ai[2]=4/dtime;
          ai[3]=1;
          ai[4]=1;
          ai[5]=0;
          ai[6]=dtime/2;
          ai[7]=dtime/2;
        
          eq_body_inertial[1]=body_inertial[1]+ai[0]*body_mass+ai[1]*cc[1];//竖向
                eq_force[1]=force[1]+body_mass*(ai[0]*body_centroid[1]+ai[2]*body_vel_prev[1]+ai[3]*accel[1])+cc[1]*(ai[1]*body_centroid[1]+ai[4]*body_vel_prev[1]+ai[5]*accel[1]);
                n_body_centroid[1]=eq_force[1]/eq_body_inertial[1];//新质心位置-竖向
                n_accel[1]=ai[0]*(n_body_centroid[1]-body_centroid[1])-ai[2]*body_vel_prev[1]-ai[3]*accel[1];//新加速度-竖向
                body_vel_prev[1]=body_vel_prev[1]+ai[6]*accel[1]+ai[7]*n_accel[1];//新速度及速度更新-竖向
  

          eq_body_inertial[2]=body_inertial[2]+ai[0]*body_im+ai[1]*cc[1];//扭转
                eq_moment[2]=moment[2]+body_im*(ai[0]*body_centroid[2]+ai[2]*body_omega_prev[2]+ai[3]*accel[2])+cc[2]*(ai[1]*body_centroid[2]+ai[4]*body_omega_prev[2]+ai[5]*accel[2]);
                n_body_centroid[2]=eq_moment[2]/eq_body_inertial[2];//新质心位置-扭转
                n_accel[2]=ai[0]*(n_body_centroid[2]-body_centroid[2])-ai[2]*body_omega_prev[2]-ai[3]*accel[2];//新加速度-扭转
                body_omega_prev[2]=body_omega_prev[2]+ai[6]*accel[2]+ai[7]*n_accel[2];//新速度及速度更新-扭转


                vel[1] =(n_body_centroid[1]-body_centroid[1])/dtime;
          moment[2] =(n_body_centroid[2]-body_centroid[2])/dtime;

          body_centroid[1]=n_body_centroid[1];//质心更新-竖向
                accel[1]=n_accel[1];//加速度更新-竖向
          body_centroid[2]=n_body_centroid[2];//质心更新-扭转
                accel[2]=n_accel[2];//加速度更新-扭转               
        
        
          fd=fopen("zhixinniu.dat","a");
          fprintf(fd,"%f,%f,%f\n", time, body_centroid[1], body_centroid[2]);
          fclose(fd);

}        
   
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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