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 "brains/DataStorage.hpp" |
40 |
+ |
#include "brains/Stats.hpp" |
41 |
+ |
#include "UseTheForce/DarkSide/simulation_interface.h" |
42 |
+ |
using namespace std; |
43 |
+ |
|
44 |
|
namespace oopse{ |
45 |
|
|
46 |
|
/** |
47 |
|
* @class Snapshot Snapshot.hpp "brains/Snapshot.hpp" |
48 |
|
* @brief Snapshot class is a repository class for storing dynamic data during |
49 |
|
* Simulation |
50 |
< |
* @see SimData |
50 |
> |
* Every snapshot class will contain one DataStorage for atoms and one DataStorage |
51 |
> |
* for rigid bodies. |
52 |
|
*/ |
53 |
|
class Snapshot { |
54 |
|
public: |
55 |
|
|
56 |
< |
PropertyMap properties_; |
56 |
> |
Snapshot(int nAtoms, int nRigidbodies) : currentTime_(0), chi_(0.0), integralOfChiDt_(0.0), eta_(0.0) { |
57 |
> |
atomData.resize(nAtoms); |
58 |
> |
rigidbodyData.resize(nRigidbodies); |
59 |
> |
} |
60 |
> |
|
61 |
|
|
62 |
+ |
/** Returns the id of this Snapshot */ |
63 |
+ |
int getID() { |
64 |
+ |
return id_; |
65 |
+ |
} |
66 |
+ |
|
67 |
+ |
/** Sets the id of this Snapshot */ |
68 |
+ |
void setID(int id) { |
69 |
+ |
id_ = id; |
70 |
+ |
} |
71 |
+ |
|
72 |
+ |
int getSize() { |
73 |
+ |
return atomData.getSize() + rigidbodyData.getSize(); |
74 |
+ |
} |
75 |
+ |
|
76 |
+ |
/** Returns the number of atoms */ |
77 |
+ |
int getNumberOfAtoms() { |
78 |
+ |
return atomData.getSize(); |
79 |
+ |
} |
80 |
+ |
|
81 |
+ |
/** Returns the number of rigid bodies */ |
82 |
+ |
int getNumberOfRigidBodies() { |
83 |
+ |
return rigidbodyData.getSize(); |
84 |
+ |
} |
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 |
+ |
double 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 |
+ |
double getTime() { |
118 |
+ |
return currentTime_; |
119 |
+ |
} |
120 |
+ |
|
121 |
+ |
void increaseTime(double dt) { |
122 |
+ |
setTime(getTime() + dt); |
123 |
+ |
} |
124 |
+ |
|
125 |
+ |
void setTime(double time) { |
126 |
+ |
currentTime_ =time; |
127 |
+ |
//time at statData is redundant |
128 |
+ |
statData[Stats::TIME] = currentTime_; |
129 |
+ |
} |
130 |
+ |
|
131 |
+ |
double getChi() { |
132 |
+ |
return chi_; |
133 |
+ |
} |
134 |
+ |
|
135 |
+ |
void setChi(double chi) { |
136 |
+ |
chi_ = chi; |
137 |
+ |
} |
138 |
+ |
|
139 |
+ |
double getIntegralOfChiDt() { |
140 |
+ |
return integralOfChiDt_; |
141 |
+ |
} |
142 |
+ |
|
143 |
+ |
void setIntegralOfChiDt(double integralOfChiDt) { |
144 |
+ |
integralOfChiDt_ = integralOfChiDt; |
145 |
+ |
} |
146 |
+ |
|
147 |
+ |
Mat3x3d getEta() { |
148 |
+ |
return eta_; |
149 |
+ |
} |
150 |
+ |
|
151 |
+ |
void setEta(const Mat3x3d& eta) { |
152 |
+ |
eta_ = eta; |
153 |
+ |
} |
154 |
+ |
|
155 |
+ |
DataStorage atomData; |
156 |
+ |
DataStorage rigidbodyData; |
157 |
+ |
Stats statData; |
158 |
+ |
|
159 |
|
private: |
160 |
+ |
double currentTime_; |
161 |
+ |
|
162 |
+ |
Mat3x3d hmat_; |
163 |
+ |
Mat3x3d invHmat_; |
164 |
+ |
int orthoRhombic_; |
165 |
+ |
|
166 |
+ |
double chi_; |
167 |
+ |
double integralOfChiDt_; |
168 |
+ |
Mat3x3d eta_; |
169 |
|
|
170 |
+ |
int id_; /**< identification number of the snapshot */ |
171 |
|
}; |
172 |
|
|
173 |
+ |
typedef DataStorage (Snapshot::*DataStoragePointer); |
174 |
|
} |
175 |
|
#endif //BRAINS_SNAPSHOT_HPP |