38 |
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
|
* [4] Vardeman & Gezelter, in progress (2009). |
40 |
|
*/ |
41 |
< |
#include "parallel/ForceDecomposition.hpp" |
41 |
> |
#include "parallel/ForceMatrixDecomposition.hpp" |
42 |
|
#include "math/SquareMatrix3.hpp" |
43 |
|
#include "nonbonded/NonBondedInteraction.hpp" |
44 |
|
#include "brains/SnapshotManager.hpp" |
51 |
|
* SimulationSetup |
52 |
|
*/ |
53 |
|
|
54 |
< |
void ForceDecomposition::distributeInitialData() { |
54 |
> |
void ForceMatrixDecomposition::distributeInitialData() { |
55 |
|
#ifdef IS_MPI |
56 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
57 |
|
int nLocal = snap->getNumberOfAtoms(); |
58 |
|
int nGroups = snap->getNumberOfCutoffGroups(); |
59 |
|
|
60 |
< |
AtomCommIntI = new Communicator<Row,int>(nLocal); |
61 |
< |
AtomCommRealI = new Communicator<Row,RealType>(nLocal); |
62 |
< |
AtomCommVectorI = new Communicator<Row,Vector3d>(nLocal); |
63 |
< |
AtomCommMatrixI = new Communicator<Row,Mat3x3d>(nLocal); |
60 |
> |
AtomCommIntRow = new Communicator<Row,int>(nLocal); |
61 |
> |
AtomCommRealRow = new Communicator<Row,RealType>(nLocal); |
62 |
> |
AtomCommVectorRow = new Communicator<Row,Vector3d>(nLocal); |
63 |
> |
AtomCommMatrixRow = new Communicator<Row,Mat3x3d>(nLocal); |
64 |
|
|
65 |
< |
AtomCommIntJ = new Communicator<Column,int>(nLocal); |
66 |
< |
AtomCommRealJ = new Communicator<Column,RealType>(nLocal); |
67 |
< |
AtomCommVectorJ = new Communicator<Column,Vector3d>(nLocal); |
68 |
< |
AtomCommMatrixJ = new Communicator<Column,Mat3x3d>(nLocal); |
65 |
> |
AtomCommIntColumn = new Communicator<Column,int>(nLocal); |
66 |
> |
AtomCommRealColumn = new Communicator<Column,RealType>(nLocal); |
67 |
> |
AtomCommVectorColumn = new Communicator<Column,Vector3d>(nLocal); |
68 |
> |
AtomCommMatrixColumn = new Communicator<Column,Mat3x3d>(nLocal); |
69 |
|
|
70 |
< |
cgCommIntI = new Communicator<Row,int>(nGroups); |
71 |
< |
cgCommVectorI = new Communicator<Row,Vector3d>(nGroups); |
72 |
< |
cgCommIntJ = new Communicator<Column,int>(nGroups); |
73 |
< |
cgCommVectorJ = new Communicator<Column,Vector3d>(nGroups); |
70 |
> |
cgCommIntRow = new Communicator<Row,int>(nGroups); |
71 |
> |
cgCommVectorRow = new Communicator<Row,Vector3d>(nGroups); |
72 |
> |
cgCommIntColumn = new Communicator<Column,int>(nGroups); |
73 |
> |
cgCommVectorColumn = new Communicator<Column,Vector3d>(nGroups); |
74 |
|
|
75 |
< |
int nAtomsInRow = AtomCommIntI->getSize(); |
76 |
< |
int nAtomsInCol = AtomCommIntJ->getSize(); |
77 |
< |
int nGroupsInRow = cgCommIntI->getSize(); |
78 |
< |
int nGroupsInCol = cgCommIntJ->getSize(); |
79 |
< |
|
75 |
> |
int nAtomsInRow = AtomCommIntRow->getSize(); |
76 |
> |
int nAtomsInCol = AtomCommIntColumn->getSize(); |
77 |
> |
int nGroupsInRow = cgCommIntRow->getSize(); |
78 |
> |
int nGroupsInCol = cgCommIntColumn->getSize(); |
79 |
> |
|
80 |
|
vector<vector<RealType> > pot_row(N_INTERACTION_FAMILIES, |
81 |
|
vector<RealType> (nAtomsInRow, 0.0)); |
82 |
|
vector<vector<RealType> > pot_col(N_INTERACTION_FAMILIES, |
83 |
|
vector<RealType> (nAtomsInCol, 0.0)); |
84 |
|
|
85 |
|
vector<RealType> pot_local(N_INTERACTION_FAMILIES, 0.0); |
86 |
< |
|
86 |
> |
|
87 |
|
// gather the information for atomtype IDs (atids): |
88 |
|
vector<int> identsLocal = info_->getIdentArray(); |
89 |
|
identsRow.reserve(nAtomsInRow); |
90 |
|
identsCol.reserve(nAtomsInCol); |
91 |
+ |
|
92 |
+ |
AtomCommIntRow->gather(identsLocal, identsRow); |
93 |
+ |
AtomCommIntColumn->gather(identsLocal, identsCol); |
94 |
+ |
|
95 |
+ |
AtomLocalToGlobal = info_->getGlobalAtomIndices(); |
96 |
+ |
AtomCommIntRow->gather(AtomLocalToGlobal, AtomRowToGlobal); |
97 |
+ |
AtomCommIntColumn->gather(AtomLocalToGlobal, AtomColToGlobal); |
98 |
+ |
|
99 |
+ |
cgLocalToGlobal = info_->getGlobalGroupIndices(); |
100 |
+ |
cgCommIntRow->gather(cgLocalToGlobal, cgRowToGlobal); |
101 |
+ |
cgCommIntColumn->gather(cgLocalToGlobal, cgColToGlobal); |
102 |
|
|
92 |
– |
AtomCommIntI->gather(identsLocal, identsRow); |
93 |
– |
AtomCommIntJ->gather(identsLocal, identsCol); |
94 |
– |
|
95 |
– |
AtomLocalToGlobal = info_->getLocalToGlobalAtomIndex(); |
96 |
– |
AtomCommIntI->gather(AtomLocalToGlobal, AtomRowToGlobal); |
97 |
– |
AtomCommIntJ->gather(AtomLocalToGlobal, AtomColToGlobal); |
98 |
– |
|
99 |
– |
cgLocalToGlobal = info_->getLocalToGlobalCutoffGroupIndex(); |
100 |
– |
cgCommIntI->gather(cgLocalToGlobal, cgRowToGlobal); |
101 |
– |
cgCommIntJ->gather(cgLocalToGlobal, cgColToGlobal); |
102 |
– |
|
103 |
– |
|
104 |
– |
|
103 |
|
// still need: |
104 |
|
// topoDist |
105 |
|
// exclude |
108 |
|
|
109 |
|
|
110 |
|
|
111 |
< |
void ForceDecomposition::distributeData() { |
111 |
> |
void ForceMatrixDecomposition::distributeData() { |
112 |
|
#ifdef IS_MPI |
113 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
114 |
|
|
115 |
|
// gather up the atomic positions |
116 |
< |
AtomCommVectorI->gather(snap->atomData.position, |
116 |
> |
AtomCommVectorRow->gather(snap->atomData.position, |
117 |
|
snap->atomIData.position); |
118 |
< |
AtomCommVectorJ->gather(snap->atomData.position, |
118 |
> |
AtomCommVectorColumn->gather(snap->atomData.position, |
119 |
|
snap->atomJData.position); |
120 |
|
|
121 |
|
// gather up the cutoff group positions |
122 |
< |
cgCommVectorI->gather(snap->cgData.position, |
122 |
> |
cgCommVectorRow->gather(snap->cgData.position, |
123 |
|
snap->cgIData.position); |
124 |
< |
cgCommVectorJ->gather(snap->cgData.position, |
124 |
> |
cgCommVectorColumn->gather(snap->cgData.position, |
125 |
|
snap->cgJData.position); |
126 |
|
|
127 |
|
// if needed, gather the atomic rotation matrices |
128 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslAmat) { |
129 |
< |
AtomCommMatrixI->gather(snap->atomData.aMat, |
129 |
> |
AtomCommMatrixRow->gather(snap->atomData.aMat, |
130 |
|
snap->atomIData.aMat); |
131 |
< |
AtomCommMatrixJ->gather(snap->atomData.aMat, |
131 |
> |
AtomCommMatrixColumn->gather(snap->atomData.aMat, |
132 |
|
snap->atomJData.aMat); |
133 |
|
} |
134 |
|
|
135 |
|
// if needed, gather the atomic eletrostatic frames |
136 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslElectroFrame) { |
137 |
< |
AtomCommMatrixI->gather(snap->atomData.electroFrame, |
137 |
> |
AtomCommMatrixRow->gather(snap->atomData.electroFrame, |
138 |
|
snap->atomIData.electroFrame); |
139 |
< |
AtomCommMatrixJ->gather(snap->atomData.electroFrame, |
139 |
> |
AtomCommMatrixColumn->gather(snap->atomData.electroFrame, |
140 |
|
snap->atomJData.electroFrame); |
141 |
|
} |
142 |
|
#endif |
143 |
|
} |
144 |
|
|
145 |
< |
void ForceDecomposition::collectIntermediateData() { |
145 |
> |
void ForceMatrixDecomposition::collectIntermediateData() { |
146 |
|
#ifdef IS_MPI |
147 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
148 |
|
|
149 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslDensity) { |
150 |
|
|
151 |
< |
AtomCommRealI->scatter(snap->atomIData.density, |
151 |
> |
AtomCommRealRow->scatter(snap->atomIData.density, |
152 |
|
snap->atomData.density); |
153 |
|
|
154 |
|
int n = snap->atomData.density.size(); |
155 |
|
std::vector<RealType> rho_tmp(n, 0.0); |
156 |
< |
AtomCommRealJ->scatter(snap->atomJData.density, rho_tmp); |
156 |
> |
AtomCommRealColumn->scatter(snap->atomJData.density, rho_tmp); |
157 |
|
for (int i = 0; i < n; i++) |
158 |
|
snap->atomData.density[i] += rho_tmp[i]; |
159 |
|
} |
160 |
|
#endif |
161 |
|
} |
162 |
|
|
163 |
< |
void ForceDecomposition::distributeIntermediateData() { |
163 |
> |
void ForceMatrixDecomposition::distributeIntermediateData() { |
164 |
|
#ifdef IS_MPI |
165 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
166 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslFunctional) { |
167 |
< |
AtomCommRealI->gather(snap->atomData.functional, |
167 |
> |
AtomCommRealRow->gather(snap->atomData.functional, |
168 |
|
snap->atomIData.functional); |
169 |
< |
AtomCommRealJ->gather(snap->atomData.functional, |
169 |
> |
AtomCommRealColumn->gather(snap->atomData.functional, |
170 |
|
snap->atomJData.functional); |
171 |
|
} |
172 |
|
|
173 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslFunctionalDerivative) { |
174 |
< |
AtomCommRealI->gather(snap->atomData.functionalDerivative, |
174 |
> |
AtomCommRealRow->gather(snap->atomData.functionalDerivative, |
175 |
|
snap->atomIData.functionalDerivative); |
176 |
< |
AtomCommRealJ->gather(snap->atomData.functionalDerivative, |
176 |
> |
AtomCommRealColumn->gather(snap->atomData.functionalDerivative, |
177 |
|
snap->atomJData.functionalDerivative); |
178 |
|
} |
179 |
|
#endif |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
< |
void ForceDecomposition::collectData() { |
183 |
> |
void ForceMatrixDecomposition::collectData() { |
184 |
|
#ifdef IS_MPI |
185 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
186 |
|
|
187 |
|
int n = snap->atomData.force.size(); |
188 |
|
vector<Vector3d> frc_tmp(n, V3Zero); |
189 |
|
|
190 |
< |
AtomCommVectorI->scatter(snap->atomIData.force, frc_tmp); |
190 |
> |
AtomCommVectorRow->scatter(snap->atomIData.force, frc_tmp); |
191 |
|
for (int i = 0; i < n; i++) { |
192 |
|
snap->atomData.force[i] += frc_tmp[i]; |
193 |
|
frc_tmp[i] = 0.0; |
194 |
|
} |
195 |
|
|
196 |
< |
AtomCommVectorJ->scatter(snap->atomJData.force, frc_tmp); |
196 |
> |
AtomCommVectorColumn->scatter(snap->atomJData.force, frc_tmp); |
197 |
|
for (int i = 0; i < n; i++) |
198 |
|
snap->atomData.force[i] += frc_tmp[i]; |
199 |
|
|
203 |
|
int nt = snap->atomData.force.size(); |
204 |
|
vector<Vector3d> trq_tmp(nt, V3Zero); |
205 |
|
|
206 |
< |
AtomCommVectorI->scatter(snap->atomIData.torque, trq_tmp); |
206 |
> |
AtomCommVectorRow->scatter(snap->atomIData.torque, trq_tmp); |
207 |
|
for (int i = 0; i < n; i++) { |
208 |
|
snap->atomData.torque[i] += trq_tmp[i]; |
209 |
|
trq_tmp[i] = 0.0; |
210 |
|
} |
211 |
|
|
212 |
< |
AtomCommVectorJ->scatter(snap->atomJData.torque, trq_tmp); |
212 |
> |
AtomCommVectorColumn->scatter(snap->atomJData.torque, trq_tmp); |
213 |
|
for (int i = 0; i < n; i++) |
214 |
|
snap->atomData.torque[i] += trq_tmp[i]; |
215 |
|
} |
220 |
|
vector<RealType> (nLocal, 0.0)); |
221 |
|
|
222 |
|
for (int i = 0; i < N_INTERACTION_FAMILIES; i++) { |
223 |
< |
AtomCommRealI->scatter(pot_row[i], pot_temp[i]); |
223 |
> |
AtomCommRealRow->scatter(pot_row[i], pot_temp[i]); |
224 |
|
for (int ii = 0; ii < pot_temp[i].size(); ii++ ) { |
225 |
|
pot_local[i] += pot_temp[i][ii]; |
226 |
|
} |