| 54 | 
  | 
  void ForceMatrixDecomposition::distributeInitialData() { | 
| 55 | 
  | 
    snap_ = sman_->getCurrentSnapshot(); | 
| 56 | 
  | 
    storageLayout_ = sman_->getStorageLayout(); | 
| 57 | 
< | 
#ifdef IS_MPI     | 
| 58 | 
< | 
    int nLocal = snap_->getNumberOfAtoms(); | 
| 59 | 
< | 
    int nGroups = snap_->getNumberOfCutoffGroups(); | 
| 60 | 
< | 
     | 
| 61 | 
< | 
    AtomCommIntRow = new Communicator<Row,int>(nLocal); | 
| 62 | 
< | 
    AtomCommRealRow = new Communicator<Row,RealType>(nLocal); | 
| 63 | 
< | 
    AtomCommVectorRow = new Communicator<Row,Vector3d>(nLocal); | 
| 64 | 
< | 
    AtomCommMatrixRow = new Communicator<Row,Mat3x3d>(nLocal); | 
| 57 | 
> | 
    nLocal_ = snap_->getNumberOfAtoms(); | 
| 58 | 
> | 
    nGroups_ = snap_->getNumberOfCutoffGroups(); | 
| 59 | 
  | 
 | 
| 60 | 
< | 
    AtomCommIntColumn = new Communicator<Column,int>(nLocal); | 
| 61 | 
< | 
    AtomCommRealColumn = new Communicator<Column,RealType>(nLocal); | 
| 62 | 
< | 
    AtomCommVectorColumn = new Communicator<Column,Vector3d>(nLocal); | 
| 63 | 
< | 
    AtomCommMatrixColumn = new Communicator<Column,Mat3x3d>(nLocal); | 
| 60 | 
> | 
#ifdef IS_MPI | 
| 61 | 
> | 
  | 
| 62 | 
> | 
    AtomCommIntRow = new Communicator<Row,int>(nLocal_); | 
| 63 | 
> | 
    AtomCommRealRow = new Communicator<Row,RealType>(nLocal_); | 
| 64 | 
> | 
    AtomCommVectorRow = new Communicator<Row,Vector3d>(nLocal_); | 
| 65 | 
> | 
    AtomCommMatrixRow = new Communicator<Row,Mat3x3d>(nLocal_); | 
| 66 | 
  | 
 | 
| 67 | 
< | 
    cgCommIntRow = new Communicator<Row,int>(nGroups); | 
| 68 | 
< | 
    cgCommVectorRow = new Communicator<Row,Vector3d>(nGroups); | 
| 69 | 
< | 
    cgCommIntColumn = new Communicator<Column,int>(nGroups); | 
| 70 | 
< | 
    cgCommVectorColumn = new Communicator<Column,Vector3d>(nGroups); | 
| 67 | 
> | 
    AtomCommIntColumn = new Communicator<Column,int>(nLocal_); | 
| 68 | 
> | 
    AtomCommRealColumn = new Communicator<Column,RealType>(nLocal_); | 
| 69 | 
> | 
    AtomCommVectorColumn = new Communicator<Column,Vector3d>(nLocal_); | 
| 70 | 
> | 
    AtomCommMatrixColumn = new Communicator<Column,Mat3x3d>(nLocal_); | 
| 71 | 
  | 
 | 
| 72 | 
< | 
    int nAtomsInRow = AtomCommIntRow->getSize(); | 
| 73 | 
< | 
    int nAtomsInCol = AtomCommIntColumn->getSize(); | 
| 74 | 
< | 
    int nGroupsInRow = cgCommIntRow->getSize(); | 
| 75 | 
< | 
    int nGroupsInCol = cgCommIntColumn->getSize(); | 
| 72 | 
> | 
    cgCommIntRow = new Communicator<Row,int>(nGroups_); | 
| 73 | 
> | 
    cgCommVectorRow = new Communicator<Row,Vector3d>(nGroups_); | 
| 74 | 
> | 
    cgCommIntColumn = new Communicator<Column,int>(nGroups_); | 
| 75 | 
> | 
    cgCommVectorColumn = new Communicator<Column,Vector3d>(nGroups_); | 
| 76 | 
  | 
 | 
| 77 | 
+ | 
    nAtomsInRow_ = AtomCommIntRow->getSize(); | 
| 78 | 
+ | 
    nAtomsInCol_ = AtomCommIntColumn->getSize(); | 
| 79 | 
+ | 
    nGroupsInRow_ = cgCommIntRow->getSize(); | 
| 80 | 
+ | 
    nGroupsInCol_ = cgCommIntColumn->getSize(); | 
| 81 | 
+ | 
 | 
| 82 | 
  | 
    // Modify the data storage objects with the correct layouts and sizes: | 
| 83 | 
< | 
    atomRowData.resize(nAtomsInRow); | 
| 83 | 
> | 
    atomRowData.resize(nAtomsInRow_); | 
| 84 | 
  | 
    atomRowData.setStorageLayout(storageLayout_); | 
| 85 | 
< | 
    atomColData.resize(nAtomsInCol); | 
| 85 | 
> | 
    atomColData.resize(nAtomsInCol_); | 
| 86 | 
  | 
    atomColData.setStorageLayout(storageLayout_); | 
| 87 | 
< | 
    cgRowData.resize(nGroupsInRow); | 
| 87 | 
> | 
    cgRowData.resize(nGroupsInRow_); | 
| 88 | 
  | 
    cgRowData.setStorageLayout(DataStorage::dslPosition); | 
| 89 | 
< | 
    cgColData.resize(nGroupsInCol); | 
| 89 | 
> | 
    cgColData.resize(nGroupsInCol_); | 
| 90 | 
  | 
    cgColData.setStorageLayout(DataStorage::dslPosition); | 
| 91 | 
  | 
     | 
| 92 | 
  | 
    vector<vector<RealType> > pot_row(N_INTERACTION_FAMILIES,  | 
| 93 | 
< | 
                                      vector<RealType> (nAtomsInRow, 0.0)); | 
| 93 | 
> | 
                                      vector<RealType> (nAtomsInRow_, 0.0)); | 
| 94 | 
  | 
    vector<vector<RealType> > pot_col(N_INTERACTION_FAMILIES, | 
| 95 | 
< | 
                                      vector<RealType> (nAtomsInCol, 0.0)); | 
| 95 | 
> | 
                                      vector<RealType> (nAtomsInCol_, 0.0)); | 
| 96 | 
  | 
 | 
| 97 | 
  | 
 | 
| 98 | 
  | 
    vector<RealType> pot_local(N_INTERACTION_FAMILIES, 0.0); | 
| 99 | 
  | 
     | 
| 100 | 
  | 
    // gather the information for atomtype IDs (atids): | 
| 101 | 
  | 
    vector<int> identsLocal = info_->getIdentArray(); | 
| 102 | 
< | 
    identsRow.reserve(nAtomsInRow); | 
| 103 | 
< | 
    identsCol.reserve(nAtomsInCol); | 
| 102 | 
> | 
    identsRow.reserve(nAtomsInRow_); | 
| 103 | 
> | 
    identsCol.reserve(nAtomsInCol_); | 
| 104 | 
  | 
     | 
| 105 | 
  | 
    AtomCommIntRow->gather(identsLocal, identsRow); | 
| 106 | 
  | 
    AtomCommIntColumn->gather(identsLocal, identsCol); | 
| 230 | 
  | 
        snap_->atomData.torque[i] += trq_tmp[i]; | 
| 231 | 
  | 
    } | 
| 232 | 
  | 
     | 
| 233 | 
< | 
    int nLocal = snap_->getNumberOfAtoms(); | 
| 233 | 
> | 
    nLocal_ = snap_->getNumberOfAtoms(); | 
| 234 | 
  | 
 | 
| 235 | 
  | 
    vector<vector<RealType> > pot_temp(N_INTERACTION_FAMILIES,  | 
| 236 | 
< | 
                                       vector<RealType> (nLocal, 0.0)); | 
| 236 | 
> | 
                                       vector<RealType> (nLocal_, 0.0)); | 
| 237 | 
  | 
     | 
| 238 | 
  | 
    for (int i = 0; i < N_INTERACTION_FAMILIES; i++) { | 
| 239 | 
  | 
      AtomCommRealRow->scatter(pot_row[i], pot_temp[i]); | 
| 313 | 
  | 
#else | 
| 314 | 
  | 
    snap_->atomData.force[atom2] += fg; | 
| 315 | 
  | 
#endif | 
| 315 | 
– | 
 | 
| 316 | 
  | 
  } | 
| 317 | 
  | 
 | 
| 318 | 
  | 
    // filling interaction blocks with pointers | 
| 319 | 
  | 
  InteractionData ForceMatrixDecomposition::fillInteractionData(int atom1, int atom2) {     | 
| 320 | 
– | 
 | 
| 320 | 
  | 
    InteractionData idat; | 
| 321 | 
+ | 
 | 
| 322 | 
  | 
#ifdef IS_MPI | 
| 323 | 
  | 
    if (storageLayout_ & DataStorage::dslAmat) { | 
| 324 | 
  | 
      idat.A1 = &(atomRowData.aMat[atom1]); | 
| 325 | 
  | 
      idat.A2 = &(atomColData.aMat[atom2]); | 
| 326 | 
  | 
    } | 
| 327 | 
< | 
 | 
| 327 | 
> | 
     | 
| 328 | 
  | 
    if (storageLayout_ & DataStorage::dslElectroFrame) { | 
| 329 | 
  | 
      idat.eFrame1 = &(atomRowData.electroFrame[atom1]); | 
| 330 | 
  | 
      idat.eFrame2 = &(atomColData.electroFrame[atom2]); | 
| 370 | 
  | 
      idat.dfrho2 = &(snap_->atomData.functionalDerivative[atom2]); | 
| 371 | 
  | 
    } | 
| 372 | 
  | 
#endif | 
| 373 | 
< | 
     | 
| 373 | 
> | 
    return idat; | 
| 374 | 
  | 
  } | 
| 375 | 
+ | 
 | 
| 376 | 
  | 
  InteractionData ForceMatrixDecomposition::fillSkipData(int atom1, int atom2){ | 
| 377 | 
+ | 
 | 
| 378 | 
  | 
    InteractionData idat; | 
| 377 | 
– | 
    skippedCharge1 | 
| 378 | 
– | 
      skippedCharge2 | 
| 379 | 
– | 
      rij | 
| 380 | 
– | 
      d | 
| 381 | 
– | 
    electroMult | 
| 382 | 
– | 
    sw | 
| 383 | 
– | 
    f | 
| 379 | 
  | 
#ifdef IS_MPI | 
| 385 | 
– | 
 | 
| 380 | 
  | 
    if (storageLayout_ & DataStorage::dslElectroFrame) { | 
| 381 | 
  | 
      idat.eFrame1 = &(atomRowData.electroFrame[atom1]); | 
| 382 | 
  | 
      idat.eFrame2 = &(atomColData.electroFrame[atom2]); | 
| 385 | 
  | 
      idat.t1 = &(atomRowData.torque[atom1]); | 
| 386 | 
  | 
      idat.t2 = &(atomColData.torque[atom2]); | 
| 387 | 
  | 
    } | 
| 388 | 
< | 
 | 
| 388 | 
> | 
    if (storageLayout_ & DataStorage::dslForce) { | 
| 389 | 
> | 
      idat.t1 = &(atomRowData.force[atom1]); | 
| 390 | 
> | 
      idat.t2 = &(atomColData.force[atom2]); | 
| 391 | 
> | 
    } | 
| 392 | 
> | 
#else | 
| 393 | 
> | 
    if (storageLayout_ & DataStorage::dslElectroFrame) { | 
| 394 | 
> | 
      idat.eFrame1 = &(snap_->atomData.electroFrame[atom1]); | 
| 395 | 
> | 
      idat.eFrame2 = &(snap_->atomData.electroFrame[atom2]); | 
| 396 | 
> | 
    } | 
| 397 | 
> | 
    if (storageLayout_ & DataStorage::dslTorque) { | 
| 398 | 
> | 
      idat.t1 = &(snap_->atomData.torque[atom1]); | 
| 399 | 
> | 
      idat.t2 = &(snap_->atomData.torque[atom2]); | 
| 400 | 
> | 
    } | 
| 401 | 
> | 
    if (storageLayout_ & DataStorage::dslForce) { | 
| 402 | 
> | 
      idat.t1 = &(snap_->atomData.force[atom1]); | 
| 403 | 
> | 
      idat.t2 = &(snap_->atomData.force[atom2]); | 
| 404 | 
> | 
    } | 
| 405 | 
> | 
#endif | 
| 406 | 
  | 
     | 
| 407 | 
  | 
  } | 
