ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-2.0/src/brains/Snapshot.hpp
Revision: 1645
Committed: Tue Oct 26 17:28:53 2004 UTC (19 years, 8 months ago) by tim
File size: 5618 byte(s)
Log Message:
Snaphot and SnapshotTestCase in progress

File Contents

# User Rev Content
1 tim 1615 /*
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 tim 1639
34 tim 1615 #ifndef BRAINS_SNAPSHOT_HPP
35     #define BRAINS_SNAPSHOT_HPP
36 tim 1630
37     #include <vector>
38    
39     #include "math/Vector3.hpp"
40     #include "math/SquareMatrix3.hpp"
41    
42     using namespace std;
43    
44 tim 1615 namespace oopse{
45    
46 tim 1645
47 tim 1639 //forward declaration
48     class Snapshot;
49     class SnapshotManager;
50 tim 1642 class StuntDouble;
51    
52 tim 1615 /**
53 tim 1642 * @class DataStorage
54     * @warning do not try to insert element into (or ease element from) private member data
55     * of DataStorage directly.
56 tim 1639 */
57     class DataStorage {
58     public:
59 tim 1642
60 tim 1645 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 tim 1642 int size();
75 tim 1645 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 tim 1642 friend class StuntDouble;
85 tim 1645
86 tim 1642 private:
87 tim 1645 int size_;
88     int storageLayout_;
89 tim 1639 vector<Vector3d> position; /** position array */
90     vector<Vector3d> velocity; /** velocity array */
91 tim 1642 vector<RotMat3x3d> aMat; /** rotation matrix array */
92 tim 1639 vector<Vector3d> angularMomentum;/** velocity array */
93 tim 1642 vector<Vector3d> unitVector; /** the lab frame unit vector array*/
94 tim 1639 vector<double> zAngle; /** z -angle array */
95     vector<Vector3d> force; /** force array */
96     vector<Vector3d> torque; /** torque array */
97     };
98    
99     /**
100 tim 1615 * @class Snapshot Snapshot.hpp "brains/Snapshot.hpp"
101     * @brief Snapshot class is a repository class for storing dynamic data during
102     * Simulation
103 tim 1639 * Every snapshot class will contain one DataStorage for atoms and one DataStorage
104     * for rigid bodies.
105 tim 1615 * @see SimData
106     */
107     class Snapshot {
108     public:
109 tim 1639
110 tim 1642 Snapshot(int nAtoms, int nRigidbodies) {
111     atomData.resize(nAtoms);
112     rigidbodyData.resize(nRigidbodies);
113 tim 1630 }
114    
115     Snapshot(const Snapshot& s);
116    
117     Snapshot& operator =(const Snapshot& s);
118 tim 1615
119 tim 1630 /** Returns the id of this Snapshot */
120     int getID() {
121     return id_;
122     }
123    
124     /** Sets the id of this Snapshot */
125     void setID(int id) {
126     id_ = id;
127     }
128    
129     //template<typename T>
130     //static typename T::ElemPointerType getArrayPointer(vector<T>& v) {
131     // return v[0]->getArrayPointer();
132     //}
133    
134 tim 1642 int getSize() {
135     return atomData.size() + rigidbodyData.size();
136     }
137 tim 1645
138     /** Returns the number of atoms */
139     int getNumberOfAtoms() {
140 tim 1642 return atomData.size();
141     }
142 tim 1645
143     /** Returns the number of rigid bodies */
144     int getNumberOfRigidBodies() {
145 tim 1642 return rigidbodyData.size();
146     }
147 tim 1645
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 tim 1639 DataStorage atomData;
174     DataStorage rigidbodyData;
175 tim 1645
176 tim 1642 friend class StuntDouble;
177 tim 1645
178 tim 1615 private:
179 tim 1645 double timeStamp_;
180     Mat3x3d hmat_;
181     Mat3x3d invHmat_;
182 tim 1630 int id_; /**< identification number of the snapshot */
183 tim 1615 };
184    
185 tim 1642 typedef DataStorage (Snapshot::*DataStoragePointer);
186 tim 1615 }
187     #endif //BRAINS_SNAPSHOT_HPP