6 |
|
* redistribute this software in source and binary code form, provided |
7 |
|
* that the following conditions are met: |
8 |
|
* |
9 |
< |
* 1. Acknowledgement of the program authors must be made in any |
10 |
< |
* publication of scientific results based in part on use of the |
11 |
< |
* program. An acceptable form of acknowledgement is citation of |
12 |
< |
* the article in which the program was described (Matthew |
13 |
< |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
< |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
< |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
< |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
< |
* |
18 |
< |
* 2. Redistributions of source code must retain the above copyright |
9 |
> |
* 1. Redistributions of source code must retain the above copyright |
10 |
|
* notice, this list of conditions and the following disclaimer. |
11 |
|
* |
12 |
< |
* 3. Redistributions in binary form must reproduce the above copyright |
12 |
> |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer in the |
14 |
|
* documentation and/or other materials provided with the |
15 |
|
* distribution. |
28 |
|
* arising out of the use of or inability to use software, even if the |
29 |
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
* such damages. |
31 |
+ |
* |
32 |
+ |
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
+ |
* research, please cite the appropriate papers when you publish your |
34 |
+ |
* work. Good starting points are: |
35 |
+ |
* |
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). |
40 |
|
*/ |
41 |
|
|
42 |
|
/** |
49 |
|
|
50 |
|
#include "brains/DataStorage.hpp" |
51 |
|
|
52 |
< |
namespace oopse { |
52 |
> |
namespace OpenMD { |
53 |
|
|
54 |
|
DataStorage::DataStorage() : size_(0), storageLayout_(0){ |
55 |
|
|
102 |
|
std::cerr << "size does not match"<< std::endl; |
103 |
|
} |
104 |
|
|
105 |
+ |
if (storageLayout_ & dslParticlePot && particlePot.size() != size_) { |
106 |
+ |
//error |
107 |
+ |
std::cerr << "size does not match"<< std::endl; |
108 |
+ |
} |
109 |
+ |
|
110 |
+ |
if (storageLayout_ & dslDensity && density.size() != size_) { |
111 |
+ |
//error |
112 |
+ |
std::cerr << "size does not match"<< std::endl; |
113 |
+ |
} |
114 |
+ |
|
115 |
+ |
if (storageLayout_ & dslFunctional && functional.size() != size_) { |
116 |
+ |
//error |
117 |
+ |
std::cerr << "size does not match"<< std::endl; |
118 |
+ |
} |
119 |
+ |
|
120 |
+ |
if (storageLayout_ & dslFunctionalDerivative && functionalDerivative.size() != size_) { |
121 |
+ |
//error |
122 |
+ |
std::cerr << "size does not match"<< std::endl; |
123 |
+ |
} |
124 |
+ |
|
125 |
+ |
if (storageLayout_ & dslElectricField && electricField.size() != size_) { |
126 |
+ |
//error |
127 |
+ |
std::cerr << "size does not match"<< std::endl; |
128 |
+ |
} |
129 |
+ |
|
130 |
+ |
if (storageLayout_ & dslSkippedCharge && skippedCharge.size() != size_) { |
131 |
+ |
//error |
132 |
+ |
std::cerr << "size does not match"<< std::endl; |
133 |
+ |
} |
134 |
+ |
|
135 |
|
return size_; |
136 |
|
|
137 |
|
} |
170 |
|
internalResize(torque, newSize); |
171 |
|
} |
172 |
|
|
173 |
+ |
if (storageLayout_ & dslParticlePot) { |
174 |
+ |
internalResize(particlePot, newSize); |
175 |
+ |
} |
176 |
+ |
|
177 |
+ |
if (storageLayout_ & dslDensity) { |
178 |
+ |
internalResize(density, newSize); |
179 |
+ |
} |
180 |
+ |
|
181 |
+ |
if (storageLayout_ & dslFunctional) { |
182 |
+ |
internalResize(functional, newSize); |
183 |
+ |
} |
184 |
+ |
|
185 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
186 |
+ |
internalResize(functionalDerivative, newSize); |
187 |
+ |
} |
188 |
+ |
|
189 |
+ |
if (storageLayout_ & dslElectricField) { |
190 |
+ |
internalResize(electricField, newSize); |
191 |
+ |
} |
192 |
+ |
|
193 |
+ |
if (storageLayout_ & dslSkippedCharge) { |
194 |
+ |
internalResize(skippedCharge, newSize); |
195 |
+ |
} |
196 |
+ |
|
197 |
|
size_ = newSize; |
198 |
|
} |
199 |
|
|
229 |
|
if (storageLayout_ & dslTorque) { |
230 |
|
torque.reserve(size); |
231 |
|
} |
232 |
+ |
|
233 |
+ |
if (storageLayout_ & dslParticlePot) { |
234 |
+ |
particlePot.reserve(size); |
235 |
+ |
} |
236 |
|
|
237 |
+ |
if (storageLayout_ & dslDensity) { |
238 |
+ |
density.reserve(size); |
239 |
+ |
} |
240 |
+ |
|
241 |
+ |
if (storageLayout_ & dslFunctional) { |
242 |
+ |
functional.reserve(size); |
243 |
+ |
} |
244 |
+ |
|
245 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
246 |
+ |
functionalDerivative.reserve(size); |
247 |
+ |
} |
248 |
+ |
|
249 |
+ |
if (storageLayout_ & dslElectricField) { |
250 |
+ |
electricField.reserve(size); |
251 |
+ |
} |
252 |
+ |
|
253 |
+ |
if (storageLayout_ & dslSkippedCharge) { |
254 |
+ |
skippedCharge.reserve(size); |
255 |
+ |
} |
256 |
+ |
|
257 |
|
} |
258 |
|
|
259 |
|
void DataStorage::copy(int source, int num, int target) { |
292 |
|
if (storageLayout_ & dslTorque) { |
293 |
|
internalCopy(torque, source, num, target); |
294 |
|
} |
217 |
– |
|
295 |
|
|
296 |
+ |
if (storageLayout_ & dslParticlePot) { |
297 |
+ |
internalCopy(particlePot, source, num, target); |
298 |
+ |
} |
299 |
+ |
|
300 |
+ |
if (storageLayout_ & dslDensity) { |
301 |
+ |
internalCopy(density, source, num, target); |
302 |
+ |
} |
303 |
+ |
|
304 |
+ |
if (storageLayout_ & dslFunctional) { |
305 |
+ |
internalCopy(functional, source, num, target); |
306 |
+ |
} |
307 |
+ |
|
308 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
309 |
+ |
internalCopy(functionalDerivative, source, num, target); |
310 |
+ |
} |
311 |
+ |
|
312 |
+ |
if (storageLayout_ & dslElectricField) { |
313 |
+ |
internalCopy(electricField, source, num, target); |
314 |
+ |
} |
315 |
+ |
|
316 |
+ |
if (storageLayout_ & dslSkippedCharge) { |
317 |
+ |
internalCopy(skippedCharge, source, num, target); |
318 |
+ |
} |
319 |
|
} |
320 |
|
|
321 |
|
int DataStorage::getStorageLayout() { |
360 |
|
|
361 |
|
case dslTorque: |
362 |
|
return internalGetArrayPointer(torque); |
363 |
< |
break; |
364 |
< |
|
363 |
> |
break; |
364 |
> |
|
365 |
> |
case dslParticlePot: |
366 |
> |
return internalGetArrayPointer(particlePot); |
367 |
> |
break; |
368 |
> |
|
369 |
> |
case dslDensity: |
370 |
> |
return internalGetArrayPointer(density); |
371 |
> |
break; |
372 |
> |
|
373 |
> |
case dslFunctional: |
374 |
> |
return internalGetArrayPointer(functional); |
375 |
> |
break; |
376 |
> |
|
377 |
> |
case dslFunctionalDerivative: |
378 |
> |
return internalGetArrayPointer(functionalDerivative); |
379 |
> |
break; |
380 |
> |
|
381 |
> |
case dslElectricField: |
382 |
> |
return internalGetArrayPointer(electricField); |
383 |
> |
break; |
384 |
> |
|
385 |
> |
case dslSkippedCharge: |
386 |
> |
return internalGetArrayPointer(skippedCharge); |
387 |
> |
break; |
388 |
> |
|
389 |
|
default: |
390 |
|
//error message |
391 |
|
return NULL; |
462 |
|
bytes += sizeof(Vector3d); |
463 |
|
} |
464 |
|
if (layout & dslAmat) { |
465 |
< |
bytes += sizeof(Mat3x3d); |
465 |
> |
bytes += sizeof(RotMat3x3d); |
466 |
|
} |
467 |
|
if (layout & dslAngularMomentum) { |
468 |
|
bytes += sizeof(Vector3d); |
471 |
|
bytes += sizeof(Mat3x3d); |
472 |
|
} |
473 |
|
if (layout & dslZAngle) { |
474 |
< |
bytes += sizeof(Vector3d); |
474 |
> |
bytes += sizeof(RealType); |
475 |
|
} |
476 |
|
if (layout & dslForce) { |
477 |
|
bytes += sizeof(Vector3d); |
479 |
|
if (layout & dslTorque) { |
480 |
|
bytes += sizeof(Vector3d); |
481 |
|
} |
482 |
+ |
if (layout & dslParticlePot) { |
483 |
+ |
bytes += sizeof(RealType); |
484 |
+ |
} |
485 |
+ |
if (layout & dslDensity) { |
486 |
+ |
bytes += sizeof(RealType); |
487 |
+ |
} |
488 |
+ |
if (layout & dslFunctional) { |
489 |
+ |
bytes += sizeof(RealType); |
490 |
+ |
} |
491 |
+ |
if (layout & dslFunctionalDerivative) { |
492 |
+ |
bytes += sizeof(RealType); |
493 |
+ |
} |
494 |
+ |
if (layout & dslElectricField) { |
495 |
+ |
bytes += sizeof(Vector3d); |
496 |
+ |
} |
497 |
+ |
if (layout & dslSkippedCharge) { |
498 |
+ |
bytes += sizeof(RealType); |
499 |
+ |
} |
500 |
+ |
|
501 |
|
return bytes; |
502 |
|
} |
503 |
|
|