# | Line 42 | Line 42 | |
---|---|---|
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 | ||
54 | < | int nAtoms; |
55 | < | int nGroups; |
54 | > | AtomCommRealI = new Communicator<Row,RealType>(nAtoms); |
55 | > | AtomCommVectorI = new Communicator<Row,Vector3d>(nAtoms); |
56 | > | AtomCommMatrixI = new Communicator<Row,Mat3x3d>(nAtoms); |
57 | ||
58 | < | AtomCommRealI = new Comm<I,RealType>(nAtoms); |
59 | < | AtomCommVectorI = new Comm<I,Vector3d>(nAtoms); |
60 | < | AtomCommMatrixI = new Comm<I,Mat3x3d>(nAtoms); |
58 | > | AtomCommRealJ = new Communicator<Column,RealType>(nAtoms); |
59 | > | AtomCommVectorJ = new Communicator<Column,Vector3d>(nAtoms); |
60 | > | AtomCommMatrixJ = new Communicator<Column,Mat3x3d>(nAtoms); |
61 | ||
62 | < | AtomCommRealJ = new Comm<J,RealType>(nAtoms); |
63 | < | AtomCommVectorJ = new Comm<J,Vector3d>(nAtoms); |
59 | < | AtomCommMatrixJ = new Comm<J,Mat3x3d>(nAtoms); |
62 | > | cgCommVectorI = new Communicator<Row,Vector3d>(nGroups); |
63 | > | cgCommVectorJ = new Communicator<Column,Vector3d>(nGroups); |
64 | ||
65 | < | cgCommVectorI = new Comm<I,Vector3d>(nGroups); |
66 | < | cgCommVectorJ = new Comm<J,Vector3d>(nGroups); |
67 | < | // more to come |
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 | ||
# | Line 69 | Line 81 | namespace OpenMD { | |
81 | void ForceDecomposition::distributeData() { | |
82 | #ifdef IS_MPI | |
83 | Snapshot* snap = sman_->getCurrentSnapshot(); | |
84 | < | |
84 | > | |
85 | // gather up the atomic positions | |
86 | AtomCommVectorI->gather(snap->atomData.position, | |
87 | snap->atomIData.position); | |
88 | AtomCommVectorJ->gather(snap->atomData.position, | |
89 | < | snap->atomJData.position); |
89 | > | snap->atomJData.position); |
90 | ||
91 | // gather up the cutoff group positions | |
92 | cgCommVectorI->gather(snap->cgData.position, | |
93 | < | snap->cgIData.position); |
93 | > | snap->cgIData.position); |
94 | cgCommVectorJ->gather(snap->cgData.position, | |
95 | < | snap->cgJData.position); |
95 | > | snap->cgJData.position); |
96 | ||
97 | // if needed, gather the atomic rotation matrices | |
98 | if (snap->atomData.getStorageLayout() & DataStorage::dslAmat) { | |
99 | AtomCommMatrixI->gather(snap->atomData.aMat, | |
100 | < | snap->atomIData.aMat); |
100 | > | snap->atomIData.aMat); |
101 | AtomCommMatrixJ->gather(snap->atomData.aMat, | |
102 | < | snap->atomJData.aMat); |
102 | > | snap->atomJData.aMat); |
103 | } | |
104 | ||
105 | // if needed, gather the atomic eletrostatic frames | |
106 | if (snap->atomData.getStorageLayout() & DataStorage::dslElectroFrame) { | |
107 | AtomCommMatrixI->gather(snap->atomData.electroFrame, | |
108 | < | snap->atomIData.electroFrame); |
108 | > | snap->atomIData.electroFrame); |
109 | AtomCommMatrixJ->gather(snap->atomData.electroFrame, | |
110 | < | snap->atomJData.electroFrame); |
110 | > | snap->atomJData.electroFrame); |
111 | } | |
112 | #endif | |
113 | } | |
# | Line 103 | Line 115 | namespace OpenMD { | |
115 | void ForceDecomposition::collectIntermediateData() { | |
116 | #ifdef IS_MPI | |
117 | Snapshot* snap = sman_->getCurrentSnapshot(); | |
106 | – | // gather up the atomic positions |
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 ); |
122 | > | snap->atomData.density); |
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]; | |
# | Line 123 | Line 135 | namespace OpenMD { | |
135 | Snapshot* snap = sman_->getCurrentSnapshot(); | |
136 | if (snap->atomData.getStorageLayout() & DataStorage::dslFunctional) { | |
137 | AtomCommRealI->gather(snap->atomData.functional, | |
138 | < | snap->atomIData.functional); |
138 | > | snap->atomIData.functional); |
139 | AtomCommRealJ->gather(snap->atomData.functional, | |
140 | < | snap->atomJData.functional); |
140 | > | snap->atomJData.functional); |
141 | } | |
142 | ||
143 | if (snap->atomData.getStorageLayout() & DataStorage::dslFunctionalDerivative) { | |
144 | AtomCommRealI->gather(snap->atomData.functionalDerivative, | |
145 | < | snap->atomIData.functionalDerivative); |
145 | > | snap->atomIData.functionalDerivative); |
146 | AtomCommRealJ->gather(snap->atomData.functionalDerivative, | |
147 | < | snap->atomJData.functionalDerivative); |
147 | > | snap->atomJData.functionalDerivative); |
148 | } | |
149 | #endif | |
150 | } | |
# | Line 140 | Line 152 | namespace OpenMD { | |
152 | ||
153 | void ForceDecomposition::collectData() { | |
154 | #ifdef IS_MPI | |
155 | + | Snapshot* snap = sman_->getCurrentSnapshot(); |
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++) { |
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++) |
168 | + | snap->atomData.force[i] += frc_tmp[i]; |
169 | + | |
170 | + | |
171 | + | if (snap->atomData.getStorageLayout() & DataStorage::dslTorque) { |
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++) { |
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 | + | |
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 | |
201 | } | |
202 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |