| 1 | < | /* | 
| 1 | > | /* | 
| 2 |  | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 |  | * | 
| 4 |  | * The University of Notre Dame grants you ("Licensee") a | 
| 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 | < | /** | 
| 44 | < | * @file DataStorage.cpp | 
| 45 | < | * @author tlin | 
| 46 | < | * @date 10/26/2004 | 
| 47 | < | * @time 11:56am | 
| 48 | < | * @version 1.0 | 
| 49 | < | */ | 
| 43 | > | /** | 
| 44 | > | * @file DataStorage.cpp | 
| 45 | > | * @author tlin | 
| 46 | > | * @date 10/26/2004 | 
| 47 | > | * @time 11:56am | 
| 48 | > | * @version 1.0 | 
| 49 | > | */ | 
| 50 |  |  | 
| 51 |  | #include "brains/DataStorage.hpp" | 
| 52 | + | using namespace std; | 
| 53 | + | namespace OpenMD { | 
| 54 |  |  | 
| 55 | < | namespace oopse { | 
| 55 | > | DataStorage::DataStorage() : size_(0), storageLayout_(0){ | 
| 56 |  |  | 
| 57 | < | DataStorage::DataStorage() : size_(0), storageLayout_(0){ | 
| 57 | > | } | 
| 58 |  |  | 
| 59 | < | } | 
| 57 | < |  | 
| 58 | < | DataStorage::DataStorage(int size, int storageLayout) : size_(size){ | 
| 59 | > | DataStorage::DataStorage(int size, int storageLayout) : size_(size){ | 
| 60 |  | setStorageLayout(storageLayout); | 
| 61 |  | resize(size); | 
| 62 | < | } | 
| 62 | > | } | 
| 63 |  |  | 
| 64 | < | int DataStorage::getSize() { | 
| 64 | > | int DataStorage::getSize() { | 
| 65 |  |  | 
| 66 |  | if (storageLayout_ & dslPosition && position.size() != size_) { | 
| 67 | < | //error | 
| 68 | < | std::cerr << "size does not match"<< std::endl; | 
| 67 | > | //error | 
| 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; | 
| 72 | > | //error | 
| 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; | 
| 77 | > | //error | 
| 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; | 
| 82 | > | //error | 
| 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; | 
| 87 | > | //error | 
| 88 | > | cerr << "size does not match"<< endl; | 
| 89 |  | } | 
| 90 |  |  | 
| 90 | – | if (storageLayout_ & dslZAngle && zAngle.size() != size_) { | 
| 91 | – | //error | 
| 92 | – | std::cerr << "size does not match"<< std::endl; | 
| 93 | – | } | 
| 94 | – |  | 
| 91 |  | if (storageLayout_ & dslForce && force.size() != size_) { | 
| 92 | < | //error | 
| 93 | < | std::cerr << "size does not match"<< std::endl; | 
| 92 | > | //error | 
| 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; | 
| 97 | > | //error | 
| 98 | > | cerr << "size does not match"<< endl; | 
| 99 |  | } | 
| 100 |  |  | 
| 101 | + | if (storageLayout_ & dslParticlePot && particlePot.size() != size_) { | 
| 102 | + | //error | 
| 103 | + | cerr << "size does not match"<< endl; | 
| 104 | + | } | 
| 105 | + |  | 
| 106 | + | if (storageLayout_ & dslDensity && density.size() != size_) { | 
| 107 | + | //error | 
| 108 | + | cerr << "size does not match"<< endl; | 
| 109 | + | } | 
| 110 | + |  | 
| 111 | + | if (storageLayout_ & dslFunctional && functional.size() != size_) { | 
| 112 | + | //error | 
| 113 | + | cerr << "size does not match"<< endl; | 
| 114 | + | } | 
| 115 | + |  | 
| 116 | + | if (storageLayout_ & dslFunctionalDerivative && functionalDerivative.size() != size_) { | 
| 117 | + | //error | 
| 118 | + | cerr << "size does not match"<< endl; | 
| 119 | + | } | 
| 120 | + |  | 
| 121 | + | if (storageLayout_ & dslElectricField && electricField.size() != size_) { | 
| 122 | + | //error | 
| 123 | + | cerr << "size does not match"<< endl; | 
| 124 | + | } | 
| 125 | + |  | 
| 126 | + | if (storageLayout_ & dslSkippedCharge && skippedCharge.size() != size_) { | 
| 127 | + | //error | 
| 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 |  |  | 
| 148 | < | } | 
| 148 | > | } | 
| 149 |  |  | 
| 150 | < | void DataStorage::resize(int newSize) { | 
| 150 | > | void DataStorage::resize(int newSize) { | 
| 151 |  |  | 
| 152 |  | if (storageLayout_ & dslPosition) { | 
| 153 | < | internalResize(position, newSize); | 
| 153 | > | internalResize(position, newSize); | 
| 154 |  | } | 
| 155 |  |  | 
| 156 |  | if (storageLayout_ & dslVelocity) { | 
| 157 | < | internalResize(velocity, newSize); | 
| 157 | > | internalResize(velocity, newSize); | 
| 158 |  | } | 
| 159 |  |  | 
| 160 |  | if (storageLayout_ & dslAmat) { | 
| 161 | < | internalResize(aMat, newSize); | 
| 161 | > | internalResize(aMat, newSize); | 
| 162 |  | } | 
| 163 |  |  | 
| 164 |  | if (storageLayout_ & dslAngularMomentum) { | 
| 165 | < | internalResize(angularMomentum, newSize); | 
| 165 | > | internalResize(angularMomentum, newSize); | 
| 166 |  | } | 
| 167 |  |  | 
| 168 |  | if (storageLayout_ & dslElectroFrame) { | 
| 169 | < | internalResize(electroFrame, newSize); | 
| 169 | > | internalResize(electroFrame, newSize); | 
| 170 |  | } | 
| 171 |  |  | 
| 131 | – | if (storageLayout_ & dslZAngle) { | 
| 132 | – | internalResize(zAngle, newSize); | 
| 133 | – | } | 
| 134 | – |  | 
| 172 |  | if (storageLayout_ & dslForce) { | 
| 173 | < | internalResize(force, newSize); | 
| 173 | > | internalResize(force, newSize); | 
| 174 |  | } | 
| 175 |  |  | 
| 176 |  | if (storageLayout_ & dslTorque) { | 
| 177 | < | internalResize(torque, newSize); | 
| 177 | > | internalResize(torque, newSize); | 
| 178 |  | } | 
| 179 |  |  | 
| 180 | < | size_ = newSize; | 
| 181 | < | } | 
| 180 | > | if (storageLayout_ & dslParticlePot) { | 
| 181 | > | internalResize(particlePot, newSize); | 
| 182 | > | } | 
| 183 |  |  | 
| 184 | < | void DataStorage::reserve(int size) { | 
| 184 | > | if (storageLayout_ & dslDensity) { | 
| 185 | > | internalResize(density, newSize); | 
| 186 | > | } | 
| 187 | > |  | 
| 188 | > | if (storageLayout_ & dslFunctional) { | 
| 189 | > | internalResize(functional, newSize); | 
| 190 | > | } | 
| 191 | > |  | 
| 192 | > | if (storageLayout_ & dslFunctionalDerivative) { | 
| 193 | > | internalResize(functionalDerivative, newSize); | 
| 194 | > | } | 
| 195 | > |  | 
| 196 | > | if (storageLayout_ & dslElectricField) { | 
| 197 | > | internalResize(electricField, newSize); | 
| 198 | > | } | 
| 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; | 
| 217 | > | } | 
| 218 | > |  | 
| 219 | > | void DataStorage::reserve(int size) { | 
| 220 |  | if (storageLayout_ & dslPosition) { | 
| 221 | < | position.reserve(size); | 
| 221 | > | position.reserve(size); | 
| 222 |  | } | 
| 223 |  |  | 
| 224 |  | if (storageLayout_ & dslVelocity) { | 
| 225 | < | velocity.reserve(size); | 
| 225 | > | velocity.reserve(size); | 
| 226 |  | } | 
| 227 |  |  | 
| 228 |  | if (storageLayout_ & dslAmat) { | 
| 229 | < | aMat.reserve(size); | 
| 229 | > | aMat.reserve(size); | 
| 230 |  | } | 
| 231 |  |  | 
| 232 |  | if (storageLayout_ & dslAngularMomentum) { | 
| 233 | < | angularMomentum.reserve(size); | 
| 233 | > | angularMomentum.reserve(size); | 
| 234 |  | } | 
| 235 |  |  | 
| 236 |  | if (storageLayout_ & dslElectroFrame) { | 
| 237 | < | electroFrame.reserve(size); | 
| 237 | > | electroFrame.reserve(size); | 
| 238 |  | } | 
| 239 |  |  | 
| 167 | – | if (storageLayout_ & dslZAngle) { | 
| 168 | – | zAngle.reserve(size); | 
| 169 | – | } | 
| 170 | – |  | 
| 240 |  | if (storageLayout_ & dslForce) { | 
| 241 | < | force.reserve(size); | 
| 241 | > | force.reserve(size); | 
| 242 |  | } | 
| 243 |  |  | 
| 244 |  | if (storageLayout_ & dslTorque) { | 
| 245 | < | torque.reserve(size); | 
| 245 | > | torque.reserve(size); | 
| 246 |  | } | 
| 247 | + |  | 
| 248 | + | if (storageLayout_ & dslParticlePot) { | 
| 249 | + | particlePot.reserve(size); | 
| 250 | + | } | 
| 251 |  |  | 
| 252 | < | } | 
| 252 | > | if (storageLayout_ & dslDensity) { | 
| 253 | > | density.reserve(size); | 
| 254 | > | } | 
| 255 |  |  | 
| 256 | < | void DataStorage::copy(int source, int num, int target) { | 
| 256 | > | if (storageLayout_ & dslFunctional) { | 
| 257 | > | functional.reserve(size); | 
| 258 | > | } | 
| 259 | > |  | 
| 260 | > | if (storageLayout_ & dslFunctionalDerivative) { | 
| 261 | > | functionalDerivative.reserve(size); | 
| 262 | > | } | 
| 263 | > |  | 
| 264 | > | if (storageLayout_ & dslElectricField) { | 
| 265 | > | electricField.reserve(size); | 
| 266 | > | } | 
| 267 | > |  | 
| 268 | > | if (storageLayout_ & dslSkippedCharge) { | 
| 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) { | 
| 286 |  | if (num + target > size_ ) { | 
| 287 | < | //error | 
| 287 | > | //error | 
| 288 |  | } | 
| 289 |  |  | 
| 290 |  | if (storageLayout_ & dslPosition) { | 
| 291 | < | internalCopy(position, source, num, target); | 
| 291 | > | internalCopy(position, source, num, target); | 
| 292 |  | } | 
| 293 |  |  | 
| 294 |  | if (storageLayout_ & dslVelocity) { | 
| 295 | < | internalCopy(velocity, source, num, target); | 
| 296 | < | } | 
| 295 | > | internalCopy(velocity, source, num, target); | 
| 296 | > | } | 
| 297 |  |  | 
| 298 |  | if (storageLayout_ & dslAmat) { | 
| 299 | < | internalCopy(aMat, source, num, target); | 
| 300 | < | } | 
| 299 | > | internalCopy(aMat, source, num, target); | 
| 300 | > | } | 
| 301 |  |  | 
| 302 |  | if (storageLayout_ & dslAngularMomentum) { | 
| 303 | < | internalCopy(angularMomentum, source, num, target); | 
| 303 | > | internalCopy(angularMomentum, source, num, target); | 
| 304 |  | } | 
| 305 |  |  | 
| 306 |  | if (storageLayout_ & dslElectroFrame) { | 
| 307 | < | internalCopy(electroFrame, source, num, target); | 
| 307 | > | internalCopy(electroFrame, source, num, target); | 
| 308 |  | } | 
| 309 |  |  | 
| 206 | – | if (storageLayout_ & dslZAngle) { | 
| 207 | – | internalCopy(zAngle, source, num, target); | 
| 208 | – | } | 
| 209 | – |  | 
| 310 |  | if (storageLayout_ & dslForce) { | 
| 311 | < | internalCopy(force, source, num, target); | 
| 311 | > | internalCopy(force, source, num, target); | 
| 312 |  | } | 
| 313 |  |  | 
| 314 |  | if (storageLayout_ & dslTorque) { | 
| 315 | < | internalCopy(torque, source, num, target); | 
| 315 | > | internalCopy(torque, source, num, target); | 
| 316 |  | } | 
| 217 | – |  | 
| 317 |  |  | 
| 318 | < | } | 
| 318 | > | if (storageLayout_ & dslParticlePot) { | 
| 319 | > | internalCopy(particlePot, source, num, target); | 
| 320 | > | } | 
| 321 |  |  | 
| 322 | < | int DataStorage::getStorageLayout() { | 
| 323 | < | return storageLayout_; | 
| 324 | < | } | 
| 322 | > | if (storageLayout_ & dslDensity) { | 
| 323 | > | internalCopy(density, source, num, target); | 
| 324 | > | } | 
| 325 |  |  | 
| 326 | < | void DataStorage::setStorageLayout(int layout) { | 
| 327 | < | storageLayout_ = layout; | 
| 328 | < | resize(size_); | 
| 228 | < | } | 
| 326 | > | if (storageLayout_ & dslFunctional) { | 
| 327 | > | internalCopy(functional, source, num, target); | 
| 328 | > | } | 
| 329 |  |  | 
| 330 | < | double* DataStorage::getArrayPointer(int whichArray) { | 
| 330 | > | if (storageLayout_ & dslFunctionalDerivative) { | 
| 331 | > | internalCopy(functionalDerivative, source, num, target); | 
| 332 | > | } | 
| 333 |  |  | 
| 334 | + | if (storageLayout_ & dslElectricField) { | 
| 335 | + | internalCopy(electricField, source, num, target); | 
| 336 | + | } | 
| 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 | + |  | 
| 354 | + | int DataStorage::getStorageLayout() { | 
| 355 | + | return storageLayout_; | 
| 356 | + | } | 
| 357 | + |  | 
| 358 | + | void DataStorage::setStorageLayout(int layout) { | 
| 359 | + | storageLayout_ = layout; | 
| 360 | + | resize(size_); | 
| 361 | + | } | 
| 362 | + |  | 
| 363 | + | RealType* DataStorage::getArrayPointer(int whichArray) { | 
| 364 | + |  | 
| 365 |  | switch (whichArray) { | 
| 366 | < | case dslPosition: | 
| 367 | < | return internalGetArrayPointer(position); | 
| 368 | < | break; | 
| 366 | > | case dslPosition: | 
| 367 | > | return internalGetArrayPointer(position); | 
| 368 | > | break; | 
| 369 |  |  | 
| 370 | < | case dslVelocity: | 
| 371 | < | return internalGetArrayPointer(velocity); | 
| 372 | < | break; | 
| 370 | > | case dslVelocity: | 
| 371 | > | return internalGetArrayPointer(velocity); | 
| 372 | > | break; | 
| 373 |  |  | 
| 374 | < | case dslAmat: | 
| 375 | < | return internalGetArrayPointer(aMat); | 
| 376 | < | break; | 
| 374 | > | case dslAmat: | 
| 375 | > | return internalGetArrayPointer(aMat); | 
| 376 | > | break; | 
| 377 |  |  | 
| 378 | < | case dslAngularMomentum: | 
| 379 | < | return internalGetArrayPointer(angularMomentum); | 
| 380 | < | break; | 
| 378 | > | case dslAngularMomentum: | 
| 379 | > | return internalGetArrayPointer(angularMomentum); | 
| 380 | > | break; | 
| 381 |  |  | 
| 382 | < | case dslElectroFrame: | 
| 383 | < | return internalGetArrayPointer(electroFrame); | 
| 384 | < | break; | 
| 382 | > | case dslElectroFrame: | 
| 383 | > | return internalGetArrayPointer(electroFrame); | 
| 384 | > | break; | 
| 385 |  |  | 
| 386 | < | case dslZAngle: | 
| 387 | < | return internalGetArrayPointer(zAngle); | 
| 388 | < | break; | 
| 386 | > | case dslForce: | 
| 387 | > | return internalGetArrayPointer(force); | 
| 388 | > | break; | 
| 389 |  |  | 
| 390 | < | case dslForce: | 
| 391 | < | return internalGetArrayPointer(force); | 
| 392 | < | break; | 
| 390 | > | case dslTorque: | 
| 391 | > | return internalGetArrayPointer(torque); | 
| 392 | > | break; | 
| 393 |  |  | 
| 394 | < | case dslTorque: | 
| 395 | < | return internalGetArrayPointer(torque); | 
| 396 | < | break; | 
| 264 | < |  | 
| 265 | < | default: | 
| 266 | < | //error message | 
| 267 | < | return NULL; | 
| 394 | > | case dslParticlePot: | 
| 395 | > | return internalGetArrayPointer(particlePot); | 
| 396 | > | break; | 
| 397 |  |  | 
| 398 | + | case dslDensity: | 
| 399 | + | return internalGetArrayPointer(density); | 
| 400 | + | break; | 
| 401 | + |  | 
| 402 | + | case dslFunctional: | 
| 403 | + | return internalGetArrayPointer(functional); | 
| 404 | + | break; | 
| 405 | + |  | 
| 406 | + | case dslFunctionalDerivative: | 
| 407 | + | return internalGetArrayPointer(functionalDerivative); | 
| 408 | + | break; | 
| 409 | + |  | 
| 410 | + | case dslElectricField: | 
| 411 | + | return internalGetArrayPointer(electricField); | 
| 412 | + | break; | 
| 413 | + |  | 
| 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; | 
| 433 | + |  | 
| 434 |  | } | 
| 435 | < | } | 
| 435 | > | } | 
| 436 |  |  | 
| 437 | < | double* DataStorage::internalGetArrayPointer(std::vector<Vector3d>& v) { | 
| 437 | > | RealType* DataStorage::internalGetArrayPointer(std::vector<Vector3d>& v) { | 
| 438 |  | if (v.size() == 0) { | 
| 439 | < | return NULL; | 
| 439 | > | return NULL; | 
| 440 |  | } else { | 
| 441 | < | return v[0].getArrayPointer(); | 
| 441 | > | return v[0].getArrayPointer(); | 
| 442 |  | } | 
| 443 | < | } | 
| 443 | > | } | 
| 444 |  |  | 
| 445 | < | double* DataStorage::internalGetArrayPointer(std::vector<RotMat3x3d>& v) { | 
| 445 | > | RealType* DataStorage::internalGetArrayPointer(std::vector<RotMat3x3d>& v) { | 
| 446 |  | if (v.size() == 0) { | 
| 447 | < | return NULL; | 
| 447 | > | return NULL; | 
| 448 |  | } else { | 
| 449 | < | return v[0].getArrayPointer(); | 
| 449 | > | return v[0].getArrayPointer(); | 
| 450 |  | } | 
| 451 |  |  | 
| 452 | < | } | 
| 452 | > | } | 
| 453 |  |  | 
| 454 | < | double* DataStorage::internalGetArrayPointer(std::vector<double>& v) { | 
| 454 | > | RealType* DataStorage::internalGetArrayPointer(std::vector<RealType>& v) { | 
| 455 |  | if (v.size() == 0) { | 
| 456 | < | return NULL; | 
| 456 | > | return NULL; | 
| 457 |  | } else { | 
| 458 | < | return &(v[0]); | 
| 458 | > | return &(v[0]); | 
| 459 |  | } | 
| 460 |  |  | 
| 461 | < | } | 
| 461 | > | } | 
| 462 |  |  | 
| 463 | < | template<typename T> | 
| 464 | < | void DataStorage::internalResize(std::vector<T>& v, int newSize){ | 
| 463 | > | template<typename T> | 
| 464 | > | void DataStorage::internalResize(std::vector<T>& v, int newSize){ | 
| 465 |  | int oldSize = v.size(); | 
| 466 |  |  | 
| 467 |  | if (oldSize == newSize) { | 
| 468 | < | return; | 
| 468 | > | return; | 
| 469 |  | } else if (oldSize < newSize) { | 
| 470 | < | v.insert(v.end(), newSize-oldSize, T()); | 
| 470 | > | v.insert(v.end(), newSize-oldSize, T()); | 
| 471 |  | } else { | 
| 472 | < | typename std::vector<T>::iterator i; | 
| 473 | < | i = v.begin(); | 
| 474 | < | std::advance(i, newSize); | 
| 475 | < | v.erase(i, v.end()); | 
| 472 | > | typename std::vector<T>::iterator i; | 
| 473 | > | i = v.begin(); | 
| 474 | > | std::advance(i, newSize); | 
| 475 | > | v.erase(i, v.end()); | 
| 476 |  | } | 
| 477 | < | } | 
| 477 | > | } | 
| 478 |  |  | 
| 479 | < | template<typename T> | 
| 480 | < | void DataStorage::internalCopy(std::vector<T>& v, int source,  int num, int target) { | 
| 479 | > | template<typename T> | 
| 480 | > | void DataStorage::internalCopy(std::vector<T>& v, int source,  int num, int target) { | 
| 481 |  | typename std::vector<T>::iterator first; | 
| 482 |  | typename std::vector<T>::iterator last; | 
| 483 |  | typename std::vector<T>::iterator result; | 
| 492 |  | std::advance(result, target ); | 
| 493 |  |  | 
| 494 |  | std::copy(first, last, result); | 
| 495 | < | } | 
| 495 | > | } | 
| 496 |  |  | 
| 497 | < | int DataStorage::getBytesPerStuntDouble(int layout) { | 
| 497 | > | int DataStorage::getBytesPerStuntDouble(int layout) { | 
| 498 |  | int bytes = 0; | 
| 499 |  | if (layout & dslPosition) { | 
| 500 | < | bytes += sizeof(Vector3d); | 
| 336 | < | } else if (layout & dslVelocity) { | 
| 337 | < | bytes += sizeof(Vector3d); | 
| 338 | < | } else if (layout & dslAmat) { | 
| 339 | < | bytes += sizeof(Mat3x3d); | 
| 340 | < | } else if (layout & dslAngularMomentum) { | 
| 341 | < | bytes += sizeof(Vector3d); | 
| 342 | < | } else if (layout & dslElectroFrame) { | 
| 343 | < | bytes += sizeof(Mat3x3d); | 
| 344 | < | } else if (layout & dslZAngle) { | 
| 345 | < | bytes += sizeof(Vector3d); | 
| 346 | < | } else if (layout & dslForce) { | 
| 347 | < | bytes += sizeof(Vector3d); | 
| 348 | < | } else if (layout & dslTorque) { | 
| 349 | < | bytes += sizeof(Vector3d); | 
| 500 | > | bytes += sizeof(Vector3d); | 
| 501 |  | } | 
| 502 | + | if (layout & dslVelocity) { | 
| 503 | + | bytes += sizeof(Vector3d); | 
| 504 | + | } | 
| 505 | + | if (layout & dslAmat) { | 
| 506 | + | bytes += sizeof(RotMat3x3d); | 
| 507 | + | } | 
| 508 | + | if (layout & dslAngularMomentum) { | 
| 509 | + | bytes += sizeof(Vector3d); | 
| 510 | + | } | 
| 511 | + | if (layout & dslElectroFrame) { | 
| 512 | + | bytes += sizeof(Mat3x3d); | 
| 513 | + | } | 
| 514 | + | if (layout & dslForce) { | 
| 515 | + | bytes += sizeof(Vector3d); | 
| 516 | + | } | 
| 517 | + | if (layout & dslTorque) { | 
| 518 | + | bytes += sizeof(Vector3d); | 
| 519 | + | } | 
| 520 | + | if (layout & dslParticlePot) { | 
| 521 | + | bytes += sizeof(RealType); | 
| 522 | + | } | 
| 523 | + | if (layout & dslDensity) { | 
| 524 | + | bytes += sizeof(RealType); | 
| 525 | + | } | 
| 526 | + | if (layout & dslFunctional) { | 
| 527 | + | bytes += sizeof(RealType); | 
| 528 | + | } | 
| 529 | + | if (layout & dslFunctionalDerivative) { | 
| 530 | + | bytes += sizeof(RealType); | 
| 531 | + | } | 
| 532 | + | if (layout & dslElectricField) { | 
| 533 | + | bytes += sizeof(Vector3d); | 
| 534 | + | } | 
| 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 | < | } | 
| 549 | > | } | 
| 550 |  |  | 
| 551 |  | } |