| 408 | 
+ | 
 | 
| 409 | 
  | 
  SelfData ForceMatrixDecomposition::fillSelfData(int atom1) { | 
| 410 | 
+ | 
    SelfData sdat; | 
| 411 | 
+ | 
    // Still Missing atype, skippedCharge, potVec pot, | 
| 412 | 
+ | 
    if (storageLayout_ & DataStorage::dslElectroFrame) { | 
| 413 | 
+ | 
      sdat.eFrame = &(snap_->atomData.electroFrame[atom1]); | 
| 414 | 
+ | 
    } | 
| 415 | 
+ | 
     | 
| 416 | 
+ | 
    if (storageLayout_ & DataStorage::dslTorque) { | 
| 417 | 
+ | 
      sdat.t = &(snap_->atomData.torque[atom1]); | 
| 418 | 
+ | 
    } | 
| 419 | 
+ | 
     | 
| 420 | 
+ | 
    if (storageLayout_ & DataStorage::dslDensity) { | 
| 421 | 
+ | 
      sdat.rho = &(snap_->atomData.density[atom1]); | 
| 422 | 
+ | 
    } | 
| 423 | 
+ | 
     | 
| 424 | 
+ | 
    if (storageLayout_ & DataStorage::dslFunctional) { | 
| 425 | 
+ | 
      sdat.frho = &(snap_->atomData.functional[atom1]); | 
| 426 | 
+ | 
    } | 
| 427 | 
+ | 
     | 
| 428 | 
+ | 
    if (storageLayout_ & DataStorage::dslFunctionalDerivative) { | 
| 429 | 
+ | 
      sdat.dfrhodrho = &(snap_->atomData.functionalDerivative[atom1]); | 
| 430 | 
+ | 
    } | 
| 431 | 
+ | 
 | 
| 432 | 
+ | 
    return sdat;     | 
| 433 | 
  | 
  } | 
| 434 | 
  | 
 | 
| 435 | 
  | 
 | 
| 436 | 
+ | 
 | 
| 437 | 
  | 
  /* | 
| 438 | 
  | 
   * buildNeighborList | 
| 439 | 
  | 
   * | 
| 440 | 
  | 
   * first element of pair is row-indexed CutoffGroup | 
| 441 | 
  | 
   * second element of pair is column-indexed CutoffGroup | 
| 442 | 
  | 
   */ | 
| 443 | 
< | 
  vector<pair<int, int> >  buildNeighborList() { | 
| 444 | 
< | 
    Vector3d dr, invWid, rs, shift; | 
| 445 | 
< | 
    Vector3i cc, m1v, m2s; | 
| 446 | 
< | 
    RealType rrNebr; | 
| 447 | 
< | 
    int c, j1, j2, m1, m1x, m1y, m1z, m2, n, offset; | 
| 443 | 
> | 
  vector<pair<int, int> > ForceMatrixDecomposition::buildNeighborList() { | 
| 444 | 
> | 
       | 
| 445 | 
> | 
    vector<pair<int, int> > neighborList; | 
| 446 | 
> | 
#ifdef IS_MPI | 
| 447 | 
> | 
    CellListRow.clear(); | 
| 448 | 
> | 
    CellListCol.clear(); | 
| 449 | 
> | 
#else | 
| 450 | 
> | 
    CellList.clear(); | 
| 451 | 
> | 
#endif | 
| 452 | 
  | 
 | 
| 453 | 
< | 
 | 
| 454 | 
< | 
    vector<pair<int, int> > neighborList;    | 
| 455 | 
< | 
    Vector3i nCells; | 
| 456 | 
< | 
    Vector3d invWid, r; | 
| 457 | 
< | 
 | 
| 458 | 
< | 
    rList_ = (rCut_ + skinThickness_); | 
| 459 | 
< | 
    rl2 = rList_ * rList_; | 
| 420 | 
< | 
 | 
| 421 | 
< | 
    snap_ = sman_->getCurrentSnapshot(); | 
| 453 | 
> | 
    // dangerous to not do error checking. | 
| 454 | 
> | 
    RealType skinThickness_ = info_->getSimParams()->getSkinThickness(); | 
| 455 | 
> | 
    RealType rCut_; | 
| 456 | 
> | 
  | 
| 457 | 
> | 
    RealType rList_ = (rCut_ + skinThickness_); | 
| 458 | 
> | 
    RealType rl2 = rList_ * rList_; | 
| 459 | 
> | 
    Snapshot* snap_ = sman_->getCurrentSnapshot(); | 
| 460 | 
  | 
    Mat3x3d Hmat = snap_->getHmat(); | 
| 461 | 
  | 
    Vector3d Hx = Hmat.getColumn(0); | 
| 462 | 
  | 
    Vector3d Hy = Hmat.getColumn(1); | 
| 463 | 
  | 
    Vector3d Hz = Hmat.getColumn(2); | 
| 464 | 
+ | 
    Vector3i nCells; | 
| 465 | 
  | 
 | 
| 466 | 
  | 
    nCells.x() = (int) ( Hx.length() )/ rList_; | 
| 467 | 
  | 
    nCells.y() = (int) ( Hy.length() )/ rList_; | 
| 468 | 
  | 
    nCells.z() = (int) ( Hz.length() )/ rList_; | 
| 469 | 
  | 
 | 
| 470 | 
< | 
    for (i = 0; i < nGroupsInRow; i++) { | 
| 470 | 
> | 
    Mat3x3d invHmat = snap_->getInvHmat(); | 
| 471 | 
> | 
    Vector3d rs, scaled, dr; | 
| 472 | 
> | 
    Vector3i whichCell; | 
| 473 | 
> | 
    int cellIndex; | 
| 474 | 
> | 
 | 
| 475 | 
> | 
#ifdef IS_MPI | 
| 476 | 
> | 
    for (int i = 0; i < nGroupsInRow_; i++) { | 
| 477 | 
  | 
      rs = cgRowData.position[i]; | 
| 478 | 
< | 
      snap_->scaleVector(rs);      | 
| 479 | 
< | 
    } | 
| 480 | 
< | 
     | 
| 478 | 
> | 
      // scaled positions relative to the box vectors | 
| 479 | 
> | 
      scaled = invHmat * rs; | 
| 480 | 
> | 
      // wrap the vector back into the unit box by subtracting integer box  | 
| 481 | 
> | 
      // numbers | 
| 482 | 
> | 
      for (int j = 0; j < 3; j++)  | 
| 483 | 
> | 
        scaled[j] -= roundMe(scaled[j]); | 
| 484 | 
> | 
      | 
| 485 | 
> | 
      // find xyz-indices of cell that cutoffGroup is in. | 
| 486 | 
> | 
      whichCell.x() = nCells.x() * scaled.x(); | 
| 487 | 
> | 
      whichCell.y() = nCells.y() * scaled.y(); | 
| 488 | 
> | 
      whichCell.z() = nCells.z() * scaled.z(); | 
| 489 | 
  | 
 | 
| 490 | 
< | 
    VDiv (invWid, cells, region); | 
| 491 | 
< | 
    for (n = nMol; n < nMol + cells.componentProduct(); n ++) cellList[n] = -1; | 
| 492 | 
< | 
    for (n = 0; n < nMol; n ++) { | 
| 493 | 
< | 
      VSAdd (rs, mol[n].r, 0.5, region); | 
| 441 | 
< | 
      VMul (cc, rs, invWid); | 
| 442 | 
< | 
      c = VLinear (cc, cells) + nMol; | 
| 443 | 
< | 
      cellList[n] = cellList[c]; | 
| 444 | 
< | 
      cellList[c] = n; | 
| 490 | 
> | 
      // find single index of this cell: | 
| 491 | 
> | 
      cellIndex = Vlinear(whichCell, nCells); | 
| 492 | 
> | 
      // add this cutoff group to the list of groups in this cell; | 
| 493 | 
> | 
      CellListRow[cellIndex].push_back(i); | 
| 494 | 
  | 
    } | 
| 495 | 
< | 
    nebrTabLen = 0; | 
| 496 | 
< | 
    for (m1z = 0; m1z < cells.z(); m1z++) { | 
| 497 | 
< | 
      for (m1y = 0; m1y < cells.y(); m1y++) { | 
| 498 | 
< | 
        for (m1x = 0; m1x < cells.x(); m1x++) { | 
| 495 | 
> | 
 | 
| 496 | 
> | 
    for (int i = 0; i < nGroupsInCol_; i++) { | 
| 497 | 
> | 
      rs = cgColData.position[i]; | 
| 498 | 
> | 
      // scaled positions relative to the box vectors | 
| 499 | 
> | 
      scaled = invHmat * rs; | 
| 500 | 
> | 
      // wrap the vector back into the unit box by subtracting integer box  | 
| 501 | 
> | 
      // numbers | 
| 502 | 
> | 
      for (int j = 0; j < 3; j++)  | 
| 503 | 
> | 
        scaled[j] -= roundMe(scaled[j]); | 
| 504 | 
> | 
 | 
| 505 | 
> | 
      // find xyz-indices of cell that cutoffGroup is in. | 
| 506 | 
> | 
      whichCell.x() = nCells.x() * scaled.x(); | 
| 507 | 
> | 
      whichCell.y() = nCells.y() * scaled.y(); | 
| 508 | 
> | 
      whichCell.z() = nCells.z() * scaled.z(); | 
| 509 | 
> | 
 | 
| 510 | 
> | 
      // find single index of this cell: | 
| 511 | 
> | 
      cellIndex = Vlinear(whichCell, nCells); | 
| 512 | 
> | 
      // add this cutoff group to the list of groups in this cell; | 
| 513 | 
> | 
      CellListCol[cellIndex].push_back(i); | 
| 514 | 
> | 
    } | 
| 515 | 
> | 
#else | 
| 516 | 
> | 
    for (int i = 0; i < nGroups_; i++) { | 
| 517 | 
> | 
      rs = snap_->cgData.position[i]; | 
| 518 | 
> | 
      // scaled positions relative to the box vectors | 
| 519 | 
> | 
      scaled = invHmat * rs; | 
| 520 | 
> | 
      // wrap the vector back into the unit box by subtracting integer box  | 
| 521 | 
> | 
      // numbers | 
| 522 | 
> | 
      for (int j = 0; j < 3; j++)  | 
| 523 | 
> | 
        scaled[j] -= roundMe(scaled[j]); | 
| 524 | 
> | 
 | 
| 525 | 
> | 
      // find xyz-indices of cell that cutoffGroup is in. | 
| 526 | 
> | 
      whichCell.x() = nCells.x() * scaled.x(); | 
| 527 | 
> | 
      whichCell.y() = nCells.y() * scaled.y(); | 
| 528 | 
> | 
      whichCell.z() = nCells.z() * scaled.z(); | 
| 529 | 
> | 
 | 
| 530 | 
> | 
      // find single index of this cell: | 
| 531 | 
> | 
      cellIndex = Vlinear(whichCell, nCells); | 
| 532 | 
> | 
      // add this cutoff group to the list of groups in this cell; | 
| 533 | 
> | 
      CellList[cellIndex].push_back(i); | 
| 534 | 
> | 
    } | 
| 535 | 
> | 
#endif | 
| 536 | 
> | 
 | 
| 537 | 
> | 
 | 
| 538 | 
> | 
 | 
| 539 | 
> | 
    for (int m1z = 0; m1z < nCells.z(); m1z++) { | 
| 540 | 
> | 
      for (int m1y = 0; m1y < nCells.y(); m1y++) { | 
| 541 | 
> | 
        for (int m1x = 0; m1x < nCells.x(); m1x++) { | 
| 542 | 
  | 
          Vector3i m1v(m1x, m1y, m1z); | 
| 543 | 
< | 
          m1 = VLinear(m1v, cells) + nMol; | 
| 544 | 
< | 
          for (offset = 0; offset < nOffset_; offset++) { | 
| 545 | 
< | 
            m2v = m1v + cellOffsets_[offset]; | 
| 454 | 
< | 
            shift = V3Zero(); | 
| 543 | 
> | 
          int m1 = Vlinear(m1v, nCells); | 
| 544 | 
> | 
          for (int offset = 0; offset < nOffset_; offset++) { | 
| 545 | 
> | 
            Vector3i m2v = m1v + cellOffsets_[offset]; | 
| 546 | 
  | 
 | 
| 547 | 
< | 
            if (m2v.x() >= cells.x) { | 
| 547 | 
> | 
            if (m2v.x() >= nCells.x()) { | 
| 548 | 
  | 
              m2v.x() = 0;            | 
| 458 | 
– | 
              shift.x() = region.x();   | 
| 549 | 
  | 
            } else if (m2v.x() < 0) { | 
| 550 | 
< | 
              m2v.x() = cells.x() - 1;  | 
| 461 | 
< | 
              shift.x() = - region.x(); | 
| 550 | 
> | 
              m2v.x() = nCells.x() - 1;  | 
| 551 | 
  | 
            } | 
| 552 | 
  | 
 | 
| 553 | 
< | 
            if (m2v.y() >= cells.y()) { | 
| 553 | 
> | 
            if (m2v.y() >= nCells.y()) { | 
| 554 | 
  | 
              m2v.y() = 0;            | 
| 466 | 
– | 
              shift.y() = region.y();   | 
| 555 | 
  | 
            } else if (m2v.y() < 0) { | 
| 556 | 
< | 
              m2v.y() = cells.y() - 1;  | 
| 469 | 
< | 
              shift.y() = - region.y(); | 
| 556 | 
> | 
              m2v.y() = nCells.y() - 1;  | 
| 557 | 
  | 
            } | 
| 558 | 
  | 
 | 
| 559 | 
< | 
            m2 = VLinear (m2v, cells) + nMol; | 
| 560 | 
< | 
            for (j1 = cellList[m1]; j1 >= 0; j1 = cellList[j1]) { | 
| 561 | 
< | 
              for (j2 = cellList[m2]; j2 >= 0; j2 = cellList[j2]) { | 
| 562 | 
< | 
                if (m1 != m2 || j2 < j1) { | 
| 563 | 
< | 
                  dr = mol[j1].r - mol[j2].r; | 
| 564 | 
< | 
                  VSub (dr, mol[j1].r, mol[j2].r); | 
| 565 | 
< | 
                  VVSub (dr, shift); | 
| 566 | 
< | 
                  if (VLenSq (dr) < rrNebr) { | 
| 567 | 
< | 
                    neighborList.push_back(make_pair(j1, j2)); | 
| 559 | 
> | 
            if (m2v.z() >= nCells.z()) { | 
| 560 | 
> | 
              m2v.z() = 0;            | 
| 561 | 
> | 
            } else if (m2v.z() < 0) { | 
| 562 | 
> | 
              m2v.z() = nCells.z() - 1;  | 
| 563 | 
> | 
            } | 
| 564 | 
> | 
 | 
| 565 | 
> | 
            int m2 = Vlinear (m2v, nCells); | 
| 566 | 
> | 
 | 
| 567 | 
> | 
#ifdef IS_MPI | 
| 568 | 
> | 
            for (vector<int>::iterator j1 = CellListRow[m1].begin();  | 
| 569 | 
> | 
                 j1 != CellListRow[m1].end(); ++j1) { | 
| 570 | 
> | 
              for (vector<int>::iterator j2 = CellListCol[m2].begin();  | 
| 571 | 
> | 
                   j2 != CellListCol[m2].end(); ++j2) { | 
| 572 | 
> | 
                                | 
| 573 | 
> | 
                // Always do this if we're in different cells or if | 
| 574 | 
> | 
                // we're in the same cell and the global index of the | 
| 575 | 
> | 
                // j2 cutoff group is less than the j1 cutoff group | 
| 576 | 
> | 
 | 
| 577 | 
> | 
                if (m2 != m1 || cgColToGlobal[(*j2)] < cgRowToGlobal[(*j1)]) { | 
| 578 | 
> | 
                  dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)]; | 
| 579 | 
> | 
                  snap_->wrapVector(dr); | 
| 580 | 
> | 
                  if (dr.lengthSquare() < rl2) { | 
| 581 | 
> | 
                    neighborList.push_back(make_pair((*j1), (*j2))); | 
| 582 | 
  | 
                  } | 
| 583 | 
  | 
                } | 
| 584 | 
  | 
              } | 
| 585 | 
  | 
            } | 
| 586 | 
+ | 
#else | 
| 587 | 
+ | 
            for (vector<int>::iterator j1 = CellList[m1].begin();  | 
| 588 | 
+ | 
                 j1 != CellList[m1].end(); ++j1) { | 
| 589 | 
+ | 
              for (vector<int>::iterator j2 = CellList[m2].begin();  | 
| 590 | 
+ | 
                   j2 != CellList[m2].end(); ++j2) { | 
| 591 | 
+ | 
                                | 
| 592 | 
+ | 
                // Always do this if we're in different cells or if | 
| 593 | 
+ | 
                // we're in the same cell and the global index of the | 
| 594 | 
+ | 
                // j2 cutoff group is less than the j1 cutoff group | 
| 595 | 
+ | 
 | 
| 596 | 
+ | 
                if (m2 != m1 || (*j2) < (*j1)) { | 
| 597 | 
+ | 
                  dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; | 
| 598 | 
+ | 
                  snap_->wrapVector(dr); | 
| 599 | 
+ | 
                  if (dr.lengthSquare() < rl2) { | 
| 600 | 
+ | 
                    neighborList.push_back(make_pair((*j1), (*j2))); | 
| 601 | 
+ | 
                  } | 
| 602 | 
+ | 
                } | 
| 603 | 
+ | 
              } | 
| 604 | 
+ | 
            } | 
| 605 | 
+ | 
#endif | 
| 606 | 
  | 
          } | 
| 607 | 
  | 
        } | 
| 608 | 
  | 
      } | 
| 609 | 
  | 
    } | 
| 610 | 
+ | 
    return neighborList; | 
| 611 | 
  | 
  } | 
| 490 | 
– | 
 | 
| 491 | 
– | 
   | 
| 612 | 
  | 
} //end namespace OpenMD |