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] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
+ |
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
|
*/ |
42 |
|
|
43 |
|
/** |
50 |
|
|
51 |
|
#include "brains/DataStorage.hpp" |
52 |
|
|
53 |
< |
namespace oopse { |
53 |
> |
namespace OpenMD { |
54 |
|
|
55 |
|
DataStorage::DataStorage() : size_(0), storageLayout_(0){ |
56 |
|
|
102 |
|
//error |
103 |
|
std::cerr << "size does not match"<< std::endl; |
104 |
|
} |
105 |
+ |
|
106 |
|
if (storageLayout_ & dslParticlePot && particlePot.size() != size_) { |
107 |
|
//error |
108 |
|
std::cerr << "size does not match"<< std::endl; |
109 |
|
} |
110 |
+ |
|
111 |
+ |
if (storageLayout_ & dslDensity && density.size() != size_) { |
112 |
+ |
//error |
113 |
+ |
std::cerr << "size does not match"<< std::endl; |
114 |
+ |
} |
115 |
+ |
|
116 |
+ |
if (storageLayout_ & dslFunctional && functional.size() != size_) { |
117 |
+ |
//error |
118 |
+ |
std::cerr << "size does not match"<< std::endl; |
119 |
+ |
} |
120 |
+ |
|
121 |
+ |
if (storageLayout_ & dslFunctionalDerivative && functionalDerivative.size() != size_) { |
122 |
+ |
//error |
123 |
+ |
std::cerr << "size does not match"<< std::endl; |
124 |
+ |
} |
125 |
+ |
|
126 |
+ |
if (storageLayout_ & dslElectricField && electricField.size() != size_) { |
127 |
+ |
//error |
128 |
+ |
std::cerr << "size does not match"<< std::endl; |
129 |
+ |
} |
130 |
+ |
|
131 |
+ |
if (storageLayout_ & dslSkippedCharge && skippedCharge.size() != size_) { |
132 |
+ |
//error |
133 |
+ |
std::cerr << "size does not match"<< std::endl; |
134 |
+ |
} |
135 |
|
|
136 |
|
return size_; |
137 |
|
|
175 |
|
internalResize(particlePot, newSize); |
176 |
|
} |
177 |
|
|
178 |
+ |
if (storageLayout_ & dslDensity) { |
179 |
+ |
internalResize(density, newSize); |
180 |
+ |
} |
181 |
+ |
|
182 |
+ |
if (storageLayout_ & dslFunctional) { |
183 |
+ |
internalResize(functional, newSize); |
184 |
+ |
} |
185 |
+ |
|
186 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
187 |
+ |
internalResize(functionalDerivative, newSize); |
188 |
+ |
} |
189 |
+ |
|
190 |
+ |
if (storageLayout_ & dslElectricField) { |
191 |
+ |
internalResize(electricField, newSize); |
192 |
+ |
} |
193 |
+ |
|
194 |
+ |
if (storageLayout_ & dslSkippedCharge) { |
195 |
+ |
internalResize(skippedCharge, newSize); |
196 |
+ |
} |
197 |
+ |
|
198 |
|
size_ = newSize; |
199 |
|
} |
200 |
|
|
235 |
|
particlePot.reserve(size); |
236 |
|
} |
237 |
|
|
238 |
+ |
if (storageLayout_ & dslDensity) { |
239 |
+ |
density.reserve(size); |
240 |
+ |
} |
241 |
+ |
|
242 |
+ |
if (storageLayout_ & dslFunctional) { |
243 |
+ |
functional.reserve(size); |
244 |
+ |
} |
245 |
+ |
|
246 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
247 |
+ |
functionalDerivative.reserve(size); |
248 |
+ |
} |
249 |
+ |
|
250 |
+ |
if (storageLayout_ & dslElectricField) { |
251 |
+ |
electricField.reserve(size); |
252 |
+ |
} |
253 |
+ |
|
254 |
+ |
if (storageLayout_ & dslSkippedCharge) { |
255 |
+ |
skippedCharge.reserve(size); |
256 |
+ |
} |
257 |
+ |
|
258 |
|
} |
259 |
|
|
260 |
|
void DataStorage::copy(int source, int num, int target) { |
297 |
|
if (storageLayout_ & dslParticlePot) { |
298 |
|
internalCopy(particlePot, source, num, target); |
299 |
|
} |
233 |
– |
|
300 |
|
|
301 |
+ |
if (storageLayout_ & dslDensity) { |
302 |
+ |
internalCopy(density, source, num, target); |
303 |
+ |
} |
304 |
+ |
|
305 |
+ |
if (storageLayout_ & dslFunctional) { |
306 |
+ |
internalCopy(functional, source, num, target); |
307 |
+ |
} |
308 |
+ |
|
309 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
310 |
+ |
internalCopy(functionalDerivative, source, num, target); |
311 |
+ |
} |
312 |
+ |
|
313 |
+ |
if (storageLayout_ & dslElectricField) { |
314 |
+ |
internalCopy(electricField, source, num, target); |
315 |
+ |
} |
316 |
+ |
|
317 |
+ |
if (storageLayout_ & dslSkippedCharge) { |
318 |
+ |
internalCopy(skippedCharge, source, num, target); |
319 |
+ |
} |
320 |
|
} |
321 |
|
|
322 |
|
int DataStorage::getStorageLayout() { |
366 |
|
case dslParticlePot: |
367 |
|
return internalGetArrayPointer(particlePot); |
368 |
|
break; |
369 |
< |
|
369 |
> |
|
370 |
> |
case dslDensity: |
371 |
> |
return internalGetArrayPointer(density); |
372 |
> |
break; |
373 |
> |
|
374 |
> |
case dslFunctional: |
375 |
> |
return internalGetArrayPointer(functional); |
376 |
> |
break; |
377 |
> |
|
378 |
> |
case dslFunctionalDerivative: |
379 |
> |
return internalGetArrayPointer(functionalDerivative); |
380 |
> |
break; |
381 |
> |
|
382 |
> |
case dslElectricField: |
383 |
> |
return internalGetArrayPointer(electricField); |
384 |
> |
break; |
385 |
> |
|
386 |
> |
case dslSkippedCharge: |
387 |
> |
return internalGetArrayPointer(skippedCharge); |
388 |
> |
break; |
389 |
> |
|
390 |
|
default: |
391 |
|
//error message |
392 |
|
return NULL; |
483 |
|
if (layout & dslParticlePot) { |
484 |
|
bytes += sizeof(RealType); |
485 |
|
} |
486 |
+ |
if (layout & dslDensity) { |
487 |
+ |
bytes += sizeof(RealType); |
488 |
+ |
} |
489 |
+ |
if (layout & dslFunctional) { |
490 |
+ |
bytes += sizeof(RealType); |
491 |
+ |
} |
492 |
+ |
if (layout & dslFunctionalDerivative) { |
493 |
+ |
bytes += sizeof(RealType); |
494 |
+ |
} |
495 |
+ |
if (layout & dslElectricField) { |
496 |
+ |
bytes += sizeof(Vector3d); |
497 |
+ |
} |
498 |
+ |
if (layout & dslSkippedCharge) { |
499 |
+ |
bytes += sizeof(RealType); |
500 |
+ |
} |
501 |
+ |
|
502 |
|
return bytes; |
503 |
|
} |
504 |
|
|