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 |
tim |
1648 |
#include "brains/DataStorage.hpp" |
40 |
tim |
1710 |
#include "brains/Stats.hpp" |
41 |
tim |
1630 |
|
42 |
|
|
using namespace std; |
43 |
|
|
|
44 |
tim |
1615 |
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 |
tim |
1639 |
* Every snapshot class will contain one DataStorage for atoms and one DataStorage |
51 |
|
|
* for rigid bodies. |
52 |
tim |
1615 |
*/ |
53 |
|
|
class Snapshot { |
54 |
|
|
public: |
55 |
tim |
1639 |
|
56 |
tim |
1642 |
Snapshot(int nAtoms, int nRigidbodies) { |
57 |
|
|
atomData.resize(nAtoms); |
58 |
|
|
rigidbodyData.resize(nRigidbodies); |
59 |
tim |
1630 |
} |
60 |
|
|
|
61 |
|
|
Snapshot(const Snapshot& s); |
62 |
|
|
|
63 |
|
|
Snapshot& operator =(const Snapshot& s); |
64 |
tim |
1615 |
|
65 |
tim |
1630 |
/** Returns the id of this Snapshot */ |
66 |
|
|
int getID() { |
67 |
|
|
return id_; |
68 |
|
|
} |
69 |
|
|
|
70 |
|
|
/** Sets the id of this Snapshot */ |
71 |
|
|
void setID(int id) { |
72 |
|
|
id_ = id; |
73 |
|
|
} |
74 |
|
|
|
75 |
tim |
1642 |
int getSize() { |
76 |
tim |
1648 |
return atomData.getSize() + rigidbodyData.getSize(); |
77 |
tim |
1642 |
} |
78 |
tim |
1645 |
|
79 |
|
|
/** Returns the number of atoms */ |
80 |
|
|
int getNumberOfAtoms() { |
81 |
tim |
1648 |
return atomData.getSize(); |
82 |
tim |
1642 |
} |
83 |
tim |
1645 |
|
84 |
|
|
/** Returns the number of rigid bodies */ |
85 |
|
|
int getNumberOfRigidBodies() { |
86 |
tim |
1648 |
return rigidbodyData.getSize(); |
87 |
tim |
1642 |
} |
88 |
tim |
1645 |
|
89 |
|
|
/** Returns the H-Matrix */ |
90 |
|
|
Mat3x3d getHmat() { |
91 |
|
|
return hmat_; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
/** Sets the H-Matrix */ |
95 |
tim |
1727 |
void setHmat(const Mat3x3d& m) { |
96 |
tim |
1645 |
hmat_ = m; |
97 |
|
|
invHmat_ = hmat_.inverse(); |
98 |
tim |
1727 |
|
99 |
|
|
//notify fortran Hmat is changed |
100 |
|
|
double fortranHmat[9]; |
101 |
|
|
double fortranInvHmat[9]; |
102 |
|
|
hmat_.getArray(fortranHmat); |
103 |
|
|
invHmat_.getArray(fortranInvHmat); |
104 |
|
|
setFortranBox(fortranHmat, fortranInvHmat, &orthoRhombic_); |
105 |
tim |
1645 |
} |
106 |
|
|
|
107 |
tim |
1727 |
void getVolume() { |
108 |
|
|
return hmat_.determinant(); |
109 |
|
|
} |
110 |
|
|
|
111 |
tim |
1645 |
/** Returns the inverse H-Matrix */ |
112 |
|
|
Mat3x3d getInvHmat() { |
113 |
tim |
1695 |
return invHmat_; |
114 |
tim |
1645 |
} |
115 |
|
|
|
116 |
tim |
1727 |
/** Wrapping the vector according to periodic boundary condition*/ |
117 |
|
|
void wrapVector(Vector3d& v); |
118 |
|
|
|
119 |
|
|
|
120 |
tim |
1739 |
double getTime() { |
121 |
|
|
return currentTime_; |
122 |
tim |
1645 |
} |
123 |
|
|
|
124 |
tim |
1739 |
void setTime(double time) { |
125 |
|
|
currentTime_ =time; |
126 |
tim |
1727 |
//time at statData is redundant |
127 |
tim |
1739 |
statData[Stats::TIME] = currentTime_; |
128 |
tim |
1645 |
} |
129 |
|
|
|
130 |
tim |
1727 |
double getChi() { |
131 |
|
|
return chi_; |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
void setChi(double chi) { |
135 |
|
|
chi_ = chi; |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
double getIntegralOfChiDt() { |
139 |
|
|
return integralOfChiDt_; |
140 |
|
|
} |
141 |
|
|
|
142 |
|
|
void setIntegralOfChiDt(double integralOfChiDt) { |
143 |
|
|
integralOfChiDt_ = integralOfChiDt; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
Mat3x3d getEta() { |
147 |
|
|
return eta_; |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
void setEta(const Mat3x3d& eta) { |
151 |
|
|
eta_ = eta; |
152 |
|
|
} |
153 |
|
|
|
154 |
tim |
1639 |
DataStorage atomData; |
155 |
|
|
DataStorage rigidbodyData; |
156 |
tim |
1710 |
Stats statData; |
157 |
tim |
1645 |
|
158 |
tim |
1615 |
private: |
159 |
tim |
1739 |
double currentTime_; |
160 |
tim |
1727 |
|
161 |
tim |
1645 |
Mat3x3d hmat_; |
162 |
|
|
Mat3x3d invHmat_; |
163 |
tim |
1727 |
int orthoRhombic_; |
164 |
|
|
|
165 |
|
|
double chi_; |
166 |
|
|
double integralOfChiDt_; |
167 |
|
|
Mat3x3d eta_; |
168 |
|
|
|
169 |
tim |
1630 |
int id_; /**< identification number of the snapshot */ |
170 |
tim |
1615 |
}; |
171 |
|
|
|
172 |
tim |
1642 |
typedef DataStorage (Snapshot::*DataStoragePointer); |
173 |
tim |
1615 |
} |
174 |
|
|
#endif //BRAINS_SNAPSHOT_HPP |