# | 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 118 | Line 119 | namespace OpenMD { | |
119 | ||
120 | #ifdef IS_MPI | |
121 | ||
122 | < | MPI::Intracomm row = rowComm.getComm(); |
123 | < | MPI::Intracomm col = colComm.getComm(); |
122 | > | MPI_Comm row = rowComm.getComm(); |
123 | > | MPI_Comm col = colComm.getComm(); |
124 | ||
125 | AtomPlanIntRow = new Plan<int>(row, nLocal_); | |
126 | AtomPlanRealRow = new Plan<RealType>(row, nLocal_); | |
# | 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_); | |
# | 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; | |
324 | int atid; | |
# | Line 413 | Line 424 | namespace OpenMD { | |
424 | gTypeCutoffs.end()); | |
425 | ||
426 | #ifdef IS_MPI | |
427 | < | MPI::COMM_WORLD.Allreduce(&groupMax, &groupMax, 1, MPI::REALTYPE, |
428 | < | MPI::MAX); |
427 | > | MPI_Allreduce(&groupMax, &groupMax, 1, MPI_REALTYPE, |
428 | > | MPI_MAX, MPI_COMM_WORLD); |
429 | #endif | |
430 | ||
431 | RealType tradRcut = groupMax; | |
432 | ||
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_) { | |
# | Line 442 | Line 462 | namespace OpenMD { | |
462 | break; | |
463 | } | |
464 | ||
465 | < | pair<int,int> key = make_pair(i,j); |
446 | < | 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 463 | 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 472 | 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 (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 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 784 | Line 814 | namespace OpenMD { | |
814 | for (int i = 0; i < nq; i++) | |
815 | snap_->atomData.flucQFrc[i] += fqfrc_tmp[i]; | |
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 869 | Line 916 | namespace OpenMD { | |
916 | for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { | |
917 | RealType ploc1 = pairwisePot[ii]; | |
918 | RealType ploc2 = 0.0; | |
919 | < | MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM); |
919 | > | MPI_Allreduce(&ploc1, &ploc2, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
920 | pairwisePot[ii] = ploc2; | |
921 | } | |
922 | ||
923 | for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { | |
924 | RealType ploc1 = excludedPot[ii]; | |
925 | RealType ploc2 = 0.0; | |
926 | < | MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM); |
926 | > | MPI_Allreduce(&ploc1, &ploc2, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
927 | excludedPot[ii] = ploc2; | |
928 | } | |
929 | ||
930 | // Here be dragons. | |
931 | < | MPI::Intracomm col = colComm.getComm(); |
931 | > | MPI_Comm col = colComm.getComm(); |
932 | ||
933 | < | col.Allreduce(MPI::IN_PLACE, |
933 | > | MPI_Allreduce(MPI_IN_PLACE, |
934 | &snap_->frameData.conductiveHeatFlux[0], 3, | |
935 | < | MPI::REALTYPE, MPI::SUM); |
935 | > | MPI_REALTYPE, MPI_SUM, col); |
936 | ||
937 | ||
938 | #endif | |
# | Line 904 | Line 951 | namespace OpenMD { | |
951 | for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { | |
952 | RealType ploc1 = embeddingPot[ii]; | |
953 | RealType ploc2 = 0.0; | |
954 | < | MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM); |
954 | > | MPI_Allreduce(&ploc1, &ploc2, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
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); |
960 | > | MPI_Allreduce(&ploc1, &ploc2, 1, MPI_REALTYPE, MPI_SUM, MPI_COMM_WORLD); |
961 | excludedSelfPot[ii] = ploc2; | |
962 | } | |
963 | #endif | |
# | Line 919 | Line 966 | namespace OpenMD { | |
966 | ||
967 | ||
968 | ||
969 | < | int ForceMatrixDecomposition::getNAtomsInRow() { |
969 | > | int& ForceMatrixDecomposition::getNAtomsInRow() { |
970 | #ifdef IS_MPI | |
971 | return nAtomsInRow_; | |
972 | #else | |
# | Line 930 | 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 938 | 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 955 | 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 967 | 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 985 | 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 998 | 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 1011 | 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 1028 | 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 1123 | Line 1175 | namespace OpenMD { | |
1175 | idat.excluded = excludeAtomPair(atom1, atom2); | |
1176 | ||
1177 | #ifdef IS_MPI | |
1178 | < | idat.atypes = make_pair( atypesRow[atom1], atypesCol[atom2]); |
1179 | < | //idat.atypes = make_pair( ff_->getAtomType(identsRow[atom1]), |
1180 | < | // ff_->getAtomType(identsCol[atom2]) ); |
1181 | < | |
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 | > | } else { |
1185 | > | idat.sameRegion = false; |
1186 | > | } |
1187 | > | |
1188 | if (storageLayout_ & DataStorage::dslAmat) { | |
1189 | idat.A1 = &(atomRowData.aMat[atom1]); | |
1190 | idat.A2 = &(atomColData.aMat[atom2]); | |
1191 | } | |
1192 | ||
1135 | – | if (storageLayout_ & DataStorage::dslElectroFrame) { |
1136 | – | idat.eFrame1 = &(atomRowData.electroFrame[atom1]); |
1137 | – | idat.eFrame2 = &(atomColData.electroFrame[atom2]); |
1138 | – | } |
1139 | – | |
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 1174 | Line 1237 | namespace OpenMD { | |
1237 | ||
1238 | #else | |
1239 | ||
1240 | < | idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]); |
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 | + | } else { |
1247 | + | idat.sameRegion = false; |
1248 | + | } |
1249 | + | |
1250 | if (storageLayout_ & DataStorage::dslAmat) { | |
1251 | idat.A1 = &(snap_->atomData.aMat[atom1]); | |
1252 | idat.A2 = &(snap_->atomData.aMat[atom2]); | |
1253 | } | |
1254 | ||
1184 | – | if (storageLayout_ & DataStorage::dslElectroFrame) { |
1185 | – | idat.eFrame1 = &(snap_->atomData.electroFrame[atom1]); |
1186 | – | idat.eFrame2 = &(snap_->atomData.electroFrame[atom2]); |
1187 | – | } |
1188 | – | |
1255 | if (storageLayout_ & DataStorage::dslTorque) { | |
1256 | idat.t1 = &(snap_->atomData.torque[atom1]); | |
1257 | idat.t2 = &(snap_->atomData.torque[atom2]); | |
1258 | } | |
1259 | ||
1260 | + | if (storageLayout_ & DataStorage::dslDipole) { |
1261 | + | idat.dipole1 = &(snap_->atomData.dipole[atom1]); |
1262 | + | idat.dipole2 = &(snap_->atomData.dipole[atom2]); |
1263 | + | } |
1264 | + | |
1265 | + | if (storageLayout_ & DataStorage::dslQuadrupole) { |
1266 | + | idat.quadrupole1 = &(snap_->atomData.quadrupole[atom1]); |
1267 | + | idat.quadrupole2 = &(snap_->atomData.quadrupole[atom2]); |
1268 | + | } |
1269 | + | |
1270 | if (storageLayout_ & DataStorage::dslDensity) { | |
1271 | idat.rho1 = &(snap_->atomData.density[atom1]); | |
1272 | idat.rho2 = &(snap_->atomData.density[atom2]); | |
# | Line 1281 | Line 1357 | namespace OpenMD { | |
1357 | * first element of pair is row-indexed CutoffGroup | |
1358 | * second element of pair is column-indexed CutoffGroup | |
1359 | */ | |
1360 | < | vector<pair<int, int> > ForceMatrixDecomposition::buildNeighborList() { |
1361 | < | |
1362 | < | vector<pair<int, int> > neighborList; |
1360 | > | void ForceMatrixDecomposition::buildNeighborList(vector<pair<int,int> >& neighborList) { |
1361 | > | |
1362 | > | neighborList.clear(); |
1363 | groupCutoffs cuts; | |
1364 | bool doAllPairs = false; | |
1365 | ||
1366 | + | RealType rList_ = (largestRcut_ + skinThickness_); |
1367 | + | RealType rcut, rcutsq, rlistsq; |
1368 | + | Snapshot* snap_ = sman_->getCurrentSnapshot(); |
1369 | + | Mat3x3d box; |
1370 | + | Mat3x3d invBox; |
1371 | + | |
1372 | + | Vector3d rs, scaled, dr; |
1373 | + | Vector3i whichCell; |
1374 | + | int cellIndex; |
1375 | + | |
1376 | #ifdef IS_MPI | |
1377 | cellListRow_.clear(); | |
1378 | cellListCol_.clear(); | |
1379 | #else | |
1380 | cellList_.clear(); | |
1381 | #endif | |
1382 | < | |
1383 | < | RealType rList_ = (largestRcut_ + skinThickness_); |
1384 | < | Snapshot* snap_ = sman_->getCurrentSnapshot(); |
1385 | < | Mat3x3d Hmat = snap_->getHmat(); |
1386 | < | Vector3d Hx = Hmat.getColumn(0); |
1387 | < | Vector3d Hy = Hmat.getColumn(1); |
1388 | < | Vector3d Hz = Hmat.getColumn(2); |
1389 | < | |
1390 | < | nCells_.x() = (int) ( Hx.length() )/ rList_; |
1391 | < | nCells_.y() = (int) ( Hy.length() )/ rList_; |
1392 | < | nCells_.z() = (int) ( Hz.length() )/ rList_; |
1393 | < | |
1382 | > | |
1383 | > | if (!usePeriodicBoundaryConditions_) { |
1384 | > | box = snap_->getBoundingBox(); |
1385 | > | invBox = snap_->getInvBoundingBox(); |
1386 | > | } else { |
1387 | > | box = snap_->getHmat(); |
1388 | > | invBox = snap_->getInvHmat(); |
1389 | > | } |
1390 | > | |
1391 | > | Vector3d boxX = box.getColumn(0); |
1392 | > | Vector3d boxY = box.getColumn(1); |
1393 | > | Vector3d boxZ = box.getColumn(2); |
1394 | > | |
1395 | > | nCells_.x() = int( boxX.length() / rList_ ); |
1396 | > | nCells_.y() = int( boxY.length() / rList_ ); |
1397 | > | nCells_.z() = int( boxZ.length() / rList_ ); |
1398 | > | |
1399 | // handle small boxes where the cell offsets can end up repeating cells | |
1400 | ||
1401 | if (nCells_.x() < 3) doAllPairs = true; | |
1402 | if (nCells_.y() < 3) doAllPairs = true; | |
1403 | if (nCells_.z() < 3) doAllPairs = true; | |
1404 | < | |
1314 | < | Mat3x3d invHmat = snap_->getInvHmat(); |
1315 | < | Vector3d rs, scaled, dr; |
1316 | < | Vector3i whichCell; |
1317 | < | int cellIndex; |
1404 | > | |
1405 | int nCtot = nCells_.x() * nCells_.y() * nCells_.z(); | |
1406 | < | |
1406 | > | |
1407 | #ifdef IS_MPI | |
1408 | cellListRow_.resize(nCtot); | |
1409 | cellListCol_.resize(nCtot); | |
1410 | #else | |
1411 | cellList_.resize(nCtot); | |
1412 | #endif | |
1413 | < | |
1413 | > | |
1414 | if (!doAllPairs) { | |
1415 | #ifdef IS_MPI | |
1416 | < | |
1416 | > | |
1417 | for (int i = 0; i < nGroupsInRow_; i++) { | |
1418 | rs = cgRowData.position[i]; | |
1419 | ||
1420 | // scaled positions relative to the box vectors | |
1421 | < | scaled = invHmat * rs; |
1421 | > | scaled = invBox * rs; |
1422 | ||
1423 | // wrap the vector back into the unit box by subtracting integer box | |
1424 | // numbers | |
# | Line 1359 | Line 1446 | namespace OpenMD { | |
1446 | rs = cgColData.position[i]; | |
1447 | ||
1448 | // scaled positions relative to the box vectors | |
1449 | < | scaled = invHmat * rs; |
1449 | > | scaled = invBox * rs; |
1450 | ||
1451 | // wrap the vector back into the unit box by subtracting integer box | |
1452 | // numbers | |
# | Line 1383 | Line 1470 | namespace OpenMD { | |
1470 | // add this cutoff group to the list of groups in this cell; | |
1471 | cellListCol_[cellIndex].push_back(i); | |
1472 | } | |
1473 | < | |
1473 | > | |
1474 | #else | |
1475 | for (int i = 0; i < nGroups_; i++) { | |
1476 | rs = snap_->cgData.position[i]; | |
1477 | ||
1478 | // scaled positions relative to the box vectors | |
1479 | < | scaled = invHmat * rs; |
1479 | > | scaled = invBox * rs; |
1480 | ||
1481 | // wrap the vector back into the unit box by subtracting integer box | |
1482 | // numbers | |
# | Line 1403 | Line 1490 | namespace OpenMD { | |
1490 | } | |
1491 | ||
1492 | // find xyz-indices of cell that cutoffGroup is in. | |
1493 | < | whichCell.x() = nCells_.x() * scaled.x(); |
1494 | < | whichCell.y() = nCells_.y() * scaled.y(); |
1495 | < | whichCell.z() = nCells_.z() * scaled.z(); |
1493 | > | whichCell.x() = int(nCells_.x() * scaled.x()); |
1494 | > | whichCell.y() = int(nCells_.y() * scaled.y()); |
1495 | > | whichCell.z() = int(nCells_.z() * scaled.z()); |
1496 | ||
1497 | // find single index of this cell: | |
1498 | cellIndex = Vlinear(whichCell, nCells_); | |
# | Line 1458 | Line 1545 | namespace OpenMD { | |
1545 | // & column indicies and will divide labor in the | |
1546 | // force evaluation later. | |
1547 | dr = cgColData.position[(*j2)] - cgRowData.position[(*j1)]; | |
1548 | < | snap_->wrapVector(dr); |
1549 | < | cuts = getGroupCutoffs( (*j1), (*j2) ); |
1550 | < | if (dr.lengthSquare() < cuts.third) { |
1548 | > | if (usePeriodicBoundaryConditions_) { |
1549 | > | snap_->wrapVector(dr); |
1550 | > | } |
1551 | > | getGroupCutoffs( (*j1), (*j2), rcut, rcutsq, rlistsq ); |
1552 | > | if (dr.lengthSquare() < rlistsq) { |
1553 | neighborList.push_back(make_pair((*j1), (*j2))); | |
1554 | } | |
1555 | } | |
# | Line 1480 | Line 1569 | namespace OpenMD { | |
1569 | // allows atoms within a single cutoff group to | |
1570 | // interact with each other. | |
1571 | ||
1483 | – | |
1484 | – | |
1572 | if (m2 != m1 || (*j2) >= (*j1) ) { | |
1573 | ||
1574 | dr = snap_->cgData.position[(*j2)] - snap_->cgData.position[(*j1)]; | |
1575 | < | snap_->wrapVector(dr); |
1576 | < | cuts = getGroupCutoffs( (*j1), (*j2) ); |
1577 | < | if (dr.lengthSquare() < cuts.third) { |
1575 | > | if (usePeriodicBoundaryConditions_) { |
1576 | > | snap_->wrapVector(dr); |
1577 | > | } |
1578 | > | getGroupCutoffs( (*j1), (*j2), rcut, rcutsq, rlistsq ); |
1579 | > | if (dr.lengthSquare() < rlistsq) { |
1580 | neighborList.push_back(make_pair((*j1), (*j2))); | |
1581 | } | |
1582 | } | |
# | Line 1504 | Line 1593 | namespace OpenMD { | |
1593 | for (int j1 = 0; j1 < nGroupsInRow_; j1++) { | |
1594 | for (int j2 = 0; j2 < nGroupsInCol_; j2++) { | |
1595 | dr = cgColData.position[j2] - cgRowData.position[j1]; | |
1596 | < | snap_->wrapVector(dr); |
1597 | < | cuts = getGroupCutoffs( j1, j2 ); |
1598 | < | if (dr.lengthSquare() < cuts.third) { |
1596 | > | if (usePeriodicBoundaryConditions_) { |
1597 | > | snap_->wrapVector(dr); |
1598 | > | } |
1599 | > | getGroupCutoffs( j1, j2, rcut, rcutsq, rlistsq); |
1600 | > | if (dr.lengthSquare() < rlistsq) { |
1601 | neighborList.push_back(make_pair(j1, j2)); | |
1602 | } | |
1603 | } | |
# | Line 1517 | Line 1608 | namespace OpenMD { | |
1608 | // include self group interactions j2 == j1 | |
1609 | for (int j2 = j1; j2 < nGroups_; j2++) { | |
1610 | dr = snap_->cgData.position[j2] - snap_->cgData.position[j1]; | |
1611 | < | snap_->wrapVector(dr); |
1612 | < | cuts = getGroupCutoffs( j1, j2 ); |
1613 | < | if (dr.lengthSquare() < cuts.third) { |
1611 | > | if (usePeriodicBoundaryConditions_) { |
1612 | > | snap_->wrapVector(dr); |
1613 | > | } |
1614 | > | getGroupCutoffs( j1, j2, rcut, rcutsq, rlistsq ); |
1615 | > | if (dr.lengthSquare() < rlistsq) { |
1616 | neighborList.push_back(make_pair(j1, j2)); | |
1617 | } | |
1618 | } | |
# | Line 1532 | Line 1625 | namespace OpenMD { | |
1625 | saved_CG_positions_.clear(); | |
1626 | for (int i = 0; i < nGroups_; i++) | |
1627 | saved_CG_positions_.push_back(snap_->cgData.position[i]); | |
1535 | – | |
1536 | – | return neighborList; |
1628 | } | |
1629 | } //end namespace OpenMD |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |