42 |
|
#include "parallel/Communicator.hpp" |
43 |
|
#include "math/SquareMatrix3.hpp" |
44 |
|
|
45 |
+ |
using namespace std; |
46 |
|
namespace OpenMD { |
47 |
|
|
48 |
|
void ForceDecomposition::distributeInitialData() { |
49 |
|
#ifdef IS_MPI |
50 |
+ |
Snapshot* snap = sman_->getCurrentSnapshot(); |
51 |
+ |
int nAtoms = snap->getNumberOfAtoms(); |
52 |
+ |
int nGroups = snap->getNumberOfCutoffGroups(); |
53 |
|
|
50 |
– |
int nAtoms; |
51 |
– |
int nGroups; |
52 |
– |
|
54 |
|
AtomCommRealI = new Communicator<Row,RealType>(nAtoms); |
55 |
|
AtomCommVectorI = new Communicator<Row,Vector3d>(nAtoms); |
56 |
|
AtomCommMatrixI = new Communicator<Row,Mat3x3d>(nAtoms); |
61 |
|
|
62 |
|
cgCommVectorI = new Communicator<Row,Vector3d>(nGroups); |
63 |
|
cgCommVectorJ = new Communicator<Column,Vector3d>(nGroups); |
64 |
< |
// more to come |
64 |
> |
|
65 |
> |
int nInRow = AtomCommRealI.getSize(); |
66 |
> |
int nInCol = AtomCommRealJ.getSize(); |
67 |
> |
|
68 |
> |
vector<vector<RealType> > pot_row(LR_POT_TYPES, |
69 |
> |
vector<RealType> (nInRow, 0.0)); |
70 |
> |
vector<vector<RealType> > pot_col(LR_POT_TYPES, |
71 |
> |
vector<RealType> (nInCol, 0.0)); |
72 |
> |
|
73 |
> |
vector<vector<RealType> > pot_local(LR_POT_TYPES, |
74 |
> |
vector<RealType> (nAtoms, 0.0)); |
75 |
> |
|
76 |
|
#endif |
77 |
|
} |
78 |
|
|
117 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
118 |
|
|
119 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslDensity) { |
120 |
+ |
|
121 |
|
AtomCommRealI->scatter(snap->atomIData.density, |
122 |
|
snap->atomData.density); |
123 |
< |
std::vector<RealType> rho_tmp; |
124 |
< |
int n = snap->getNumberOfAtoms(); |
125 |
< |
rho_tmp.reserve( n ); |
123 |
> |
|
124 |
> |
int n = snap->atomData.density.size(); |
125 |
> |
std::vector<RealType> rho_tmp(n, 0.0); |
126 |
|
AtomCommRealJ->scatter(snap->atomJData.density, rho_tmp); |
127 |
|
for (int i = 0; i < n; i++) |
128 |
|
snap->atomData.density[i] += rho_tmp[i]; |
153 |
|
void ForceDecomposition::collectData() { |
154 |
|
#ifdef IS_MPI |
155 |
|
Snapshot* snap = sman_->getCurrentSnapshot(); |
143 |
– |
int n = snap->getNumberOfAtoms(); |
144 |
– |
|
145 |
– |
std::vector<Vector3d> frc_tmp; |
146 |
– |
frc_tmp.reserve( n ); |
156 |
|
|
157 |
+ |
int n = snap->atomData.force.size(); |
158 |
+ |
std::vector<Vector3d> frc_tmp(n, 0.0); |
159 |
+ |
|
160 |
|
AtomCommVectorI->scatter(snap->atomIData.force, frc_tmp); |
161 |
< |
for (int i = 0; i < n; i++) |
161 |
> |
for (int i = 0; i < n; i++) { |
162 |
|
snap->atomData.force[i] += frc_tmp[i]; |
163 |
+ |
frc_tmp[i] = 0.0; |
164 |
+ |
} |
165 |
|
|
166 |
|
AtomCommVectorJ->scatter(snap->atomJData.force, frc_tmp); |
167 |
|
for (int i = 0; i < n; i++) |
169 |
|
|
170 |
|
|
171 |
|
if (snap->atomData.getStorageLayout() & DataStorage::dslTorque) { |
172 |
< |
std::vector<Vector3d> trq_tmp; |
173 |
< |
trq_tmp.reserve( n ); |
174 |
< |
|
172 |
> |
|
173 |
> |
int nt = snap->atomData.force.size(); |
174 |
> |
std::vector<Vector3d> trq_tmp(nt, 0.0); |
175 |
> |
|
176 |
|
AtomCommVectorI->scatter(snap->atomIData.torque, trq_tmp); |
177 |
< |
for (int i = 0; i < n; i++) |
177 |
> |
for (int i = 0; i < n; i++) { |
178 |
|
snap->atomData.torque[i] += trq_tmp[i]; |
179 |
+ |
trq_tmp[i] = 0.0; |
180 |
+ |
} |
181 |
|
|
182 |
|
AtomCommVectorJ->scatter(snap->atomJData.torque, trq_tmp); |
183 |
|
for (int i = 0; i < n; i++) |
184 |
|
snap->atomData.torque[i] += trq_tmp[i]; |
185 |
|
} |
186 |
|
|
170 |
– |
// Still need pot! |
187 |
|
|
188 |
+ |
vector<vector<RealType> > pot_temp(LR_POT_TYPES, |
189 |
+ |
vector<RealType> (nAtoms, 0.0)); |
190 |
+ |
|
191 |
+ |
for (int i = 0; i < LR_POT_TYPES; i++) { |
192 |
+ |
AtomCommRealI->scatter(pot_row[i], pot_temp[i]); |
193 |
+ |
for (int ii = 0; ii < pot_temp[i].size(); ii++ ) { |
194 |
+ |
pot_local[i] += pot_temp[i][ii]; |
195 |
+ |
} |
196 |
+ |
} |
197 |
+ |
|
198 |
|
|
199 |
|
|
200 |
|
#endif |