# | Line 57 | Line 57 | namespace OpenMD { | |
---|---|---|
57 | storageLayout_ = sman_->getStorageLayout(); | |
58 | ff_ = info_->getForceField(); | |
59 | nLocal_ = snap_->getNumberOfAtoms(); | |
60 | < | |
60 | > | |
61 | nGroups_ = info_->getNLocalCutoffGroups(); | |
62 | // gather the information for atomtype IDs (atids): | |
63 | < | identsLocal = info_->getIdentArray(); |
63 | > | idents = info_->getIdentArray(); |
64 | AtomLocalToGlobal = info_->getGlobalAtomIndices(); | |
65 | cgLocalToGlobal = info_->getGlobalGroupIndices(); | |
66 | vector<int> globalGroupMembership = info_->getGlobalGroupMembership(); | |
67 | – | vector<RealType> massFactorsLocal = info_->getMassFactors(); |
68 | – | PairList excludes = info_->getExcludedInteractions(); |
69 | – | PairList oneTwo = info_->getOneTwoInteractions(); |
70 | – | PairList oneThree = info_->getOneThreeInteractions(); |
71 | – | PairList oneFour = info_->getOneFourInteractions(); |
67 | ||
68 | + | massFactors = info_->getMassFactors(); |
69 | + | |
70 | + | PairList* excludes = info_->getExcludedInteractions(); |
71 | + | PairList* oneTwo = info_->getOneTwoInteractions(); |
72 | + | PairList* oneThree = info_->getOneThreeInteractions(); |
73 | + | PairList* oneFour = info_->getOneFourInteractions(); |
74 | + | |
75 | #ifdef IS_MPI | |
76 | ||
77 | AtomCommIntRow = new Communicator<Row,int>(nLocal_); | |
# | Line 107 | Line 109 | namespace OpenMD { | |
109 | identsRow.resize(nAtomsInRow_); | |
110 | identsCol.resize(nAtomsInCol_); | |
111 | ||
112 | < | AtomCommIntRow->gather(identsLocal, identsRow); |
113 | < | AtomCommIntColumn->gather(identsLocal, identsCol); |
112 | > | AtomCommIntRow->gather(idents, identsRow); |
113 | > | AtomCommIntColumn->gather(idents, identsCol); |
114 | ||
115 | + | // allocate memory for the parallel objects |
116 | + | atypesRow.resize(nAtomsInRow_); |
117 | + | atypesCol.resize(nAtomsInCol_); |
118 | + | |
119 | + | for (int i = 0; i < nAtomsInRow_; i++) |
120 | + | atypesRow[i] = ff_->getAtomType(identsRow[i]); |
121 | + | for (int i = 0; i < nAtomsInCol_; i++) |
122 | + | atypesCol[i] = ff_->getAtomType(identsCol[i]); |
123 | + | |
124 | + | pot_row.resize(nAtomsInRow_); |
125 | + | pot_col.resize(nAtomsInCol_); |
126 | + | |
127 | + | AtomRowToGlobal.resize(nAtomsInRow_); |
128 | + | AtomColToGlobal.resize(nAtomsInCol_); |
129 | AtomCommIntRow->gather(AtomLocalToGlobal, AtomRowToGlobal); | |
130 | AtomCommIntColumn->gather(AtomLocalToGlobal, AtomColToGlobal); | |
131 | ||
132 | + | cgRowToGlobal.resize(nGroupsInRow_); |
133 | + | cgColToGlobal.resize(nGroupsInCol_); |
134 | cgCommIntRow->gather(cgLocalToGlobal, cgRowToGlobal); | |
135 | cgCommIntColumn->gather(cgLocalToGlobal, cgColToGlobal); | |
136 | ||
137 | < | AtomCommRealRow->gather(massFactorsLocal, massFactorsRow); |
138 | < | AtomCommRealColumn->gather(massFactorsLocal, massFactorsCol); |
137 | > | massFactorsRow.resize(nAtomsInRow_); |
138 | > | massFactorsCol.resize(nAtomsInCol_); |
139 | > | AtomCommRealRow->gather(massFactors, massFactorsRow); |
140 | > | AtomCommRealColumn->gather(massFactors, massFactorsCol); |
141 | ||
142 | groupListRow_.clear(); | |
143 | groupListRow_.resize(nGroupsInRow_); | |
# | Line 141 | Line 161 | namespace OpenMD { | |
161 | } | |
162 | } | |
163 | ||
164 | < | skipsForRowAtom.clear(); |
165 | < | skipsForRowAtom.resize(nAtomsInRow_); |
164 | > | excludesForAtom.clear(); |
165 | > | excludesForAtom.resize(nAtomsInRow_); |
166 | > | toposForAtom.clear(); |
167 | > | toposForAtom.resize(nAtomsInRow_); |
168 | > | topoDist.clear(); |
169 | > | topoDist.resize(nAtomsInRow_); |
170 | for (int i = 0; i < nAtomsInRow_; i++) { | |
171 | 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 | – | } |
172 | ||
155 | – | toposForRowAtom.clear(); |
156 | – | toposForRowAtom.resize(nAtomsInRow_); |
157 | – | for (int i = 0; i < nAtomsInRow_; i++) { |
158 | – | int iglob = AtomRowToGlobal[i]; |
159 | – | int nTopos = 0; |
173 | for (int j = 0; j < nAtomsInCol_; j++) { | |
174 | < | int jglob = AtomColToGlobal[j]; |
175 | < | if (oneTwo.hasPair(iglob, jglob)) { |
176 | < | toposForRowAtom[i].push_back(j); |
177 | < | topoDistRow[i][nTopos] = 1; |
178 | < | nTopos++; |
174 | > | int jglob = AtomColToGlobal[j]; |
175 | > | |
176 | > | if (excludes->hasPair(iglob, jglob)) |
177 | > | excludesForAtom[i].push_back(j); |
178 | > | |
179 | > | if (oneTwo->hasPair(iglob, jglob)) { |
180 | > | toposForAtom[i].push_back(j); |
181 | > | topoDist[i].push_back(1); |
182 | > | } else { |
183 | > | if (oneThree->hasPair(iglob, jglob)) { |
184 | > | toposForAtom[i].push_back(j); |
185 | > | topoDist[i].push_back(2); |
186 | > | } else { |
187 | > | if (oneFour->hasPair(iglob, jglob)) { |
188 | > | toposForAtom[i].push_back(j); |
189 | > | topoDist[i].push_back(3); |
190 | > | } |
191 | > | } |
192 | } | |
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 | – | } |
193 | } | |
194 | } | |
195 | ||
196 | #endif | |
197 | + | |
198 | + | // allocate memory for the parallel objects |
199 | + | atypesLocal.resize(nLocal_); |
200 | + | |
201 | + | for (int i = 0; i < nLocal_; i++) |
202 | + | atypesLocal[i] = ff_->getAtomType(idents[i]); |
203 | + | |
204 | groupList_.clear(); | |
205 | groupList_.resize(nGroups_); | |
206 | for (int i = 0; i < nGroups_; i++) { | |
# | Line 186 | Line 209 | namespace OpenMD { | |
209 | int aid = AtomLocalToGlobal[j]; | |
210 | if (globalGroupMembership[aid] == gid) { | |
211 | groupList_[i].push_back(j); | |
189 | – | |
212 | } | |
213 | } | |
214 | } | |
215 | ||
216 | < | skipsForLocalAtom.clear(); |
217 | < | skipsForLocalAtom.resize(nLocal_); |
216 | > | excludesForAtom.clear(); |
217 | > | excludesForAtom.resize(nLocal_); |
218 | > | toposForAtom.clear(); |
219 | > | toposForAtom.resize(nLocal_); |
220 | > | topoDist.clear(); |
221 | > | topoDist.resize(nLocal_); |
222 | ||
223 | for (int i = 0; i < nLocal_; i++) { | |
224 | int iglob = AtomLocalToGlobal[i]; | |
225 | + | |
226 | for (int j = 0; j < nLocal_; j++) { | |
227 | < | int jglob = AtomLocalToGlobal[j]; |
228 | < | if (excludes.hasPair(iglob, jglob)) |
229 | < | skipsForLocalAtom[i].push_back(j); |
230 | < | } |
231 | < | } |
232 | < | toposForLocalAtom.clear(); |
233 | < | toposForLocalAtom.resize(nLocal_); |
234 | < | for (int i = 0; i < nLocal_; i++) { |
235 | < | int iglob = AtomLocalToGlobal[i]; |
236 | < | int nTopos = 0; |
237 | < | for (int j = 0; j < nLocal_; j++) { |
238 | < | int jglob = AtomLocalToGlobal[j]; |
239 | < | if (oneTwo.hasPair(iglob, jglob)) { |
240 | < | toposForLocalAtom[i].push_back(j); |
241 | < | topoDistLocal[i][nTopos] = 1; |
242 | < | nTopos++; |
227 | > | int jglob = AtomLocalToGlobal[j]; |
228 | > | |
229 | > | if (excludes->hasPair(iglob, jglob)) |
230 | > | excludesForAtom[i].push_back(j); |
231 | > | |
232 | > | if (oneTwo->hasPair(iglob, jglob)) { |
233 | > | toposForAtom[i].push_back(j); |
234 | > | topoDist[i].push_back(1); |
235 | > | } else { |
236 | > | if (oneThree->hasPair(iglob, jglob)) { |
237 | > | toposForAtom[i].push_back(j); |
238 | > | topoDist[i].push_back(2); |
239 | > | } else { |
240 | > | if (oneFour->hasPair(iglob, jglob)) { |
241 | > | toposForAtom[i].push_back(j); |
242 | > | topoDist[i].push_back(3); |
243 | > | } |
244 | > | } |
245 | } | |
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 | – | } |
246 | } | |
247 | < | } |
247 | > | } |
248 | > | |
249 | > | createGtypeCutoffMap(); |
250 | ||
251 | } | |
252 | ||
253 | void ForceMatrixDecomposition::createGtypeCutoffMap() { | |
254 | < | |
254 | > | |
255 | RealType tol = 1e-6; | |
256 | RealType rc; | |
257 | int atid; | |
258 | set<AtomType*> atypes = info_->getSimulatedAtomTypes(); | |
259 | < | vector<RealType> atypeCutoff; |
260 | < | atypeCutoff.resize( atypes.size() ); |
261 | < | |
262 | < | for (set<AtomType*>::iterator at = atypes.begin(); at != atypes.end(); ++at){ |
242 | < | rc = interactionMan_->getSuggestedCutoffRadius(*at); |
259 | > | map<int, RealType> atypeCutoff; |
260 | > | |
261 | > | for (set<AtomType*>::iterator at = atypes.begin(); |
262 | > | at != atypes.end(); ++at){ |
263 | atid = (*at)->getIdent(); | |
264 | < | atypeCutoff[atid] = rc; |
264 | > | if (userChoseCutoff_) |
265 | > | atypeCutoff[atid] = userCutoff_; |
266 | > | else |
267 | > | atypeCutoff[atid] = interactionMan_->getSuggestedCutoffRadius(*at); |
268 | } | |
269 | ||
270 | vector<RealType> gTypeCutoffs; | |
248 | – | |
271 | // first we do a single loop over the cutoff groups to find the | |
272 | // largest cutoff for any atypes present in this group. | |
273 | #ifdef IS_MPI | |
274 | vector<RealType> groupCutoffRow(nGroupsInRow_, 0.0); | |
275 | + | groupRowToGtype.resize(nGroupsInRow_); |
276 | for (int cg1 = 0; cg1 < nGroupsInRow_; cg1++) { | |
277 | vector<int> atomListRow = getAtomsInGroupRow(cg1); | |
278 | for (vector<int>::iterator ia = atomListRow.begin(); | |
# | Line 275 | Line 298 | namespace OpenMD { | |
298 | ||
299 | } | |
300 | vector<RealType> groupCutoffCol(nGroupsInCol_, 0.0); | |
301 | + | groupColToGtype.resize(nGroupsInCol_); |
302 | for (int cg2 = 0; cg2 < nGroupsInCol_; cg2++) { | |
303 | vector<int> atomListCol = getAtomsInGroupColumn(cg2); | |
304 | for (vector<int>::iterator jb = atomListCol.begin(); | |
# | Line 298 | Line 322 | namespace OpenMD { | |
322 | } | |
323 | } | |
324 | #else | |
325 | + | |
326 | vector<RealType> groupCutoff(nGroups_, 0.0); | |
327 | + | groupToGtype.resize(nGroups_); |
328 | for (int cg1 = 0; cg1 < nGroups_; cg1++) { | |
329 | + | |
330 | groupCutoff[cg1] = 0.0; | |
331 | vector<int> atomList = getAtomsInGroupRow(cg1); | |
332 | + | |
333 | for (vector<int>::iterator ia = atomList.begin(); | |
334 | ia != atomList.end(); ++ia) { | |
335 | int atom1 = (*ia); | |
336 | < | atid = identsLocal[atom1]; |
336 | > | atid = idents[atom1]; |
337 | if (atypeCutoff[atid] > groupCutoff[cg1]) { | |
338 | groupCutoff[cg1] = atypeCutoff[atid]; | |
339 | } | |
# | Line 327 | Line 355 | namespace OpenMD { | |
355 | ||
356 | // Now we find the maximum group cutoff value present in the simulation | |
357 | ||
358 | < | vector<RealType>::iterator groupMaxLoc = max_element(gTypeCutoffs.begin(), gTypeCutoffs.end()); |
359 | < | RealType groupMax = *groupMaxLoc; |
358 | > | RealType groupMax = *max_element(gTypeCutoffs.begin(), |
359 | > | gTypeCutoffs.end()); |
360 | ||
361 | #ifdef IS_MPI | |
362 | < | MPI::COMM_WORLD.Allreduce(&groupMax, &groupMax, 1, MPI::REALTYPE, MPI::MAX); |
362 | > | MPI::COMM_WORLD.Allreduce(&groupMax, &groupMax, 1, MPI::REALTYPE, |
363 | > | MPI::MAX); |
364 | #endif | |
365 | ||
366 | RealType tradRcut = groupMax; | |
367 | ||
368 | for (int i = 0; i < gTypeCutoffs.size(); i++) { | |
369 | < | for (int j = 0; j < gTypeCutoffs.size(); j++) { |
341 | < | |
369 | > | for (int j = 0; j < gTypeCutoffs.size(); j++) { |
370 | RealType thisRcut; | |
371 | switch(cutoffPolicy_) { | |
372 | case TRADITIONAL: | |
373 | thisRcut = tradRcut; | |
374 | + | break; |
375 | case MIX: | |
376 | thisRcut = 0.5 * (gTypeCutoffs[i] + gTypeCutoffs[j]); | |
377 | + | break; |
378 | case MAX: | |
379 | thisRcut = max(gTypeCutoffs[i], gTypeCutoffs[j]); | |
380 | + | break; |
381 | default: | |
382 | sprintf(painCave.errMsg, | |
383 | "ForceMatrixDecomposition::createGtypeCutoffMap " | |
384 | "hit an unknown cutoff policy!\n"); | |
385 | painCave.severity = OPENMD_ERROR; | |
386 | painCave.isFatal = 1; | |
387 | < | simError(); |
387 | > | simError(); |
388 | > | break; |
389 | } | |
390 | ||
391 | pair<int,int> key = make_pair(i,j); | |
# | Line 371 | Line 403 | namespace OpenMD { | |
403 | if (abs(gTypeCutoffMap[key].first - userCutoff_) > 0.0001) { | |
404 | sprintf(painCave.errMsg, | |
405 | "ForceMatrixDecomposition::createGtypeCutoffMap " | |
406 | < | "user-specified rCut does not match computed group Cutoff\n"); |
406 | > | "user-specified rCut (%lf) does not match computed group Cutoff\n", userCutoff_); |
407 | painCave.severity = OPENMD_ERROR; | |
408 | painCave.isFatal = 1; | |
409 | simError(); | |
# | Line 383 | Line 415 | namespace OpenMD { | |
415 | ||
416 | ||
417 | groupCutoffs ForceMatrixDecomposition::getGroupCutoffs(int cg1, int cg2) { | |
418 | < | int i, j; |
387 | < | |
418 | > | int i, j; |
419 | #ifdef IS_MPI | |
420 | i = groupRowToGtype[cg1]; | |
421 | j = groupColToGtype[cg2]; | |
422 | #else | |
423 | i = groupToGtype[cg1]; | |
424 | j = groupToGtype[cg2]; | |
425 | < | #endif |
395 | < | |
425 | > | #endif |
426 | return gTypeCutoffMap[make_pair(i,j)]; | |
427 | } | |
428 | ||
429 | + | int ForceMatrixDecomposition::getTopologicalDistance(int atom1, int atom2) { |
430 | + | for (int j = 0; j < toposForAtom[atom1].size(); j++) { |
431 | + | if (toposForAtom[atom1][j] == atom2) |
432 | + | return topoDist[atom1][j]; |
433 | + | } |
434 | + | return 0; |
435 | + | } |
436 | ||
437 | void ForceMatrixDecomposition::zeroWorkArrays() { | |
438 | + | pairwisePot = 0.0; |
439 | + | embeddingPot = 0.0; |
440 | ||
402 | – | for (int j = 0; j < N_INTERACTION_FAMILIES; j++) { |
403 | – | longRangePot_[j] = 0.0; |
404 | – | } |
405 | – | |
441 | #ifdef IS_MPI | |
442 | if (storageLayout_ & DataStorage::dslForce) { | |
443 | fill(atomRowData.force.begin(), atomRowData.force.end(), V3Zero); | |
# | Line 418 | Line 453 | namespace OpenMD { | |
453 | Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); | |
454 | ||
455 | fill(pot_col.begin(), pot_col.end(), | |
456 | < | Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
422 | < | |
423 | < | pot_local = Vector<RealType, N_INTERACTION_FAMILIES>(0.0); |
456 | > | Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
457 | ||
458 | if (storageLayout_ & DataStorage::dslParticlePot) { | |
459 | < | fill(atomRowData.particlePot.begin(), atomRowData.particlePot.end(), 0.0); |
460 | < | fill(atomColData.particlePot.begin(), atomColData.particlePot.end(), 0.0); |
459 | > | fill(atomRowData.particlePot.begin(), atomRowData.particlePot.end(), |
460 | > | 0.0); |
461 | > | fill(atomColData.particlePot.begin(), atomColData.particlePot.end(), |
462 | > | 0.0); |
463 | } | |
464 | ||
465 | if (storageLayout_ & DataStorage::dslDensity) { | |
# | Line 433 | Line 468 | namespace OpenMD { | |
468 | } | |
469 | ||
470 | if (storageLayout_ & DataStorage::dslFunctional) { | |
471 | < | fill(atomRowData.functional.begin(), atomRowData.functional.end(), 0.0); |
472 | < | fill(atomColData.functional.begin(), atomColData.functional.end(), 0.0); |
471 | > | fill(atomRowData.functional.begin(), atomRowData.functional.end(), |
472 | > | 0.0); |
473 | > | fill(atomColData.functional.begin(), atomColData.functional.end(), |
474 | > | 0.0); |
475 | } | |
476 | ||
477 | if (storageLayout_ & DataStorage::dslFunctionalDerivative) { | |
# | Line 444 | Line 481 | namespace OpenMD { | |
481 | atomColData.functionalDerivative.end(), 0.0); | |
482 | } | |
483 | ||
484 | < | #else |
485 | < | |
484 | > | if (storageLayout_ & DataStorage::dslSkippedCharge) { |
485 | > | fill(atomRowData.skippedCharge.begin(), |
486 | > | atomRowData.skippedCharge.end(), 0.0); |
487 | > | fill(atomColData.skippedCharge.begin(), |
488 | > | atomColData.skippedCharge.end(), 0.0); |
489 | > | } |
490 | > | |
491 | > | #endif |
492 | > | // even in parallel, we need to zero out the local arrays: |
493 | > | |
494 | if (storageLayout_ & DataStorage::dslParticlePot) { | |
495 | fill(snap_->atomData.particlePot.begin(), | |
496 | snap_->atomData.particlePot.end(), 0.0); | |
# | Line 463 | Line 508 | namespace OpenMD { | |
508 | fill(snap_->atomData.functionalDerivative.begin(), | |
509 | snap_->atomData.functionalDerivative.end(), 0.0); | |
510 | } | |
511 | < | #endif |
511 | > | if (storageLayout_ & DataStorage::dslSkippedCharge) { |
512 | > | fill(snap_->atomData.skippedCharge.begin(), |
513 | > | snap_->atomData.skippedCharge.end(), 0.0); |
514 | > | } |
515 | ||
516 | } | |
517 | ||
# | Line 500 | Line 548 | namespace OpenMD { | |
548 | AtomCommMatrixColumn->gather(snap_->atomData.electroFrame, | |
549 | atomColData.electroFrame); | |
550 | } | |
551 | + | |
552 | #endif | |
553 | } | |
554 | ||
# | Line 566 | Line 615 | namespace OpenMD { | |
615 | AtomCommVectorColumn->scatter(atomColData.force, frc_tmp); | |
616 | for (int i = 0; i < n; i++) | |
617 | snap_->atomData.force[i] += frc_tmp[i]; | |
618 | < | |
570 | < | |
618 | > | |
619 | if (storageLayout_ & DataStorage::dslTorque) { | |
620 | ||
621 | < | int nt = snap_->atomData.force.size(); |
621 | > | int nt = snap_->atomData.torque.size(); |
622 | vector<Vector3d> trq_tmp(nt, V3Zero); | |
623 | ||
624 | AtomCommVectorRow->scatter(atomRowData.torque, trq_tmp); | |
625 | < | for (int i = 0; i < n; i++) { |
625 | > | for (int i = 0; i < nt; i++) { |
626 | snap_->atomData.torque[i] += trq_tmp[i]; | |
627 | trq_tmp[i] = 0.0; | |
628 | } | |
629 | ||
630 | AtomCommVectorColumn->scatter(atomColData.torque, trq_tmp); | |
631 | < | for (int i = 0; i < n; i++) |
631 | > | for (int i = 0; i < nt; i++) |
632 | snap_->atomData.torque[i] += trq_tmp[i]; | |
633 | + | } |
634 | + | |
635 | + | if (storageLayout_ & DataStorage::dslSkippedCharge) { |
636 | + | |
637 | + | int ns = snap_->atomData.skippedCharge.size(); |
638 | + | vector<RealType> skch_tmp(ns, 0.0); |
639 | + | |
640 | + | AtomCommRealRow->scatter(atomRowData.skippedCharge, skch_tmp); |
641 | + | for (int i = 0; i < ns; i++) { |
642 | + | snap_->atomData.skippedCharge[i] += skch_tmp[i]; |
643 | + | skch_tmp[i] = 0.0; |
644 | + | } |
645 | + | |
646 | + | AtomCommRealColumn->scatter(atomColData.skippedCharge, skch_tmp); |
647 | + | for (int i = 0; i < ns; i++) |
648 | + | snap_->atomData.skippedCharge[i] += skch_tmp[i]; |
649 | } | |
650 | ||
651 | nLocal_ = snap_->getNumberOfAtoms(); | |
# | Line 594 | Line 658 | namespace OpenMD { | |
658 | AtomCommPotRow->scatter(pot_row, pot_temp); | |
659 | ||
660 | for (int ii = 0; ii < pot_temp.size(); ii++ ) | |
661 | < | pot_local += pot_temp[ii]; |
661 | > | pairwisePot += pot_temp[ii]; |
662 | ||
663 | fill(pot_temp.begin(), pot_temp.end(), | |
664 | Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); | |
# | Line 602 | Line 666 | namespace OpenMD { | |
666 | AtomCommPotColumn->scatter(pot_col, pot_temp); | |
667 | ||
668 | for (int ii = 0; ii < pot_temp.size(); ii++ ) | |
669 | < | pot_local += pot_temp[ii]; |
606 | < | |
669 | > | pairwisePot += pot_temp[ii]; |
670 | #endif | |
671 | + | |
672 | } | |
673 | ||
674 | int ForceMatrixDecomposition::getNAtomsInRow() { | |
# | Line 679 | Line 743 | namespace OpenMD { | |
743 | #ifdef IS_MPI | |
744 | return massFactorsRow[atom1]; | |
745 | #else | |
746 | < | return massFactorsLocal[atom1]; |
746 | > | return massFactors[atom1]; |
747 | #endif | |
748 | } | |
749 | ||
# | Line 687 | Line 751 | namespace OpenMD { | |
751 | #ifdef IS_MPI | |
752 | return massFactorsCol[atom2]; | |
753 | #else | |
754 | < | return massFactorsLocal[atom2]; |
754 | > | return massFactors[atom2]; |
755 | #endif | |
756 | ||
757 | } | |
# | Line 705 | Line 769 | namespace OpenMD { | |
769 | return d; | |
770 | } | |
771 | ||
772 | < | vector<int> ForceMatrixDecomposition::getSkipsForRowAtom(int atom1) { |
773 | < | #ifdef IS_MPI |
710 | < | return skipsForRowAtom[atom1]; |
711 | < | #else |
712 | < | return skipsForLocalAtom[atom1]; |
713 | < | #endif |
772 | > | vector<int> ForceMatrixDecomposition::getExcludesForAtom(int atom1) { |
773 | > | return excludesForAtom[atom1]; |
774 | } | |
775 | ||
776 | /** | |
777 | < | * There are a number of reasons to skip a pair or a |
718 | < | * particle. Mostly we do this to exclude atoms who are involved in |
719 | < | * short range interactions (bonds, bends, torsions), but we also |
720 | < | * need to exclude some overcounted interactions that result from |
777 | > | * We need to exclude some overcounted interactions that result from |
778 | * the parallel decomposition. | |
779 | */ | |
780 | bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) { | |
# | Line 737 | Line 794 | namespace OpenMD { | |
794 | } else { | |
795 | if ((unique_id_1 + unique_id_2) % 2 == 1) return true; | |
796 | } | |
740 | – | #else |
741 | – | // in the normal loop, the atom numbers are unique |
742 | – | unique_id_1 = atom1; |
743 | – | unique_id_2 = atom2; |
797 | #endif | |
798 | < | |
746 | < | #ifdef IS_MPI |
747 | < | for (vector<int>::iterator i = skipsForRowAtom[atom1].begin(); |
748 | < | i != skipsForRowAtom[atom1].end(); ++i) { |
749 | < | if ( (*i) == unique_id_2 ) return true; |
750 | < | } |
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 |
798 | > | return false; |
799 | } | |
800 | ||
801 | < | int ForceMatrixDecomposition::getTopoDistance(int atom1, int atom2) { |
801 | > | /** |
802 | > | * We need to handle the interactions for atoms who are involved in |
803 | > | * the same rigid body as well as some short range interactions |
804 | > | * (bonds, bends, torsions) differently from other interactions. |
805 | > | * We'll still visit the pairwise routines, but with a flag that |
806 | > | * tells those routines to exclude the pair from direct long range |
807 | > | * interactions. Some indirect interactions (notably reaction |
808 | > | * field) must still be handled for these pairs. |
809 | > | */ |
810 | > | bool ForceMatrixDecomposition::excludeAtomPair(int atom1, int atom2) { |
811 | > | int unique_id_2; |
812 | ||
813 | #ifdef IS_MPI | |
814 | < | for (int i = 0; i < toposForRowAtom[atom1].size(); i++) { |
815 | < | if ( toposForRowAtom[atom1][i] == atom2 ) return topoDistRow[atom1][i]; |
764 | < | } |
814 | > | // in MPI, we have to look up the unique IDs for the row atom. |
815 | > | unique_id_2 = AtomColToGlobal[atom2]; |
816 | #else | |
817 | < | for (int i = 0; i < toposForLocalAtom[atom1].size(); i++) { |
818 | < | if ( toposForLocalAtom[atom1][i] == atom2 ) return topoDistLocal[atom1][i]; |
768 | < | } |
817 | > | // in the normal loop, the atom numbers are unique |
818 | > | unique_id_2 = atom2; |
819 | #endif | |
820 | + | |
821 | + | for (vector<int>::iterator i = excludesForAtom[atom1].begin(); |
822 | + | i != excludesForAtom[atom1].end(); ++i) { |
823 | + | if ( (*i) == unique_id_2 ) return true; |
824 | + | } |
825 | ||
826 | < | // zero is default for unconnected (i.e. normal) pair interactions |
772 | < | return 0; |
826 | > | return false; |
827 | } | |
828 | ||
829 | + | |
830 | void ForceMatrixDecomposition::addForceToAtomRow(int atom1, Vector3d fg){ | |
831 | #ifdef IS_MPI | |
832 | atomRowData.force[atom1] += fg; | |
# | Line 789 | Line 844 | namespace OpenMD { | |
844 | } | |
845 | ||
846 | // filling interaction blocks with pointers | |
847 | < | InteractionData ForceMatrixDecomposition::fillInteractionData(int atom1, int atom2) { |
848 | < | InteractionData idat; |
847 | > | void ForceMatrixDecomposition::fillInteractionData(InteractionData &idat, |
848 | > | int atom1, int atom2) { |
849 | ||
850 | + | idat.excluded = excludeAtomPair(atom1, atom2); |
851 | + | |
852 | #ifdef IS_MPI | |
853 | + | idat.atypes = make_pair( atypesRow[atom1], atypesCol[atom2]); |
854 | + | //idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), |
855 | + | // ff_->getAtomType(identsCol[atom2]) ); |
856 | ||
797 | – | idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), |
798 | – | ff_->getAtomType(identsCol[atom2]) ); |
799 | – | |
800 | – | |
857 | if (storageLayout_ & DataStorage::dslAmat) { | |
858 | idat.A1 = &(atomRowData.aMat[atom1]); | |
859 | idat.A2 = &(atomColData.aMat[atom2]); | |
# | Line 831 | Line 887 | namespace OpenMD { | |
887 | if (storageLayout_ & DataStorage::dslParticlePot) { | |
888 | idat.particlePot1 = &(atomRowData.particlePot[atom1]); | |
889 | idat.particlePot2 = &(atomColData.particlePot[atom2]); | |
890 | + | } |
891 | + | |
892 | + | if (storageLayout_ & DataStorage::dslSkippedCharge) { |
893 | + | idat.skippedCharge1 = &(atomRowData.skippedCharge[atom1]); |
894 | + | idat.skippedCharge2 = &(atomColData.skippedCharge[atom2]); |
895 | } | |
896 | ||
897 | #else | |
898 | ||
899 | < | idat.atypes = make_pair( ff_->getAtomType(identsLocal[atom1]), |
900 | < | ff_->getAtomType(identsLocal[atom2]) ); |
899 | > | idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]); |
900 | > | //idat.atypes = make_pair( ff_->getAtomType(idents[atom1]), |
901 | > | // ff_->getAtomType(idents[atom2]) ); |
902 | ||
903 | if (storageLayout_ & DataStorage::dslAmat) { | |
904 | idat.A1 = &(snap_->atomData.aMat[atom1]); | |
# | Line 853 | Line 915 | namespace OpenMD { | |
915 | idat.t2 = &(snap_->atomData.torque[atom2]); | |
916 | } | |
917 | ||
918 | < | if (storageLayout_ & DataStorage::dslDensity) { |
918 | > | if (storageLayout_ & DataStorage::dslDensity) { |
919 | idat.rho1 = &(snap_->atomData.density[atom1]); | |
920 | idat.rho2 = &(snap_->atomData.density[atom2]); | |
921 | } | |
# | Line 873 | Line 935 | namespace OpenMD { | |
935 | idat.particlePot2 = &(snap_->atomData.particlePot[atom2]); | |
936 | } | |
937 | ||
938 | + | if (storageLayout_ & DataStorage::dslSkippedCharge) { |
939 | + | idat.skippedCharge1 = &(snap_->atomData.skippedCharge[atom1]); |
940 | + | idat.skippedCharge2 = &(snap_->atomData.skippedCharge[atom2]); |
941 | + | } |
942 | #endif | |
877 | – | return idat; |
943 | } | |
944 | ||
945 | ||
946 | < | void ForceMatrixDecomposition::unpackInteractionData(InteractionData idat, int atom1, int atom2) { |
946 | > | void ForceMatrixDecomposition::unpackInteractionData(InteractionData &idat, int atom1, int atom2) { |
947 | #ifdef IS_MPI | |
948 | pot_row[atom1] += 0.5 * *(idat.pot); | |
949 | pot_col[atom2] += 0.5 * *(idat.pot); | |
# | Line 886 | Line 951 | namespace OpenMD { | |
951 | atomRowData.force[atom1] += *(idat.f1); | |
952 | atomColData.force[atom2] -= *(idat.f1); | |
953 | #else | |
954 | < | longRangePot_ += *(idat.pot); |
955 | < | |
954 | > | pairwisePot += *(idat.pot); |
955 | > | |
956 | snap_->atomData.force[atom1] += *(idat.f1); | |
957 | snap_->atomData.force[atom2] -= *(idat.f1); | |
958 | #endif | |
959 | < | |
959 | > | |
960 | } | |
961 | ||
897 | – | |
898 | – | InteractionData ForceMatrixDecomposition::fillSkipData(int atom1, int atom2){ |
899 | – | |
900 | – | InteractionData idat; |
901 | – | #ifdef IS_MPI |
902 | – | idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), |
903 | – | ff_->getAtomType(identsCol[atom2]) ); |
904 | – | |
905 | – | if (storageLayout_ & DataStorage::dslElectroFrame) { |
906 | – | idat.eFrame1 = &(atomRowData.electroFrame[atom1]); |
907 | – | idat.eFrame2 = &(atomColData.electroFrame[atom2]); |
908 | – | } |
909 | – | if (storageLayout_ & DataStorage::dslTorque) { |
910 | – | idat.t1 = &(atomRowData.torque[atom1]); |
911 | – | idat.t2 = &(atomColData.torque[atom2]); |
912 | – | } |
913 | – | #else |
914 | – | idat.atypes = make_pair( ff_->getAtomType(identsLocal[atom1]), |
915 | – | ff_->getAtomType(identsLocal[atom2]) ); |
916 | – | |
917 | – | if (storageLayout_ & DataStorage::dslElectroFrame) { |
918 | – | idat.eFrame1 = &(snap_->atomData.electroFrame[atom1]); |
919 | – | idat.eFrame2 = &(snap_->atomData.electroFrame[atom2]); |
920 | – | } |
921 | – | if (storageLayout_ & DataStorage::dslTorque) { |
922 | – | idat.t1 = &(snap_->atomData.torque[atom1]); |
923 | – | idat.t2 = &(snap_->atomData.torque[atom2]); |
924 | – | } |
925 | – | #endif |
926 | – | } |
927 | – | |
962 | /* | |
963 | * buildNeighborList | |
964 | * | |
# | Line 935 | Line 969 | namespace OpenMD { | |
969 | ||
970 | vector<pair<int, int> > neighborList; | |
971 | groupCutoffs cuts; | |
972 | + | bool doAllPairs = false; |
973 | + | |
974 | #ifdef IS_MPI | |
975 | cellListRow_.clear(); | |
976 | cellListCol_.clear(); | |
# | Line 954 | Line 990 | namespace OpenMD { | |
990 | nCells_.y() = (int) ( Hy.length() )/ rList_; | |
991 | nCells_.z() = (int) ( Hz.length() )/ rList_; | |
992 | ||
993 | + | // handle small boxes where the cell offsets can end up repeating cells |
994 | + | |
995 | + | if (nCells_.x() < 3) doAllPairs = true; |
996 | + | if (nCells_.y() < 3) doAllPairs = true; |
997 | + | if (nCells_.z() < 3) doAllPairs = true; |
998 | + | |
999 | Mat3x3d invHmat = snap_->getInvHmat(); | |
1000 | Vector3d rs, scaled, dr; | |
1001 | Vector3i whichCell; | |
1002 | int cellIndex; | |
1003 | + | int nCtot = nCells_.x() * nCells_.y() * nCells_.z(); |
1004 | ||
1005 | #ifdef IS_MPI | |
1006 | < | for (int i = 0; i < nGroupsInRow_; i++) { |
1007 | < | rs = cgRowData.position[i]; |
965 | < | // scaled positions relative to the box vectors |
966 | < | scaled = invHmat * rs; |
967 | < | // wrap the vector back into the unit box by subtracting integer box |
968 | < | // numbers |
969 | < | for (int j = 0; j < 3; j++) |
970 | < | scaled[j] -= roundMe(scaled[j]); |
971 | < | |
972 | < | // find xyz-indices of cell that cutoffGroup is in. |
973 | < | whichCell.x() = nCells_.x() * scaled.x(); |
974 | < | whichCell.y() = nCells_.y() * scaled.y(); |
975 | < | whichCell.z() = nCells_.z() * scaled.z(); |
976 | < | |
977 | < | // find single index of this cell: |
978 | < | cellIndex = Vlinear(whichCell, nCells_); |
979 | < | // add this cutoff group to the list of groups in this cell; |
980 | < | cellListRow_[cellIndex].push_back(i); |
981 | < | } |
982 | < | |
983 | < | for (int i = 0; i < nGroupsInCol_; i++) { |
984 | < | rs = cgColData.position[i]; |
985 | < | // scaled positions relative to the box vectors |
986 | < | scaled = invHmat * rs; |
987 | < | // wrap the vector back into the unit box by subtracting integer box |
988 | < | // numbers |
989 | < | for (int j = 0; j < 3; j++) |
990 | < | scaled[j] -= roundMe(scaled[j]); |
991 | < | |
992 | < | // find xyz-indices of cell that cutoffGroup is in. |
993 | < | whichCell.x() = nCells_.x() * scaled.x(); |
994 | < | whichCell.y() = nCells_.y() * scaled.y(); |
995 | < | whichCell.z() = nCells_.z() * scaled.z(); |
996 | < | |
997 | < | // find single index of this cell: |
998 | < | cellIndex = Vlinear(whichCell, nCells_); |
999 | < | // add this cutoff group to the list of groups in this cell; |
1000 | < | cellListCol_[cellIndex].push_back(i); |
1001 | < | } |
1006 | > | cellListRow_.resize(nCtot); |
1007 | > | cellListCol_.resize(nCtot); |
1008 | #else | |
1009 | < | for (int i = 0; i < nGroups_; i++) { |
1004 | < | rs = snap_->cgData.position[i]; |
1005 | < | // scaled positions relative to the box vectors |
1006 | < | scaled = invHmat * rs; |
1007 | < | // wrap the vector back into the unit box by subtracting integer box |
1008 | < | // numbers |
1009 | < | for (int j = 0; j < 3; j++) |
1010 | < | scaled[j] -= roundMe(scaled[j]); |
1011 | < | |
1012 | < | // find xyz-indices of cell that cutoffGroup is in. |
1013 | < | whichCell.x() = nCells_.x() * scaled.x(); |
1014 | < | whichCell.y() = nCells_.y() * scaled.y(); |
1015 | < | whichCell.z() = nCells_.z() * scaled.z(); |
1016 | < | |
1017 | < | // find single index of this cell: |
1018 | < | cellIndex = Vlinear(whichCell, nCells_); |
1019 | < | // add this cutoff group to the list of groups in this cell; |
1020 | < | cellList_[cellIndex].push_back(i); |
1021 | < | } |
1009 | > | cellList_.resize(nCtot); |
1010 | #endif | |
1011 | ||
1012 | < | for (int m1z = 0; m1z < nCells_.z(); m1z++) { |
1013 | < | for (int m1y = 0; m1y < nCells_.y(); m1y++) { |
1026 | < | for (int m1x = 0; m1x < nCells_.x(); m1x++) { |
1027 | < | Vector3i m1v(m1x, m1y, m1z); |
1028 | < | int m1 = Vlinear(m1v, nCells_); |
1012 | > | if (!doAllPairs) { |
1013 | > | #ifdef IS_MPI |
1014 | ||
1015 | < | for (vector<Vector3i>::iterator os = cellOffsets_.begin(); |
1016 | < | os != cellOffsets_.end(); ++os) { |
1017 | < | |
1018 | < | Vector3i m2v = m1v + (*os); |
1019 | < | |
1020 | < | if (m2v.x() >= nCells_.x()) { |
1021 | < | m2v.x() = 0; |
1022 | < | } else if (m2v.x() < 0) { |
1023 | < | m2v.x() = nCells_.x() - 1; |
1024 | < | } |
1025 | < | |
1026 | < | if (m2v.y() >= nCells_.y()) { |
1027 | < | m2v.y() = 0; |
1028 | < | } else if (m2v.y() < 0) { |
1029 | < | m2v.y() = nCells_.y() - 1; |
1030 | < | } |
1031 | < | |
1032 | < | if (m2v.z() >= nCells_.z()) { |
1033 | < | m2v.z() = 0; |
1034 | < | } else if (m2v.z() < 0) { |
1035 | < | m2v.z() = nCells_.z() - 1; |
1036 | < | } |
1037 | < | |
1038 | < | int m2 = Vlinear (m2v, nCells_); |
1015 | > | for (int i = 0; i < nGroupsInRow_; i++) { |
1016 | > | rs = cgRowData.position[i]; |
1017 | > | |
1018 | > | // scaled positions relative to the box vectors |
1019 | > | scaled = invHmat * rs; |
1020 | > | |
1021 | > | // wrap the vector back into the unit box by subtracting integer box |
1022 | > | // numbers |
1023 | > | for (int j = 0; j < 3; j++) { |
1024 | > | scaled[j] -= roundMe(scaled[j]); |
1025 | > | scaled[j] += 0.5; |
1026 | > | } |
1027 | > | |
1028 | > | // find xyz-indices of cell that cutoffGroup is in. |
1029 | > | whichCell.x() = nCells_.x() * scaled.x(); |
1030 | > | whichCell.y() = nCells_.y() * scaled.y(); |
1031 | > | whichCell.z() = nCells_.z() * scaled.z(); |
1032 | > | |
1033 | > | // find single index of this cell: |
1034 | > | cellIndex = Vlinear(whichCell, nCells_); |
1035 | > | |
1036 | > | // add this cutoff group to the list of groups in this cell; |
1037 | > | cellListRow_[cellIndex].push_back(i); |
1038 | > | } |
1039 | > | |
1040 | > | for (int i = 0; i < nGroupsInCol_; i++) { |
1041 | > | rs = cgColData.position[i]; |
1042 | > | |
1043 | > | // scaled positions relative to the box vectors |
1044 | > | scaled = invHmat * rs; |
1045 | > | |
1046 | > | // wrap the vector back into the unit box by subtracting integer box |
1047 | > | // numbers |
1048 | > | for (int j = 0; j < 3; j++) { |
1049 | > | scaled[j] -= roundMe(scaled[j]); |
1050 | > | scaled[j] += 0.5; |
1051 | > | } |
1052 | > | |
1053 | > | // find xyz-indices of cell that cutoffGroup is in. |
1054 | > | whichCell.x() = nCells_.x() * scaled.x(); |
1055 | > | whichCell.y() = nCells_.y() * scaled.y(); |
1056 | > | whichCell.z() = nCells_.z() * scaled.z(); |
1057 | > | |
1058 | > | // find single index of this cell: |
1059 | > | cellIndex = Vlinear(whichCell, nCells_); |
1060 | > | |
1061 | > | // add this cutoff group to the list of groups in this cell; |
1062 | > | cellListCol_[cellIndex].push_back(i); |
1063 | > | } |
1064 | > | #else |
1065 | > | for (int i = 0; i < nGroups_; i++) { |
1066 | > | rs = snap_->cgData.position[i]; |
1067 | > | |
1068 | > | // scaled positions relative to the box vectors |
1069 | > | scaled = invHmat * rs; |
1070 | > | |
1071 | > | // wrap the vector back into the unit box by subtracting integer box |
1072 | > | // numbers |
1073 | > | for (int j = 0; j < 3; j++) { |
1074 | > | scaled[j] -= roundMe(scaled[j]); |
1075 | > | scaled[j] += 0.5; |
1076 | > | } |
1077 | > | |
1078 | > | // find xyz-indices of cell that cutoffGroup is in. |
1079 | > | whichCell.x() = nCells_.x() * scaled.x(); |
1080 | > | whichCell.y() = nCells_.y() * scaled.y(); |
1081 | > | whichCell.z() = nCells_.z() * scaled.z(); |
1082 | > | |
1083 | > | // find single index of this cell: |
1084 | > | cellIndex = Vlinear(whichCell, nCells_); |
1085 | > | |
1086 | > | // add this cutoff group to the list of groups in this cell; |
1087 | > | cellList_[cellIndex].push_back(i); |
1088 | > | } |
1089 | > | #endif |
1090 | ||
1091 | + | for (int m1z = 0; m1z < nCells_.z(); m1z++) { |
1092 | + | for (int m1y = 0; m1y < nCells_.y(); m1y++) { |
1093 | + | for (int m1x = 0; m1x < nCells_.x(); m1x++) { |
1094 | + | Vector3i m1v(m1x, m1y, m1z); |
1095 | + | int m1 = Vlinear(m1v, nCells_); |
1096 | + | |
1097 | + | for (vector<Vector3i>::iterator os = cellOffsets_.begin(); |
1098 | + | os != cellOffsets_.end(); ++os) { |
1099 | + | |
1100 | + | Vector3i m2v = m1v + (*os); |
1101 | + | |
1102 | + | if (m2v.x() >= nCells_.x()) { |
1103 | + | m2v.x() = 0; |
1104 | + | } else if (m2v.x() < 0) { |
1105 | + | m2v.x() = nCells_.x() - 1; |
1106 | + | } |
1107 | + | |
1108 | + | if (m2v.y() >= nCells_.y()) { |
1109 | + | m2v.y() = 0; |
1110 | + | } else if (m2v.y() < 0) { |
1111 | + | m2v.y() = nCells_.y() - 1; |
1112 | + | } |
1113 | + | |
1114 | + | if (m2v.z() >= nCells_.z()) { |
1115 | + | m2v.z() = 0; |
1116 | + | } else if (m2v.z() < 0) { |
1117 | + | m2v.z() = nCells_.z() - 1; |
1118 | + | } |
1119 | + | |
1120 | + | int m2 = Vlinear (m2v, nCells_); |
1121 | + | |
1122 | #ifdef IS_MPI | |
1123 | < | for (vector<int>::iterator j1 = cellListRow_[m1].begin(); |
1124 | < | j1 != cellListRow_[m1].end(); ++j1) { |
1125 | < | for (vector<int>::iterator j2 = cellListCol_[m2].begin(); |
1126 | < | j2 != cellListCol_[m2].end(); ++j2) { |
1127 | < | |
1128 | < | // Always do this if we're in different cells or if |
1129 | < | // we're in the same cell and the global index of the |
1130 | < | // j2 cutoff group is less than the j1 cutoff group |
1131 | < | |
1132 | < | if (m2 != m1 || cgColToGlobal[(*j2)] < cgRowToGlobal[(*j1)]) { |
1133 | < | dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)]; |
1134 | < | snap_->wrapVector(dr); |
1135 | < | cuts = getGroupCutoffs( (*j1), (*j2) ); |
1136 | < | if (dr.lengthSquare() < cuts.third) { |
1137 | < | neighborList.push_back(make_pair((*j1), (*j2))); |
1123 | > | for (vector<int>::iterator j1 = cellListRow_[m1].begin(); |
1124 | > | j1 != cellListRow_[m1].end(); ++j1) { |
1125 | > | for (vector<int>::iterator j2 = cellListCol_[m2].begin(); |
1126 | > | j2 != cellListCol_[m2].end(); ++j2) { |
1127 | > | |
1128 | > | // Always do this if we're in different cells or if |
1129 | > | // we're in the same cell and the global index of the |
1130 | > | // j2 cutoff group is less than the j1 cutoff group |
1131 | > | |
1132 | > | if (m2 != m1 || cgColToGlobal[(*j2)] < cgRowToGlobal[(*j1)]) { |
1133 | > | dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)]; |
1134 | > | snap_->wrapVector(dr); |
1135 | > | cuts = getGroupCutoffs( (*j1), (*j2) ); |
1136 | > | if (dr.lengthSquare() < cuts.third) { |
1137 | > | neighborList.push_back(make_pair((*j1), (*j2))); |
1138 | > | } |
1139 | } | |
1140 | } | |
1141 | } | |
1074 | – | } |
1142 | #else | |
1143 | < | for (vector<int>::iterator j1 = cellList_[m1].begin(); |
1144 | < | j1 != cellList_[m1].end(); ++j1) { |
1145 | < | for (vector<int>::iterator j2 = cellList_[m2].begin(); |
1146 | < | j2 != cellList_[m2].end(); ++j2) { |
1147 | < | |
1148 | < | // Always do this if we're in different cells or if |
1149 | < | // we're in the same cell and the global index of the |
1150 | < | // j2 cutoff group is less than the j1 cutoff group |
1151 | < | |
1152 | < | if (m2 != m1 || (*j2) < (*j1)) { |
1153 | < | dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; |
1154 | < | snap_->wrapVector(dr); |
1155 | < | cuts = getGroupCutoffs( (*j1), (*j2) ); |
1156 | < | if (dr.lengthSquare() < cuts.third) { |
1157 | < | neighborList.push_back(make_pair((*j1), (*j2))); |
1143 | > | |
1144 | > | for (vector<int>::iterator j1 = cellList_[m1].begin(); |
1145 | > | j1 != cellList_[m1].end(); ++j1) { |
1146 | > | for (vector<int>::iterator j2 = cellList_[m2].begin(); |
1147 | > | j2 != cellList_[m2].end(); ++j2) { |
1148 | > | |
1149 | > | // Always do this if we're in different cells or if |
1150 | > | // we're in the same cell and the global index of the |
1151 | > | // j2 cutoff group is less than the j1 cutoff group |
1152 | > | |
1153 | > | if (m2 != m1 || (*j2) < (*j1)) { |
1154 | > | dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; |
1155 | > | snap_->wrapVector(dr); |
1156 | > | cuts = getGroupCutoffs( (*j1), (*j2) ); |
1157 | > | if (dr.lengthSquare() < cuts.third) { |
1158 | > | neighborList.push_back(make_pair((*j1), (*j2))); |
1159 | > | } |
1160 | } | |
1161 | } | |
1162 | } | |
1094 | – | } |
1163 | #endif | |
1164 | + | } |
1165 | } | |
1166 | } | |
1167 | } | |
1168 | + | } else { |
1169 | + | // branch to do all cutoff group pairs |
1170 | + | #ifdef IS_MPI |
1171 | + | for (int j1 = 0; j1 < nGroupsInRow_; j1++) { |
1172 | + | for (int j2 = 0; j2 < nGroupsInCol_; j2++) { |
1173 | + | dr = cgColData.position[j2] - cgRowData.position[j1]; |
1174 | + | snap_->wrapVector(dr); |
1175 | + | cuts = getGroupCutoffs( j1, j2 ); |
1176 | + | if (dr.lengthSquare() < cuts.third) { |
1177 | + | neighborList.push_back(make_pair(j1, j2)); |
1178 | + | } |
1179 | + | } |
1180 | + | } |
1181 | + | #else |
1182 | + | for (int j1 = 0; j1 < nGroups_ - 1; j1++) { |
1183 | + | for (int j2 = j1 + 1; j2 < nGroups_; j2++) { |
1184 | + | dr = snap_->cgData.position[j2] - snap_->cgData.position[j1]; |
1185 | + | snap_->wrapVector(dr); |
1186 | + | cuts = getGroupCutoffs( j1, j2 ); |
1187 | + | if (dr.lengthSquare() < cuts.third) { |
1188 | + | neighborList.push_back(make_pair(j1, j2)); |
1189 | + | } |
1190 | + | } |
1191 | + | } |
1192 | + | #endif |
1193 | } | |
1194 | < | |
1194 | > | |
1195 | // save the local cutoff group positions for the check that is | |
1196 | // done on each loop: | |
1197 | saved_CG_positions_.clear(); | |
1198 | for (int i = 0; i < nGroups_; i++) | |
1199 | saved_CG_positions_.push_back(snap_->cgData.position[i]); | |
1200 | < | |
1200 | > | |
1201 | return neighborList; | |
1202 | } | |
1203 | } //end namespace OpenMD |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |