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). |
39 |
< |
* [4] Vardeman & Gezelter, in progress (2009). |
39 |
> |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
> |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
/** |
49 |
|
*/ |
50 |
|
|
51 |
|
#include "brains/DataStorage.hpp" |
52 |
< |
|
52 |
> |
using namespace std; |
53 |
|
namespace OpenMD { |
54 |
|
|
55 |
|
DataStorage::DataStorage() : size_(0), storageLayout_(0){ |
65 |
|
|
66 |
|
if (storageLayout_ & dslPosition && position.size() != size_) { |
67 |
|
//error |
68 |
< |
std::cerr << "size does not match"<< std::endl; |
68 |
> |
cerr << "size does not match"<< endl; |
69 |
|
} |
70 |
|
|
71 |
|
if (storageLayout_ & dslVelocity && velocity.size() != size_) { |
72 |
|
//error |
73 |
< |
std::cerr << "size does not match"<< std::endl; |
73 |
> |
cerr << "size does not match"<< endl; |
74 |
|
} |
75 |
|
|
76 |
< |
if (storageLayout_ & dslAmat && aMat.size() != size_) { |
76 |
> |
if (storageLayout_ & dslForce && force.size() != size_) { |
77 |
|
//error |
78 |
< |
std::cerr << "size does not match"<< std::endl; |
78 |
> |
cerr << "size does not match"<< endl; |
79 |
|
} |
80 |
|
|
81 |
< |
if (storageLayout_ & dslAngularMomentum && angularMomentum.size() != size_) { |
81 |
> |
if (storageLayout_ & dslAmat && aMat.size() != size_) { |
82 |
|
//error |
83 |
< |
std::cerr << "size does not match"<< std::endl; |
83 |
> |
cerr << "size does not match"<< endl; |
84 |
|
} |
85 |
|
|
86 |
< |
if (storageLayout_ & dslElectroFrame && electroFrame.size() != size_) { |
86 |
> |
if (storageLayout_ & dslAngularMomentum && angularMomentum.size() != size_) { |
87 |
|
//error |
88 |
< |
std::cerr << "size does not match"<< std::endl; |
88 |
> |
cerr << "size does not match"<< endl; |
89 |
|
} |
90 |
|
|
91 |
< |
if (storageLayout_ & dslZAngle && zAngle.size() != size_) { |
91 |
> |
if (storageLayout_ & dslTorque && torque.size() != size_) { |
92 |
|
//error |
93 |
< |
std::cerr << "size does not match"<< std::endl; |
93 |
> |
cerr << "size does not match"<< endl; |
94 |
|
} |
95 |
|
|
96 |
< |
if (storageLayout_ & dslForce && force.size() != size_) { |
96 |
> |
if (storageLayout_ & dslParticlePot && particlePot.size() != size_) { |
97 |
|
//error |
98 |
< |
std::cerr << "size does not match"<< std::endl; |
98 |
> |
cerr << "size does not match"<< endl; |
99 |
|
} |
100 |
|
|
101 |
< |
if (storageLayout_ & dslTorque && torque.size() != size_) { |
101 |
> |
if (storageLayout_ & dslDensity && density.size() != size_) { |
102 |
|
//error |
103 |
< |
std::cerr << "size does not match"<< std::endl; |
103 |
> |
cerr << "size does not match"<< endl; |
104 |
|
} |
105 |
|
|
106 |
< |
if (storageLayout_ & dslParticlePot && particlePot.size() != size_) { |
106 |
> |
if (storageLayout_ & dslFunctional && functional.size() != size_) { |
107 |
|
//error |
108 |
< |
std::cerr << "size does not match"<< std::endl; |
108 |
> |
cerr << "size does not match"<< endl; |
109 |
|
} |
110 |
|
|
111 |
< |
if (storageLayout_ & dslDensity && density.size() != size_) { |
111 |
> |
if (storageLayout_ & dslFunctionalDerivative && functionalDerivative.size() != size_) { |
112 |
|
//error |
113 |
< |
std::cerr << "size does not match"<< std::endl; |
113 |
> |
cerr << "size does not match"<< endl; |
114 |
|
} |
115 |
|
|
116 |
< |
if (storageLayout_ & dslFunctional && functional.size() != size_) { |
116 |
> |
if (storageLayout_ & dslDipole && dipole.size() != size_) { |
117 |
|
//error |
118 |
< |
std::cerr << "size does not match"<< std::endl; |
118 |
> |
cerr << "size does not match"<< endl; |
119 |
|
} |
120 |
|
|
121 |
< |
if (storageLayout_ & dslFunctionalDerivative && functionalDerivative.size() != size_) { |
121 |
> |
if (storageLayout_ & dslQuadrupole && quadrupole.size() != size_) { |
122 |
|
//error |
123 |
< |
std::cerr << "size does not match"<< std::endl; |
123 |
> |
cerr << "size does not match"<< endl; |
124 |
|
} |
125 |
|
|
126 |
|
if (storageLayout_ & dslElectricField && electricField.size() != size_) { |
127 |
|
//error |
128 |
< |
std::cerr << "size does not match"<< std::endl; |
128 |
> |
cerr << "size does not match"<< endl; |
129 |
|
} |
130 |
|
|
131 |
|
if (storageLayout_ & dslSkippedCharge && skippedCharge.size() != size_) { |
132 |
|
//error |
133 |
< |
std::cerr << "size does not match"<< std::endl; |
133 |
> |
cerr << "size does not match"<< endl; |
134 |
|
} |
135 |
+ |
|
136 |
+ |
if (storageLayout_ & dslFlucQPosition && flucQPos.size() != size_) { |
137 |
+ |
//error |
138 |
+ |
cerr << "size does not match"<< endl; |
139 |
+ |
} |
140 |
+ |
|
141 |
+ |
if (storageLayout_ & dslFlucQVelocity && flucQVel.size() != size_) { |
142 |
+ |
//error |
143 |
+ |
cerr << "size does not match"<< endl; |
144 |
+ |
} |
145 |
+ |
|
146 |
+ |
if (storageLayout_ & dslFlucQForce && flucQFrc.size() != size_) { |
147 |
+ |
//error |
148 |
+ |
cerr << "size does not match"<< endl; |
149 |
+ |
} |
150 |
|
|
151 |
|
return size_; |
152 |
|
|
162 |
|
internalResize(velocity, newSize); |
163 |
|
} |
164 |
|
|
165 |
+ |
if (storageLayout_ & dslForce) { |
166 |
+ |
internalResize(force, newSize); |
167 |
+ |
} |
168 |
+ |
|
169 |
|
if (storageLayout_ & dslAmat) { |
170 |
|
internalResize(aMat, newSize); |
171 |
|
} |
173 |
|
if (storageLayout_ & dslAngularMomentum) { |
174 |
|
internalResize(angularMomentum, newSize); |
175 |
|
} |
156 |
– |
|
157 |
– |
if (storageLayout_ & dslElectroFrame) { |
158 |
– |
internalResize(electroFrame, newSize); |
159 |
– |
} |
176 |
|
|
161 |
– |
if (storageLayout_ & dslZAngle) { |
162 |
– |
internalResize(zAngle, newSize); |
163 |
– |
} |
164 |
– |
|
165 |
– |
if (storageLayout_ & dslForce) { |
166 |
– |
internalResize(force, newSize); |
167 |
– |
} |
168 |
– |
|
177 |
|
if (storageLayout_ & dslTorque) { |
178 |
|
internalResize(torque, newSize); |
179 |
|
} |
194 |
|
internalResize(functionalDerivative, newSize); |
195 |
|
} |
196 |
|
|
197 |
+ |
if (storageLayout_ & dslDipole) { |
198 |
+ |
internalResize(dipole, newSize); |
199 |
+ |
} |
200 |
+ |
|
201 |
+ |
if (storageLayout_ & dslQuadrupole) { |
202 |
+ |
internalResize(quadrupole, newSize); |
203 |
+ |
} |
204 |
+ |
|
205 |
|
if (storageLayout_ & dslElectricField) { |
206 |
|
internalResize(electricField, newSize); |
207 |
|
} |
210 |
|
internalResize(skippedCharge, newSize); |
211 |
|
} |
212 |
|
|
213 |
+ |
if (storageLayout_ & dslFlucQPosition) { |
214 |
+ |
internalResize(flucQPos, newSize); |
215 |
+ |
} |
216 |
+ |
|
217 |
+ |
if (storageLayout_ & dslFlucQVelocity) { |
218 |
+ |
internalResize(flucQVel, newSize); |
219 |
+ |
} |
220 |
+ |
|
221 |
+ |
if (storageLayout_ & dslFlucQForce) { |
222 |
+ |
internalResize(flucQFrc, newSize); |
223 |
+ |
} |
224 |
+ |
|
225 |
|
size_ = newSize; |
226 |
|
} |
227 |
|
|
234 |
|
velocity.reserve(size); |
235 |
|
} |
236 |
|
|
237 |
+ |
if (storageLayout_ & dslForce) { |
238 |
+ |
force.reserve(size); |
239 |
+ |
} |
240 |
+ |
|
241 |
|
if (storageLayout_ & dslAmat) { |
242 |
|
aMat.reserve(size); |
243 |
|
} |
246 |
|
angularMomentum.reserve(size); |
247 |
|
} |
248 |
|
|
217 |
– |
if (storageLayout_ & dslElectroFrame) { |
218 |
– |
electroFrame.reserve(size); |
219 |
– |
} |
220 |
– |
|
221 |
– |
if (storageLayout_ & dslZAngle) { |
222 |
– |
zAngle.reserve(size); |
223 |
– |
} |
224 |
– |
|
225 |
– |
if (storageLayout_ & dslForce) { |
226 |
– |
force.reserve(size); |
227 |
– |
} |
228 |
– |
|
249 |
|
if (storageLayout_ & dslTorque) { |
250 |
|
torque.reserve(size); |
251 |
|
} |
266 |
|
functionalDerivative.reserve(size); |
267 |
|
} |
268 |
|
|
269 |
+ |
if (storageLayout_ & dslDipole) { |
270 |
+ |
dipole.reserve(size); |
271 |
+ |
} |
272 |
+ |
|
273 |
+ |
if (storageLayout_ & dslQuadrupole) { |
274 |
+ |
quadrupole.reserve(size); |
275 |
+ |
} |
276 |
+ |
|
277 |
|
if (storageLayout_ & dslElectricField) { |
278 |
|
electricField.reserve(size); |
279 |
|
} |
282 |
|
skippedCharge.reserve(size); |
283 |
|
} |
284 |
|
|
285 |
+ |
if (storageLayout_ & dslFlucQPosition) { |
286 |
+ |
flucQPos.reserve(size); |
287 |
+ |
} |
288 |
+ |
|
289 |
+ |
if (storageLayout_ & dslFlucQVelocity) { |
290 |
+ |
flucQVel.reserve(size); |
291 |
+ |
} |
292 |
+ |
|
293 |
+ |
if (storageLayout_ & dslFlucQForce) { |
294 |
+ |
flucQFrc.reserve(size); |
295 |
+ |
} |
296 |
|
} |
297 |
|
|
298 |
|
void DataStorage::copy(int source, int num, int target) { |
308 |
|
internalCopy(velocity, source, num, target); |
309 |
|
} |
310 |
|
|
311 |
+ |
if (storageLayout_ & dslForce) { |
312 |
+ |
internalCopy(force, source, num, target); |
313 |
+ |
} |
314 |
+ |
|
315 |
|
if (storageLayout_ & dslAmat) { |
316 |
|
internalCopy(aMat, source, num, target); |
317 |
|
} |
320 |
|
internalCopy(angularMomentum, source, num, target); |
321 |
|
} |
322 |
|
|
280 |
– |
if (storageLayout_ & dslElectroFrame) { |
281 |
– |
internalCopy(electroFrame, source, num, target); |
282 |
– |
} |
283 |
– |
|
284 |
– |
if (storageLayout_ & dslZAngle) { |
285 |
– |
internalCopy(zAngle, source, num, target); |
286 |
– |
} |
287 |
– |
|
288 |
– |
if (storageLayout_ & dslForce) { |
289 |
– |
internalCopy(force, source, num, target); |
290 |
– |
} |
291 |
– |
|
323 |
|
if (storageLayout_ & dslTorque) { |
324 |
|
internalCopy(torque, source, num, target); |
325 |
|
} |
340 |
|
internalCopy(functionalDerivative, source, num, target); |
341 |
|
} |
342 |
|
|
343 |
+ |
if (storageLayout_ & dslDipole) { |
344 |
+ |
internalCopy(dipole, source, num, target); |
345 |
+ |
} |
346 |
+ |
|
347 |
+ |
if (storageLayout_ & dslQuadrupole) { |
348 |
+ |
internalCopy(quadrupole, source, num, target); |
349 |
+ |
} |
350 |
+ |
|
351 |
|
if (storageLayout_ & dslElectricField) { |
352 |
|
internalCopy(electricField, source, num, target); |
353 |
|
} |
355 |
|
if (storageLayout_ & dslSkippedCharge) { |
356 |
|
internalCopy(skippedCharge, source, num, target); |
357 |
|
} |
358 |
+ |
|
359 |
+ |
if (storageLayout_ & dslFlucQPosition) { |
360 |
+ |
internalCopy(flucQPos, source, num, target); |
361 |
+ |
} |
362 |
+ |
|
363 |
+ |
if (storageLayout_ & dslFlucQVelocity) { |
364 |
+ |
internalCopy(flucQVel, source, num, target); |
365 |
+ |
} |
366 |
+ |
if (storageLayout_ & dslFlucQForce) { |
367 |
+ |
internalCopy(flucQFrc, source, num, target); |
368 |
+ |
} |
369 |
|
} |
370 |
|
|
371 |
|
int DataStorage::getStorageLayout() { |
388 |
|
return internalGetArrayPointer(velocity); |
389 |
|
break; |
390 |
|
|
391 |
+ |
case dslForce: |
392 |
+ |
return internalGetArrayPointer(force); |
393 |
+ |
break; |
394 |
+ |
|
395 |
|
case dslAmat: |
396 |
|
return internalGetArrayPointer(aMat); |
397 |
|
break; |
400 |
|
return internalGetArrayPointer(angularMomentum); |
401 |
|
break; |
402 |
|
|
349 |
– |
case dslElectroFrame: |
350 |
– |
return internalGetArrayPointer(electroFrame); |
351 |
– |
break; |
352 |
– |
|
353 |
– |
case dslZAngle: |
354 |
– |
return internalGetArrayPointer(zAngle); |
355 |
– |
break; |
356 |
– |
|
357 |
– |
case dslForce: |
358 |
– |
return internalGetArrayPointer(force); |
359 |
– |
break; |
360 |
– |
|
403 |
|
case dslTorque: |
404 |
|
return internalGetArrayPointer(torque); |
405 |
|
break; |
420 |
|
return internalGetArrayPointer(functionalDerivative); |
421 |
|
break; |
422 |
|
|
423 |
+ |
case dslDipole: |
424 |
+ |
return internalGetArrayPointer(dipole); |
425 |
+ |
break; |
426 |
+ |
|
427 |
+ |
case dslQuadrupole: |
428 |
+ |
return internalGetArrayPointer(quadrupole); |
429 |
+ |
break; |
430 |
+ |
|
431 |
|
case dslElectricField: |
432 |
|
return internalGetArrayPointer(electricField); |
433 |
|
break; |
435 |
|
case dslSkippedCharge: |
436 |
|
return internalGetArrayPointer(skippedCharge); |
437 |
|
break; |
438 |
+ |
|
439 |
+ |
case dslFlucQPosition: |
440 |
+ |
return internalGetArrayPointer(flucQPos); |
441 |
+ |
break; |
442 |
+ |
|
443 |
+ |
case dslFlucQVelocity: |
444 |
+ |
return internalGetArrayPointer(flucQVel); |
445 |
+ |
break; |
446 |
|
|
447 |
+ |
case dslFlucQForce: |
448 |
+ |
return internalGetArrayPointer(flucQFrc); |
449 |
+ |
break; |
450 |
+ |
|
451 |
|
default: |
452 |
|
//error message |
453 |
|
return NULL; |
463 |
|
} |
464 |
|
} |
465 |
|
|
466 |
< |
RealType* DataStorage::internalGetArrayPointer(std::vector<RotMat3x3d>& v) { |
466 |
> |
RealType* DataStorage::internalGetArrayPointer(std::vector<Mat3x3d>& v) { |
467 |
|
if (v.size() == 0) { |
468 |
|
return NULL; |
469 |
|
} else { |
523 |
|
if (layout & dslVelocity) { |
524 |
|
bytes += sizeof(Vector3d); |
525 |
|
} |
526 |
+ |
if (layout & dslForce) { |
527 |
+ |
bytes += sizeof(Vector3d); |
528 |
+ |
} |
529 |
|
if (layout & dslAmat) { |
530 |
|
bytes += sizeof(RotMat3x3d); |
531 |
|
} |
532 |
|
if (layout & dslAngularMomentum) { |
533 |
|
bytes += sizeof(Vector3d); |
534 |
|
} |
470 |
– |
if (layout & dslElectroFrame) { |
471 |
– |
bytes += sizeof(Mat3x3d); |
472 |
– |
} |
473 |
– |
if (layout & dslZAngle) { |
474 |
– |
bytes += sizeof(RealType); |
475 |
– |
} |
476 |
– |
if (layout & dslForce) { |
477 |
– |
bytes += sizeof(Vector3d); |
478 |
– |
} |
535 |
|
if (layout & dslTorque) { |
536 |
|
bytes += sizeof(Vector3d); |
537 |
|
} |
547 |
|
if (layout & dslFunctionalDerivative) { |
548 |
|
bytes += sizeof(RealType); |
549 |
|
} |
550 |
+ |
if (layout & dslDipole) { |
551 |
+ |
bytes += sizeof(Vector3d); |
552 |
+ |
} |
553 |
+ |
if (layout & dslQuadrupole) { |
554 |
+ |
bytes += sizeof(Mat3x3d); |
555 |
+ |
} |
556 |
|
if (layout & dslElectricField) { |
557 |
|
bytes += sizeof(Vector3d); |
558 |
|
} |
559 |
|
if (layout & dslSkippedCharge) { |
560 |
|
bytes += sizeof(RealType); |
561 |
|
} |
562 |
+ |
if (layout & dslFlucQPosition) { |
563 |
+ |
bytes += sizeof(RealType); |
564 |
+ |
} |
565 |
+ |
if (layout & dslFlucQVelocity) { |
566 |
+ |
bytes += sizeof(RealType); |
567 |
+ |
} |
568 |
+ |
if (layout & dslFlucQForce) { |
569 |
+ |
bytes += sizeof(RealType); |
570 |
+ |
} |
571 |
|
|
572 |
|
return bytes; |
573 |
|
} |