| 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 |
|
|
| 101 |
|
//error |
| 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 |
|
return size_; |
| 131 |
|
|
| 169 |
|
internalResize(particlePot, newSize); |
| 170 |
|
} |
| 171 |
|
|
| 172 |
+ |
if (storageLayout_ & dslDensity) { |
| 173 |
+ |
internalResize(density, newSize); |
| 174 |
+ |
} |
| 175 |
+ |
|
| 176 |
+ |
if (storageLayout_ & dslFunctional) { |
| 177 |
+ |
internalResize(functional, newSize); |
| 178 |
+ |
} |
| 179 |
+ |
|
| 180 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
| 181 |
+ |
internalResize(functionalDerivative, newSize); |
| 182 |
+ |
} |
| 183 |
+ |
|
| 184 |
+ |
if (storageLayout_ & dslElectricField) { |
| 185 |
+ |
internalResize(electricField, newSize); |
| 186 |
+ |
} |
| 187 |
+ |
|
| 188 |
|
size_ = newSize; |
| 189 |
|
} |
| 190 |
|
|
| 223 |
|
|
| 224 |
|
if (storageLayout_ & dslParticlePot) { |
| 225 |
|
particlePot.reserve(size); |
| 226 |
+ |
} |
| 227 |
+ |
|
| 228 |
+ |
if (storageLayout_ & dslDensity) { |
| 229 |
+ |
density.reserve(size); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
+ |
if (storageLayout_ & dslFunctional) { |
| 233 |
+ |
functional.reserve(size); |
| 234 |
+ |
} |
| 235 |
+ |
|
| 236 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
| 237 |
+ |
functionalDerivative.reserve(size); |
| 238 |
+ |
} |
| 239 |
+ |
|
| 240 |
+ |
if (storageLayout_ & dslElectricField) { |
| 241 |
+ |
electricField.reserve(size); |
| 242 |
+ |
} |
| 243 |
+ |
|
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
void DataStorage::copy(int source, int num, int target) { |
| 283 |
|
if (storageLayout_ & dslParticlePot) { |
| 284 |
|
internalCopy(particlePot, source, num, target); |
| 285 |
|
} |
| 233 |
– |
|
| 286 |
|
|
| 287 |
+ |
if (storageLayout_ & dslDensity) { |
| 288 |
+ |
internalCopy(density, source, num, target); |
| 289 |
+ |
} |
| 290 |
+ |
|
| 291 |
+ |
if (storageLayout_ & dslFunctional) { |
| 292 |
+ |
internalCopy(functional, source, num, target); |
| 293 |
+ |
} |
| 294 |
+ |
|
| 295 |
+ |
if (storageLayout_ & dslFunctionalDerivative) { |
| 296 |
+ |
internalCopy(functionalDerivative, source, num, target); |
| 297 |
+ |
} |
| 298 |
+ |
|
| 299 |
+ |
if (storageLayout_ & dslElectricField) { |
| 300 |
+ |
internalCopy(electricField, source, num, target); |
| 301 |
+ |
} |
| 302 |
|
} |
| 303 |
|
|
| 304 |
|
int DataStorage::getStorageLayout() { |
| 348 |
|
case dslParticlePot: |
| 349 |
|
return internalGetArrayPointer(particlePot); |
| 350 |
|
break; |
| 351 |
< |
|
| 351 |
> |
|
| 352 |
> |
case dslDensity: |
| 353 |
> |
return internalGetArrayPointer(density); |
| 354 |
> |
break; |
| 355 |
> |
|
| 356 |
> |
case dslFunctional: |
| 357 |
> |
return internalGetArrayPointer(functional); |
| 358 |
> |
break; |
| 359 |
> |
|
| 360 |
> |
case dslFunctionalDerivative: |
| 361 |
> |
return internalGetArrayPointer(functionalDerivative); |
| 362 |
> |
break; |
| 363 |
> |
|
| 364 |
> |
case dslElectricField: |
| 365 |
> |
return internalGetArrayPointer(electricField); |
| 366 |
> |
break; |
| 367 |
> |
|
| 368 |
|
default: |
| 369 |
|
//error message |
| 370 |
|
return NULL; |
| 461 |
|
if (layout & dslParticlePot) { |
| 462 |
|
bytes += sizeof(RealType); |
| 463 |
|
} |
| 464 |
+ |
if (layout & dslDensity) { |
| 465 |
+ |
bytes += sizeof(RealType); |
| 466 |
+ |
} |
| 467 |
+ |
if (layout & dslFunctional) { |
| 468 |
+ |
bytes += sizeof(RealType); |
| 469 |
+ |
} |
| 470 |
+ |
if (layout & dslFunctionalDerivative) { |
| 471 |
+ |
bytes += sizeof(RealType); |
| 472 |
+ |
} |
| 473 |
+ |
if (layout & dslElectricField) { |
| 474 |
+ |
bytes += sizeof(Vector3d); |
| 475 |
+ |
} |
| 476 |
+ |
|
| 477 |
|
return bytes; |
| 478 |
|
} |
| 479 |
|
|