| 1 | /* | 
| 2 | * Copyright (C) 2000-2004  Object Oriented Parallel Simulation Engine (OOPSE) project | 
| 3 | * | 
| 4 | * Contact: oopse@oopse.org | 
| 5 | * | 
| 6 | * This program is free software; you can redistribute it and/or | 
| 7 | * modify it under the terms of the GNU Lesser General Public License | 
| 8 | * as published by the Free Software Foundation; either version 2.1 | 
| 9 | * of the License, or (at your option) any later version. | 
| 10 | * All we ask is that proper credit is given for our work, which includes | 
| 11 | * - but is not limited to - adding the above copyright notice to the beginning | 
| 12 | * of your source code files, and to any copyright notice that you may distribute | 
| 13 | * with programs based on this work. | 
| 14 | * | 
| 15 | * This program is distributed in the hope that it will be useful, | 
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 18 | * GNU Lesser General Public License for more details. | 
| 19 | * | 
| 20 | * You should have received a copy of the GNU Lesser General Public License | 
| 21 | * along with this program; if not, write to the Free Software | 
| 22 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
| 23 | * | 
| 24 | */ | 
| 25 |  | 
| 26 | /** | 
| 27 | * @file Snapshot.hpp | 
| 28 | * @author tlin | 
| 29 | * @date 10/20/2004 | 
| 30 | * @time 23:56am | 
| 31 | * @version 1.0 | 
| 32 | */ | 
| 33 |  | 
| 34 | #ifndef BRAINS_SNAPSHOT_HPP | 
| 35 | #define BRAINS_SNAPSHOT_HPP | 
| 36 |  | 
| 37 | #include <vector> | 
| 38 |  | 
| 39 | #include "math/Vector3.hpp" | 
| 40 | #include "math/SquareMatrix3.hpp" | 
| 41 |  | 
| 42 | using namespace std; | 
| 43 |  | 
| 44 | namespace oopse{ | 
| 45 |  | 
| 46 | //forward declaration | 
| 47 | class Snapshot; | 
| 48 | class SnapshotManager; | 
| 49 |  | 
| 50 | /** | 
| 51 | * @struct DataStorage | 
| 52 | * @brief | 
| 53 | */ | 
| 54 | class DataStorage { | 
| 55 | public: | 
| 56 | DataStorage() {}; | 
| 57 | DataStorage(size_t size); | 
| 58 | void resize(size_t size); | 
| 59 | void reserve(size_t size); | 
| 60 |  | 
| 61 | //friend Snapshot; | 
| 62 | //friend SnapshotManager; | 
| 63 | //private: | 
| 64 | vector<Vector3d> position;               /** position array */ | 
| 65 | vector<Vector3d> velocity;               /** velocity array */ | 
| 66 | vector<RotMat3x3d> Amat;            /** rotation matrix array */ | 
| 67 | vector<Vector3d> angularMomentum;/** velocity array */ | 
| 68 | vector<Vector3d> ul;                /** the lab frame unit vector array*/ | 
| 69 | vector<double> zAngle;              /** z -angle array */ | 
| 70 | vector<Vector3d> force;               /** force array */ | 
| 71 | vector<Vector3d> torque;               /** torque array */ | 
| 72 |  | 
| 73 | }; | 
| 74 |  | 
| 75 | /** | 
| 76 | * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" | 
| 77 | * @brief Snapshot class is a repository class for storing dynamic data during | 
| 78 | *  Simulation | 
| 79 | * Every snapshot class will contain one DataStorage  for atoms and one DataStorage | 
| 80 | *  for rigid bodies. | 
| 81 | * @see SimData | 
| 82 | */ | 
| 83 | class Snapshot { | 
| 84 | public: | 
| 85 |  | 
| 86 | Snapshot() {} | 
| 87 | Snapshot(int i) { | 
| 88 |  | 
| 89 | } | 
| 90 |  | 
| 91 | Snapshot(const Snapshot& s); | 
| 92 |  | 
| 93 | Snapshot& operator =(const Snapshot& s); | 
| 94 |  | 
| 95 | /** Returns the id of this Snapshot */ | 
| 96 | int getID() { | 
| 97 | return id_; | 
| 98 | } | 
| 99 |  | 
| 100 | /** Sets the id of this Snapshot */ | 
| 101 | void setID(int id) { | 
| 102 | id_ = id; | 
| 103 | } | 
| 104 |  | 
| 105 | //template<typename T> | 
| 106 | //static typename T::ElemPointerType getArrayPointer(vector<T>& v) { | 
| 107 | //    return v[0]->getArrayPointer(); | 
| 108 | //} | 
| 109 |  | 
| 110 | static double* getArrayPointer(vector<Vector3d>& v) { | 
| 111 | assert(v.size() > 0); | 
| 112 | return v[0].getArrayPointer(); | 
| 113 | } | 
| 114 |  | 
| 115 | static double* getArrayPointer(vector<RotMat3x3d>& v) { | 
| 116 | assert(v.size() > 0); | 
| 117 | return v[0].getArrayPointer(); | 
| 118 | } | 
| 119 |  | 
| 120 | static double* getArrayPointer(vector<double>& v) { | 
| 121 | assert(v.size() > 0); | 
| 122 | return &(v[0]); | 
| 123 | } | 
| 124 |  | 
| 125 | /** */ | 
| 126 | void resize(size_t size); | 
| 127 |  | 
| 128 |  | 
| 129 | /** */ | 
| 130 | void reserve(size_t size); | 
| 131 |  | 
| 132 | DataStorage atomData; | 
| 133 | DataStorage rigidbodyData; | 
| 134 |  | 
| 135 | friend class SnapshotManager; | 
| 136 | private: | 
| 137 |  | 
| 138 | int id_; /**< identification number of the snapshot */ | 
| 139 | }; | 
| 140 |  | 
| 141 | typedef DataStorage* (Snapshot::*DataStoragePointer); | 
| 142 | } | 
| 143 | #endif //BRAINS_SNAPSHOT_HPP |