| 57 |  | storageLayout_ = sman_->getStorageLayout(); | 
| 58 |  | ff_ = info_->getForceField(); | 
| 59 |  | nLocal_ = snap_->getNumberOfAtoms(); | 
| 60 | – | nGroups_ = snap_->getNumberOfCutoffGroups(); | 
| 60 |  |  | 
| 61 | + | nGroups_ = info_->getNLocalCutoffGroups(); | 
| 62 | + | cerr << "in dId, nGroups = " << nGroups_ << "\n"; | 
| 63 |  | // gather the information for atomtype IDs (atids): | 
| 64 |  | identsLocal = info_->getIdentArray(); | 
| 65 |  | AtomLocalToGlobal = info_->getGlobalAtomIndices(); | 
| 66 |  | cgLocalToGlobal = info_->getGlobalGroupIndices(); | 
| 67 |  | vector<int> globalGroupMembership = info_->getGlobalGroupMembership(); | 
| 68 | < | vector<RealType> massFactorsLocal = info_->getMassFactors(); | 
| 68 | > | massFactors = info_->getMassFactors(); | 
| 69 |  | PairList excludes = info_->getExcludedInteractions(); | 
| 70 |  | PairList oneTwo = info_->getOneTwoInteractions(); | 
| 71 |  | PairList oneThree = info_->getOneThreeInteractions(); | 
| 105 |  | cgColData.resize(nGroupsInCol_); | 
| 106 |  | cgColData.setStorageLayout(DataStorage::dslPosition); | 
| 107 |  |  | 
| 108 | < | identsRow.reserve(nAtomsInRow_); | 
| 109 | < | identsCol.reserve(nAtomsInCol_); | 
| 108 | > | identsRow.resize(nAtomsInRow_); | 
| 109 | > | identsCol.resize(nAtomsInCol_); | 
| 110 |  |  | 
| 111 |  | AtomCommIntRow->gather(identsLocal, identsRow); | 
| 112 |  | AtomCommIntColumn->gather(identsLocal, identsCol); | 
| 117 |  | cgCommIntRow->gather(cgLocalToGlobal, cgRowToGlobal); | 
| 118 |  | cgCommIntColumn->gather(cgLocalToGlobal, cgColToGlobal); | 
| 119 |  |  | 
| 120 | < | AtomCommRealRow->gather(massFactorsLocal, massFactorsRow); | 
| 121 | < | AtomCommRealColumn->gather(massFactorsLocal, massFactorsCol); | 
| 120 | > | AtomCommRealRow->gather(massFactors, massFactorsRow); | 
| 121 | > | AtomCommRealColumn->gather(massFactors, massFactorsCol); | 
| 122 |  |  | 
| 123 |  | groupListRow_.clear(); | 
| 124 | < | groupListRow_.reserve(nGroupsInRow_); | 
| 124 | > | groupListRow_.resize(nGroupsInRow_); | 
| 125 |  | for (int i = 0; i < nGroupsInRow_; i++) { | 
| 126 |  | int gid = cgRowToGlobal[i]; | 
| 127 |  | for (int j = 0; j < nAtomsInRow_; j++) { | 
| 132 |  | } | 
| 133 |  |  | 
| 134 |  | groupListCol_.clear(); | 
| 135 | < | groupListCol_.reserve(nGroupsInCol_); | 
| 135 | > | groupListCol_.resize(nGroupsInCol_); | 
| 136 |  | for (int i = 0; i < nGroupsInCol_; i++) { | 
| 137 |  | int gid = cgColToGlobal[i]; | 
| 138 |  | for (int j = 0; j < nAtomsInCol_; j++) { | 
| 142 |  | } | 
| 143 |  | } | 
| 144 |  |  | 
| 145 | < | skipsForRowAtom.clear(); | 
| 146 | < | skipsForRowAtom.reserve(nAtomsInRow_); | 
| 145 | > | skipsForAtom.clear(); | 
| 146 | > | skipsForAtom.resize(nAtomsInRow_); | 
| 147 | > | toposForAtom.clear(); | 
| 148 | > | toposForAtom.resize(nAtomsInRow_); | 
| 149 | > | topoDist.clear(); | 
| 150 | > | topoDist.resize(nAtomsInRow_); | 
| 151 |  | for (int i = 0; i < nAtomsInRow_; i++) { | 
| 152 |  | int iglob = AtomRowToGlobal[i]; | 
| 148 | – | for (int j = 0; j < nAtomsInCol_; j++) { | 
| 149 | – | int jglob = AtomColToGlobal[j]; | 
| 150 | – | if (excludes.hasPair(iglob, jglob)) | 
| 151 | – | skipsForRowAtom[i].push_back(j); | 
| 152 | – | } | 
| 153 | – | } | 
| 153 |  |  | 
| 155 | – | toposForRowAtom.clear(); | 
| 156 | – | toposForRowAtom.reserve(nAtomsInRow_); | 
| 157 | – | for (int i = 0; i < nAtomsInRow_; i++) { | 
| 158 | – | int iglob = AtomRowToGlobal[i]; | 
| 159 | – | int nTopos = 0; | 
| 154 |  | for (int j = 0; j < nAtomsInCol_; j++) { | 
| 155 | < | int jglob = AtomColToGlobal[j]; | 
| 155 | > | int jglob = AtomColToGlobal[j]; | 
| 156 | > |  | 
| 157 | > | if (excludes.hasPair(iglob, jglob)) | 
| 158 | > | skipsForAtom[i].push_back(j); | 
| 159 | > |  | 
| 160 |  | if (oneTwo.hasPair(iglob, jglob)) { | 
| 161 | < | toposForRowAtom[i].push_back(j); | 
| 162 | < | topoDistRow[i][nTopos] = 1; | 
| 163 | < | nTopos++; | 
| 161 | > | toposForAtom[i].push_back(j); | 
| 162 | > | topoDist[i].push_back(1); | 
| 163 | > | } else { | 
| 164 | > | if (oneThree.hasPair(iglob, jglob)) { | 
| 165 | > | toposForAtom[i].push_back(j); | 
| 166 | > | topoDist[i].push_back(2); | 
| 167 | > | } else { | 
| 168 | > | if (oneFour.hasPair(iglob, jglob)) { | 
| 169 | > | toposForAtom[i].push_back(j); | 
| 170 | > | topoDist[i].push_back(3); | 
| 171 | > | } | 
| 172 | > | } | 
| 173 |  | } | 
| 167 | – | if (oneThree.hasPair(iglob, jglob)) { | 
| 168 | – | toposForRowAtom[i].push_back(j); | 
| 169 | – | topoDistRow[i][nTopos] = 2; | 
| 170 | – | nTopos++; | 
| 171 | – | } | 
| 172 | – | if (oneFour.hasPair(iglob, jglob)) { | 
| 173 | – | toposForRowAtom[i].push_back(j); | 
| 174 | – | topoDistRow[i][nTopos] = 3; | 
| 175 | – | nTopos++; | 
| 176 | – | } | 
| 174 |  | } | 
| 175 |  | } | 
| 176 |  |  | 
| 177 |  | #endif | 
| 178 |  |  | 
| 179 |  | groupList_.clear(); | 
| 180 | < | groupList_.reserve(nGroups_); | 
| 180 | > | groupList_.resize(nGroups_); | 
| 181 |  | for (int i = 0; i < nGroups_; i++) { | 
| 182 |  | int gid = cgLocalToGlobal[i]; | 
| 183 |  | for (int j = 0; j < nLocal_; j++) { | 
| 184 |  | int aid = AtomLocalToGlobal[j]; | 
| 185 | < | if (globalGroupMembership[aid] == gid) | 
| 185 | > | if (globalGroupMembership[aid] == gid) { | 
| 186 |  | groupList_[i].push_back(j); | 
| 187 | + | } | 
| 188 |  | } | 
| 189 |  | } | 
| 190 |  |  | 
| 191 | < | skipsForLocalAtom.clear(); | 
| 192 | < | skipsForLocalAtom.reserve(nLocal_); | 
| 191 | > | skipsForAtom.clear(); | 
| 192 | > | skipsForAtom.resize(nLocal_); | 
| 193 | > | toposForAtom.clear(); | 
| 194 | > | toposForAtom.resize(nLocal_); | 
| 195 | > | topoDist.clear(); | 
| 196 | > | topoDist.resize(nLocal_); | 
| 197 |  |  | 
| 198 |  | for (int i = 0; i < nLocal_; i++) { | 
| 199 |  | int iglob = AtomLocalToGlobal[i]; | 
| 198 | – | for (int j = 0; j < nLocal_; j++) { | 
| 199 | – | int jglob = AtomLocalToGlobal[j]; | 
| 200 | – | if (excludes.hasPair(iglob, jglob)) | 
| 201 | – | skipsForLocalAtom[i].push_back(j); | 
| 202 | – | } | 
| 203 | – | } | 
| 200 |  |  | 
| 205 | – | toposForLocalAtom.clear(); | 
| 206 | – | toposForLocalAtom.reserve(nLocal_); | 
| 207 | – | for (int i = 0; i < nLocal_; i++) { | 
| 208 | – | int iglob = AtomLocalToGlobal[i]; | 
| 209 | – | int nTopos = 0; | 
| 201 |  | for (int j = 0; j < nLocal_; j++) { | 
| 202 | < | int jglob = AtomLocalToGlobal[j]; | 
| 202 | > | int jglob = AtomLocalToGlobal[j]; | 
| 203 | > |  | 
| 204 | > | if (excludes.hasPair(iglob, jglob)) | 
| 205 | > | skipsForAtom[i].push_back(j); | 
| 206 | > |  | 
| 207 |  | if (oneTwo.hasPair(iglob, jglob)) { | 
| 208 | < | toposForLocalAtom[i].push_back(j); | 
| 209 | < | topoDistLocal[i][nTopos] = 1; | 
| 210 | < | nTopos++; | 
| 208 | > | toposForAtom[i].push_back(j); | 
| 209 | > | topoDist[i].push_back(1); | 
| 210 | > | } else { | 
| 211 | > | if (oneThree.hasPair(iglob, jglob)) { | 
| 212 | > | toposForAtom[i].push_back(j); | 
| 213 | > | topoDist[i].push_back(2); | 
| 214 | > | } else { | 
| 215 | > | if (oneFour.hasPair(iglob, jglob)) { | 
| 216 | > | toposForAtom[i].push_back(j); | 
| 217 | > | topoDist[i].push_back(3); | 
| 218 | > | } | 
| 219 | > | } | 
| 220 |  | } | 
| 217 | – | if (oneThree.hasPair(iglob, jglob)) { | 
| 218 | – | toposForLocalAtom[i].push_back(j); | 
| 219 | – | topoDistLocal[i][nTopos] = 2; | 
| 220 | – | nTopos++; | 
| 221 | – | } | 
| 222 | – | if (oneFour.hasPair(iglob, jglob)) { | 
| 223 | – | toposForLocalAtom[i].push_back(j); | 
| 224 | – | topoDistLocal[i][nTopos] = 3; | 
| 225 | – | nTopos++; | 
| 226 | – | } | 
| 221 |  | } | 
| 222 | < | } | 
| 223 | < |  | 
| 222 | > | } | 
| 223 | > |  | 
| 224 | > | createGtypeCutoffMap(); | 
| 225 |  | } | 
| 226 |  |  | 
| 227 |  | void ForceMatrixDecomposition::createGtypeCutoffMap() { | 
| 231 |  | int atid; | 
| 232 |  | set<AtomType*> atypes = info_->getSimulatedAtomTypes(); | 
| 233 |  | vector<RealType> atypeCutoff; | 
| 234 | < | atypeCutoff.reserve( atypes.size() ); | 
| 234 | > | atypeCutoff.resize( atypes.size() ); | 
| 235 |  |  | 
| 236 | < | for (set<AtomType*>::iterator at = atypes.begin(); at != atypes.end(); ++at){ | 
| 236 | > | for (set<AtomType*>::iterator at = atypes.begin(); | 
| 237 | > | at != atypes.end(); ++at){ | 
| 238 |  | rc = interactionMan_->getSuggestedCutoffRadius(*at); | 
| 239 |  | atid = (*at)->getIdent(); | 
| 240 |  | atypeCutoff[atid] = rc; | 
| 246 |  | // largest cutoff for any atypes present in this group. | 
| 247 |  | #ifdef IS_MPI | 
| 248 |  | vector<RealType> groupCutoffRow(nGroupsInRow_, 0.0); | 
| 249 | + | groupRowToGtype.resize(nGroupsInRow_); | 
| 250 |  | for (int cg1 = 0; cg1 < nGroupsInRow_; cg1++) { | 
| 251 |  | vector<int> atomListRow = getAtomsInGroupRow(cg1); | 
| 252 |  | for (vector<int>::iterator ia = atomListRow.begin(); | 
| 272 |  |  | 
| 273 |  | } | 
| 274 |  | vector<RealType> groupCutoffCol(nGroupsInCol_, 0.0); | 
| 275 | + | groupColToGtype.resize(nGroupsInCol_); | 
| 276 |  | for (int cg2 = 0; cg2 < nGroupsInCol_; cg2++) { | 
| 277 |  | vector<int> atomListCol = getAtomsInGroupColumn(cg2); | 
| 278 |  | for (vector<int>::iterator jb = atomListCol.begin(); | 
| 296 |  | } | 
| 297 |  | } | 
| 298 |  | #else | 
| 299 | + |  | 
| 300 |  | vector<RealType> groupCutoff(nGroups_, 0.0); | 
| 301 | + | groupToGtype.resize(nGroups_); | 
| 302 | + |  | 
| 303 | + | cerr << "nGroups = " << nGroups_ << "\n"; | 
| 304 |  | for (int cg1 = 0; cg1 < nGroups_; cg1++) { | 
| 305 | + |  | 
| 306 |  | groupCutoff[cg1] = 0.0; | 
| 307 |  | vector<int> atomList = getAtomsInGroupRow(cg1); | 
| 308 | + |  | 
| 309 |  | for (vector<int>::iterator ia = atomList.begin(); | 
| 310 |  | ia != atomList.end(); ++ia) { | 
| 311 |  | int atom1 = (*ia); | 
| 329 |  | } | 
| 330 |  | #endif | 
| 331 |  |  | 
| 332 | + | cerr << "gTypeCutoffs.size() = " << gTypeCutoffs.size() << "\n"; | 
| 333 |  | // Now we find the maximum group cutoff value present in the simulation | 
| 334 |  |  | 
| 335 | < | vector<RealType>::iterator groupMaxLoc = max_element(gTypeCutoffs.begin(), gTypeCutoffs.end()); | 
| 331 | < | RealType groupMax = *groupMaxLoc; | 
| 335 | > | RealType groupMax = *max_element(gTypeCutoffs.begin(), gTypeCutoffs.end()); | 
| 336 |  |  | 
| 337 |  | #ifdef IS_MPI | 
| 338 |  | MPI::COMM_WORLD.Allreduce(&groupMax, &groupMax, 1, MPI::REALTYPE, MPI::MAX); | 
| 341 |  | RealType tradRcut = groupMax; | 
| 342 |  |  | 
| 343 |  | for (int i = 0; i < gTypeCutoffs.size();  i++) { | 
| 344 | < | for (int j = 0; j < gTypeCutoffs.size();  j++) { | 
| 341 | < |  | 
| 344 | > | for (int j = 0; j < gTypeCutoffs.size();  j++) { | 
| 345 |  | RealType thisRcut; | 
| 346 |  | switch(cutoffPolicy_) { | 
| 347 |  | case TRADITIONAL: | 
| 348 |  | thisRcut = tradRcut; | 
| 349 | + | break; | 
| 350 |  | case MIX: | 
| 351 |  | thisRcut = 0.5 * (gTypeCutoffs[i] + gTypeCutoffs[j]); | 
| 352 | + | break; | 
| 353 |  | case MAX: | 
| 354 |  | thisRcut = max(gTypeCutoffs[i], gTypeCutoffs[j]); | 
| 355 | + | break; | 
| 356 |  | default: | 
| 357 |  | sprintf(painCave.errMsg, | 
| 358 |  | "ForceMatrixDecomposition::createGtypeCutoffMap " | 
| 359 |  | "hit an unknown cutoff policy!\n"); | 
| 360 |  | painCave.severity = OPENMD_ERROR; | 
| 361 |  | painCave.isFatal = 1; | 
| 362 | < | simError(); | 
| 362 | > | simError(); | 
| 363 | > | break; | 
| 364 |  | } | 
| 365 |  |  | 
| 366 |  | pair<int,int> key = make_pair(i,j); | 
| 390 |  |  | 
| 391 |  |  | 
| 392 |  | groupCutoffs ForceMatrixDecomposition::getGroupCutoffs(int cg1, int cg2) { | 
| 393 | < | int i, j; | 
| 387 | < |  | 
| 393 | > | int i, j; | 
| 394 |  | #ifdef IS_MPI | 
| 395 |  | i = groupRowToGtype[cg1]; | 
| 396 |  | j = groupColToGtype[cg2]; | 
| 397 |  | #else | 
| 398 |  | i = groupToGtype[cg1]; | 
| 399 |  | j = groupToGtype[cg2]; | 
| 400 | < | #endif | 
| 395 | < |  | 
| 400 | > | #endif | 
| 401 |  | return gTypeCutoffMap[make_pair(i,j)]; | 
| 402 |  | } | 
| 403 |  |  | 
| 404 | + | int ForceMatrixDecomposition::getTopologicalDistance(int atom1, int atom2) { | 
| 405 | + | for (int j = 0; j < toposForAtom[atom1].size(); j++) { | 
| 406 | + | if (toposForAtom[atom1][j] == atom2) | 
| 407 | + | return topoDist[atom1][j]; | 
| 408 | + | } | 
| 409 | + | return 0; | 
| 410 | + | } | 
| 411 |  |  | 
| 412 |  | void ForceMatrixDecomposition::zeroWorkArrays() { | 
| 413 |  |  | 
| 691 |  | #ifdef IS_MPI | 
| 692 |  | return massFactorsRow[atom1]; | 
| 693 |  | #else | 
| 694 | < | return massFactorsLocal[atom1]; | 
| 694 | > | return massFactors[atom1]; | 
| 695 |  | #endif | 
| 696 |  | } | 
| 697 |  |  | 
| 699 |  | #ifdef IS_MPI | 
| 700 |  | return massFactorsCol[atom2]; | 
| 701 |  | #else | 
| 702 | < | return massFactorsLocal[atom2]; | 
| 702 | > | return massFactors[atom2]; | 
| 703 |  | #endif | 
| 704 |  |  | 
| 705 |  | } | 
| 717 |  | return d; | 
| 718 |  | } | 
| 719 |  |  | 
| 720 | < | vector<int> ForceMatrixDecomposition::getSkipsForRowAtom(int atom1) { | 
| 721 | < | #ifdef IS_MPI | 
| 710 | < | return skipsForRowAtom[atom1]; | 
| 711 | < | #else | 
| 712 | < | return skipsForLocalAtom[atom1]; | 
| 713 | < | #endif | 
| 720 | > | vector<int> ForceMatrixDecomposition::getSkipsForAtom(int atom1) { | 
| 721 | > | return skipsForAtom[atom1]; | 
| 722 |  | } | 
| 723 |  |  | 
| 724 |  | /** | 
| 751 |  | unique_id_2 = atom2; | 
| 752 |  | #endif | 
| 753 |  |  | 
| 754 | < | #ifdef IS_MPI | 
| 755 | < | for (vector<int>::iterator i = skipsForRowAtom[atom1].begin(); | 
| 748 | < | i != skipsForRowAtom[atom1].end(); ++i) { | 
| 754 | > | for (vector<int>::iterator i = skipsForAtom[atom1].begin(); | 
| 755 | > | i != skipsForAtom[atom1].end(); ++i) { | 
| 756 |  | if ( (*i) == unique_id_2 ) return true; | 
| 757 |  | } | 
| 751 | – | #else | 
| 752 | – | for (vector<int>::iterator i = skipsForLocalAtom[atom1].begin(); | 
| 753 | – | i != skipsForLocalAtom[atom1].end(); ++i) { | 
| 754 | – | if ( (*i) == unique_id_2 ) return true; | 
| 755 | – | } | 
| 756 | – | #endif | 
| 757 | – | } | 
| 758 |  |  | 
| 759 | – | int ForceMatrixDecomposition::getTopoDistance(int atom1, int atom2) { | 
| 760 | – |  | 
| 761 | – | #ifdef IS_MPI | 
| 762 | – | for (int i = 0; i < toposForRowAtom[atom1].size(); i++) { | 
| 763 | – | if ( toposForRowAtom[atom1][i] == atom2 ) return topoDistRow[atom1][i]; | 
| 764 | – | } | 
| 765 | – | #else | 
| 766 | – | for (int i = 0; i < toposForLocalAtom[atom1].size(); i++) { | 
| 767 | – | if ( toposForLocalAtom[atom1][i] == atom2 ) return topoDistLocal[atom1][i]; | 
| 768 | – | } | 
| 769 | – | #endif | 
| 770 | – |  | 
| 771 | – | // zero is default for unconnected (i.e. normal) pair interactions | 
| 772 | – | return 0; | 
| 759 |  | } | 
| 760 |  |  | 
| 761 | + |  | 
| 762 |  | void ForceMatrixDecomposition::addForceToAtomRow(int atom1, Vector3d fg){ | 
| 763 |  | #ifdef IS_MPI | 
| 764 |  | atomRowData.force[atom1] += fg; | 
| 776 |  | } | 
| 777 |  |  | 
| 778 |  | // filling interaction blocks with pointers | 
| 779 | < | InteractionData ForceMatrixDecomposition::fillInteractionData(int atom1, int atom2) { | 
| 780 | < | InteractionData idat; | 
| 794 | < |  | 
| 779 | > | void ForceMatrixDecomposition::fillInteractionData(InteractionData &idat, | 
| 780 | > | int atom1, int atom2) { | 
| 781 |  | #ifdef IS_MPI | 
| 782 |  |  | 
| 783 |  | idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), | 
| 784 |  | ff_->getAtomType(identsCol[atom2]) ); | 
| 799 | – |  | 
| 785 |  |  | 
| 786 |  | if (storageLayout_ & DataStorage::dslAmat) { | 
| 787 |  | idat.A1 = &(atomRowData.aMat[atom1]); | 
| 859 |  | } | 
| 860 |  |  | 
| 861 |  | #endif | 
| 877 | – | return idat; | 
| 862 |  | } | 
| 863 |  |  | 
| 864 |  |  | 
| 865 | < | void ForceMatrixDecomposition::unpackInteractionData(InteractionData idat, int atom1, int atom2) { | 
| 865 | > | void ForceMatrixDecomposition::unpackInteractionData(InteractionData &idat, int atom1, int atom2) { | 
| 866 |  | #ifdef IS_MPI | 
| 867 |  | pot_row[atom1] += 0.5 *  *(idat.pot); | 
| 868 |  | pot_col[atom2] += 0.5 *  *(idat.pot); | 
| 879 |  | } | 
| 880 |  |  | 
| 881 |  |  | 
| 882 | < | InteractionData ForceMatrixDecomposition::fillSkipData(int atom1, int atom2){ | 
| 883 | < |  | 
| 900 | < | InteractionData idat; | 
| 882 | > | void ForceMatrixDecomposition::fillSkipData(InteractionData &idat, | 
| 883 | > | int atom1, int atom2) { | 
| 884 |  | #ifdef IS_MPI | 
| 885 |  | idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), | 
| 886 |  | ff_->getAtomType(identsCol[atom2]) ); | 
| 941 |  | Vector3d rs, scaled, dr; | 
| 942 |  | Vector3i whichCell; | 
| 943 |  | int cellIndex; | 
| 944 | + | int nCtot = nCells_.x() * nCells_.y() * nCells_.z(); | 
| 945 |  |  | 
| 946 |  | #ifdef IS_MPI | 
| 947 | + | cellListRow_.resize(nCtot); | 
| 948 | + | cellListCol_.resize(nCtot); | 
| 949 | + | #else | 
| 950 | + | cellList_.resize(nCtot); | 
| 951 | + | #endif | 
| 952 | + |  | 
| 953 | + | #ifdef IS_MPI | 
| 954 |  | for (int i = 0; i < nGroupsInRow_; i++) { | 
| 955 |  | rs = cgRowData.position[i]; | 
| 956 | + |  | 
| 957 |  | // scaled positions relative to the box vectors | 
| 958 |  | scaled = invHmat * rs; | 
| 959 | + |  | 
| 960 |  | // wrap the vector back into the unit box by subtracting integer box | 
| 961 |  | // numbers | 
| 962 | < | for (int j = 0; j < 3; j++) | 
| 962 | > | for (int j = 0; j < 3; j++) { | 
| 963 |  | scaled[j] -= roundMe(scaled[j]); | 
| 964 | + | scaled[j] += 0.5; | 
| 965 | + | } | 
| 966 |  |  | 
| 967 |  | // find xyz-indices of cell that cutoffGroup is in. | 
| 968 |  | whichCell.x() = nCells_.x() * scaled.x(); | 
| 971 |  |  | 
| 972 |  | // find single index of this cell: | 
| 973 |  | cellIndex = Vlinear(whichCell, nCells_); | 
| 974 | + |  | 
| 975 |  | // add this cutoff group to the list of groups in this cell; | 
| 976 |  | cellListRow_[cellIndex].push_back(i); | 
| 977 |  | } | 
| 978 |  |  | 
| 979 |  | for (int i = 0; i < nGroupsInCol_; i++) { | 
| 980 |  | rs = cgColData.position[i]; | 
| 981 | + |  | 
| 982 |  | // scaled positions relative to the box vectors | 
| 983 |  | scaled = invHmat * rs; | 
| 984 | + |  | 
| 985 |  | // wrap the vector back into the unit box by subtracting integer box | 
| 986 |  | // numbers | 
| 987 | < | for (int j = 0; j < 3; j++) | 
| 987 | > | for (int j = 0; j < 3; j++) { | 
| 988 |  | scaled[j] -= roundMe(scaled[j]); | 
| 989 | + | scaled[j] += 0.5; | 
| 990 | + | } | 
| 991 |  |  | 
| 992 |  | // find xyz-indices of cell that cutoffGroup is in. | 
| 993 |  | whichCell.x() = nCells_.x() * scaled.x(); | 
| 996 |  |  | 
| 997 |  | // find single index of this cell: | 
| 998 |  | cellIndex = Vlinear(whichCell, nCells_); | 
| 999 | + |  | 
| 1000 |  | // add this cutoff group to the list of groups in this cell; | 
| 1001 |  | cellListCol_[cellIndex].push_back(i); | 
| 1002 |  | } | 
| 1003 |  | #else | 
| 1004 |  | for (int i = 0; i < nGroups_; i++) { | 
| 1005 |  | rs = snap_->cgData.position[i]; | 
| 1006 | + |  | 
| 1007 |  | // scaled positions relative to the box vectors | 
| 1008 |  | scaled = invHmat * rs; | 
| 1009 | + |  | 
| 1010 |  | // wrap the vector back into the unit box by subtracting integer box | 
| 1011 |  | // numbers | 
| 1012 | < | for (int j = 0; j < 3; j++) | 
| 1012 | > | for (int j = 0; j < 3; j++) { | 
| 1013 |  | scaled[j] -= roundMe(scaled[j]); | 
| 1014 | + | scaled[j] += 0.5; | 
| 1015 | + | } | 
| 1016 |  |  | 
| 1017 |  | // find xyz-indices of cell that cutoffGroup is in. | 
| 1018 |  | whichCell.x() = nCells_.x() * scaled.x(); | 
| 1020 |  | whichCell.z() = nCells_.z() * scaled.z(); | 
| 1021 |  |  | 
| 1022 |  | // find single index of this cell: | 
| 1023 | < | cellIndex = Vlinear(whichCell, nCells_); | 
| 1023 | > | cellIndex = Vlinear(whichCell, nCells_); | 
| 1024 | > |  | 
| 1025 |  | // add this cutoff group to the list of groups in this cell; | 
| 1026 |  | cellList_[cellIndex].push_back(i); | 
| 1027 |  | } | 
| 1079 |  | } | 
| 1080 |  | } | 
| 1081 |  | #else | 
| 1082 | + |  | 
| 1083 |  | for (vector<int>::iterator j1 = cellList_[m1].begin(); | 
| 1084 |  | j1 != cellList_[m1].end(); ++j1) { | 
| 1085 |  | for (vector<int>::iterator j2 = cellList_[m2].begin(); | 
| 1086 |  | j2 != cellList_[m2].end(); ++j2) { | 
| 1087 | < |  | 
| 1087 | > |  | 
| 1088 |  | // Always do this if we're in different cells or if | 
| 1089 |  | // we're in the same cell and the global index of the | 
| 1090 |  | // j2 cutoff group is less than the j1 cutoff group | 
| 1104 |  | } | 
| 1105 |  | } | 
| 1106 |  | } | 
| 1107 | < |  | 
| 1107 | > |  | 
| 1108 |  | // save the local cutoff group positions for the check that is | 
| 1109 |  | // done on each loop: | 
| 1110 |  | saved_CG_positions_.clear(); | 
| 1111 |  | for (int i = 0; i < nGroups_; i++) | 
| 1112 |  | saved_CG_positions_.push_back(snap_->cgData.position[i]); | 
| 1113 | < |  | 
| 1113 | > |  | 
| 1114 |  | return neighborList; | 
| 1115 |  | } | 
| 1116 |  | } //end namespace OpenMD |