声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2968|回复: 7

[UDF专题] 求助:单机双核运算想改并行计算,udf怎么改呢?

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

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

您需要 登录 才可以下载或查看,没有账号?我要加入

x
这是我单机双核计算时的代码:
#include "udf.h"
#define pi 4.*atan(1.)
#define diam2 2.5e-4
#define smallnumber 1.e-15
DEFINE_EXCHANGE_PROPERTY(custom_drag1, 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, void_g, void_s, tmp1, tmp2, Cd_Cd, 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 reynolds number*/


                         /* compute particle relaxation time */
        void_g = C_VOF(cell, thread_g);        /* gas vol frac*/
        void_s = C_VOF(cell, thread_s);        /* solid vol frac*/
   
        reyp = void_g*abs_v*diam2*rho_g/mu_g;

                      if(reyp<1000.0)
                    Cd_Cd = (24.0/reyp)*(1.0+0.15* pow(reyp,0.687));
                        else
                    Cd_Cd = 0.44;

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

if(void_g<0.8)
                        {
                tmp1=150*mu_g*pow(void_s,2)/pow(void_g,2)/pow(diam2,2);
                tmp2=1.75*rho_g*void_s/void_g/diam2*abs_v;
                        k_g_s =tmp1+tmp2;
                        }
else
k_g_s =3*Cd_Cd*void_s*void_g*rho_g*abs_v*pow(void_g,-2.65)/(4*diam2);  
return k_g_s;
}

现在想到服务器上并行计算,udf加载失败,需要进行修改,但是我不知道该怎么改哪位知道帮忙改一下啊?非常感谢!
回复
分享到:

使用道具 举报

 楼主| 发表于 2012-3-28 16:22 | 显示全部楼层
原来是单机一个cpu双核计算,现在并行是采用多个cpu计算
发表于 2012-3-29 06:54 | 显示全部楼层
回复 2 # 潇叶飞扬 的帖子

楼主的UDF是单CPU的,没有并行处理的部分。你确定在双核CPU上你的模型是并行计算的?是不是只用了一个核呢?
 楼主| 发表于 2012-3-29 14:34 | 显示全部楼层
回复 3 # Seventy721 的帖子

我传上的代码是单cpu的,计算用了两个核,现在想在多个cpu的服务器上计算,那么该怎么修改呢
发表于 2012-3-30 05:37 | 显示全部楼层
回复 4 # 潇叶飞扬 的帖子

你需要增加一些数据传输的语句。但是首先你得搞清楚并行计算的逻辑结构。看Fluent User's Guide 第31章:
http://hpce.iitm.ac.in/website/M ... tml/ug/node1224.htm
发表于 2012-3-30 05:38 | 显示全部楼层
回复 5 # Seventy721 的帖子

然后再看Fluent UDF Manual 第7章:
http://hpce.iitm.ac.in/website/M ... tml/udf/node200.htm
 楼主| 发表于 2012-3-30 08:38 | 显示全部楼层
回复 6 # Seventy721 的帖子

好的,我去看一下,非常感谢
发表于 2012-7-30 10:18 | 显示全部楼层
不知道lz单机多核的时候是怎样实现的,求教
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-4-29 12:19 , Processed in 0.049723 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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