猿代码 — 科研/AI模型/高性能计算
0

parallelmultigrid, 多重网格会陷入死循环,程序有BUG

摘要: 1)https://github.com/bcrestel/parallelmultigrid2)void v_cycle(double* array3d, double h, int N, double* function_3d, int v1, int v2){ std::cout "v_cycle" std::endl; // base case if(N == 1){ smoother7 ...
1)
https://github.com/bcrestel/parallelmultigrid

2)

void v_cycle(double*& array3d, double h, int N, double* function_3d, int v1, int v2)
{
std::cout << "v_cycle"<< std::endl;
// base case
if(N == 1){
smoother7p_3dfun(array3d, N, function_3d );}
else{
// (1) pre-smooth (v1) times:
for(int i = 0; i < v1; i++)
smoother7p_3dfun(array3d, N, function_3d );

// (2) compute residual vector:
double* mat_vec = matvecAv7p(array3d, N);
double *residual = vecSub_fun3d(mat_vec, function_3d, N);
delete[] mat_vec;

// (3) restrict residual:
restrict_3d_full_weighting(residual, N);  // N will become floor(N/2)

// (4) make the initial guess for subsequent calls = 0 (as we are solving for the error !)
double* e_2h = new double[N*N*N];
#pragma omp parallel for
for(int i = 0; i < (N*N*N); i++){
e_2h[i] = 0;}

// (5) recurse: 
v_cycle(e_2h, 2*h, N, residual, v1, v2);
delete[] residual;

// (6) prolongate:
prolongation3d(e_2h, N); // N will become N = 2*N+1
double* addition =  vecAdd(array3d, e_2h, N);
delete[] array3d;
array3d = addition;

// (7) post-smooth (v2) times ..
for(int i = 0; i < v2; i++)
smoother7p_3dfun(array3d, N, function_3d );
printf("v_cycle\n");
}
}

3)如上所示,全陷入死循环,就没有搞了。

说点什么...

已有0条评论

最新评论...

本文作者
2024-2-25 01:04
  • 0
    粉丝
  • 239
    阅读
  • 0
    回复
资讯幻灯片
热门评论
热门专题
排行榜
Copyright   ©2015-2023   猿代码-超算人才智造局 高性能计算|并行计算|人工智能      ( 京ICP备2021026424号-2 )