diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index e283e08e20..ad8669d6c1 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -158,7 +158,7 @@ void CommBrick::setup() // for multi: // cutghostmulti = same as cutghost, only for each atom type - int i; + int i,j; int ntypes = atom->ntypes; double *prd,*sublo,*subhi; @@ -175,14 +175,23 @@ void CommBrick::setup() if (mode == Comm::MULTI) { if (multi2) { - // If using multi2 binlists, use the itype-itype interaction distance for communication + // If using multi2 binlists, communicate itype particles a distance + // equal to the max of itype-jtype interaction given smaller jtype particles double **cutneighsq = neighbor->cutneighsq; - for (i = 1; i <= ntypes; i++) { + double *cuttypesq = neighbor->cuttypesq; + for (i = 1; i <= ntypes; i++) { cut = 0.0; - if (cutusermulti) cut = cutusermulti[i]; - cutghostmulti[i][0] = MAX(cut,sqrt(cutneighsq[i][i])); - cutghostmulti[i][1] = MAX(cut,sqrt(cutneighsq[i][i])); - cutghostmulti[i][2] = MAX(cut,sqrt(cutneighsq[i][i])); + if (cutusermulti) { + cutghostmulti[i][0] = cutusermulti[i]; + cutghostmulti[i][1] = cutusermulti[i]; + cutghostmulti[i][2] = cutusermulti[i]; + } + for (j = 1; j <= ntypes; j++){ + if(cuttypesq[j] > cuttypesq[i]) continue; + cutghostmulti[i][0] = MAX(cutghostmulti[i][0],sqrt(cutneighsq[i][j])); + cutghostmulti[i][1] = MAX(cutghostmulti[i][1],sqrt(cutneighsq[i][j])); + cutghostmulti[i][2] = MAX(cutghostmulti[i][2],sqrt(cutneighsq[i][j])); + } } } else { // If using a single binlist, use the max itype-jtype interaction distance for communication @@ -212,14 +221,27 @@ void CommBrick::setup() if (mode == Comm::MULTI) { if (multi2) { - // If using multi2 binlists, use the itype-itype interaction distance for communication + // If using multi2 binlists, communicate itype particles a distance + // equal to the max of itype-jtype interaction given smaller jtype particles double **cutneighsq = neighbor->cutneighsq; + double *cuttypesq = neighbor->cuttypesq; for (i = 1; i <= ntypes; i++) { cut = 0.0; - if (cutusermulti) cut = cutusermulti[i]; - cutghostmulti[i][0] = length0 * MAX(cut,sqrt(cutneighsq[i][i])); - cutghostmulti[i][1] = length1 * MAX(cut,sqrt(cutneighsq[i][i])); - cutghostmulti[i][2] = length2 * MAX(cut,sqrt(cutneighsq[i][i])); + if (cutusermulti) { + cutghostmulti[i][0] = cutusermulti[i]; + cutghostmulti[i][1] = cutusermulti[i]; + cutghostmulti[i][2] = cutusermulti[i]; + } + for (j = 1; j <= ntypes; j++){ + if(cuttypesq[j] > cuttypesq[i]) continue; + cutghostmulti[i][0] = MAX(cutghostmulti[i][0],sqrt(cutneighsq[i][j])); + cutghostmulti[i][1] = MAX(cutghostmulti[i][1],sqrt(cutneighsq[i][j])); + cutghostmulti[i][2] = MAX(cutghostmulti[i][2],sqrt(cutneighsq[i][j])); + } + + cutghostmulti[i][0] *= length0; + cutghostmulti[i][1] *= length1; + cutghostmulti[i][2] *= length2; } } else { // If using a single binlist, use the max itype-jtype interaction distance for communication diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index 16ae86b4a3..4835251b77 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -177,15 +177,24 @@ void CommTiled::setup() if (mode == Comm::MULTI) { double cut; if (multi2) { - // If using multi2 binlists, use the itype-itype interaction distance for communication - double **cutneighsq = neighbor->cutneighsq; - for (i = 1; i <= ntypes; i++) { - cut = 0.0; - if (cutusermulti) cut = cutusermulti[i]; - cutghostmulti[i][0] = MAX(cut,sqrt(cutneighsq[i][i])); - cutghostmulti[i][1] = MAX(cut,sqrt(cutneighsq[i][i])); - cutghostmulti[i][2] = MAX(cut,sqrt(cutneighsq[i][i])); - } + // If using multi2 binlists, communicate itype particles a distance + // equal to the max of itype-jtype interaction given smaller jtype particles + double **cutneighsq = neighbor->cutneighsq; + double *cuttypesq = neighbor->cuttypesq; + for (i = 1; i <= ntypes; i++) { + cut = 0.0; + if (cutusermulti) { + cutghostmulti[i][0] = cutusermulti[i]; + cutghostmulti[i][1] = cutusermulti[i]; + cutghostmulti[i][2] = cutusermulti[i]; + } + for (j = 1; j <= ntypes; j++){ + if(cuttypesq[j] > cuttypesq[i]) continue; + cutghostmulti[i][0] = MAX(cutghostmulti[i][0],sqrt(cutneighsq[i][j])); + cutghostmulti[i][1] = MAX(cutghostmulti[i][1],sqrt(cutneighsq[i][j])); + cutghostmulti[i][2] = MAX(cutghostmulti[i][2],sqrt(cutneighsq[i][j])); + } + } } else { // If using a single binlist, use the max itype-jtype interaction distance for communication double *cuttype = neighbor->cuttype; diff --git a/src/nstencil.cpp b/src/nstencil.cpp index 2ace1125e8..57aff6a71b 100644 --- a/src/nstencil.cpp +++ b/src/nstencil.cpp @@ -324,6 +324,7 @@ void NStencil::create_setup() stencil_multi2[i] = new int*[n+1](); for (j = 1; j <= n; ++j) { maxstencil_multi2[i][j] = 0; + nstencil_multi2[i][j] = 0; } } } diff --git a/src/nstencil_full_multi2_2d.cpp b/src/nstencil_full_multi2_2d.cpp index 627a1e2f9e..2a31f95dad 100644 --- a/src/nstencil_full_multi2_2d.cpp +++ b/src/nstencil_full_multi2_2d.cpp @@ -85,7 +85,7 @@ void NStencilFullMulti22d::create() mbinx = stencil_mbinx_multi2[itype][jtype]; mbiny = stencil_mbiny_multi2[itype][jtype]; - bin_type = stencil_bin_type[i][j]; + bin_type = stencil_bin_type[itype][jtype]; cutsq = stencil_cut[itype][jtype]; diff --git a/src/nstencil_full_multi2_3d.cpp b/src/nstencil_full_multi2_3d.cpp index 19bf30ec07..e028e631a8 100644 --- a/src/nstencil_full_multi2_3d.cpp +++ b/src/nstencil_full_multi2_3d.cpp @@ -87,7 +87,7 @@ void NStencilFullMulti23d::create() mbiny = stencil_mbiny_multi2[itype][jtype]; mbinz = stencil_mbinz_multi2[itype][jtype]; - bin_type = stencil_bin_type[i][j]; + bin_type = stencil_bin_type[itype][jtype]; cutsq = stencil_cut[itype][jtype]; diff --git a/src/nstencil_half_multi2_2d.cpp b/src/nstencil_half_multi2_2d.cpp index 2a3c8da45c..70aa24f9f2 100644 --- a/src/nstencil_half_multi2_2d.cpp +++ b/src/nstencil_half_multi2_2d.cpp @@ -71,7 +71,7 @@ void NStencilHalfMulti22d::set_stencil_properties() void NStencilHalfMulti22d::create() { - int itype, jtype, i, j, ns; + int itype, jtype, bin_type, i, j, ns; int n = atom->ntypes; double cutsq; @@ -88,19 +88,21 @@ void NStencilHalfMulti22d::create() mbinx = stencil_mbinx_multi2[itype][jtype]; mbiny = stencil_mbiny_multi2[itype][jtype]; + bin_type = stencil_bin_type[itype][jtype]; + cutsq = stencil_cut[itype][jtype]; if (stencil_half[itype][jtype]) { for (j = 0; j <= sy; j++) for (i = -sx; i <= sx; i++) if (j > 0 || (j == 0 && i > 0)) { - if (bin_distance(i,j,0) < cutsq) + if (bin_distance_multi2(i,j,0,bin_type) < cutsq) stencil_multi2[itype][jtype][ns++] = j*mbinx + i; } } else { for (j = -sy; j <= sy; j++) for (i = -sx; i <= sx; i++) - if (bin_distance(i,j,0) < cutsq) + if (bin_distance_multi2(i,j,0,bin_type) < cutsq) stencil_multi2[itype][jtype][ns++] = j*mbinx + i; } diff --git a/src/nstencil_half_multi2_2d_tri.cpp b/src/nstencil_half_multi2_2d_tri.cpp index 08568139ad..739803c0db 100755 --- a/src/nstencil_half_multi2_2d_tri.cpp +++ b/src/nstencil_half_multi2_2d_tri.cpp @@ -88,7 +88,7 @@ void NStencilHalfMulti22dTri::create() mbinx = stencil_mbinx_multi2[itype][jtype]; mbiny = stencil_mbiny_multi2[itype][jtype]; - bin_type = stencil_bin_type[i][j]; + bin_type = stencil_bin_type[itype][jtype]; cutsq = stencil_cut[itype][jtype]; diff --git a/src/nstencil_half_multi2_3d.cpp b/src/nstencil_half_multi2_3d.cpp index 21bd29269a..1433273f27 100644 --- a/src/nstencil_half_multi2_3d.cpp +++ b/src/nstencil_half_multi2_3d.cpp @@ -90,7 +90,7 @@ void NStencilHalfMulti23d::create() mbiny = stencil_mbiny_multi2[itype][jtype]; mbinz = stencil_mbinz_multi2[itype][jtype]; - bin_type = stencil_bin_type[i][j]; + bin_type = stencil_bin_type[itype][jtype]; cutsq = stencil_cut[itype][jtype]; diff --git a/src/nstencil_half_multi2_3d_tri.cpp b/src/nstencil_half_multi2_3d_tri.cpp index 1b71a096e3..b62993caa2 100755 --- a/src/nstencil_half_multi2_3d_tri.cpp +++ b/src/nstencil_half_multi2_3d_tri.cpp @@ -90,7 +90,7 @@ void NStencilHalfMulti23dTri::create() mbiny = stencil_mbiny_multi2[itype][jtype]; mbinz = stencil_mbinz_multi2[itype][jtype]; - bin_type = stencil_bin_type[i][j]; + bin_type = stencil_bin_type[itype][jtype]; cutsq = stencil_cut[itype][jtype];