ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/parallel/ForceMatrixDecomposition.cpp
(Generate patch)

Comparing:
branches/development/src/parallel/ForceMatrixDecomposition.cpp (file contents), Revision 1760 by gezelter, Thu Jun 21 19:26:46 2012 UTC vs.
trunk/src/parallel/ForceMatrixDecomposition.cpp (file contents), Revision 1929 by gezelter, Mon Aug 19 13:12:00 2013 UTC

# Line 35 | Line 35
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   */
# Line 99 | Line 99 | namespace OpenMD {
99      nGroups_ = info_->getNLocalCutoffGroups();
100      // gather the information for atomtype IDs (atids):
101      idents = info_->getIdentArray();
102 +    regions = info_->getRegions();
103      AtomLocalToGlobal = info_->getGlobalAtomIndices();
104      cgLocalToGlobal = info_->getGlobalGroupIndices();
105      vector<int> globalGroupMembership = info_->getGlobalGroupMembership();
# Line 163 | Line 164 | namespace OpenMD {
164      
165      AtomPlanIntRow->gather(idents, identsRow);
166      AtomPlanIntColumn->gather(idents, identsCol);
167 +
168 +    regionsRow.resize(nAtomsInRow_);
169 +    regionsCol.resize(nAtomsInCol_);
170      
171 +    AtomPlanIntRow->gather(regions, regionsRow);
172 +    AtomPlanIntColumn->gather(regions, regionsCol);
173 +    
174      // allocate memory for the parallel objects
175      atypesRow.resize(nAtomsInRow_);
176      atypesCol.resize(nAtomsInCol_);
# Line 308 | Line 315 | namespace OpenMD {
315    
316    void ForceMatrixDecomposition::createGtypeCutoffMap() {
317      
318 +    GrCut.clear();
319 +    GrCutSq.clear();
320 +    GrlistSq.clear();
321 +
322      RealType tol = 1e-6;
323      largestRcut_ = 0.0;
313    RealType rc;
324      int atid;
325      set<AtomType*> atypes = info_->getSimulatedAtomTypes();
326      
# Line 395 | Line 405 | namespace OpenMD {
405        }
406        
407        bool gTypeFound = false;
408 <      for (int gt = 0; gt < gTypeCutoffs.size(); gt++) {
408 >      for (unsigned int gt = 0; gt < gTypeCutoffs.size(); gt++) {
409          if (abs(groupCutoff[cg1] - gTypeCutoffs[gt]) < tol) {
410            groupToGtype[cg1] = gt;
411            gTypeFound = true;
# Line 420 | Line 430 | namespace OpenMD {
430      
431      RealType tradRcut = groupMax;
432  
433 <    for (int i = 0; i < gTypeCutoffs.size();  i++) {
434 <      for (int j = 0; j < gTypeCutoffs.size();  j++) {      
433 >    GrCut.resize( gTypeCutoffs.size() );
434 >    GrCutSq.resize( gTypeCutoffs.size() );
435 >    GrlistSq.resize( gTypeCutoffs.size() );
436 >
437 >
438 >    for (unsigned int i = 0; i < gTypeCutoffs.size();  i++) {
439 >      GrCut[i].resize( gTypeCutoffs.size() , 0.0);
440 >      GrCutSq[i].resize( gTypeCutoffs.size(), 0.0 );
441 >      GrlistSq[i].resize( gTypeCutoffs.size(), 0.0 );
442 >
443 >      for (unsigned int j = 0; j < gTypeCutoffs.size();  j++) {      
444          RealType thisRcut;
445          switch(cutoffPolicy_) {
446          case TRADITIONAL:
# Line 443 | Line 462 | namespace OpenMD {
462            break;
463          }
464  
465 <        pair<int,int> key = make_pair(i,j);
447 <        gTypeCutoffMap[key].first = thisRcut;
465 >        GrCut[i][j] = thisRcut;
466          if (thisRcut > largestRcut_) largestRcut_ = thisRcut;
467 <        gTypeCutoffMap[key].second = thisRcut*thisRcut;
468 <        gTypeCutoffMap[key].third = pow(thisRcut + skinThickness_, 2);
467 >        GrCutSq[i][j] = thisRcut * thisRcut;
468 >        GrlistSq[i][j] = pow(thisRcut + skinThickness_, 2);
469 >
470 >        // pair<int,int> key = make_pair(i,j);
471 >        // gTypeCutoffMap[key].first = thisRcut;
472 >        // gTypeCutoffMap[key].third = pow(thisRcut + skinThickness_, 2);
473          // sanity check
474          
475          if (userChoseCutoff_) {
476 <          if (abs(gTypeCutoffMap[key].first - userCutoff_) > 0.0001) {
476 >          if (abs(GrCut[i][j] - userCutoff_) > 0.0001) {
477              sprintf(painCave.errMsg,
478                      "ForceMatrixDecomposition::createGtypeCutoffMap "
479                      "user-specified rCut (%lf) does not match computed group Cutoff\n", userCutoff_);
# Line 464 | Line 486 | namespace OpenMD {
486      }
487    }
488  
489 <  groupCutoffs ForceMatrixDecomposition::getGroupCutoffs(int cg1, int cg2) {
489 >  void ForceMatrixDecomposition::getGroupCutoffs(int &cg1, int &cg2, RealType &rcut, RealType &rcutsq, RealType &rlistsq) {
490      int i, j;  
491   #ifdef IS_MPI
492      i = groupRowToGtype[cg1];
# Line 473 | Line 495 | namespace OpenMD {
495      i = groupToGtype[cg1];
496      j = groupToGtype[cg2];
497   #endif    
498 <    return gTypeCutoffMap[make_pair(i,j)];
498 >    rcut = GrCut[i][j];
499 >    rcutsq = GrCutSq[i][j];
500 >    rlistsq = GrlistSq[i][j];
501 >    return;
502 >    //return gTypeCutoffMap[make_pair(i,j)];
503    }
504  
505    int ForceMatrixDecomposition::getTopologicalDistance(int atom1, int atom2) {
506 <    for (int j = 0; j < toposForAtom[atom1].size(); j++) {
506 >    for (unsigned int j = 0; j < toposForAtom[atom1].size(); j++) {
507        if (toposForAtom[atom1][j] == atom2)
508          return topoDist[atom1][j];
509 <    }
509 >    }                                          
510      return 0;
511    }
512  
# Line 488 | Line 514 | namespace OpenMD {
514      pairwisePot = 0.0;
515      embeddingPot = 0.0;
516      excludedPot = 0.0;
517 +    excludedSelfPot = 0.0;
518  
519   #ifdef IS_MPI
520      if (storageLayout_ & DataStorage::dslForce) {
# Line 559 | Line 586 | namespace OpenMD {
586             atomColData.electricField.end(), V3Zero);
587      }
588  
562    if (storageLayout_ & DataStorage::dslFlucQForce) {    
563      fill(atomRowData.flucQFrc.begin(), atomRowData.flucQFrc.end(),
564           0.0);
565      fill(atomColData.flucQFrc.begin(), atomColData.flucQFrc.end(),
566           0.0);
567    }
568
589   #endif
590      // even in parallel, we need to zero out the local arrays:
591  
# Line 639 | Line 659 | namespace OpenMD {
659        AtomPlanMatrixColumn->gather(snap_->atomData.aMat,
660                                     atomColData.aMat);
661      }
662 <    
663 <    // if needed, gather the atomic eletrostatic frames
664 <    if (storageLayout_ & DataStorage::dslElectroFrame) {
665 <      AtomPlanMatrixRow->gather(snap_->atomData.electroFrame,
666 <                                atomRowData.electroFrame);
667 <      AtomPlanMatrixColumn->gather(snap_->atomData.electroFrame,
668 <                                   atomColData.electroFrame);
662 >
663 >    // if needed, gather the atomic eletrostatic information
664 >    if (storageLayout_ & DataStorage::dslDipole) {
665 >      AtomPlanVectorRow->gather(snap_->atomData.dipole,
666 >                                atomRowData.dipole);
667 >      AtomPlanVectorColumn->gather(snap_->atomData.dipole,
668 >                                   atomColData.dipole);
669      }
670  
671 +    if (storageLayout_ & DataStorage::dslQuadrupole) {
672 +      AtomPlanMatrixRow->gather(snap_->atomData.quadrupole,
673 +                                atomRowData.quadrupole);
674 +      AtomPlanMatrixColumn->gather(snap_->atomData.quadrupole,
675 +                                   atomColData.quadrupole);
676 +    }
677 +        
678      // if needed, gather the atomic fluctuating charge values
679      if (storageLayout_ & DataStorage::dslFlucQPosition) {
680        AtomPlanRealRow->gather(snap_->atomData.flucQPos,
# Line 679 | Line 706 | namespace OpenMD {
706          snap_->atomData.density[i] += rho_tmp[i];
707      }
708  
709 +    // this isn't necessary if we don't have polarizable atoms, but
710 +    // we'll leave it here for now.
711      if (storageLayout_ & DataStorage::dslElectricField) {
712        
713        AtomPlanVectorRow->scatter(atomRowData.electricField,
# Line 686 | Line 715 | namespace OpenMD {
715        
716        int n = snap_->atomData.electricField.size();
717        vector<Vector3d> field_tmp(n, V3Zero);
718 <      AtomPlanVectorColumn->scatter(atomColData.electricField, field_tmp);
718 >      AtomPlanVectorColumn->scatter(atomColData.electricField,
719 >                                    field_tmp);
720        for (int i = 0; i < n; i++)
721          snap_->atomData.electricField[i] += field_tmp[i];
722      }
# Line 786 | Line 816 | namespace OpenMD {
816              
817      }
818  
819 +    if (storageLayout_ & DataStorage::dslElectricField) {
820 +
821 +      int nef = snap_->atomData.electricField.size();
822 +      vector<Vector3d> efield_tmp(nef, V3Zero);
823 +
824 +      AtomPlanVectorRow->scatter(atomRowData.electricField, efield_tmp);
825 +      for (int i = 0; i < nef; i++) {
826 +        snap_->atomData.electricField[i] += efield_tmp[i];
827 +        efield_tmp[i] = 0.0;
828 +      }
829 +      
830 +      AtomPlanVectorColumn->scatter(atomColData.electricField, efield_tmp);
831 +      for (int i = 0; i < nef; i++)
832 +        snap_->atomData.electricField[i] += efield_tmp[i];
833 +    }
834 +
835 +
836      nLocal_ = snap_->getNumberOfAtoms();
837  
838      vector<potVec> pot_temp(nLocal_,
# Line 907 | Line 954 | namespace OpenMD {
954        MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM);
955        embeddingPot[ii] = ploc2;
956      }    
957 +    for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) {
958 +      RealType ploc1 = excludedSelfPot[ii];
959 +      RealType ploc2 = 0.0;
960 +      MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM);
961 +      excludedSelfPot[ii] = ploc2;
962 +    }    
963   #endif
964      
965    }
966  
967  
968  
969 <  int ForceMatrixDecomposition::getNAtomsInRow() {  
969 >  int& ForceMatrixDecomposition::getNAtomsInRow() {  
970   #ifdef IS_MPI
971      return nAtomsInRow_;
972   #else
# Line 924 | Line 977 | namespace OpenMD {
977    /**
978     * returns the list of atoms belonging to this group.  
979     */
980 <  vector<int> ForceMatrixDecomposition::getAtomsInGroupRow(int cg1){
980 >  vector<int>& ForceMatrixDecomposition::getAtomsInGroupRow(int cg1){
981   #ifdef IS_MPI
982      return groupListRow_[cg1];
983   #else
# Line 932 | Line 985 | namespace OpenMD {
985   #endif
986    }
987  
988 <  vector<int> ForceMatrixDecomposition::getAtomsInGroupColumn(int cg2){
988 >  vector<int>& ForceMatrixDecomposition::getAtomsInGroupColumn(int cg2){
989   #ifdef IS_MPI
990      return groupListCol_[cg2];
991   #else
# Line 949 | Line 1002 | namespace OpenMD {
1002      d = snap_->cgData.position[cg2] - snap_->cgData.position[cg1];
1003   #endif
1004      
1005 <    snap_->wrapVector(d);
1005 >    if (usePeriodicBoundaryConditions_) {
1006 >      snap_->wrapVector(d);
1007 >    }
1008      return d;    
1009    }
1010  
1011 <  Vector3d ForceMatrixDecomposition::getGroupVelocityColumn(int cg2){
1011 >  Vector3d& ForceMatrixDecomposition::getGroupVelocityColumn(int cg2){
1012   #ifdef IS_MPI
1013      return cgColData.velocity[cg2];
1014   #else
# Line 961 | Line 1016 | namespace OpenMD {
1016   #endif
1017    }
1018  
1019 <  Vector3d ForceMatrixDecomposition::getAtomVelocityColumn(int atom2){
1019 >  Vector3d& ForceMatrixDecomposition::getAtomVelocityColumn(int atom2){
1020   #ifdef IS_MPI
1021      return atomColData.velocity[atom2];
1022   #else
# Line 979 | Line 1034 | namespace OpenMD {
1034   #else
1035      d = snap_->cgData.position[cg1] - snap_->atomData.position[atom1];
1036   #endif
1037 <
1038 <    snap_->wrapVector(d);
1037 >    if (usePeriodicBoundaryConditions_) {
1038 >      snap_->wrapVector(d);
1039 >    }
1040      return d;    
1041    }
1042    
# Line 992 | Line 1048 | namespace OpenMD {
1048   #else
1049      d = snap_->cgData.position[cg2] - snap_->atomData.position[atom2];
1050   #endif
1051 <    
1052 <    snap_->wrapVector(d);
1051 >    if (usePeriodicBoundaryConditions_) {
1052 >      snap_->wrapVector(d);
1053 >    }
1054      return d;    
1055    }
1056  
1057 <  RealType ForceMatrixDecomposition::getMassFactorRow(int atom1) {
1057 >  RealType& ForceMatrixDecomposition::getMassFactorRow(int atom1) {
1058   #ifdef IS_MPI
1059      return massFactorsRow[atom1];
1060   #else
# Line 1005 | Line 1062 | namespace OpenMD {
1062   #endif
1063    }
1064  
1065 <  RealType ForceMatrixDecomposition::getMassFactorColumn(int atom2) {
1065 >  RealType& ForceMatrixDecomposition::getMassFactorColumn(int atom2) {
1066   #ifdef IS_MPI
1067      return massFactorsCol[atom2];
1068   #else
# Line 1022 | Line 1079 | namespace OpenMD {
1079   #else
1080      d = snap_->atomData.position[atom2] - snap_->atomData.position[atom1];
1081   #endif
1082 <
1083 <    snap_->wrapVector(d);
1082 >    if (usePeriodicBoundaryConditions_) {
1083 >      snap_->wrapVector(d);
1084 >    }
1085      return d;    
1086    }
1087  
1088 <  vector<int> ForceMatrixDecomposition::getExcludesForAtom(int atom1) {
1088 >  vector<int>& ForceMatrixDecomposition::getExcludesForAtom(int atom1) {
1089      return excludesForAtom[atom1];
1090    }
1091  
# Line 1036 | Line 1094 | namespace OpenMD {
1094     * the parallel decomposition.
1095     */
1096    bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2, int cg1, int cg2) {
1097 <    int unique_id_1, unique_id_2, group1, group2;
1097 >    int unique_id_1, unique_id_2;
1098          
1099   #ifdef IS_MPI
1100      // in MPI, we have to look up the unique IDs for each atom
1101      unique_id_1 = AtomRowToGlobal[atom1];
1102      unique_id_2 = AtomColToGlobal[atom2];
1103 <    group1 = cgRowToGlobal[cg1];
1104 <    group2 = cgColToGlobal[cg2];
1103 >    // group1 = cgRowToGlobal[cg1];
1104 >    // group2 = cgColToGlobal[cg2];
1105   #else
1106      unique_id_1 = AtomLocalToGlobal[atom1];
1107      unique_id_2 = AtomLocalToGlobal[atom2];
1108 <    group1 = cgLocalToGlobal[cg1];
1109 <    group2 = cgLocalToGlobal[cg2];
1108 >    int group1 = cgLocalToGlobal[cg1];
1109 >    int group2 = cgLocalToGlobal[cg2];
1110   #endif  
1111  
1112      if (unique_id_1 == unique_id_2) return true;
# Line 1118 | Line 1176 | namespace OpenMD {
1176    
1177   #ifdef IS_MPI
1178      idat.atypes = make_pair( atypesRow[atom1], atypesCol[atom2]);
1179 +    idat.atid1 = identsRow[atom1];
1180 +    idat.atid2 = identsCol[atom2];
1181 +
1182 +    if (regionsRow[atom1] >= 0 && regionsCol[atom2] >= 0)
1183 +      idat.sameRegion = (regionsRow[atom1] == regionsCol[atom2]);
1184 +      
1185      //idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]),
1186      //                         ff_->getAtomType(identsCol[atom2]) );
1187      
# Line 1126 | Line 1190 | namespace OpenMD {
1190        idat.A2 = &(atomColData.aMat[atom2]);
1191      }
1192      
1129    if (storageLayout_ & DataStorage::dslElectroFrame) {
1130      idat.eFrame1 = &(atomRowData.electroFrame[atom1]);
1131      idat.eFrame2 = &(atomColData.electroFrame[atom2]);
1132    }
1133
1193      if (storageLayout_ & DataStorage::dslTorque) {
1194        idat.t1 = &(atomRowData.torque[atom1]);
1195        idat.t2 = &(atomColData.torque[atom2]);
1196      }
1197  
1198 +    if (storageLayout_ & DataStorage::dslDipole) {
1199 +      idat.dipole1 = &(atomRowData.dipole[atom1]);
1200 +      idat.dipole2 = &(atomColData.dipole[atom2]);
1201 +    }
1202 +
1203 +    if (storageLayout_ & DataStorage::dslQuadrupole) {
1204 +      idat.quadrupole1 = &(atomRowData.quadrupole[atom1]);
1205 +      idat.quadrupole2 = &(atomColData.quadrupole[atom2]);
1206 +    }
1207 +
1208      if (storageLayout_ & DataStorage::dslDensity) {
1209        idat.rho1 = &(atomRowData.density[atom1]);
1210        idat.rho2 = &(atomColData.density[atom2]);
# Line 1169 | Line 1238 | namespace OpenMD {
1238   #else
1239      
1240      idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]);
1241 +    idat.atid1 = idents[atom1];
1242 +    idat.atid2 = idents[atom2];
1243  
1244 +    if (regions[atom1] >= 0 && regions[atom2] >= 0)
1245 +      idat.sameRegion = (regions[atom1] == regions[atom2]);
1246 +
1247      if (storageLayout_ & DataStorage::dslAmat) {
1248        idat.A1 = &(snap_->atomData.aMat[atom1]);
1249        idat.A2 = &(snap_->atomData.aMat[atom2]);
1250      }
1251  
1178    if (storageLayout_ & DataStorage::dslElectroFrame) {
1179      idat.eFrame1 = &(snap_->atomData.electroFrame[atom1]);
1180      idat.eFrame2 = &(snap_->atomData.electroFrame[atom2]);
1181    }
1182
1252      if (storageLayout_ & DataStorage::dslTorque) {
1253        idat.t1 = &(snap_->atomData.torque[atom1]);
1254        idat.t2 = &(snap_->atomData.torque[atom2]);
1255      }
1256  
1257 +    if (storageLayout_ & DataStorage::dslDipole) {
1258 +      idat.dipole1 = &(snap_->atomData.dipole[atom1]);
1259 +      idat.dipole2 = &(snap_->atomData.dipole[atom2]);
1260 +    }
1261 +
1262 +    if (storageLayout_ & DataStorage::dslQuadrupole) {
1263 +      idat.quadrupole1 = &(snap_->atomData.quadrupole[atom1]);
1264 +      idat.quadrupole2 = &(snap_->atomData.quadrupole[atom2]);
1265 +    }
1266 +
1267      if (storageLayout_ & DataStorage::dslDensity) {    
1268        idat.rho1 = &(snap_->atomData.density[atom1]);
1269        idat.rho2 = &(snap_->atomData.density[atom2]);
# Line 1275 | Line 1354 | namespace OpenMD {
1354     * first element of pair is row-indexed CutoffGroup
1355     * second element of pair is column-indexed CutoffGroup
1356     */
1357 <  vector<pair<int, int> > ForceMatrixDecomposition::buildNeighborList() {
1358 <      
1359 <    vector<pair<int, int> > neighborList;
1357 >  void ForceMatrixDecomposition::buildNeighborList(vector<pair<int,int> >& neighborList) {
1358 >    
1359 >    neighborList.clear();
1360      groupCutoffs cuts;
1361      bool doAllPairs = false;
1362  
1363 +    RealType rList_ = (largestRcut_ + skinThickness_);
1364 +    RealType rcut, rcutsq, rlistsq;
1365 +    Snapshot* snap_ = sman_->getCurrentSnapshot();
1366 +    Mat3x3d box;
1367 +    Mat3x3d invBox;
1368 +
1369 +    Vector3d rs, scaled, dr;
1370 +    Vector3i whichCell;
1371 +    int cellIndex;
1372 +
1373   #ifdef IS_MPI
1374      cellListRow_.clear();
1375      cellListCol_.clear();
1376   #else
1377      cellList_.clear();
1378   #endif
1379 <
1380 <    RealType rList_ = (largestRcut_ + skinThickness_);
1381 <    RealType rl2 = rList_ * rList_;
1382 <    Snapshot* snap_ = sman_->getCurrentSnapshot();
1383 <    Mat3x3d Hmat = snap_->getHmat();
1384 <    Vector3d Hx = Hmat.getColumn(0);
1385 <    Vector3d Hy = Hmat.getColumn(1);
1386 <    Vector3d Hz = Hmat.getColumn(2);
1387 <
1388 <    nCells_.x() = (int) ( Hx.length() )/ rList_;
1389 <    nCells_.y() = (int) ( Hy.length() )/ rList_;
1390 <    nCells_.z() = (int) ( Hz.length() )/ rList_;
1391 <
1379 >    
1380 >    if (!usePeriodicBoundaryConditions_) {
1381 >      box = snap_->getBoundingBox();
1382 >      invBox = snap_->getInvBoundingBox();
1383 >    } else {
1384 >      box = snap_->getHmat();
1385 >      invBox = snap_->getInvHmat();
1386 >    }
1387 >    
1388 >    Vector3d boxX = box.getColumn(0);
1389 >    Vector3d boxY = box.getColumn(1);
1390 >    Vector3d boxZ = box.getColumn(2);
1391 >    
1392 >    nCells_.x() = (int) ( boxX.length() )/ rList_;
1393 >    nCells_.y() = (int) ( boxY.length() )/ rList_;
1394 >    nCells_.z() = (int) ( boxZ.length() )/ rList_;
1395 >    
1396      // handle small boxes where the cell offsets can end up repeating cells
1397      
1398      if (nCells_.x() < 3) doAllPairs = true;
1399      if (nCells_.y() < 3) doAllPairs = true;
1400      if (nCells_.z() < 3) doAllPairs = true;
1401 <
1309 <    Mat3x3d invHmat = snap_->getInvHmat();
1310 <    Vector3d rs, scaled, dr;
1311 <    Vector3i whichCell;
1312 <    int cellIndex;
1401 >    
1402      int nCtot = nCells_.x() * nCells_.y() * nCells_.z();
1403 <
1403 >    
1404   #ifdef IS_MPI
1405      cellListRow_.resize(nCtot);
1406      cellListCol_.resize(nCtot);
1407   #else
1408      cellList_.resize(nCtot);
1409   #endif
1410 <
1410 >    
1411      if (!doAllPairs) {
1412   #ifdef IS_MPI
1413 <
1413 >      
1414        for (int i = 0; i < nGroupsInRow_; i++) {
1415          rs = cgRowData.position[i];
1416          
1417          // scaled positions relative to the box vectors
1418 <        scaled = invHmat * rs;
1418 >        scaled = invBox * rs;
1419          
1420          // wrap the vector back into the unit box by subtracting integer box
1421          // numbers
1422          for (int j = 0; j < 3; j++) {
1423            scaled[j] -= roundMe(scaled[j]);
1424            scaled[j] += 0.5;
1425 +          // Handle the special case when an object is exactly on the
1426 +          // boundary (a scaled coordinate of 1.0 is the same as
1427 +          // scaled coordinate of 0.0)
1428 +          if (scaled[j] >= 1.0) scaled[j] -= 1.0;
1429          }
1430          
1431          // find xyz-indices of cell that cutoffGroup is in.
# Line 1350 | Line 1443 | namespace OpenMD {
1443          rs = cgColData.position[i];
1444          
1445          // scaled positions relative to the box vectors
1446 <        scaled = invHmat * rs;
1446 >        scaled = invBox * rs;
1447          
1448          // wrap the vector back into the unit box by subtracting integer box
1449          // numbers
1450          for (int j = 0; j < 3; j++) {
1451            scaled[j] -= roundMe(scaled[j]);
1452            scaled[j] += 0.5;
1453 +          // Handle the special case when an object is exactly on the
1454 +          // boundary (a scaled coordinate of 1.0 is the same as
1455 +          // scaled coordinate of 0.0)
1456 +          if (scaled[j] >= 1.0) scaled[j] -= 1.0;
1457          }
1458          
1459          // find xyz-indices of cell that cutoffGroup is in.
# Line 1370 | Line 1467 | namespace OpenMD {
1467          // add this cutoff group to the list of groups in this cell;
1468          cellListCol_[cellIndex].push_back(i);
1469        }
1470 <    
1470 >      
1471   #else
1472        for (int i = 0; i < nGroups_; i++) {
1473          rs = snap_->cgData.position[i];
1474          
1475          // scaled positions relative to the box vectors
1476 <        scaled = invHmat * rs;
1476 >        scaled = invBox * rs;
1477          
1478          // wrap the vector back into the unit box by subtracting integer box
1479          // numbers
1480          for (int j = 0; j < 3; j++) {
1481            scaled[j] -= roundMe(scaled[j]);
1482            scaled[j] += 0.5;
1483 +          // Handle the special case when an object is exactly on the
1484 +          // boundary (a scaled coordinate of 1.0 is the same as
1485 +          // scaled coordinate of 0.0)
1486 +          if (scaled[j] >= 1.0) scaled[j] -= 1.0;
1487          }
1488          
1489          // find xyz-indices of cell that cutoffGroup is in.
# Line 1441 | Line 1542 | namespace OpenMD {
1542                    // & column indicies and will divide labor in the
1543                    // force evaluation later.
1544                    dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)];
1545 <                  snap_->wrapVector(dr);
1546 <                  cuts = getGroupCutoffs( (*j1), (*j2) );
1547 <                  if (dr.lengthSquare() < cuts.third) {
1545 >                  if (usePeriodicBoundaryConditions_) {
1546 >                    snap_->wrapVector(dr);
1547 >                  }
1548 >                  getGroupCutoffs( (*j1), (*j2), rcut, rcutsq, rlistsq );
1549 >                  if (dr.lengthSquare() < rlistsq) {
1550                      neighborList.push_back(make_pair((*j1), (*j2)));
1551                    }                  
1552                  }
# Line 1463 | Line 1566 | namespace OpenMD {
1566                    // allows atoms within a single cutoff group to
1567                    // interact with each other.
1568  
1466
1467
1569                    if (m2 != m1 || (*j2) >= (*j1) ) {
1570  
1571                      dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)];
1572 <                    snap_->wrapVector(dr);
1573 <                    cuts = getGroupCutoffs( (*j1), (*j2) );
1574 <                    if (dr.lengthSquare() < cuts.third) {
1572 >                    if (usePeriodicBoundaryConditions_) {
1573 >                      snap_->wrapVector(dr);
1574 >                    }
1575 >                    getGroupCutoffs( (*j1), (*j2), rcut, rcutsq, rlistsq );
1576 >                    if (dr.lengthSquare() < rlistsq) {
1577                        neighborList.push_back(make_pair((*j1), (*j2)));
1578                      }
1579                    }
# Line 1487 | Line 1590 | namespace OpenMD {
1590        for (int j1 = 0; j1 < nGroupsInRow_; j1++) {
1591          for (int j2 = 0; j2 < nGroupsInCol_; j2++) {    
1592            dr = cgColData.position[j2] - cgRowData.position[j1];
1593 <          snap_->wrapVector(dr);
1594 <          cuts = getGroupCutoffs( j1, j2 );
1595 <          if (dr.lengthSquare() < cuts.third) {
1593 >          if (usePeriodicBoundaryConditions_) {
1594 >            snap_->wrapVector(dr);
1595 >          }
1596 >          getGroupCutoffs( j1, j2, rcut, rcutsq, rlistsq);
1597 >          if (dr.lengthSquare() < rlistsq) {
1598              neighborList.push_back(make_pair(j1, j2));
1599            }
1600          }
# Line 1500 | Line 1605 | namespace OpenMD {
1605          // include self group interactions j2 == j1
1606          for (int j2 = j1; j2 < nGroups_; j2++) {
1607            dr = snap_->cgData.position[j2] - snap_->cgData.position[j1];
1608 <          snap_->wrapVector(dr);
1609 <          cuts = getGroupCutoffs( j1, j2 );
1610 <          if (dr.lengthSquare() < cuts.third) {
1608 >          if (usePeriodicBoundaryConditions_) {
1609 >            snap_->wrapVector(dr);
1610 >          }
1611 >          getGroupCutoffs( j1, j2, rcut, rcutsq, rlistsq );
1612 >          if (dr.lengthSquare() < rlistsq) {
1613              neighborList.push_back(make_pair(j1, j2));
1614            }
1615          }    
# Line 1515 | Line 1622 | namespace OpenMD {
1622      saved_CG_positions_.clear();
1623      for (int i = 0; i < nGroups_; i++)
1624        saved_CG_positions_.push_back(snap_->cgData.position[i]);
1518    
1519    return neighborList;
1625    }
1626   } //end namespace OpenMD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines