24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1579  |  回复: 1

姜家木木

铜虫 (初入文坛)

[求助] FLUENT计算节点数据汇总(MPI)

小弟用FLUENT进行并行计算,打算实现将计算节点的某个数据汇总到计算节点0,并输出,就是计算节点间的数据汇总。udf程序可编译,可hook,没什么问题,但是一计算就出现下面的错误,网上也找不到解答,希望有了解fluent并行计算MPI这块的大佬给些指点,下面是我的udf和报错信息。
udf:
DEFINE_ADJUST(Mon,domain)
{
#if !RP_HOST
        Thread *t,**pt;
real temp,time,r,rj,zc;
cell_t c;
real x[ND_ND];
int num_c,total_c,mark_c,ci,ci1,cj1,ci2,cj2,node_i,i;
real (*xc_array)[3],(*yc_array)[3];
time=CURRENT_TIME;
rj=0.001;
if(current_ts!=N_TIME)
{
current_ts=N_TIME;
mp_thread_loop_c(t,domain,pt)
if(FLUID_THREAD_P(t))       
{Thread *p_phase=pt[1];
        begin_c_loop_int(c,t)
                {   
                        C_CENTROID(x,c,t);
                        if(C_VOF(c,p_phase)>0.5&&C_VOF(c,p_phase)<1&&sqrt(pow(x[0]-csped*time+dla-x0,2)+x[1]*x[1])<=rj)
                        {
                                num_c++;
                        }
                }
                end_c_loop_int(c,t)

                xc_array=(real (*)[3])calloc(3*num_c,sizeof(real));
                ci=0;
                begin_c_loop_int(c,t)
                {
                        C_CENTROID(x,c,t);
                        if(C_VOF(c,p_phase)>0.5&&C_VOF(c,p_phase)<1&&sqrt(pow(x[0]-csped*time+dla-x0,2)+x[1]*x[1])<=rj)
                        {
                                xc_array[ci][0]=x[0];
                                xc_array[ci][1]=x[1];
                                xc_array[ci][2]=x[2];
                                ci++;
                        }
               
                }
                end_c_loop_int(c,t)       

#if RP_NODE
                total_c=PRF_GISUM1(num_c);
#endif
#if !PARALLEL
                total_c=num_c;
#endif
                yc_array=(real (*)[3])calloc(3*total_c,sizeof(real));
               
#if RP_NODE
       
                if(!I_AM_NODE_ZERO_P)
                {
                        PRF_CSEND_INT(node_zero,&num_c,1,myid);
                        PRF_CSEND_REAL(node_zero,xc_array[0],3*num_c,myid);
                }
               
                if( I_AM_NODE_ZERO_P)
                {         
                        for(ci1=0;ci1<num_c;ci1++)
                        {
                                for(cj1=0;cj1<3;cj1++)
                                {
                                        yc_array[ci1][cj1]=xc_array[ci1][cj1];

                                }
                        }
                        mark_c=num_c;
                        compute_node_loop_not_zero(node_i)
                        {
                                PRF_CRECV_INT(node_i,&num_c,1,node_i);
                                xc_array=(real (*)[3])realloc(xc_array,3*num_c*sizeof(real));
                                PRF_CRECV_REAL(node_i,xc_array[0],3*num_c,node_i);
                                for(ci2=0;ci2<num_c;ci2++)
                                {
                                for(cj2=0;cj2<3;cj2++)
                                {
                                        yc_array[ci2+mark_c][cj2]=xc_array[ci2][cj2];
                                }
                                }
                                mark_c=mark_c+num_c;
                        }

                        compute_node_loop_not_zero(node_i)
                        {
                                PRF_CSEND_REAL(node_i,yc_array[0],3*total_c,node_zero);
                        }
                }

                free(xc_array);

                if(!I_AM_NODE_ZERO_P)
                {  
                        PRF_CRECV_REAL(node_zero,yc_array[0],3*total_c,node_zero);                                                                                                                                               
                }
#endif

begin_c_loop(c,t)
{
    C_CENTROID(x,c,t);
    temp=C_T(c,t);

        for(i=0;i<total_c;i++)
                {
                        if(x[0]==yc_array[0]&&x[1]==yc_array[1]&&x[2]==yc_array[2])
                        {
       
                                C_UDMI(c,t,10)=1;
                                break;
                        }
                        else
                        C_UDMI(c,t,10)=0;       
                }
}
end_c_loop(c,t)
}
}
free(yc_array);
#endif
}
报错:
==============================================================================

Node 0: Process 12088: Received signal SIGSEGV.

==============================================================================
MPI Application rank 0 exited before MPI_Finalize() with status 2

Interrupting at the end of timestep. If you want to interrupt at the end of iteration, press Ctrl+C once again.
The fl process could not be started.
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

姜家木木

铜虫 (初入文坛)

自顶一个
2楼2019-07-22 22:02:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 姜家木木 的主题更新
信息提示
请填处理意见