ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/brains/Snapshot.hpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/brains/Snapshot.hpp (file contents):
Revision 1630 by tim, Thu Oct 21 21:31:39 2004 UTC vs.
Revision 1645 by tim, Tue Oct 26 17:28:53 2004 UTC

# Line 30 | Line 30
30    * @time 23:56am
31    * @version 1.0
32    */
33 +  
34   #ifndef BRAINS_SNAPSHOT_HPP
35   #define BRAINS_SNAPSHOT_HPP
36  
# Line 42 | Line 43 | namespace oopse{
43  
44   namespace oopse{
45  
46 +
47 +    //forward declaration
48 +    class Snapshot;
49 +    class SnapshotManager;
50 +    class StuntDouble;
51 +    
52      /**
53 +     * @class DataStorage
54 +     * @warning do not try to insert element into (or ease element from) private member data
55 +     * of DataStorage directly.
56 +     */
57 +    class DataStorage {
58 +        public:
59 +
60 +            enum{
61 +                slPosition = 1,
62 +                slVelocity = 2,
63 +                slAmat = 4,
64 +                slAngularMomentum = 8,
65 +                slUnitVector = 16,
66 +                slZAngle = 32,
67 +                slForce = 64,
68 +                slTorque = 128
69 +            };
70 +            
71 +            DataStorage(int size);
72 +
73 +            /** return the size of this DataStorage */
74 +            int size();
75 +            void resize(int size);
76 +            void reserve(int size);
77 +
78 +            void move(int source, int num, int target);
79 +            int getStorageLayout();
80 +            void setStorageLayout(int layout);
81 +
82 +            double *getArrayPointer(int );
83 +
84 +            friend class StuntDouble;
85 +
86 +        private:
87 +            int size_;
88 +            int storageLayout_;
89 +            vector<Vector3d> position;               /** position array */
90 +            vector<Vector3d> velocity;               /** velocity array */
91 +            vector<RotMat3x3d> aMat;            /** rotation matrix array */
92 +            vector<Vector3d> angularMomentum;/** velocity array */
93 +            vector<Vector3d> unitVector;                /** the lab frame unit vector array*/
94 +            vector<double> zAngle;              /** z -angle array */        
95 +            vector<Vector3d> force;               /** force array */
96 +            vector<Vector3d> torque;               /** torque array */
97 +    };
98 +
99 +    /**
100       * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
101       * @brief Snapshot class is a repository class for storing dynamic data during
102       *  Simulation
103 +     * Every snapshot class will contain one DataStorage  for atoms and one DataStorage
104 +     *  for rigid bodies.
105       * @see SimData
106       */
107      class Snapshot {
108          public:
109 <
110 <            Snapshot(int i) {
111 <
109 >            
110 >            Snapshot(int nAtoms, int nRigidbodies) {
111 >                atomData.resize(nAtoms);
112 >                rigidbodyData.resize(nRigidbodies);
113              }
114  
115              Snapshot(const Snapshot& s);
# Line 69 | Line 126 | namespace oopse{
126                  id_ = id;
127              }
128  
72            /** */
73            Snapshot* clone() {
74                return new Snapshot(*this);
75            }
76
77
129              //template<typename T>
130              //static typename T::ElemPointerType getArrayPointer(vector<T>& v) {
131              //    return v[0]->getArrayPointer();
132              //}
133  
134 <            static double* getArrayPointer(vector<Vector3d>& v) {
135 <                return v[0].getArrayPointer();
134 >            int getSize() {
135 >                return atomData.size() + rigidbodyData.size();
136              }
137 <            
138 <            static double* getArrayPointer(vector<RotMat3x3d>& v) {
139 <                return v[0].getArrayPointer();
137 >
138 >            /** Returns the number of atoms */
139 >            int getNumberOfAtoms() {
140 >                return atomData.size();
141              }
142 <            
143 <            static double* getArrayPointer(vector<double>& v) {
144 <                assert(v.size() > 0);
145 <                return &(v[0]);
142 >
143 >            /** Returns the number of rigid bodies */
144 >            int getNumberOfRigidBodies() {
145 >                return rigidbodyData.size();
146              }
147 +
148 +            /** Returns the H-Matrix */
149 +            Mat3x3d getHmat() {
150 +                return hmat_;
151 +            }
152 +
153 +            /** Sets the H-Matrix */
154 +            void setHamt(const Mat3x3d& m) {
155 +                hmat_ = m;
156 +                invHmat_ = hmat_.inverse();
157 +            }
158 +
159 +            /** Returns the inverse H-Matrix */
160 +            Mat3x3d getInvHmat() {
161 +                return invHmat_
162 +            }
163 +
164 +            double getTimeStamp() {
165 +                return timeStamp_;
166 +            }
167 +
168 +            void setTimeStamp(double timeStamp) {
169 +                timeStamp_ =timeStamp;
170 +            }
171 +
172 +
173 +            DataStorage atomData;
174 +            DataStorage rigidbodyData;
175              
176 <            vector<Vector3d> pos;
97 <            vector<Vector3d> vel;
98 <            vector<Vector3d> frc;
99 <            vector<Vector3d> trq;
100 <            vector<RotMat3x3d> Amat;
101 <            vector<Vector3d> mu;
102 <            vector<Vector3d> ul;
103 <            vector<double> zAngle;
176 >            friend class StuntDouble;
177              
178          private:
179 <
179 >            double timeStamp_;
180 >            Mat3x3d hmat_;
181 >            Mat3x3d invHmat_;
182              int id_; /**< identification number of the snapshot */
183      };
184  
185 +    typedef DataStorage (Snapshot::*DataStoragePointer);
186   }
187   #endif //BRAINS_SNAPSHOT_HPP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines