| 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_); |
| 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 |
|
AtomCommIntRow->gather(AtomLocalToGlobal, AtomRowToGlobal); |
| 116 |
|
AtomCommIntColumn->gather(AtomLocalToGlobal, AtomColToGlobal); |
| 118 |
|
cgCommIntRow->gather(cgLocalToGlobal, cgRowToGlobal); |
| 119 |
|
cgCommIntColumn->gather(cgLocalToGlobal, cgColToGlobal); |
| 120 |
|
|
| 121 |
< |
AtomCommRealRow->gather(massFactorsLocal, massFactorsRow); |
| 122 |
< |
AtomCommRealColumn->gather(massFactorsLocal, massFactorsCol); |
| 121 |
> |
AtomCommRealRow->gather(massFactors, massFactorsRow); |
| 122 |
> |
AtomCommRealColumn->gather(massFactors, massFactorsCol); |
| 123 |
|
|
| 124 |
|
groupListRow_.clear(); |
| 125 |
|
groupListRow_.resize(nGroupsInRow_); |
| 143 |
|
} |
| 144 |
|
} |
| 145 |
|
|
| 146 |
< |
skipsForRowAtom.clear(); |
| 147 |
< |
skipsForRowAtom.resize(nAtomsInRow_); |
| 146 |
> |
excludesForAtom.clear(); |
| 147 |
> |
excludesForAtom.resize(nAtomsInRow_); |
| 148 |
> |
toposForAtom.clear(); |
| 149 |
> |
toposForAtom.resize(nAtomsInRow_); |
| 150 |
> |
topoDist.clear(); |
| 151 |
> |
topoDist.resize(nAtomsInRow_); |
| 152 |
|
for (int i = 0; i < nAtomsInRow_; i++) { |
| 153 |
|
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 |
– |
} |
| 154 |
|
|
| 155 |
– |
toposForRowAtom.clear(); |
| 156 |
– |
toposForRowAtom.resize(nAtomsInRow_); |
| 157 |
– |
for (int i = 0; i < nAtomsInRow_; i++) { |
| 158 |
– |
int iglob = AtomRowToGlobal[i]; |
| 159 |
– |
int nTopos = 0; |
| 155 |
|
for (int j = 0; j < nAtomsInCol_; j++) { |
| 156 |
< |
int jglob = AtomColToGlobal[j]; |
| 157 |
< |
if (oneTwo.hasPair(iglob, jglob)) { |
| 158 |
< |
toposForRowAtom[i].push_back(j); |
| 159 |
< |
topoDistRow[i][nTopos] = 1; |
| 160 |
< |
nTopos++; |
| 156 |
> |
int jglob = AtomColToGlobal[j]; |
| 157 |
> |
|
| 158 |
> |
if (excludes->hasPair(iglob, jglob)) |
| 159 |
> |
excludesForAtom[i].push_back(j); |
| 160 |
> |
|
| 161 |
> |
if (oneTwo->hasPair(iglob, jglob)) { |
| 162 |
> |
toposForAtom[i].push_back(j); |
| 163 |
> |
topoDist[i].push_back(1); |
| 164 |
> |
} else { |
| 165 |
> |
if (oneThree->hasPair(iglob, jglob)) { |
| 166 |
> |
toposForAtom[i].push_back(j); |
| 167 |
> |
topoDist[i].push_back(2); |
| 168 |
> |
} else { |
| 169 |
> |
if (oneFour->hasPair(iglob, jglob)) { |
| 170 |
> |
toposForAtom[i].push_back(j); |
| 171 |
> |
topoDist[i].push_back(3); |
| 172 |
> |
} |
| 173 |
> |
} |
| 174 |
|
} |
| 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 |
– |
} |
| 175 |
|
} |
| 176 |
|
} |
| 177 |
|
|
| 178 |
|
#endif |
| 179 |
+ |
|
| 180 |
|
groupList_.clear(); |
| 181 |
|
groupList_.resize(nGroups_); |
| 182 |
|
for (int i = 0; i < nGroups_; i++) { |
| 185 |
|
int aid = AtomLocalToGlobal[j]; |
| 186 |
|
if (globalGroupMembership[aid] == gid) { |
| 187 |
|
groupList_[i].push_back(j); |
| 189 |
– |
|
| 188 |
|
} |
| 189 |
|
} |
| 190 |
|
} |
| 191 |
|
|
| 192 |
< |
skipsForLocalAtom.clear(); |
| 193 |
< |
skipsForLocalAtom.resize(nLocal_); |
| 192 |
> |
excludesForAtom.clear(); |
| 193 |
> |
excludesForAtom.resize(nLocal_); |
| 194 |
> |
toposForAtom.clear(); |
| 195 |
> |
toposForAtom.resize(nLocal_); |
| 196 |
> |
topoDist.clear(); |
| 197 |
> |
topoDist.resize(nLocal_); |
| 198 |
|
|
| 199 |
|
for (int i = 0; i < nLocal_; i++) { |
| 200 |
|
int iglob = AtomLocalToGlobal[i]; |
| 201 |
+ |
|
| 202 |
|
for (int j = 0; j < nLocal_; j++) { |
| 203 |
< |
int jglob = AtomLocalToGlobal[j]; |
| 204 |
< |
if (excludes.hasPair(iglob, jglob)) |
| 205 |
< |
skipsForLocalAtom[i].push_back(j); |
| 206 |
< |
} |
| 207 |
< |
} |
| 208 |
< |
toposForLocalAtom.clear(); |
| 209 |
< |
toposForLocalAtom.resize(nLocal_); |
| 210 |
< |
for (int i = 0; i < nLocal_; i++) { |
| 211 |
< |
int iglob = AtomLocalToGlobal[i]; |
| 212 |
< |
int nTopos = 0; |
| 213 |
< |
for (int j = 0; j < nLocal_; j++) { |
| 214 |
< |
int jglob = AtomLocalToGlobal[j]; |
| 215 |
< |
if (oneTwo.hasPair(iglob, jglob)) { |
| 216 |
< |
toposForLocalAtom[i].push_back(j); |
| 217 |
< |
topoDistLocal[i][nTopos] = 1; |
| 218 |
< |
nTopos++; |
| 203 |
> |
int jglob = AtomLocalToGlobal[j]; |
| 204 |
> |
|
| 205 |
> |
if (excludes->hasPair(iglob, jglob)) |
| 206 |
> |
excludesForAtom[i].push_back(j); |
| 207 |
> |
|
| 208 |
> |
if (oneTwo->hasPair(iglob, jglob)) { |
| 209 |
> |
toposForAtom[i].push_back(j); |
| 210 |
> |
topoDist[i].push_back(1); |
| 211 |
> |
} else { |
| 212 |
> |
if (oneThree->hasPair(iglob, jglob)) { |
| 213 |
> |
toposForAtom[i].push_back(j); |
| 214 |
> |
topoDist[i].push_back(2); |
| 215 |
> |
} else { |
| 216 |
> |
if (oneFour->hasPair(iglob, jglob)) { |
| 217 |
> |
toposForAtom[i].push_back(j); |
| 218 |
> |
topoDist[i].push_back(3); |
| 219 |
> |
} |
| 220 |
> |
} |
| 221 |
|
} |
| 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 |
– |
} |
| 222 |
|
} |
| 223 |
< |
} |
| 223 |
> |
} |
| 224 |
> |
|
| 225 |
> |
createGtypeCutoffMap(); |
| 226 |
|
|
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
void ForceMatrixDecomposition::createGtypeCutoffMap() { |
| 230 |
< |
|
| 230 |
> |
|
| 231 |
|
RealType tol = 1e-6; |
| 232 |
|
RealType rc; |
| 233 |
|
int atid; |
| 234 |
|
set<AtomType*> atypes = info_->getSimulatedAtomTypes(); |
| 235 |
< |
vector<RealType> atypeCutoff; |
| 236 |
< |
atypeCutoff.resize( atypes.size() ); |
| 237 |
< |
|
| 238 |
< |
for (set<AtomType*>::iterator at = atypes.begin(); at != atypes.end(); ++at){ |
| 242 |
< |
rc = interactionMan_->getSuggestedCutoffRadius(*at); |
| 235 |
> |
map<int, RealType> atypeCutoff; |
| 236 |
> |
|
| 237 |
> |
for (set<AtomType*>::iterator at = atypes.begin(); |
| 238 |
> |
at != atypes.end(); ++at){ |
| 239 |
|
atid = (*at)->getIdent(); |
| 240 |
< |
atypeCutoff[atid] = rc; |
| 240 |
> |
if (userChoseCutoff_) |
| 241 |
> |
atypeCutoff[atid] = userCutoff_; |
| 242 |
> |
else |
| 243 |
> |
atypeCutoff[atid] = interactionMan_->getSuggestedCutoffRadius(*at); |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
vector<RealType> gTypeCutoffs; |
| 248 |
– |
|
| 247 |
|
// first we do a single loop over the cutoff groups to find the |
| 248 |
|
// largest cutoff for any atypes present in this group. |
| 249 |
|
#ifdef IS_MPI |
| 250 |
|
vector<RealType> groupCutoffRow(nGroupsInRow_, 0.0); |
| 251 |
+ |
groupRowToGtype.resize(nGroupsInRow_); |
| 252 |
|
for (int cg1 = 0; cg1 < nGroupsInRow_; cg1++) { |
| 253 |
|
vector<int> atomListRow = getAtomsInGroupRow(cg1); |
| 254 |
|
for (vector<int>::iterator ia = atomListRow.begin(); |
| 274 |
|
|
| 275 |
|
} |
| 276 |
|
vector<RealType> groupCutoffCol(nGroupsInCol_, 0.0); |
| 277 |
+ |
groupColToGtype.resize(nGroupsInCol_); |
| 278 |
|
for (int cg2 = 0; cg2 < nGroupsInCol_; cg2++) { |
| 279 |
|
vector<int> atomListCol = getAtomsInGroupColumn(cg2); |
| 280 |
|
for (vector<int>::iterator jb = atomListCol.begin(); |
| 298 |
|
} |
| 299 |
|
} |
| 300 |
|
#else |
| 301 |
+ |
|
| 302 |
|
vector<RealType> groupCutoff(nGroups_, 0.0); |
| 303 |
+ |
groupToGtype.resize(nGroups_); |
| 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); |
| 312 |
< |
atid = identsLocal[atom1]; |
| 312 |
> |
atid = idents[atom1]; |
| 313 |
|
if (atypeCutoff[atid] > groupCutoff[cg1]) { |
| 314 |
|
groupCutoff[cg1] = atypeCutoff[atid]; |
| 315 |
|
} |
| 331 |
|
|
| 332 |
|
// Now we find the maximum group cutoff value present in the simulation |
| 333 |
|
|
| 334 |
< |
vector<RealType>::iterator groupMaxLoc = max_element(gTypeCutoffs.begin(), gTypeCutoffs.end()); |
| 331 |
< |
RealType groupMax = *groupMaxLoc; |
| 334 |
> |
RealType groupMax = *max_element(gTypeCutoffs.begin(), gTypeCutoffs.end()); |
| 335 |
|
|
| 336 |
|
#ifdef IS_MPI |
| 337 |
|
MPI::COMM_WORLD.Allreduce(&groupMax, &groupMax, 1, MPI::REALTYPE, MPI::MAX); |
| 340 |
|
RealType tradRcut = groupMax; |
| 341 |
|
|
| 342 |
|
for (int i = 0; i < gTypeCutoffs.size(); i++) { |
| 343 |
< |
for (int j = 0; j < gTypeCutoffs.size(); j++) { |
| 341 |
< |
|
| 343 |
> |
for (int j = 0; j < gTypeCutoffs.size(); j++) { |
| 344 |
|
RealType thisRcut; |
| 345 |
|
switch(cutoffPolicy_) { |
| 346 |
|
case TRADITIONAL: |
| 347 |
|
thisRcut = tradRcut; |
| 348 |
+ |
break; |
| 349 |
|
case MIX: |
| 350 |
|
thisRcut = 0.5 * (gTypeCutoffs[i] + gTypeCutoffs[j]); |
| 351 |
+ |
break; |
| 352 |
|
case MAX: |
| 353 |
|
thisRcut = max(gTypeCutoffs[i], gTypeCutoffs[j]); |
| 354 |
+ |
break; |
| 355 |
|
default: |
| 356 |
|
sprintf(painCave.errMsg, |
| 357 |
|
"ForceMatrixDecomposition::createGtypeCutoffMap " |
| 358 |
|
"hit an unknown cutoff policy!\n"); |
| 359 |
|
painCave.severity = OPENMD_ERROR; |
| 360 |
|
painCave.isFatal = 1; |
| 361 |
< |
simError(); |
| 361 |
> |
simError(); |
| 362 |
> |
break; |
| 363 |
|
} |
| 364 |
|
|
| 365 |
|
pair<int,int> key = make_pair(i,j); |
| 377 |
|
if (abs(gTypeCutoffMap[key].first - userCutoff_) > 0.0001) { |
| 378 |
|
sprintf(painCave.errMsg, |
| 379 |
|
"ForceMatrixDecomposition::createGtypeCutoffMap " |
| 380 |
< |
"user-specified rCut does not match computed group Cutoff\n"); |
| 380 |
> |
"user-specified rCut (%lf) does not match computed group Cutoff\n", userCutoff_); |
| 381 |
|
painCave.severity = OPENMD_ERROR; |
| 382 |
|
painCave.isFatal = 1; |
| 383 |
|
simError(); |
| 389 |
|
|
| 390 |
|
|
| 391 |
|
groupCutoffs ForceMatrixDecomposition::getGroupCutoffs(int cg1, int cg2) { |
| 392 |
< |
int i, j; |
| 387 |
< |
|
| 392 |
> |
int i, j; |
| 393 |
|
#ifdef IS_MPI |
| 394 |
|
i = groupRowToGtype[cg1]; |
| 395 |
|
j = groupColToGtype[cg2]; |
| 396 |
|
#else |
| 397 |
|
i = groupToGtype[cg1]; |
| 398 |
|
j = groupToGtype[cg2]; |
| 399 |
< |
#endif |
| 395 |
< |
|
| 399 |
> |
#endif |
| 400 |
|
return gTypeCutoffMap[make_pair(i,j)]; |
| 401 |
|
} |
| 402 |
|
|
| 403 |
+ |
int ForceMatrixDecomposition::getTopologicalDistance(int atom1, int atom2) { |
| 404 |
+ |
for (int j = 0; j < toposForAtom[atom1].size(); j++) { |
| 405 |
+ |
if (toposForAtom[atom1][j] == atom2) |
| 406 |
+ |
return topoDist[atom1][j]; |
| 407 |
+ |
} |
| 408 |
+ |
return 0; |
| 409 |
+ |
} |
| 410 |
|
|
| 411 |
|
void ForceMatrixDecomposition::zeroWorkArrays() { |
| 412 |
+ |
pairwisePot = 0.0; |
| 413 |
+ |
embeddingPot = 0.0; |
| 414 |
|
|
| 402 |
– |
for (int j = 0; j < N_INTERACTION_FAMILIES; j++) { |
| 403 |
– |
longRangePot_[j] = 0.0; |
| 404 |
– |
} |
| 405 |
– |
|
| 415 |
|
#ifdef IS_MPI |
| 416 |
|
if (storageLayout_ & DataStorage::dslForce) { |
| 417 |
|
fill(atomRowData.force.begin(), atomRowData.force.end(), V3Zero); |
| 427 |
|
Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
| 428 |
|
|
| 429 |
|
fill(pot_col.begin(), pot_col.end(), |
| 430 |
< |
Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
| 422 |
< |
|
| 423 |
< |
pot_local = Vector<RealType, N_INTERACTION_FAMILIES>(0.0); |
| 430 |
> |
Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
| 431 |
|
|
| 432 |
|
if (storageLayout_ & DataStorage::dslParticlePot) { |
| 433 |
|
fill(atomRowData.particlePot.begin(), atomRowData.particlePot.end(), 0.0); |
| 451 |
|
atomColData.functionalDerivative.end(), 0.0); |
| 452 |
|
} |
| 453 |
|
|
| 454 |
+ |
if (storageLayout_ & DataStorage::dslSkippedCharge) { |
| 455 |
+ |
fill(atomRowData.skippedCharge.begin(), |
| 456 |
+ |
atomRowData.skippedCharge.end(), 0.0); |
| 457 |
+ |
fill(atomColData.skippedCharge.begin(), |
| 458 |
+ |
atomColData.skippedCharge.end(), 0.0); |
| 459 |
+ |
} |
| 460 |
+ |
|
| 461 |
|
#else |
| 462 |
|
|
| 463 |
|
if (storageLayout_ & DataStorage::dslParticlePot) { |
| 477 |
|
fill(snap_->atomData.functionalDerivative.begin(), |
| 478 |
|
snap_->atomData.functionalDerivative.end(), 0.0); |
| 479 |
|
} |
| 480 |
+ |
if (storageLayout_ & DataStorage::dslSkippedCharge) { |
| 481 |
+ |
fill(snap_->atomData.skippedCharge.begin(), |
| 482 |
+ |
snap_->atomData.skippedCharge.end(), 0.0); |
| 483 |
+ |
} |
| 484 |
|
#endif |
| 485 |
|
|
| 486 |
|
} |
| 588 |
|
|
| 589 |
|
if (storageLayout_ & DataStorage::dslTorque) { |
| 590 |
|
|
| 591 |
< |
int nt = snap_->atomData.force.size(); |
| 591 |
> |
int nt = snap_->atomData.torque.size(); |
| 592 |
|
vector<Vector3d> trq_tmp(nt, V3Zero); |
| 593 |
|
|
| 594 |
|
AtomCommVectorRow->scatter(atomRowData.torque, trq_tmp); |
| 595 |
< |
for (int i = 0; i < n; i++) { |
| 595 |
> |
for (int i = 0; i < nt; i++) { |
| 596 |
|
snap_->atomData.torque[i] += trq_tmp[i]; |
| 597 |
|
trq_tmp[i] = 0.0; |
| 598 |
|
} |
| 599 |
|
|
| 600 |
|
AtomCommVectorColumn->scatter(atomColData.torque, trq_tmp); |
| 601 |
< |
for (int i = 0; i < n; i++) |
| 601 |
> |
for (int i = 0; i < nt; i++) |
| 602 |
|
snap_->atomData.torque[i] += trq_tmp[i]; |
| 603 |
+ |
} |
| 604 |
+ |
|
| 605 |
+ |
if (storageLayout_ & DataStorage::dslSkippedCharge) { |
| 606 |
+ |
|
| 607 |
+ |
int ns = snap_->atomData.skippedCharge.size(); |
| 608 |
+ |
vector<RealType> skch_tmp(ns, 0.0); |
| 609 |
+ |
|
| 610 |
+ |
AtomCommRealRow->scatter(atomRowData.skippedCharge, skch_tmp); |
| 611 |
+ |
for (int i = 0; i < ns; i++) { |
| 612 |
+ |
snap_->atomData.skippedCharge[i] = skch_tmp[i]; |
| 613 |
+ |
skch_tmp[i] = 0.0; |
| 614 |
+ |
} |
| 615 |
+ |
|
| 616 |
+ |
AtomCommRealColumn->scatter(atomColData.skippedCharge, skch_tmp); |
| 617 |
+ |
for (int i = 0; i < ns; i++) |
| 618 |
+ |
snap_->atomData.skippedCharge[i] += skch_tmp[i]; |
| 619 |
|
} |
| 620 |
|
|
| 621 |
|
nLocal_ = snap_->getNumberOfAtoms(); |
| 628 |
|
AtomCommPotRow->scatter(pot_row, pot_temp); |
| 629 |
|
|
| 630 |
|
for (int ii = 0; ii < pot_temp.size(); ii++ ) |
| 631 |
< |
pot_local += pot_temp[ii]; |
| 631 |
> |
pairwisePot += pot_temp[ii]; |
| 632 |
|
|
| 633 |
|
fill(pot_temp.begin(), pot_temp.end(), |
| 634 |
|
Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
| 636 |
|
AtomCommPotColumn->scatter(pot_col, pot_temp); |
| 637 |
|
|
| 638 |
|
for (int ii = 0; ii < pot_temp.size(); ii++ ) |
| 639 |
< |
pot_local += pot_temp[ii]; |
| 606 |
< |
|
| 639 |
> |
pairwisePot += pot_temp[ii]; |
| 640 |
|
#endif |
| 641 |
+ |
|
| 642 |
|
} |
| 643 |
|
|
| 644 |
|
int ForceMatrixDecomposition::getNAtomsInRow() { |
| 713 |
|
#ifdef IS_MPI |
| 714 |
|
return massFactorsRow[atom1]; |
| 715 |
|
#else |
| 716 |
< |
return massFactorsLocal[atom1]; |
| 716 |
> |
return massFactors[atom1]; |
| 717 |
|
#endif |
| 718 |
|
} |
| 719 |
|
|
| 721 |
|
#ifdef IS_MPI |
| 722 |
|
return massFactorsCol[atom2]; |
| 723 |
|
#else |
| 724 |
< |
return massFactorsLocal[atom2]; |
| 724 |
> |
return massFactors[atom2]; |
| 725 |
|
#endif |
| 726 |
|
|
| 727 |
|
} |
| 739 |
|
return d; |
| 740 |
|
} |
| 741 |
|
|
| 742 |
< |
vector<int> ForceMatrixDecomposition::getSkipsForRowAtom(int atom1) { |
| 743 |
< |
#ifdef IS_MPI |
| 710 |
< |
return skipsForRowAtom[atom1]; |
| 711 |
< |
#else |
| 712 |
< |
return skipsForLocalAtom[atom1]; |
| 713 |
< |
#endif |
| 742 |
> |
vector<int> ForceMatrixDecomposition::getExcludesForAtom(int atom1) { |
| 743 |
> |
return excludesForAtom[atom1]; |
| 744 |
|
} |
| 745 |
|
|
| 746 |
|
/** |
| 747 |
< |
* 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 |
| 747 |
> |
* We need to exclude some overcounted interactions that result from |
| 748 |
|
* the parallel decomposition. |
| 749 |
|
*/ |
| 750 |
|
bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) { |
| 764 |
|
} else { |
| 765 |
|
if ((unique_id_1 + unique_id_2) % 2 == 1) return true; |
| 766 |
|
} |
| 767 |
+ |
#endif |
| 768 |
+ |
return false; |
| 769 |
+ |
} |
| 770 |
+ |
|
| 771 |
+ |
/** |
| 772 |
+ |
* We need to handle the interactions for atoms who are involved in |
| 773 |
+ |
* the same rigid body as well as some short range interactions |
| 774 |
+ |
* (bonds, bends, torsions) differently from other interactions. |
| 775 |
+ |
* We'll still visit the pairwise routines, but with a flag that |
| 776 |
+ |
* tells those routines to exclude the pair from direct long range |
| 777 |
+ |
* interactions. Some indirect interactions (notably reaction |
| 778 |
+ |
* field) must still be handled for these pairs. |
| 779 |
+ |
*/ |
| 780 |
+ |
bool ForceMatrixDecomposition::excludeAtomPair(int atom1, int atom2) { |
| 781 |
+ |
int unique_id_2; |
| 782 |
+ |
|
| 783 |
+ |
#ifdef IS_MPI |
| 784 |
+ |
// in MPI, we have to look up the unique IDs for the row atom. |
| 785 |
+ |
unique_id_2 = AtomColToGlobal[atom2]; |
| 786 |
|
#else |
| 787 |
|
// in the normal loop, the atom numbers are unique |
| 742 |
– |
unique_id_1 = atom1; |
| 788 |
|
unique_id_2 = atom2; |
| 789 |
|
#endif |
| 790 |
|
|
| 791 |
< |
#ifdef IS_MPI |
| 792 |
< |
for (vector<int>::iterator i = skipsForRowAtom[atom1].begin(); |
| 748 |
< |
i != skipsForRowAtom[atom1].end(); ++i) { |
| 791 |
> |
for (vector<int>::iterator i = excludesForAtom[atom1].begin(); |
| 792 |
> |
i != excludesForAtom[atom1].end(); ++i) { |
| 793 |
|
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 |
| 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]; |
| 794 |
|
} |
| 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 |
| 795 |
|
|
| 796 |
< |
// zero is default for unconnected (i.e. normal) pair interactions |
| 772 |
< |
return 0; |
| 796 |
> |
return false; |
| 797 |
|
} |
| 798 |
|
|
| 799 |
+ |
|
| 800 |
|
void ForceMatrixDecomposition::addForceToAtomRow(int atom1, Vector3d fg){ |
| 801 |
|
#ifdef IS_MPI |
| 802 |
|
atomRowData.force[atom1] += fg; |
| 814 |
|
} |
| 815 |
|
|
| 816 |
|
// filling interaction blocks with pointers |
| 817 |
< |
InteractionData ForceMatrixDecomposition::fillInteractionData(int atom1, int atom2) { |
| 818 |
< |
InteractionData idat; |
| 817 |
> |
void ForceMatrixDecomposition::fillInteractionData(InteractionData &idat, |
| 818 |
> |
int atom1, int atom2) { |
| 819 |
|
|
| 820 |
+ |
idat.excluded = excludeAtomPair(atom1, atom2); |
| 821 |
+ |
|
| 822 |
|
#ifdef IS_MPI |
| 823 |
|
|
| 824 |
|
idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), |
| 825 |
|
ff_->getAtomType(identsCol[atom2]) ); |
| 799 |
– |
|
| 826 |
|
|
| 827 |
|
if (storageLayout_ & DataStorage::dslAmat) { |
| 828 |
|
idat.A1 = &(atomRowData.aMat[atom1]); |
| 859 |
|
idat.particlePot2 = &(atomColData.particlePot[atom2]); |
| 860 |
|
} |
| 861 |
|
|
| 862 |
+ |
if (storageLayout_ & DataStorage::dslSkippedCharge) { |
| 863 |
+ |
idat.skippedCharge1 = &(atomRowData.skippedCharge[atom1]); |
| 864 |
+ |
idat.skippedCharge2 = &(atomColData.skippedCharge[atom2]); |
| 865 |
+ |
} |
| 866 |
+ |
|
| 867 |
|
#else |
| 868 |
|
|
| 869 |
< |
idat.atypes = make_pair( ff_->getAtomType(identsLocal[atom1]), |
| 870 |
< |
ff_->getAtomType(identsLocal[atom2]) ); |
| 869 |
> |
idat.atypes = make_pair( ff_->getAtomType(idents[atom1]), |
| 870 |
> |
ff_->getAtomType(idents[atom2]) ); |
| 871 |
|
|
| 872 |
|
if (storageLayout_ & DataStorage::dslAmat) { |
| 873 |
|
idat.A1 = &(snap_->atomData.aMat[atom1]); |
| 884 |
|
idat.t2 = &(snap_->atomData.torque[atom2]); |
| 885 |
|
} |
| 886 |
|
|
| 887 |
< |
if (storageLayout_ & DataStorage::dslDensity) { |
| 887 |
> |
if (storageLayout_ & DataStorage::dslDensity) { |
| 888 |
|
idat.rho1 = &(snap_->atomData.density[atom1]); |
| 889 |
|
idat.rho2 = &(snap_->atomData.density[atom2]); |
| 890 |
|
} |
| 904 |
|
idat.particlePot2 = &(snap_->atomData.particlePot[atom2]); |
| 905 |
|
} |
| 906 |
|
|
| 907 |
+ |
if (storageLayout_ & DataStorage::dslSkippedCharge) { |
| 908 |
+ |
idat.skippedCharge1 = &(snap_->atomData.skippedCharge[atom1]); |
| 909 |
+ |
idat.skippedCharge2 = &(snap_->atomData.skippedCharge[atom2]); |
| 910 |
+ |
} |
| 911 |
|
#endif |
| 877 |
– |
return idat; |
| 912 |
|
} |
| 913 |
|
|
| 914 |
|
|
| 915 |
< |
void ForceMatrixDecomposition::unpackInteractionData(InteractionData idat, int atom1, int atom2) { |
| 915 |
> |
void ForceMatrixDecomposition::unpackInteractionData(InteractionData &idat, int atom1, int atom2) { |
| 916 |
|
#ifdef IS_MPI |
| 917 |
|
pot_row[atom1] += 0.5 * *(idat.pot); |
| 918 |
|
pot_col[atom2] += 0.5 * *(idat.pot); |
| 920 |
|
atomRowData.force[atom1] += *(idat.f1); |
| 921 |
|
atomColData.force[atom2] -= *(idat.f1); |
| 922 |
|
#else |
| 923 |
< |
longRangePot_ += *(idat.pot); |
| 924 |
< |
|
| 923 |
> |
pairwisePot += *(idat.pot); |
| 924 |
> |
|
| 925 |
|
snap_->atomData.force[atom1] += *(idat.f1); |
| 926 |
|
snap_->atomData.force[atom2] -= *(idat.f1); |
| 927 |
|
#endif |
| 928 |
< |
|
| 895 |
< |
} |
| 896 |
< |
|
| 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 |
| 928 |
> |
|
| 929 |
|
} |
| 930 |
|
|
| 931 |
|
/* |
| 938 |
|
|
| 939 |
|
vector<pair<int, int> > neighborList; |
| 940 |
|
groupCutoffs cuts; |
| 941 |
+ |
bool doAllPairs = false; |
| 942 |
+ |
|
| 943 |
|
#ifdef IS_MPI |
| 944 |
|
cellListRow_.clear(); |
| 945 |
|
cellListCol_.clear(); |
| 959 |
|
nCells_.y() = (int) ( Hy.length() )/ rList_; |
| 960 |
|
nCells_.z() = (int) ( Hz.length() )/ rList_; |
| 961 |
|
|
| 962 |
+ |
// handle small boxes where the cell offsets can end up repeating cells |
| 963 |
+ |
|
| 964 |
+ |
if (nCells_.x() < 3) doAllPairs = true; |
| 965 |
+ |
if (nCells_.y() < 3) doAllPairs = true; |
| 966 |
+ |
if (nCells_.z() < 3) doAllPairs = true; |
| 967 |
+ |
|
| 968 |
|
Mat3x3d invHmat = snap_->getInvHmat(); |
| 969 |
|
Vector3d rs, scaled, dr; |
| 970 |
|
Vector3i whichCell; |
| 971 |
|
int cellIndex; |
| 972 |
+ |
int nCtot = nCells_.x() * nCells_.y() * nCells_.z(); |
| 973 |
|
|
| 974 |
|
#ifdef IS_MPI |
| 975 |
< |
for (int i = 0; i < nGroupsInRow_; i++) { |
| 976 |
< |
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 |
< |
} |
| 975 |
> |
cellListRow_.resize(nCtot); |
| 976 |
> |
cellListCol_.resize(nCtot); |
| 977 |
|
#else |
| 978 |
< |
for (int i = 0; i < nGroups_; i++) { |
| 979 |
< |
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]); |
| 978 |
> |
cellList_.resize(nCtot); |
| 979 |
> |
#endif |
| 980 |
|
|
| 981 |
< |
// find xyz-indices of cell that cutoffGroup is in. |
| 982 |
< |
whichCell.x() = nCells_.x() * scaled.x(); |
| 1014 |
< |
whichCell.y() = nCells_.y() * scaled.y(); |
| 1015 |
< |
whichCell.z() = nCells_.z() * scaled.z(); |
| 981 |
> |
if (!doAllPairs) { |
| 982 |
> |
#ifdef IS_MPI |
| 983 |
|
|
| 984 |
< |
// find single index of this cell: |
| 985 |
< |
cellIndex = Vlinear(whichCell, nCells_); |
| 986 |
< |
// add this cutoff group to the list of groups in this cell; |
| 987 |
< |
cellList_[cellIndex].push_back(i); |
| 988 |
< |
} |
| 984 |
> |
for (int i = 0; i < nGroupsInRow_; i++) { |
| 985 |
> |
rs = cgRowData.position[i]; |
| 986 |
> |
|
| 987 |
> |
// scaled positions relative to the box vectors |
| 988 |
> |
scaled = invHmat * rs; |
| 989 |
> |
|
| 990 |
> |
// wrap the vector back into the unit box by subtracting integer box |
| 991 |
> |
// numbers |
| 992 |
> |
for (int j = 0; j < 3; j++) { |
| 993 |
> |
scaled[j] -= roundMe(scaled[j]); |
| 994 |
> |
scaled[j] += 0.5; |
| 995 |
> |
} |
| 996 |
> |
|
| 997 |
> |
// find xyz-indices of cell that cutoffGroup is in. |
| 998 |
> |
whichCell.x() = nCells_.x() * scaled.x(); |
| 999 |
> |
whichCell.y() = nCells_.y() * scaled.y(); |
| 1000 |
> |
whichCell.z() = nCells_.z() * scaled.z(); |
| 1001 |
> |
|
| 1002 |
> |
// find single index of this cell: |
| 1003 |
> |
cellIndex = Vlinear(whichCell, nCells_); |
| 1004 |
> |
|
| 1005 |
> |
// add this cutoff group to the list of groups in this cell; |
| 1006 |
> |
cellListRow_[cellIndex].push_back(i); |
| 1007 |
> |
} |
| 1008 |
> |
|
| 1009 |
> |
for (int i = 0; i < nGroupsInCol_; i++) { |
| 1010 |
> |
rs = cgColData.position[i]; |
| 1011 |
> |
|
| 1012 |
> |
// scaled positions relative to the box vectors |
| 1013 |
> |
scaled = invHmat * rs; |
| 1014 |
> |
|
| 1015 |
> |
// wrap the vector back into the unit box by subtracting integer box |
| 1016 |
> |
// numbers |
| 1017 |
> |
for (int j = 0; j < 3; j++) { |
| 1018 |
> |
scaled[j] -= roundMe(scaled[j]); |
| 1019 |
> |
scaled[j] += 0.5; |
| 1020 |
> |
} |
| 1021 |
> |
|
| 1022 |
> |
// find xyz-indices of cell that cutoffGroup is in. |
| 1023 |
> |
whichCell.x() = nCells_.x() * scaled.x(); |
| 1024 |
> |
whichCell.y() = nCells_.y() * scaled.y(); |
| 1025 |
> |
whichCell.z() = nCells_.z() * scaled.z(); |
| 1026 |
> |
|
| 1027 |
> |
// find single index of this cell: |
| 1028 |
> |
cellIndex = Vlinear(whichCell, nCells_); |
| 1029 |
> |
|
| 1030 |
> |
// add this cutoff group to the list of groups in this cell; |
| 1031 |
> |
cellListCol_[cellIndex].push_back(i); |
| 1032 |
> |
} |
| 1033 |
> |
#else |
| 1034 |
> |
for (int i = 0; i < nGroups_; i++) { |
| 1035 |
> |
rs = snap_->cgData.position[i]; |
| 1036 |
> |
|
| 1037 |
> |
// scaled positions relative to the box vectors |
| 1038 |
> |
scaled = invHmat * rs; |
| 1039 |
> |
|
| 1040 |
> |
// wrap the vector back into the unit box by subtracting integer box |
| 1041 |
> |
// numbers |
| 1042 |
> |
for (int j = 0; j < 3; j++) { |
| 1043 |
> |
scaled[j] -= roundMe(scaled[j]); |
| 1044 |
> |
scaled[j] += 0.5; |
| 1045 |
> |
} |
| 1046 |
> |
|
| 1047 |
> |
// find xyz-indices of cell that cutoffGroup is in. |
| 1048 |
> |
whichCell.x() = nCells_.x() * scaled.x(); |
| 1049 |
> |
whichCell.y() = nCells_.y() * scaled.y(); |
| 1050 |
> |
whichCell.z() = nCells_.z() * scaled.z(); |
| 1051 |
> |
|
| 1052 |
> |
// find single index of this cell: |
| 1053 |
> |
cellIndex = Vlinear(whichCell, nCells_); |
| 1054 |
> |
|
| 1055 |
> |
// add this cutoff group to the list of groups in this cell; |
| 1056 |
> |
cellList_[cellIndex].push_back(i); |
| 1057 |
> |
} |
| 1058 |
|
#endif |
| 1059 |
|
|
| 1060 |
< |
for (int m1z = 0; m1z < nCells_.z(); m1z++) { |
| 1061 |
< |
for (int m1y = 0; m1y < nCells_.y(); m1y++) { |
| 1062 |
< |
for (int m1x = 0; m1x < nCells_.x(); m1x++) { |
| 1063 |
< |
Vector3i m1v(m1x, m1y, m1z); |
| 1064 |
< |
int m1 = Vlinear(m1v, nCells_); |
| 1029 |
< |
|
| 1030 |
< |
for (vector<Vector3i>::iterator os = cellOffsets_.begin(); |
| 1031 |
< |
os != cellOffsets_.end(); ++os) { |
| 1060 |
> |
for (int m1z = 0; m1z < nCells_.z(); m1z++) { |
| 1061 |
> |
for (int m1y = 0; m1y < nCells_.y(); m1y++) { |
| 1062 |
> |
for (int m1x = 0; m1x < nCells_.x(); m1x++) { |
| 1063 |
> |
Vector3i m1v(m1x, m1y, m1z); |
| 1064 |
> |
int m1 = Vlinear(m1v, nCells_); |
| 1065 |
|
|
| 1066 |
< |
Vector3i m2v = m1v + (*os); |
| 1067 |
< |
|
| 1068 |
< |
if (m2v.x() >= nCells_.x()) { |
| 1069 |
< |
m2v.x() = 0; |
| 1070 |
< |
} else if (m2v.x() < 0) { |
| 1071 |
< |
m2v.x() = nCells_.x() - 1; |
| 1072 |
< |
} |
| 1073 |
< |
|
| 1074 |
< |
if (m2v.y() >= nCells_.y()) { |
| 1075 |
< |
m2v.y() = 0; |
| 1076 |
< |
} else if (m2v.y() < 0) { |
| 1077 |
< |
m2v.y() = nCells_.y() - 1; |
| 1078 |
< |
} |
| 1079 |
< |
|
| 1080 |
< |
if (m2v.z() >= nCells_.z()) { |
| 1081 |
< |
m2v.z() = 0; |
| 1082 |
< |
} else if (m2v.z() < 0) { |
| 1083 |
< |
m2v.z() = nCells_.z() - 1; |
| 1084 |
< |
} |
| 1085 |
< |
|
| 1086 |
< |
int m2 = Vlinear (m2v, nCells_); |
| 1087 |
< |
|
| 1066 |
> |
for (vector<Vector3i>::iterator os = cellOffsets_.begin(); |
| 1067 |
> |
os != cellOffsets_.end(); ++os) { |
| 1068 |
> |
|
| 1069 |
> |
Vector3i m2v = m1v + (*os); |
| 1070 |
> |
|
| 1071 |
> |
if (m2v.x() >= nCells_.x()) { |
| 1072 |
> |
m2v.x() = 0; |
| 1073 |
> |
} else if (m2v.x() < 0) { |
| 1074 |
> |
m2v.x() = nCells_.x() - 1; |
| 1075 |
> |
} |
| 1076 |
> |
|
| 1077 |
> |
if (m2v.y() >= nCells_.y()) { |
| 1078 |
> |
m2v.y() = 0; |
| 1079 |
> |
} else if (m2v.y() < 0) { |
| 1080 |
> |
m2v.y() = nCells_.y() - 1; |
| 1081 |
> |
} |
| 1082 |
> |
|
| 1083 |
> |
if (m2v.z() >= nCells_.z()) { |
| 1084 |
> |
m2v.z() = 0; |
| 1085 |
> |
} else if (m2v.z() < 0) { |
| 1086 |
> |
m2v.z() = nCells_.z() - 1; |
| 1087 |
> |
} |
| 1088 |
> |
|
| 1089 |
> |
int m2 = Vlinear (m2v, nCells_); |
| 1090 |
> |
|
| 1091 |
|
#ifdef IS_MPI |
| 1092 |
< |
for (vector<int>::iterator j1 = cellListRow_[m1].begin(); |
| 1093 |
< |
j1 != cellListRow_[m1].end(); ++j1) { |
| 1094 |
< |
for (vector<int>::iterator j2 = cellListCol_[m2].begin(); |
| 1095 |
< |
j2 != cellListCol_[m2].end(); ++j2) { |
| 1096 |
< |
|
| 1097 |
< |
// Always do this if we're in different cells or if |
| 1098 |
< |
// we're in the same cell and the global index of the |
| 1099 |
< |
// j2 cutoff group is less than the j1 cutoff group |
| 1100 |
< |
|
| 1101 |
< |
if (m2 != m1 || cgColToGlobal[(*j2)] < cgRowToGlobal[(*j1)]) { |
| 1102 |
< |
dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)]; |
| 1103 |
< |
snap_->wrapVector(dr); |
| 1104 |
< |
cuts = getGroupCutoffs( (*j1), (*j2) ); |
| 1105 |
< |
if (dr.lengthSquare() < cuts.third) { |
| 1106 |
< |
neighborList.push_back(make_pair((*j1), (*j2))); |
| 1092 |
> |
for (vector<int>::iterator j1 = cellListRow_[m1].begin(); |
| 1093 |
> |
j1 != cellListRow_[m1].end(); ++j1) { |
| 1094 |
> |
for (vector<int>::iterator j2 = cellListCol_[m2].begin(); |
| 1095 |
> |
j2 != cellListCol_[m2].end(); ++j2) { |
| 1096 |
> |
|
| 1097 |
> |
// Always do this if we're in different cells or if |
| 1098 |
> |
// we're in the same cell and the global index of the |
| 1099 |
> |
// j2 cutoff group is less than the j1 cutoff group |
| 1100 |
> |
|
| 1101 |
> |
if (m2 != m1 || cgColToGlobal[(*j2)] < cgRowToGlobal[(*j1)]) { |
| 1102 |
> |
dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)]; |
| 1103 |
> |
snap_->wrapVector(dr); |
| 1104 |
> |
cuts = getGroupCutoffs( (*j1), (*j2) ); |
| 1105 |
> |
if (dr.lengthSquare() < cuts.third) { |
| 1106 |
> |
neighborList.push_back(make_pair((*j1), (*j2))); |
| 1107 |
> |
} |
| 1108 |
|
} |
| 1109 |
|
} |
| 1110 |
|
} |
| 1074 |
– |
} |
| 1111 |
|
#else |
| 1112 |
< |
for (vector<int>::iterator j1 = cellList_[m1].begin(); |
| 1113 |
< |
j1 != cellList_[m1].end(); ++j1) { |
| 1114 |
< |
for (vector<int>::iterator j2 = cellList_[m2].begin(); |
| 1115 |
< |
j2 != cellList_[m2].end(); ++j2) { |
| 1116 |
< |
|
| 1117 |
< |
// Always do this if we're in different cells or if |
| 1118 |
< |
// we're in the same cell and the global index of the |
| 1119 |
< |
// j2 cutoff group is less than the j1 cutoff group |
| 1120 |
< |
|
| 1121 |
< |
if (m2 != m1 || (*j2) < (*j1)) { |
| 1122 |
< |
dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; |
| 1123 |
< |
snap_->wrapVector(dr); |
| 1124 |
< |
cuts = getGroupCutoffs( (*j1), (*j2) ); |
| 1125 |
< |
if (dr.lengthSquare() < cuts.third) { |
| 1126 |
< |
neighborList.push_back(make_pair((*j1), (*j2))); |
| 1112 |
> |
|
| 1113 |
> |
for (vector<int>::iterator j1 = cellList_[m1].begin(); |
| 1114 |
> |
j1 != cellList_[m1].end(); ++j1) { |
| 1115 |
> |
for (vector<int>::iterator j2 = cellList_[m2].begin(); |
| 1116 |
> |
j2 != cellList_[m2].end(); ++j2) { |
| 1117 |
> |
|
| 1118 |
> |
// Always do this if we're in different cells or if |
| 1119 |
> |
// we're in the same cell and the global index of the |
| 1120 |
> |
// j2 cutoff group is less than the j1 cutoff group |
| 1121 |
> |
|
| 1122 |
> |
if (m2 != m1 || (*j2) < (*j1)) { |
| 1123 |
> |
dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; |
| 1124 |
> |
snap_->wrapVector(dr); |
| 1125 |
> |
cuts = getGroupCutoffs( (*j1), (*j2) ); |
| 1126 |
> |
if (dr.lengthSquare() < cuts.third) { |
| 1127 |
> |
neighborList.push_back(make_pair((*j1), (*j2))); |
| 1128 |
> |
} |
| 1129 |
|
} |
| 1130 |
|
} |
| 1131 |
|
} |
| 1094 |
– |
} |
| 1132 |
|
#endif |
| 1133 |
+ |
} |
| 1134 |
|
} |
| 1135 |
|
} |
| 1136 |
|
} |
| 1137 |
+ |
} else { |
| 1138 |
+ |
// branch to do all cutoff group pairs |
| 1139 |
+ |
#ifdef IS_MPI |
| 1140 |
+ |
for (int j1 = 0; j1 < nGroupsInRow_; j1++) { |
| 1141 |
+ |
for (int j2 = 0; j2 < nGroupsInCol_; j2++) { |
| 1142 |
+ |
dr = cgColData.position[j2] - cgRowData.position[j1]; |
| 1143 |
+ |
snap_->wrapVector(dr); |
| 1144 |
+ |
cuts = getGroupCutoffs( j1, j2 ); |
| 1145 |
+ |
if (dr.lengthSquare() < cuts.third) { |
| 1146 |
+ |
neighborList.push_back(make_pair(j1, j2)); |
| 1147 |
+ |
} |
| 1148 |
+ |
} |
| 1149 |
+ |
} |
| 1150 |
+ |
#else |
| 1151 |
+ |
for (int j1 = 0; j1 < nGroups_ - 1; j1++) { |
| 1152 |
+ |
for (int j2 = j1 + 1; j2 < nGroups_; j2++) { |
| 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)); |
| 1158 |
+ |
} |
| 1159 |
+ |
} |
| 1160 |
+ |
} |
| 1161 |
+ |
#endif |
| 1162 |
|
} |
| 1163 |
< |
|
| 1163 |
> |
|
| 1164 |
|
// save the local cutoff group positions for the check that is |
| 1165 |
|
// done on each loop: |
| 1166 |
|
saved_CG_positions_.clear(); |
| 1167 |
|
for (int i = 0; i < nGroups_; i++) |
| 1168 |
|
saved_CG_positions_.push_back(snap_->cgData.position[i]); |
| 1169 |
< |
|
| 1169 |
> |
|
| 1170 |
|
return neighborList; |
| 1171 |
|
} |
| 1172 |
|
} //end namespace OpenMD |