| 63 |
|
|
| 64 |
|
ForceManager::ForceManager(SimInfo * info) : info_(info) { |
| 65 |
|
|
| 66 |
– |
#ifdef IS_MPI |
| 66 |
|
fDecomp_ = new ForceMatrixDecomposition(info_); |
| 68 |
– |
#else |
| 69 |
– |
// fDecomp_ = new ForceSerialDecomposition(info); |
| 70 |
– |
#endif |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
void ForceManager::calcForces() { |
| 70 |
|
|
| 71 |
< |
if (!info_->isFortranInitialized()) { |
| 71 |
> |
if (!info_->isTopologyDone()) { |
| 72 |
|
info_->update(); |
| 73 |
|
interactionMan_->setSimInfo(info_); |
| 74 |
|
interactionMan_->initialize(); |
| 75 |
|
swfun_ = interactionMan_->getSwitchingFunction(); |
| 76 |
+ |
info_->prepareTopology(); |
| 77 |
|
fDecomp_->distributeInitialData(); |
| 81 |
– |
info_->setupFortran(); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
preCalculation(); |
| 261 |
|
rc = pos; |
| 262 |
|
} |
| 263 |
|
|
| 268 |
– |
//initialize data before passing to fortran |
| 269 |
– |
RealType longRangePotential[N_INTERACTION_FAMILIES]; |
| 270 |
– |
RealType lrPot = 0.0; |
| 271 |
– |
int isError = 0; |
| 272 |
– |
|
| 273 |
– |
// dangerous to iterate over enums, but we'll live on the edge: |
| 274 |
– |
for (int i = NO_FAMILY; i != N_INTERACTION_FAMILIES; ++i){ |
| 275 |
– |
longRangePotential[i]=0.0; //Initialize array |
| 276 |
– |
} |
| 277 |
– |
|
| 264 |
|
// new stuff starts here: |
| 265 |
< |
|
| 265 |
> |
fDecomp_->zeroWorkArrays(); |
| 266 |
|
fDecomp_->distributeData(); |
| 267 |
|
|
| 268 |
|
int cg1, cg2, atom1, atom2; |
| 278 |
|
InteractionData idat; |
| 279 |
|
SelfData sdat; |
| 280 |
|
RealType mf; |
| 281 |
+ |
potVec pot(0.0); |
| 282 |
+ |
potVec longRangePotential(0.0); |
| 283 |
+ |
RealType lrPot; |
| 284 |
|
|
| 285 |
|
int loopStart, loopEnd; |
| 286 |
|
|
| 312 |
|
rCutSq = groupCutoffMap[gtypes].first; |
| 313 |
|
|
| 314 |
|
if (rgrpsq < rCutSq) { |
| 315 |
< |
idat.rcut = groupCutoffMap[gtypes].second; |
| 315 |
> |
*(idat.rcut) = groupCutoffMap[gtypes].second; |
| 316 |
|
if (iLoop == PAIR_LOOP) { |
| 317 |
|
vij *= 0.0; |
| 318 |
|
fij = V3Zero; |
| 319 |
|
} |
| 320 |
|
|
| 321 |
< |
in_switching_region = swfun_->getSwitch(rgrpsq, idat.sw, dswdr, rgrp); |
| 321 |
> |
in_switching_region = swfun_->getSwitch(rgrpsq, *(idat.sw), dswdr, |
| 322 |
> |
rgrp); |
| 323 |
|
atomListRow = fDecomp_->getAtomsInGroupRow(cg1); |
| 324 |
|
atomListColumn = fDecomp_->getAtomsInGroupColumn(cg2); |
| 325 |
|
|
| 333 |
|
|
| 334 |
|
if (!fDecomp_->skipAtomPair(atom1, atom2)) { |
| 335 |
|
|
| 336 |
+ |
pot *= 0.0; |
| 337 |
+ |
|
| 338 |
|
idat = fDecomp_->fillInteractionData(atom1, atom2); |
| 339 |
+ |
*(idat.pot) = pot; |
| 340 |
|
|
| 341 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 342 |
< |
idat.d = d_grp; |
| 343 |
< |
idat.r2 = rgrpsq; |
| 342 |
> |
*(idat.d) = d_grp; |
| 343 |
> |
*(idat.r2) = rgrpsq; |
| 344 |
|
} else { |
| 345 |
< |
idat.d = fDecomp_->getInteratomicVector(atom1, atom2); |
| 346 |
< |
curSnapshot->wrapVector(idat.d); |
| 347 |
< |
idat.r2 = idat.d.lengthSquare(); |
| 345 |
> |
*(idat.d) = fDecomp_->getInteratomicVector(atom1, atom2); |
| 346 |
> |
curSnapshot->wrapVector( *(idat.d) ); |
| 347 |
> |
*(idat.r2) = idat.d->lengthSquare(); |
| 348 |
|
} |
| 349 |
|
|
| 350 |
< |
idat.rij = sqrt(idat.r2); |
| 350 |
> |
*(idat.rij) = sqrt( *(idat.r2) ); |
| 351 |
|
|
| 352 |
|
if (iLoop == PREPAIR_LOOP) { |
| 353 |
|
interactionMan_->doPrePair(idat); |
| 354 |
|
} else { |
| 355 |
|
interactionMan_->doPair(idat); |
| 356 |
< |
vij += idat.vpair; |
| 357 |
< |
fij += idat.f1; |
| 358 |
< |
tau -= outProduct(idat.d, idat.f1); |
| 356 |
> |
fDecomp_->unpackInteractionData(idat, atom1, atom2); |
| 357 |
> |
vij += *(idat.vpair); |
| 358 |
> |
fij += *(idat.f1); |
| 359 |
> |
tau -= outProduct( *(idat.d), *(idat.f1)); |
| 360 |
|
} |
| 361 |
|
} |
| 362 |
|
} |
| 370 |
|
fij += fg; |
| 371 |
|
|
| 372 |
|
if (atomListRow.size() == 1 && atomListColumn.size() == 1) { |
| 373 |
< |
tau -= outProduct(idat.d, fg); |
| 373 |
> |
tau -= outProduct( *(idat.d), fg); |
| 374 |
|
} |
| 375 |
|
|
| 376 |
|
for (vector<int>::iterator ia = atomListRow.begin(); |
| 377 |
|
ia != atomListRow.end(); ++ia) { |
| 378 |
|
atom1 = (*ia); |
| 379 |
< |
mf = fDecomp_->getMfactRow(atom1); |
| 379 |
> |
mf = fDecomp_->getMassFactorRow(atom1); |
| 380 |
|
// fg is the force on atom ia due to cutoff group's |
| 381 |
|
// presence in switching region |
| 382 |
|
fg = swderiv * d_grp * mf; |
| 394 |
|
for (vector<int>::iterator jb = atomListColumn.begin(); |
| 395 |
|
jb != atomListColumn.end(); ++jb) { |
| 396 |
|
atom2 = (*jb); |
| 397 |
< |
mf = fDecomp_->getMfactColumn(atom2); |
| 397 |
> |
mf = fDecomp_->getMassFactorColumn(atom2); |
| 398 |
|
// fg is the force on atom jb due to cutoff group's |
| 399 |
|
// presence in switching region |
| 400 |
|
fg = -swderiv * d_grp * mf; |
| 420 |
|
if (iLoop == PREPAIR_LOOP) { |
| 421 |
|
if (info_->requiresPrepair()) { |
| 422 |
|
fDecomp_->collectIntermediateData(); |
| 423 |
< |
atomListLocal = fDecomp_->getAtomList(); |
| 424 |
< |
for (vector<int>::iterator ia = atomListLocal.begin(); |
| 431 |
< |
ia != atomListLocal.end(); ++ia) { |
| 432 |
< |
atom1 = (*ia); |
| 423 |
> |
|
| 424 |
> |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 425 |
|
sdat = fDecomp_->fillSelfData(atom1); |
| 426 |
|
interactionMan_->doPreForce(sdat); |
| 427 |
|
} |
| 428 |
+ |
|
| 429 |
|
fDecomp_->distributeIntermediateData(); |
| 430 |
|
} |
| 431 |
|
} |
| 434 |
|
|
| 435 |
|
fDecomp_->collectData(); |
| 436 |
|
|
| 437 |
< |
if (info_->requiresSkipCorrection() || info_->requiresSelfCorrection()) { |
| 438 |
< |
atomListLocal = fDecomp_->getAtomList(); |
| 439 |
< |
for (vector<int>::iterator ia = atomListLocal.begin(); |
| 447 |
< |
ia != atomListLocal.end(); ++ia) { |
| 448 |
< |
atom1 = (*ia); |
| 437 |
> |
if ( info_->requiresSkipCorrection() ) { |
| 438 |
> |
|
| 439 |
> |
for (int atom1 = 0; atom1 < fDecomp_->getNAtomsInRow(); atom1++) { |
| 440 |
|
|
| 441 |
< |
if (info_->requiresSkipCorrection()) { |
| 442 |
< |
vector<int> skipList = fDecomp_->getSkipsForAtom(atom1); |
| 443 |
< |
for (vector<int>::iterator jb = skipList.begin(); |
| 444 |
< |
jb != skipList.end(); ++jb) { |
| 445 |
< |
atom2 = (*jb); |
| 446 |
< |
idat = fDecomp_->fillSkipData(atom1, atom2); |
| 447 |
< |
interactionMan_->doSkipCorrection(idat); |
| 448 |
< |
} |
| 441 |
> |
vector<int> skipList = fDecomp_->getSkipsForRowAtom( atom1 ); |
| 442 |
> |
|
| 443 |
> |
for (vector<int>::iterator jb = skipList.begin(); |
| 444 |
> |
jb != skipList.end(); ++jb) { |
| 445 |
> |
|
| 446 |
> |
atom2 = (*jb); |
| 447 |
> |
idat = fDecomp_->fillSkipData(atom1, atom2); |
| 448 |
> |
interactionMan_->doSkipCorrection(idat); |
| 449 |
> |
|
| 450 |
|
} |
| 459 |
– |
|
| 460 |
– |
if (info_->requiresSelfCorrection()) { |
| 461 |
– |
sdat = fDecomp_->fillSelfData(atom1); |
| 462 |
– |
interactionMan_->doSelfCorrection(sdat); |
| 463 |
– |
} |
| 451 |
|
} |
| 452 |
|
} |
| 453 |
+ |
|
| 454 |
+ |
if (info_->requiresSelfCorrection()) { |
| 455 |
|
|
| 456 |
< |
// dangerous to iterate over enums, but we'll live on the edge: |
| 457 |
< |
for (int i = NO_FAMILY; i != N_INTERACTION_FAMILIES; ++i){ |
| 458 |
< |
lrPot += longRangePotential[i]; //Quick hack |
| 456 |
> |
for (int atom1 = 0; atom1 < info_->getNAtoms(); atom1++) { |
| 457 |
> |
sdat = fDecomp_->fillSelfData(atom1); |
| 458 |
> |
interactionMan_->doSelfCorrection(sdat); |
| 459 |
> |
} |
| 460 |
> |
|
| 461 |
|
} |
| 462 |
< |
|
| 462 |
> |
|
| 463 |
> |
longRangePotential = fDecomp_->getLongRangePotential(); |
| 464 |
> |
lrPot = longRangePotential.sum(); |
| 465 |
> |
|
| 466 |
|
//store the tau and long range potential |
| 467 |
|
curSnapshot->statData[Stats::LONG_RANGE_POTENTIAL] = lrPot; |
| 468 |
|
curSnapshot->statData[Stats::VANDERWAALS_POTENTIAL] = longRangePotential[VANDERWAALS_FAMILY]; |