| 查看: 596 | 回复: 1 | |||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | |||
[交流]
【求助】传热计算的OpenMP并行计算 已有1人参与
|
|||
|
请大家帮帮忙 在温度场的计算过程中,时间步长上的迭代过程是相互关联,相互影响的。一次迭代需要使用上一次迭代的运算结果,故迭代之间不宜实现并行化。而在一次迭代内部,温度场的计算仅需要前一次时刻的计算结果,各个计算过程之间没有影响,可以进行并行计算。但我进行以下的并行计算后结果同串行相差很大,且计算时间反而增加,不知道问题出在哪里。 以下即是我的并行程序,用到的OpenMP指令是section指令: (其中,程序中的h_w_f,Water_Tem_in,Mould_dt,Mould_dy等为全局变量,AA、BB、C_mould,float Density_mould等为局部变量,q1,Q2,q3,Q4为调用函数。) for(k=0;k<100;k++) { for(i=0;i<=xx;i++) { for(j=0;j<=yy;j++) { thermal_1[j]=thermal_0[j]; } } #pragma omp parallel sections { #pragma omp section { for(i=0;i<=xx;i++) { for(j=0;j<=yA;j++) { if (i==xK && j==0)//K { thermal_0[j] = float(2*AA*thermal_1[i+1][j]+2*BB*thermal_1[j+1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_w_f*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dy*C_mould*Density_mould)); } else if (i==xJ && j==0)//J { thermal_0[j] = float(2*AA*thermal_1[i-1][j]+2*BB*thermal_1[j+1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_w_f*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dy*C_mould*Density_mould)); } //////////[side] else if ((i>=xK && i<=xJ) && j==0)//KJ { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j+1]) +thermal_1[j]*(1-2*AA-2*BB) +2*h_w_f*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dy*C_mould*Density_mould)); } else if (i==xJ && (j>=0 && j<=yA))//JP { thermal_0[j] = float(2*AA*(thermal_1[i-1][j])+BB*(thermal_1[j-1]+thermal_1[j+1]) +thermal_1[j]*(1-2*AA-2*BB)); } else if ((i>=xK && i<=xJ) && j==yA)//PL { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j-1]) +thermal_1[j]*(1-2*AA-2*BB)+2*Q4(i-xK)*Mould_dt/(Mould_dy*C_mould*Density_mould)); } else if (i==xK && (j>=0 && j<=yA))//LK { thermal_0[j] = float(2*AA*(thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB)); } else if ((i>=xK && i<=xJ) && (j<=yA) )// fix { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1.0-2*AA-2*BB)); } } } } pragma omp section { for(i=0;i<=xx;i++) { for(j=yB;j<=yy;j++) { if (i==xJ && j==yy)//E { thermal_0[j] = float(2*AA*thermal_1[i-1][j]+2*BB*thermal_1[j-1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_w_l*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dy*C_mould*Density_mould)); } else if (i==xK && j==yy)//D { thermal_0[j] = float(2*AA*thermal_1[i+1][j]+2*BB*thermal_1[j-1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_w_l*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dy*C_mould*Density_mould)); } ////side else if ((i>=xK && i<=xJ) && j==yB)//MN { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j+1]) +thermal_1[j]*(1-2*AA-2*BB)+2*Q2(i-xK)*Mould_dt/(Mould_dy*C_mould*Density_mould)); } else if (i==xJ && (j>=yB && j<=yy))//NE { thermal_0[j] = float(2*AA*(thermal_1[i-1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB)); } else if ((i>=xK && i<=xJ) && j==yy)//ED { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j-1])+thermal_1[j]*(1-2*AA-2*BB) +2*h_w_l*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dy*C_mould*Density_mould)); } else if (i==xK && (j>=yB && j<=yy))//DM { thermal_0[j] = float(2*AA*(thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB)); } else if((i>=xK && i<=xJ) && (j>=yB))// loose { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1.0-2*AA-2*BB)); } } } } #pragma omp section { for(i=0;i<=xK;i++) { for(j=yA;j<=yB;j++) { if (i==0 && j==yA)//A { thermal_0[j] = float(2*AA*thermal_1[i+1][j]+2*BB*thermal_1[j+1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_n_l*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i==0 && j==yB)//B { thermal_0[j] = float(2*AA*thermal_1[i+1][j]+2*BB*thermal_1[j-1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_n_l*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i==xK && j==yA)//L { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB) +Q4(i-xK)*Mould_dt/(Mould_dy*C_mould*Density_mould)+q1(j)*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i==xK && j==yB)//M { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB) +Q2(i-xK)*Mould_dt/(Mould_dy*C_mould*Density_mould)+q1(j)*Mould_dt/(Mould_dx*C_mould*Density_mould)); } ///side else if ((i>=0 && i<=xK) && j==yA)//AL { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB)); } else if (i==xK && (j>=yA && j<=yB))//LM { thermal_0[j] = float(2*AA*(thermal_1[i-1][j])+BB*(thermal_1[j-1]+thermal_1[j+1]) +thermal_1[j]*(1-2*AA-2*BB)+2*q1(j)*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if ((i>=0 && i<=xK) && j==yB)//MB { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j-1])+thermal_1[j]*(1-2*AA-2*BB)); } else if (i==0 && (j>=yA && j<=yB))//BA { thermal_0[j] = float(2*AA*(thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB) +2*h_n_l*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i<=xK && (j>=yA && j<=yB))// left { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1.0-2*AA-2*BB)); } } } } #pragma omp section { for(i=xJ;i<=xx;i++) { for(j=yA;j<=yB;j++) { if (i==xJ && j==yA)//P { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB) +Q4(i-xK)*Mould_dt/(Mould_dy*C_mould*Density_mould)+q3(j)*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i==xx && j==yA)//H { thermal_0[j] = float(2*AA*thermal_1[i-1][j]+2*BB*thermal_1[j+1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_n_r*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i==xJ && j==yB)//N { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB) +Q2(i-xK)*Mould_dt/(Mould_dy*C_mould*Density_mould)+q3(j)*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if (i==xx && j==yB)//G { thermal_0[j] = float(2*AA*thermal_1[i-1][j]+2*BB*thermal_1[j-1]+thermal_1[j]*(1-2*AA-2*BB) +2*h_n_r*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dx*C_mould*Density_mould)); } ////side else if ((i>=xJ && i<=xx) && j==yA)//PH { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j+1])+thermal_1[j]*(1-2*AA-2*BB)); } else if (i==xx && (j>=yA && j<=yB))//HG { thermal_0[j] = float(2*AA*(thermal_1[i-1][j])+BB*(thermal_1[j-1]+thermal_1[j+1]) +thermal_1[j]*(1-2*AA-2*BB)+2*h_n_r*(Water_Tem_in - thermal_1[j])*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if ((i>=xJ && i<=xx) && j==yB)//GN { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+2*BB*(thermal_1[j-1])+thermal_1[j]*(1-2*AA-2*BB)); } else if (i==xJ && (j>=yA && j<=yB))//NP { thermal_0[j] = float(2*AA*(thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1]) +thermal_1[j]*(1-2*AA-2*BB)+2*q3(j)*Mould_dt/(Mould_dx*C_mould*Density_mould)); } else if ( i>=xJ && (j>=yA && j<=yB))// right { thermal_0[j] = float(AA*(thermal_1[i-1][j]+thermal_1[i+1][j])+BB*(thermal_1[j-1]+thermal_1[j+1])+thermal_1[j]*(1.0-2*AA-2*BB)); } } } } } } 本文来自: 小木虫论坛 http://muchong.com/bbs/viewthread.php?tid=2410411 |
» 猜你喜欢
2025年遐想
已经有4人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
自然科学基金委宣布启动申请书“瘦身提质”行动
已经有4人回复
求个博导看看
已经有18人回复
» 本主题相关价值贴推荐,对您同样有帮助:
VASP并行计算出错
已经有9人回复
远程登录linux系统如何实现fluent并行计算?
已经有6人回复
并行计算如何实现k点平均分配?
已经有5人回复
gaussian 03Revison-E01版在Window 下不能并行计算啊!
已经有9人回复
intel visual fortran 多核并行计算
已经有14人回复
【求助】单机多核UDF怎么并行计算
已经有15人回复
中科院深圳先进技术研究院2011年校园招聘开始了,敬请关注,待遇已补上
已经有79人回复
【求助】并行计算问题
已经有13人回复
【求助】castep并行计算问题
已经有15人回复








回复此楼