36 |
|
|
37 |
|
#include <vector> |
38 |
|
|
39 |
< |
#include "math/Vector3.hpp" |
40 |
< |
#include "math/SquareMatrix3.hpp" |
39 |
> |
#include "brains/DataStorage.hpp" |
40 |
> |
#include "brains/Stats.hpp" |
41 |
|
|
42 |
|
using namespace std; |
43 |
|
|
44 |
|
namespace oopse{ |
45 |
|
|
46 |
– |
enum DataStorageLayout { |
47 |
– |
dslPosition = 1, |
48 |
– |
dslVelocity = 2, |
49 |
– |
dslAMat = 4, |
50 |
– |
dslAngularMomentum = 8, |
51 |
– |
dslUnitVector = 16, |
52 |
– |
dslZAngle = 32, |
53 |
– |
dslForce = 64, |
54 |
– |
dslTorque = 128 |
55 |
– |
}; |
56 |
– |
//forward declaration |
57 |
– |
class Snapshot; |
58 |
– |
class SnapshotManager; |
59 |
– |
class StuntDouble; |
60 |
– |
|
46 |
|
/** |
62 |
– |
* @class DataStorage |
63 |
– |
* @brief |
64 |
– |
* @warning do not try to insert element into (or ease element from) private member data |
65 |
– |
* of DataStorage directly. |
66 |
– |
*/ |
67 |
– |
class DataStorage { |
68 |
– |
public: |
69 |
– |
DataStorage() {}; |
70 |
– |
DataStorage(size_t size); |
71 |
– |
|
72 |
– |
int size(); |
73 |
– |
void resize(size_t size); |
74 |
– |
void reserve(size_t size); |
75 |
– |
|
76 |
– |
friend class Snapshot; |
77 |
– |
friend class StuntDouble; |
78 |
– |
private: |
79 |
– |
vector<Vector3d> position; /** position array */ |
80 |
– |
vector<Vector3d> velocity; /** velocity array */ |
81 |
– |
vector<RotMat3x3d> aMat; /** rotation matrix array */ |
82 |
– |
vector<Vector3d> angularMomentum;/** velocity array */ |
83 |
– |
vector<Vector3d> unitVector; /** the lab frame unit vector array*/ |
84 |
– |
vector<double> zAngle; /** z -angle array */ |
85 |
– |
vector<Vector3d> force; /** force array */ |
86 |
– |
vector<Vector3d> torque; /** torque array */ |
87 |
– |
|
88 |
– |
}; |
89 |
– |
|
90 |
– |
/** |
47 |
|
* @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" |
48 |
|
* @brief Snapshot class is a repository class for storing dynamic data during |
49 |
|
* Simulation |
73 |
|
id_ = id; |
74 |
|
} |
75 |
|
|
76 |
< |
//template<typename T> |
77 |
< |
//static typename T::ElemPointerType getArrayPointer(vector<T>& v) { |
78 |
< |
// return v[0]->getArrayPointer(); |
123 |
< |
//} |
76 |
> |
int getSize() { |
77 |
> |
return atomData.getSize() + rigidbodyData.getSize(); |
78 |
> |
} |
79 |
|
|
80 |
< |
static double* getArrayPointer(vector<Vector3d>& v) { |
81 |
< |
assert(v.size() > 0); |
82 |
< |
return v[0].getArrayPointer(); |
80 |
> |
/** Returns the number of atoms */ |
81 |
> |
int getNumberOfAtoms() { |
82 |
> |
return atomData.getSize(); |
83 |
|
} |
84 |
< |
|
85 |
< |
static double* getArrayPointer(vector<RotMat3x3d>& v) { |
86 |
< |
assert(v.size() > 0); |
87 |
< |
return v[0].getArrayPointer(); |
84 |
> |
|
85 |
> |
/** Returns the number of rigid bodies */ |
86 |
> |
int getNumberOfRigidBodies() { |
87 |
> |
return rigidbodyData.getSize(); |
88 |
|
} |
89 |
< |
|
90 |
< |
static double* getArrayPointer(vector<double>& v) { |
91 |
< |
assert(v.size() > 0); |
92 |
< |
return &(v[0]); |
89 |
> |
|
90 |
> |
/** Returns the H-Matrix */ |
91 |
> |
Mat3x3d getHmat() { |
92 |
> |
return hmat_; |
93 |
|
} |
94 |
|
|
95 |
< |
int getSize() { |
96 |
< |
return atomData.size() + rigidbodyData.size(); |
95 |
> |
/** Sets the H-Matrix */ |
96 |
> |
void setHamt(const Mat3x3d& m) { |
97 |
> |
hmat_ = m; |
98 |
> |
invHmat_ = hmat_.inverse(); |
99 |
|
} |
100 |
< |
|
101 |
< |
int getSizeOfAtoms() { |
102 |
< |
return atomData.size(); |
100 |
> |
|
101 |
> |
/** Returns the inverse H-Matrix */ |
102 |
> |
Mat3x3d getInvHmat() { |
103 |
> |
return invHmat_; |
104 |
|
} |
105 |
< |
|
106 |
< |
int getSizeOfRigidBodies() { |
107 |
< |
return rigidbodyData.size(); |
105 |
> |
|
106 |
> |
double getTimeStamp() { |
107 |
> |
return timeStamp_; |
108 |
|
} |
109 |
< |
|
109 |
> |
|
110 |
> |
void setTimeStamp(double timeStamp) { |
111 |
> |
timeStamp_ =timeStamp; |
112 |
> |
} |
113 |
> |
|
114 |
|
DataStorage atomData; |
115 |
|
DataStorage rigidbodyData; |
116 |
< |
|
117 |
< |
friend class StuntDouble; |
116 |
> |
Stats statData; |
117 |
> |
|
118 |
|
private: |
119 |
< |
|
119 |
> |
double timeStamp_; |
120 |
> |
Mat3x3d hmat_; |
121 |
> |
Mat3x3d invHmat_; |
122 |
|
int id_; /**< identification number of the snapshot */ |
123 |
|
}; |
124 |
|
|