diff --git a/src/special.cpp b/src/special.cpp index 7f855163e0..903794c0f6 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -821,21 +821,26 @@ void Special::angle_trim() int nsend = 0; for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_angle[i]; j++) { - if (tag[i] != angle_atom2[i][j]) continue; - m = atom->map(angle_atom1[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(angle_atom3[i][j]); - if (m < 0 || m >= nlocal) nsend++; + if (num_angle) { + for (j = 0; j < num_angle[i]; j++) { + if (tag[i] != angle_atom2[i][j]) continue; + m = atom->map(angle_atom1[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(angle_atom3[i][j]); + if (m < 0 || m >= nlocal) nsend++; + } } - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; - m = atom->map(dihedral_atom1[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(dihedral_atom3[i][j]); - if (m < 0 || m >= nlocal) nsend++; - m = atom->map(dihedral_atom4[i][j]); - if (m < 0 || m >= nlocal) nsend++; + + if (num_dihedral) { + for (j = 0; j < num_dihedral[i]; j++) { + if (tag[i] != dihedral_atom2[i][j]) continue; + m = atom->map(dihedral_atom1[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(dihedral_atom3[i][j]); + if (m < 0 || m >= nlocal) nsend++; + m = atom->map(dihedral_atom4[i][j]); + if (m < 0 || m >= nlocal) nsend++; + } } } @@ -852,51 +857,55 @@ void Special::angle_trim() nsend = 0; for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_angle[i]; j++) { - if (tag[i] != angle_atom2[i][j]) continue; + if (num_angle) { + for (j = 0; j < num_angle[i]; j++) { + if (tag[i] != angle_atom2[i][j]) continue; - m = atom->map(angle_atom1[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = angle_atom1[i][j] % nprocs; - inbuf[nsend].atomID = angle_atom1[i][j]; - inbuf[nsend].partnerID = angle_atom3[i][j]; - nsend++; - } + m = atom->map(angle_atom1[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = angle_atom1[i][j] % nprocs; + inbuf[nsend].atomID = angle_atom1[i][j]; + inbuf[nsend].partnerID = angle_atom3[i][j]; + nsend++; + } - m = atom->map(angle_atom3[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = angle_atom3[i][j] % nprocs; - inbuf[nsend].atomID = angle_atom3[i][j]; - inbuf[nsend].partnerID = angle_atom1[i][j]; - nsend++; + m = atom->map(angle_atom3[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = angle_atom3[i][j] % nprocs; + inbuf[nsend].atomID = angle_atom3[i][j]; + inbuf[nsend].partnerID = angle_atom1[i][j]; + nsend++; + } } } - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; + if (num_dihedral) { + for (j = 0; j < num_dihedral[i]; j++) { + if (tag[i] != dihedral_atom2[i][j]) continue; - m = atom->map(dihedral_atom1[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom1[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom1[i][j]; - inbuf[nsend].partnerID = dihedral_atom3[i][j]; - nsend++; - } + m = atom->map(dihedral_atom1[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom1[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom1[i][j]; + inbuf[nsend].partnerID = dihedral_atom3[i][j]; + nsend++; + } - m = atom->map(dihedral_atom3[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom3[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom3[i][j]; - inbuf[nsend].partnerID = dihedral_atom1[i][j]; - nsend++; - } + m = atom->map(dihedral_atom3[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom3[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom3[i][j]; + inbuf[nsend].partnerID = dihedral_atom1[i][j]; + nsend++; + } - m = atom->map(dihedral_atom4[i][j]); - if (m < 0 || m >= nlocal) { - proclist[nsend] = dihedral_atom4[i][j] % nprocs; - inbuf[nsend].atomID = dihedral_atom4[i][j]; - inbuf[nsend].partnerID = dihedral_atom2[i][j]; - nsend++; + m = atom->map(dihedral_atom4[i][j]); + if (m < 0 || m >= nlocal) { + proclist[nsend] = dihedral_atom4[i][j] % nprocs; + inbuf[nsend].atomID = dihedral_atom4[i][j]; + inbuf[nsend].partnerID = dihedral_atom2[i][j]; + nsend++; + } } } } @@ -932,56 +941,60 @@ void Special::angle_trim() // output datums = pairs of atoms that are 1-3 neighbors for (i = 0; i < nlocal; i++) { - for (j = 0; j < num_angle[i]; j++) { - if (tag[i] != angle_atom2[i][j]) continue; + if (num_angle) { + for (j = 0; j < num_angle[i]; j++) { + if (tag[i] != angle_atom2[i][j]) continue; - m = atom->map(angle_atom1[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == angle_atom3[i][j]) { - flag[m][k] = 1; - break; - } - } + m = atom->map(angle_atom1[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == angle_atom3[i][j]) { + flag[m][k] = 1; + break; + } + } - m = atom->map(angle_atom3[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == angle_atom1[i][j]) { - flag[m][k] = 1; - break; - } + m = atom->map(angle_atom3[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == angle_atom1[i][j]) { + flag[m][k] = 1; + break; + } + } } } - for (j = 0; j < num_dihedral[i]; j++) { - if (tag[i] != dihedral_atom2[i][j]) continue; + if (num_dihedral) { + for (j = 0; j < num_dihedral[i]; j++) { + if (tag[i] != dihedral_atom2[i][j]) continue; - m = atom->map(dihedral_atom1[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == dihedral_atom3[i][j]) { - flag[m][k] = 1; - break; - } - } + m = atom->map(dihedral_atom1[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == dihedral_atom3[i][j]) { + flag[m][k] = 1; + break; + } + } - m = atom->map(dihedral_atom3[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == dihedral_atom1[i][j]) { - flag[m][k] = 1; - break; - } - } + m = atom->map(dihedral_atom3[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == dihedral_atom1[i][j]) { + flag[m][k] = 1; + break; + } + } - m = atom->map(dihedral_atom4[i][j]); - if (m >= 0 && m < nlocal) { - for (k = 0; k < nspecial[m][1]; k++) - if (onethree[m][k] == dihedral_atom2[i][j]) { - flag[m][k] = 1; - break; - } + m = atom->map(dihedral_atom4[i][j]); + if (m >= 0 && m < nlocal) { + for (k = 0; k < nspecial[m][1]; k++) + if (onethree[m][k] == dihedral_atom2[i][j]) { + flag[m][k] = 1; + break; + } + } } } } @@ -1012,7 +1025,7 @@ void Special::angle_trim() memory->destroy(flag); - // if no angles or dihedrals are defined, delete all 1-3 neighs + // if no angles or dihedrals are defined, delete all 1-3 neighs } else { for (i = 0; i < nlocal; i++) nspecial[i][1] = 0;