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_) { |
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_) { |
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_) { |
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_) { |
92 |
– |
//error |
93 |
– |
std::cerr << "size does not match"<< std::endl; |
94 |
– |
} |
95 |
– |
|
91 |
|
if (storageLayout_ & dslForce && force.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_ & dslTorque && torque.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_ & dslParticlePot && particlePot.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_ & dslDensity && density.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_ & dslFunctional && functional.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_ & dslFunctionalDerivative && functionalDerivative.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_ & dslElectricField && electricField.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_ & dslSkippedCharge && skippedCharge.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_ & dslFlucQPosition && flucQPos.size() != size_) { |
132 |
+ |
//error |
133 |
+ |
cerr << "size does not match"<< endl; |
134 |
+ |
} |
135 |
+ |
|
136 |
+ |
if (storageLayout_ & dslFlucQVelocity && flucQVel.size() != size_) { |
137 |
+ |
//error |
138 |
+ |
cerr << "size does not match"<< endl; |
139 |
+ |
} |
140 |
+ |
|
141 |
+ |
if (storageLayout_ & dslFlucQForce && flucQFrc.size() != size_) { |
142 |
+ |
//error |
143 |
+ |
cerr << "size does not match"<< endl; |
144 |
+ |
} |
145 |
|
|
146 |
|
return size_; |
147 |
|
|
169 |
|
internalResize(electroFrame, newSize); |
170 |
|
} |
171 |
|
|
162 |
– |
if (storageLayout_ & dslZAngle) { |
163 |
– |
internalResize(zAngle, newSize); |
164 |
– |
} |
165 |
– |
|
172 |
|
if (storageLayout_ & dslForce) { |
173 |
|
internalResize(force, newSize); |
174 |
|
} |
199 |
|
|
200 |
|
if (storageLayout_ & dslSkippedCharge) { |
201 |
|
internalResize(skippedCharge, newSize); |
202 |
+ |
} |
203 |
+ |
|
204 |
+ |
if (storageLayout_ & dslFlucQPosition) { |
205 |
+ |
internalResize(flucQPos, newSize); |
206 |
+ |
} |
207 |
+ |
|
208 |
+ |
if (storageLayout_ & dslFlucQVelocity) { |
209 |
+ |
internalResize(flucQVel, newSize); |
210 |
+ |
} |
211 |
+ |
|
212 |
+ |
if (storageLayout_ & dslFlucQForce) { |
213 |
+ |
internalResize(flucQFrc, newSize); |
214 |
|
} |
215 |
|
|
216 |
|
size_ = newSize; |
237 |
|
electroFrame.reserve(size); |
238 |
|
} |
239 |
|
|
222 |
– |
if (storageLayout_ & dslZAngle) { |
223 |
– |
zAngle.reserve(size); |
224 |
– |
} |
225 |
– |
|
240 |
|
if (storageLayout_ & dslForce) { |
241 |
|
force.reserve(size); |
242 |
|
} |
269 |
|
skippedCharge.reserve(size); |
270 |
|
} |
271 |
|
|
272 |
+ |
if (storageLayout_ & dslFlucQPosition) { |
273 |
+ |
flucQPos.reserve(size); |
274 |
+ |
} |
275 |
+ |
|
276 |
+ |
if (storageLayout_ & dslFlucQVelocity) { |
277 |
+ |
flucQVel.reserve(size); |
278 |
+ |
} |
279 |
+ |
|
280 |
+ |
if (storageLayout_ & dslFlucQForce) { |
281 |
+ |
flucQFrc.reserve(size); |
282 |
+ |
} |
283 |
|
} |
284 |
|
|
285 |
|
void DataStorage::copy(int source, int num, int target) { |
307 |
|
internalCopy(electroFrame, source, num, target); |
308 |
|
} |
309 |
|
|
285 |
– |
if (storageLayout_ & dslZAngle) { |
286 |
– |
internalCopy(zAngle, source, num, target); |
287 |
– |
} |
288 |
– |
|
310 |
|
if (storageLayout_ & dslForce) { |
311 |
|
internalCopy(force, source, num, target); |
312 |
|
} |
337 |
|
|
338 |
|
if (storageLayout_ & dslSkippedCharge) { |
339 |
|
internalCopy(skippedCharge, source, num, target); |
340 |
+ |
} |
341 |
+ |
|
342 |
+ |
if (storageLayout_ & dslFlucQPosition) { |
343 |
+ |
internalCopy(flucQPos, source, num, target); |
344 |
+ |
} |
345 |
+ |
|
346 |
+ |
if (storageLayout_ & dslFlucQVelocity) { |
347 |
+ |
internalCopy(flucQVel, source, num, target); |
348 |
+ |
} |
349 |
+ |
if (storageLayout_ & dslFlucQForce) { |
350 |
+ |
internalCopy(flucQFrc, source, num, target); |
351 |
|
} |
352 |
|
} |
353 |
|
|
383 |
|
return internalGetArrayPointer(electroFrame); |
384 |
|
break; |
385 |
|
|
354 |
– |
case dslZAngle: |
355 |
– |
return internalGetArrayPointer(zAngle); |
356 |
– |
break; |
357 |
– |
|
386 |
|
case dslForce: |
387 |
|
return internalGetArrayPointer(force); |
388 |
|
break; |
414 |
|
case dslSkippedCharge: |
415 |
|
return internalGetArrayPointer(skippedCharge); |
416 |
|
break; |
417 |
+ |
|
418 |
+ |
case dslFlucQPosition: |
419 |
+ |
return internalGetArrayPointer(flucQPos); |
420 |
+ |
break; |
421 |
+ |
|
422 |
+ |
case dslFlucQVelocity: |
423 |
+ |
return internalGetArrayPointer(flucQVel); |
424 |
+ |
break; |
425 |
|
|
426 |
+ |
case dslFlucQForce: |
427 |
+ |
return internalGetArrayPointer(flucQFrc); |
428 |
+ |
break; |
429 |
+ |
|
430 |
|
default: |
431 |
|
//error message |
432 |
|
return NULL; |
511 |
|
if (layout & dslElectroFrame) { |
512 |
|
bytes += sizeof(Mat3x3d); |
513 |
|
} |
474 |
– |
if (layout & dslZAngle) { |
475 |
– |
bytes += sizeof(RealType); |
476 |
– |
} |
514 |
|
if (layout & dslForce) { |
515 |
|
bytes += sizeof(Vector3d); |
516 |
|
} |
535 |
|
if (layout & dslSkippedCharge) { |
536 |
|
bytes += sizeof(RealType); |
537 |
|
} |
538 |
+ |
if (layout & dslFlucQPosition) { |
539 |
+ |
bytes += sizeof(RealType); |
540 |
+ |
} |
541 |
+ |
if (layout & dslFlucQVelocity) { |
542 |
+ |
bytes += sizeof(RealType); |
543 |
+ |
} |
544 |
+ |
if (layout & dslFlucQForce) { |
545 |
+ |
bytes += sizeof(RealType); |
546 |
+ |
} |
547 |
|
|
548 |
|
return bytes; |
549 |
|
} |