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 |
– |
//forward declaration |
47 |
– |
class Snapshot; |
48 |
– |
class SnapshotManager; |
49 |
– |
|
46 |
|
/** |
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 |
– |
/** |
47 |
|
* @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" |
48 |
|
* @brief Snapshot class is a repository class for storing dynamic data during |
49 |
|
* Simulation |
50 |
|
* Every snapshot class will contain one DataStorage for atoms and one DataStorage |
51 |
|
* for rigid bodies. |
81 |
– |
* @see SimData |
52 |
|
*/ |
53 |
|
class Snapshot { |
54 |
|
public: |
55 |
|
|
56 |
< |
Snapshot() {} |
57 |
< |
Snapshot(int i) { |
58 |
< |
|
56 |
> |
Snapshot(int nAtoms, int nRigidbodies) : currentTime_(0), chi_(0), integralOfChiDt_(0), eta_(0) { |
57 |
> |
atomData.resize(nAtoms); |
58 |
> |
rigidbodyData.resize(nRigidbodies); |
59 |
|
} |
60 |
|
|
91 |
– |
Snapshot(const Snapshot& s); |
92 |
– |
|
93 |
– |
Snapshot& operator =(const Snapshot& s); |
61 |
|
|
62 |
|
/** Returns the id of this Snapshot */ |
63 |
|
int getID() { |
69 |
|
id_ = id; |
70 |
|
} |
71 |
|
|
72 |
< |
//template<typename T> |
73 |
< |
//static typename T::ElemPointerType getArrayPointer(vector<T>& v) { |
74 |
< |
// return v[0]->getArrayPointer(); |
108 |
< |
//} |
72 |
> |
int getSize() { |
73 |
> |
return atomData.getSize() + rigidbodyData.getSize(); |
74 |
> |
} |
75 |
|
|
76 |
< |
static double* getArrayPointer(vector<Vector3d>& v) { |
77 |
< |
assert(v.size() > 0); |
78 |
< |
return v[0].getArrayPointer(); |
76 |
> |
/** Returns the number of atoms */ |
77 |
> |
int getNumberOfAtoms() { |
78 |
> |
return atomData.getSize(); |
79 |
|
} |
80 |
< |
|
81 |
< |
static double* getArrayPointer(vector<RotMat3x3d>& v) { |
82 |
< |
assert(v.size() > 0); |
83 |
< |
return v[0].getArrayPointer(); |
80 |
> |
|
81 |
> |
/** Returns the number of rigid bodies */ |
82 |
> |
int getNumberOfRigidBodies() { |
83 |
> |
return rigidbodyData.getSize(); |
84 |
|
} |
85 |
< |
|
86 |
< |
static double* getArrayPointer(vector<double>& v) { |
87 |
< |
assert(v.size() > 0); |
88 |
< |
return &(v[0]); |
85 |
> |
|
86 |
> |
/** Returns the H-Matrix */ |
87 |
> |
Mat3x3d getHmat() { |
88 |
> |
return hmat_; |
89 |
|
} |
90 |
+ |
|
91 |
+ |
/** Sets the H-Matrix */ |
92 |
+ |
void setHmat(const Mat3x3d& m) { |
93 |
+ |
hmat_ = m; |
94 |
+ |
invHmat_ = hmat_.inverse(); |
95 |
+ |
|
96 |
+ |
//notify fortran Hmat is changed |
97 |
+ |
double fortranHmat[9]; |
98 |
+ |
double fortranInvHmat[9]; |
99 |
+ |
hmat_.getArray(fortranHmat); |
100 |
+ |
invHmat_.getArray(fortranInvHmat); |
101 |
+ |
setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
102 |
+ |
} |
103 |
+ |
|
104 |
+ |
void getVolume() { |
105 |
+ |
return hmat_.determinant(); |
106 |
+ |
} |
107 |
+ |
|
108 |
+ |
/** Returns the inverse H-Matrix */ |
109 |
+ |
Mat3x3d getInvHmat() { |
110 |
+ |
return invHmat_; |
111 |
+ |
} |
112 |
+ |
|
113 |
+ |
/** Wrapping the vector according to periodic boundary condition*/ |
114 |
+ |
void wrapVector(Vector3d& v); |
115 |
+ |
|
116 |
|
|
117 |
< |
/** */ |
118 |
< |
void resize(size_t size); |
117 |
> |
double getTime() { |
118 |
> |
return currentTime_; |
119 |
> |
} |
120 |
|
|
121 |
+ |
void setTime(double time) { |
122 |
+ |
currentTime_ =time; |
123 |
+ |
//time at statData is redundant |
124 |
+ |
statData[Stats::TIME] = currentTime_; |
125 |
+ |
} |
126 |
|
|
127 |
< |
/** */ |
128 |
< |
void reserve(size_t size); |
127 |
> |
double getChi() { |
128 |
> |
return chi_; |
129 |
> |
} |
130 |
|
|
131 |
+ |
void setChi(double chi) { |
132 |
+ |
chi_ = chi; |
133 |
+ |
} |
134 |
+ |
|
135 |
+ |
double getIntegralOfChiDt() { |
136 |
+ |
return integralOfChiDt_; |
137 |
+ |
} |
138 |
+ |
|
139 |
+ |
void setIntegralOfChiDt(double integralOfChiDt) { |
140 |
+ |
integralOfChiDt_ = integralOfChiDt; |
141 |
+ |
} |
142 |
+ |
|
143 |
+ |
Mat3x3d getEta() { |
144 |
+ |
return eta_; |
145 |
+ |
} |
146 |
+ |
|
147 |
+ |
void setEta(const Mat3x3d& eta) { |
148 |
+ |
eta_ = eta; |
149 |
+ |
} |
150 |
+ |
|
151 |
|
DataStorage atomData; |
152 |
|
DataStorage rigidbodyData; |
153 |
< |
|
154 |
< |
friend class SnapshotManager; |
153 |
> |
Stats statData; |
154 |
> |
|
155 |
|
private: |
156 |
+ |
double currentTime_; |
157 |
|
|
158 |
+ |
Mat3x3d hmat_; |
159 |
+ |
Mat3x3d invHmat_; |
160 |
+ |
int orthoRhombic_; |
161 |
+ |
|
162 |
+ |
double chi_; |
163 |
+ |
double integralOfChiDt_; |
164 |
+ |
Mat3x3d eta_; |
165 |
+ |
|
166 |
|
int id_; /**< identification number of the snapshot */ |
167 |
|
}; |
168 |
|
|
169 |
< |
typedef DataStorage* (Snapshot::*DataStoragePointer); |
169 |
> |
typedef DataStorage (Snapshot::*DataStoragePointer); |
170 |
|
} |
171 |
|
#endif //BRAINS_SNAPSHOT_HPP |