95 |
|
storageLayout_ = sman_->getStorageLayout(); |
96 |
|
ff_ = info_->getForceField(); |
97 |
|
nLocal_ = snap_->getNumberOfAtoms(); |
98 |
< |
|
98 |
> |
|
99 |
|
nGroups_ = info_->getNLocalCutoffGroups(); |
100 |
|
// gather the information for atomtype IDs (atids): |
101 |
|
idents = info_->getIdentArray(); |
109 |
|
PairList* oneTwo = info_->getOneTwoInteractions(); |
110 |
|
PairList* oneThree = info_->getOneThreeInteractions(); |
111 |
|
PairList* oneFour = info_->getOneFourInteractions(); |
112 |
< |
|
112 |
> |
|
113 |
> |
if (needVelocities_) |
114 |
> |
snap_->cgData.setStorageLayout(DataStorage::dslPosition | |
115 |
> |
DataStorage::dslVelocity); |
116 |
> |
else |
117 |
> |
snap_->cgData.setStorageLayout(DataStorage::dslPosition); |
118 |
> |
|
119 |
|
#ifdef IS_MPI |
120 |
|
|
121 |
|
MPI::Intracomm row = rowComm.getComm(); |
151 |
|
cgRowData.resize(nGroupsInRow_); |
152 |
|
cgRowData.setStorageLayout(DataStorage::dslPosition); |
153 |
|
cgColData.resize(nGroupsInCol_); |
154 |
< |
cgColData.setStorageLayout(DataStorage::dslPosition); |
155 |
< |
|
154 |
> |
if (needVelocities_) |
155 |
> |
// we only need column velocities if we need them. |
156 |
> |
cgColData.setStorageLayout(DataStorage::dslPosition | |
157 |
> |
DataStorage::dslVelocity); |
158 |
> |
else |
159 |
> |
cgColData.setStorageLayout(DataStorage::dslPosition); |
160 |
> |
|
161 |
|
identsRow.resize(nAtomsInRow_); |
162 |
|
identsCol.resize(nAtomsInCol_); |
163 |
|
|
461 |
|
} |
462 |
|
} |
463 |
|
|
453 |
– |
|
464 |
|
groupCutoffs ForceMatrixDecomposition::getGroupCutoffs(int cg1, int cg2) { |
465 |
|
int i, j; |
466 |
|
#ifdef IS_MPI |
610 |
|
cgPlanVectorColumn->gather(snap_->cgData.position, |
611 |
|
cgColData.position); |
612 |
|
|
613 |
+ |
|
614 |
+ |
|
615 |
+ |
if (needVelocities_) { |
616 |
+ |
// gather up the atomic velocities |
617 |
+ |
AtomPlanVectorColumn->gather(snap_->atomData.velocity, |
618 |
+ |
atomColData.velocity); |
619 |
+ |
|
620 |
+ |
cgPlanVectorColumn->gather(snap_->cgData.velocity, |
621 |
+ |
cgColData.velocity); |
622 |
+ |
} |
623 |
+ |
|
624 |
|
|
625 |
|
// if needed, gather the atomic rotation matrices |
626 |
|
if (storageLayout_ & DataStorage::dslAmat) { |
787 |
|
|
788 |
|
for (int ii = 0; ii < pot_temp.size(); ii++ ) |
789 |
|
pairwisePot += pot_temp[ii]; |
790 |
< |
|
790 |
> |
|
791 |
> |
if (storageLayout_ & DataStorage::dslParticlePot) { |
792 |
> |
// This is the pairwise contribution to the particle pot. The |
793 |
> |
// embedding contribution is added in each of the low level |
794 |
> |
// non-bonded routines. In single processor, this is done in |
795 |
> |
// unpackInteractionData, not in collectData. |
796 |
> |
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
797 |
> |
for (int i = 0; i < nLocal_; i++) { |
798 |
> |
// factor of two is because the total potential terms are divided |
799 |
> |
// by 2 in parallel due to row/ column scatter |
800 |
> |
snap_->atomData.particlePot[i] += 2.0 * pot_temp[i](ii); |
801 |
> |
} |
802 |
> |
} |
803 |
> |
} |
804 |
> |
|
805 |
|
fill(pot_temp.begin(), pot_temp.end(), |
806 |
|
Vector<RealType, N_INTERACTION_FAMILIES> (0.0)); |
807 |
|
|
809 |
|
|
810 |
|
for (int ii = 0; ii < pot_temp.size(); ii++ ) |
811 |
|
pairwisePot += pot_temp[ii]; |
812 |
+ |
|
813 |
+ |
if (storageLayout_ & DataStorage::dslParticlePot) { |
814 |
+ |
// This is the pairwise contribution to the particle pot. The |
815 |
+ |
// embedding contribution is added in each of the low level |
816 |
+ |
// non-bonded routines. In single processor, this is done in |
817 |
+ |
// unpackInteractionData, not in collectData. |
818 |
+ |
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
819 |
+ |
for (int i = 0; i < nLocal_; i++) { |
820 |
+ |
// factor of two is because the total potential terms are divided |
821 |
+ |
// by 2 in parallel due to row/ column scatter |
822 |
+ |
snap_->atomData.particlePot[i] += 2.0 * pot_temp[i](ii); |
823 |
+ |
} |
824 |
+ |
} |
825 |
+ |
} |
826 |
|
|
827 |
+ |
if (storageLayout_ & DataStorage::dslParticlePot) { |
828 |
+ |
int npp = snap_->atomData.particlePot.size(); |
829 |
+ |
vector<RealType> ppot_temp(npp, 0.0); |
830 |
+ |
|
831 |
+ |
// This is the direct or embedding contribution to the particle |
832 |
+ |
// pot. |
833 |
+ |
|
834 |
+ |
AtomPlanRealRow->scatter(atomRowData.particlePot, ppot_temp); |
835 |
+ |
for (int i = 0; i < npp; i++) { |
836 |
+ |
snap_->atomData.particlePot[i] += ppot_temp[i]; |
837 |
+ |
} |
838 |
+ |
|
839 |
+ |
fill(ppot_temp.begin(), ppot_temp.end(), 0.0); |
840 |
+ |
|
841 |
+ |
AtomPlanRealColumn->scatter(atomColData.particlePot, ppot_temp); |
842 |
+ |
for (int i = 0; i < npp; i++) { |
843 |
+ |
snap_->atomData.particlePot[i] += ppot_temp[i]; |
844 |
+ |
} |
845 |
+ |
} |
846 |
+ |
|
847 |
|
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
848 |
|
RealType ploc1 = pairwisePot[ii]; |
849 |
|
RealType ploc2 = 0.0; |
851 |
|
pairwisePot[ii] = ploc2; |
852 |
|
} |
853 |
|
|
854 |
+ |
// Here be dragons. |
855 |
+ |
MPI::Intracomm col = colComm.getComm(); |
856 |
+ |
|
857 |
+ |
col.Allreduce(MPI::IN_PLACE, |
858 |
+ |
&snap_->frameData.conductiveHeatFlux[0], 3, |
859 |
+ |
MPI::REALTYPE, MPI::SUM); |
860 |
+ |
|
861 |
+ |
|
862 |
+ |
#endif |
863 |
+ |
|
864 |
+ |
} |
865 |
+ |
|
866 |
+ |
/** |
867 |
+ |
* Collects information obtained during the post-pair (and embedding |
868 |
+ |
* functional) loops onto local data structures. |
869 |
+ |
*/ |
870 |
+ |
void ForceMatrixDecomposition::collectSelfData() { |
871 |
+ |
snap_ = sman_->getCurrentSnapshot(); |
872 |
+ |
storageLayout_ = sman_->getStorageLayout(); |
873 |
+ |
|
874 |
+ |
#ifdef IS_MPI |
875 |
|
for (int ii = 0; ii < N_INTERACTION_FAMILIES; ii++) { |
876 |
|
RealType ploc1 = embeddingPot[ii]; |
877 |
|
RealType ploc2 = 0.0; |
878 |
|
MPI::COMM_WORLD.Allreduce(&ploc1, &ploc2, 1, MPI::REALTYPE, MPI::SUM); |
879 |
|
embeddingPot[ii] = ploc2; |
880 |
< |
} |
791 |
< |
|
880 |
> |
} |
881 |
|
#endif |
882 |
< |
|
882 |
> |
|
883 |
|
} |
884 |
|
|
885 |
+ |
|
886 |
+ |
|
887 |
|
int ForceMatrixDecomposition::getNAtomsInRow() { |
888 |
|
#ifdef IS_MPI |
889 |
|
return nAtomsInRow_; |
924 |
|
return d; |
925 |
|
} |
926 |
|
|
927 |
+ |
Vector3d ForceMatrixDecomposition::getGroupVelocityColumn(int cg2){ |
928 |
+ |
#ifdef IS_MPI |
929 |
+ |
return cgColData.velocity[cg2]; |
930 |
+ |
#else |
931 |
+ |
return snap_->cgData.velocity[cg2]; |
932 |
+ |
#endif |
933 |
+ |
} |
934 |
|
|
935 |
+ |
Vector3d ForceMatrixDecomposition::getAtomVelocityColumn(int atom2){ |
936 |
+ |
#ifdef IS_MPI |
937 |
+ |
return atomColData.velocity[atom2]; |
938 |
+ |
#else |
939 |
+ |
return snap_->atomData.velocity[atom2]; |
940 |
+ |
#endif |
941 |
+ |
} |
942 |
+ |
|
943 |
+ |
|
944 |
|
Vector3d ForceMatrixDecomposition::getAtomToGroupVectorRow(int atom1, int cg1){ |
945 |
|
|
946 |
|
Vector3d d; |
1006 |
|
* We need to exclude some overcounted interactions that result from |
1007 |
|
* the parallel decomposition. |
1008 |
|
*/ |
1009 |
< |
bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2) { |
1010 |
< |
int unique_id_1, unique_id_2; |
1009 |
> |
bool ForceMatrixDecomposition::skipAtomPair(int atom1, int atom2, int cg1, int cg2) { |
1010 |
> |
int unique_id_1, unique_id_2, group1, group2; |
1011 |
|
|
1012 |
|
#ifdef IS_MPI |
1013 |
|
// in MPI, we have to look up the unique IDs for each atom |
1014 |
|
unique_id_1 = AtomRowToGlobal[atom1]; |
1015 |
|
unique_id_2 = AtomColToGlobal[atom2]; |
1016 |
+ |
group1 = cgRowToGlobal[cg1]; |
1017 |
+ |
group2 = cgColToGlobal[cg2]; |
1018 |
|
#else |
1019 |
|
unique_id_1 = AtomLocalToGlobal[atom1]; |
1020 |
|
unique_id_2 = AtomLocalToGlobal[atom2]; |
1021 |
+ |
group1 = cgLocalToGlobal[cg1]; |
1022 |
+ |
group2 = cgLocalToGlobal[cg2]; |
1023 |
|
#endif |
1024 |
|
|
1025 |
|
if (unique_id_1 == unique_id_2) return true; |
1031 |
|
} else { |
1032 |
|
if ((unique_id_1 + unique_id_2) % 2 == 1) return true; |
1033 |
|
} |
1034 |
+ |
#endif |
1035 |
+ |
|
1036 |
+ |
#ifndef IS_MPI |
1037 |
+ |
if (group1 == group2) { |
1038 |
+ |
if (unique_id_1 < unique_id_2) return true; |
1039 |
+ |
} |
1040 |
|
#endif |
1041 |
|
|
1042 |
|
return false; |
1139 |
|
|
1140 |
|
#else |
1141 |
|
|
1025 |
– |
|
1026 |
– |
// cerr << "atoms = " << atom1 << " " << atom2 << "\n"; |
1027 |
– |
// cerr << "pos1 = " << snap_->atomData.position[atom1] << "\n"; |
1028 |
– |
// cerr << "pos2 = " << snap_->atomData.position[atom2] << "\n"; |
1029 |
– |
|
1142 |
|
idat.atypes = make_pair( atypesLocal[atom1], atypesLocal[atom2]); |
1031 |
– |
//idat.atypes = make_pair( ff_->getAtomType(idents[atom1]), |
1032 |
– |
// ff_->getAtomType(idents[atom2]) ); |
1143 |
|
|
1144 |
|
if (storageLayout_ & DataStorage::dslAmat) { |
1145 |
|
idat.A1 = &(snap_->atomData.aMat[atom1]); |
1199 |
|
atomColData.force[atom2] -= *(idat.f1); |
1200 |
|
|
1201 |
|
if (storageLayout_ & DataStorage::dslFlucQForce) { |
1202 |
< |
atomRowData.flucQFrc[atom1] += *(idat.dVdFQ1); |
1203 |
< |
atomColData.flucQFrc[atom2] += *(idat.dVdFQ2); |
1202 |
> |
atomRowData.flucQFrc[atom1] -= *(idat.dVdFQ1); |
1203 |
> |
atomColData.flucQFrc[atom2] -= *(idat.dVdFQ2); |
1204 |
|
} |
1205 |
|
|
1206 |
|
if (storageLayout_ & DataStorage::dslElectricField) { |
1208 |
|
atomColData.electricField[atom2] += *(idat.eField2); |
1209 |
|
} |
1210 |
|
|
1101 |
– |
// should particle pot be done here also? |
1211 |
|
#else |
1212 |
|
pairwisePot += *(idat.pot); |
1213 |
|
|
1215 |
|
snap_->atomData.force[atom2] -= *(idat.f1); |
1216 |
|
|
1217 |
|
if (idat.doParticlePot) { |
1218 |
+ |
// This is the pairwise contribution to the particle pot. The |
1219 |
+ |
// embedding contribution is added in each of the low level |
1220 |
+ |
// non-bonded routines. In parallel, this calculation is done |
1221 |
+ |
// in collectData, not in unpackInteractionData. |
1222 |
|
snap_->atomData.particlePot[atom1] += *(idat.vpair) * *(idat.sw); |
1223 |
< |
snap_->atomData.particlePot[atom2] -= *(idat.vpair) * *(idat.sw); |
1223 |
> |
snap_->atomData.particlePot[atom2] += *(idat.vpair) * *(idat.sw); |
1224 |
|
} |
1225 |
|
|
1226 |
|
if (storageLayout_ & DataStorage::dslFlucQForce) { |
1227 |
< |
snap_->atomData.flucQFrc[atom1] += *(idat.dVdFQ1); |
1227 |
> |
snap_->atomData.flucQFrc[atom1] -= *(idat.dVdFQ1); |
1228 |
|
snap_->atomData.flucQFrc[atom2] -= *(idat.dVdFQ2); |
1229 |
|
} |
1230 |
|
|