| 35 |
|
* |
| 36 |
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
| 37 |
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
| 38 |
< |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
| 38 |
> |
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008). |
| 39 |
|
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
| 40 |
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
| 41 |
|
*/ |
| 516 |
|
RealType x; |
| 517 |
|
RealType y; |
| 518 |
|
RealType a; |
| 519 |
– |
int old_atoms; |
| 520 |
– |
int add_atoms; |
| 521 |
– |
int new_atoms; |
| 522 |
– |
int nTarget; |
| 523 |
– |
int done; |
| 524 |
– |
int i; |
| 525 |
– |
int loops; |
| 526 |
– |
int which_proc; |
| 519 |
|
int nProcessors; |
| 520 |
|
std::vector<int> atomsPerProc; |
| 521 |
|
int nGlobalMols = info->getNGlobalMolecules(); |
| 522 |
< |
std::vector<int> molToProcMap(nGlobalMols, -1); // default to an error condition: |
| 522 |
> |
std::vector<int> molToProcMap(nGlobalMols, -1); // default to an |
| 523 |
> |
// error |
| 524 |
> |
// condition: |
| 525 |
|
|
| 526 |
|
nProcessors = MPI::COMM_WORLD.Get_size(); |
| 527 |
|
|
| 532 |
|
"\tthe number of molecules. This will not result in a \n" |
| 533 |
|
"\tusable division of atoms for force decomposition.\n" |
| 534 |
|
"\tEither try a smaller number of processors, or run the\n" |
| 535 |
< |
"\tsingle-processor version of OpenMD.\n", nProcessors, nGlobalMols); |
| 535 |
> |
"\tsingle-processor version of OpenMD.\n", nProcessors, |
| 536 |
> |
nGlobalMols); |
| 537 |
|
|
| 538 |
|
painCave.isFatal = 1; |
| 539 |
|
simError(); |
| 540 |
|
} |
| 541 |
|
|
| 547 |
– |
int seedValue; |
| 542 |
|
Globals * simParams = info->getSimParams(); |
| 543 |
< |
SeqRandNumGen* myRandom; //divide labor does not need Parallel random number generator |
| 543 |
> |
SeqRandNumGen* myRandom; //divide labor does not need Parallel |
| 544 |
> |
//random number generator |
| 545 |
|
if (simParams->haveSeed()) { |
| 546 |
< |
seedValue = simParams->getSeed(); |
| 546 |
> |
int seedValue = simParams->getSeed(); |
| 547 |
|
myRandom = new SeqRandNumGen(seedValue); |
| 548 |
|
}else { |
| 549 |
|
myRandom = new SeqRandNumGen(); |
| 559 |
|
numerator = info->getNGlobalAtoms(); |
| 560 |
|
denominator = nProcessors; |
| 561 |
|
precast = numerator / denominator; |
| 562 |
< |
nTarget = (int)(precast + 0.5); |
| 562 |
> |
int nTarget = (int)(precast + 0.5); |
| 563 |
|
|
| 564 |
< |
for(i = 0; i < nGlobalMols; i++) { |
| 564 |
> |
for(int i = 0; i < nGlobalMols; i++) { |
| 565 |
|
|
| 566 |
< |
done = 0; |
| 567 |
< |
loops = 0; |
| 566 |
> |
int done = 0; |
| 567 |
> |
int loops = 0; |
| 568 |
|
|
| 569 |
|
while (!done) { |
| 570 |
|
loops++; |
| 571 |
|
|
| 572 |
|
// Pick a processor at random |
| 573 |
|
|
| 574 |
< |
which_proc = (int) (myRandom->rand() * nProcessors); |
| 574 |
> |
int which_proc = (int) (myRandom->rand() * nProcessors); |
| 575 |
|
|
| 576 |
|
//get the molecule stamp first |
| 577 |
|
int stampId = info->getMoleculeStampId(i); |
| 578 |
|
MoleculeStamp * moleculeStamp = info->getMoleculeStamp(stampId); |
| 579 |
|
|
| 580 |
|
// How many atoms does this processor have so far? |
| 581 |
< |
old_atoms = atomsPerProc[which_proc]; |
| 582 |
< |
add_atoms = moleculeStamp->getNAtoms(); |
| 583 |
< |
new_atoms = old_atoms + add_atoms; |
| 581 |
> |
int old_atoms = atomsPerProc[which_proc]; |
| 582 |
> |
int add_atoms = moleculeStamp->getNAtoms(); |
| 583 |
> |
int new_atoms = old_atoms + add_atoms; |
| 584 |
|
|
| 585 |
|
// If we've been through this loop too many times, we need |
| 586 |
|
// to just give up and assign the molecule to this processor |