找回密码
 注册
查看: 1431|回复: 2

UDF求助

[复制链接]
发表于 2012-3-27 15:53:32 | 显示全部楼层 |阅读模式

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

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

x
写了一个UDF,帮忙鉴定下是不是有什么问题啊,不能编译啊,
#include<stdio.h>
#include"udf.h"
DEFINE_CG_MOTION(name,dt,moving_wall_vel,omega,time,dtime)
{
  if(time>=0&&time<=1)
     moving_wall_vel[0]=0.03-0.03*cos(3.141593*time);
  else
     moving_wall_vel[0]=0.06;
}
发表于 2012-3-27 16:28:50 | 显示全部楼层
没有问题的,可能是你vc平台没装好。

另外就是if(time>=0&&time<=1)没必要这么写,if(time<=1.)就行了。
发表于 2012-3-30 15:35:42 | 显示全部楼层

回复 2# 浪子轻狂 的帖子

你好,我现在单机采用的udf代码如下:
#include "udf.h"

#define pi 4.*atan(1.)
#define diam2 3.e-4

DEFINE_EXCHANGE_PROPERTY(custom_drag3,cell,mix_thread,s_col,f_col)
{
Thread *thread_g, *thread_s;
real x_vel_g, x_vel_s, y_vel_g, y_vel_s, abs_v, slip_x, slip_y,
      rho_g, rho_s, mu_g, reyp, afac,
      bfac, void_g, vfac, fdrgs, taup, k_g_s;

/* find the threads for the gas (primary) */
/* and solids (secondary phases)          */

thread_g = THREAD_SUB_THREAD(mix_thread, s_col);/* gas phase  */
thread_s = THREAD_SUB_THREAD(mix_thread, f_col);/* solid phase*/

/* find phase velocities and properties*/

x_vel_g = C_U(cell, thread_g);
y_vel_g = C_V(cell, thread_g);

x_vel_s = C_U(cell, thread_s);
y_vel_s = C_V(cell, thread_s);

slip_x = x_vel_g - x_vel_s;
slip_y = y_vel_g - y_vel_s;

rho_g = C_R(cell, thread_g);
rho_s = C_R(cell, thread_s);

mu_g = C_MU_L(cell, thread_g);

/*compute slip*/
abs_v = sqrt(slip_x*slip_x + slip_y*slip_y);

/*compute Reynold's number*/

reyp = rho_g*abs_v*diam2/mu_g;

/* compute particle relaxation time */

taup = rho_s*diam2*diam2/18./mu_g;

void_g = C_VOF(cell, thread_g);/* gas vol frac*/

/*compute drag and return drag coeff, k_g_s*/

afac = pow(void_g,4.14);

if(void_g<=0.85)
  bfac = 0.281632*pow(void_g, 1.28);
else
  bfac = pow(void_g, 9.076960);

vfac = 0.5*(afac-0.06*reyp+sqrt(0.0036*reyp*reyp+0.12*reyp*(2.*bfac-
              afac)+afac*afac));
fdrgs = void_g*(pow((0.63*sqrt(reyp)/
                            vfac+4.8*sqrt(vfac)/vfac),2))/24.0;

k_g_s = (1.-void_g)*rho_s*fdrgs/taup;

return k_g_s;
}

现在想要到服务器上并行计算,要加一些语句,具体在哪儿加呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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