1 |
gezelter |
246 |
/* |
2 |
|
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
|
* |
4 |
|
|
* The University of Notre Dame grants you ("Licensee") a |
5 |
|
|
* non-exclusive, royalty free, license to use, modify and |
6 |
|
|
* redistribute this software in source and binary code form, provided |
7 |
|
|
* that the following conditions are met: |
8 |
|
|
* |
9 |
|
|
* 1. Acknowledgement of the program authors must be made in any |
10 |
|
|
* publication of scientific results based in part on use of the |
11 |
|
|
* program. An acceptable form of acknowledgement is citation of |
12 |
|
|
* the article in which the program was described (Matthew |
13 |
|
|
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
|
|
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
|
|
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
|
|
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
|
|
* |
18 |
|
|
* 2. Redistributions of source code must retain the above copyright |
19 |
|
|
* notice, this list of conditions and the following disclaimer. |
20 |
|
|
* |
21 |
|
|
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
|
|
* notice, this list of conditions and the following disclaimer in the |
23 |
|
|
* documentation and/or other materials provided with the |
24 |
|
|
* distribution. |
25 |
|
|
* |
26 |
|
|
* This software is provided "AS IS," without a warranty of any |
27 |
|
|
* kind. All express or implied conditions, representations and |
28 |
|
|
* warranties, including any implied warranty of merchantability, |
29 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
30 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
31 |
|
|
* be liable for any damages suffered by licensee as a result of |
32 |
|
|
* using, modifying or distributing the software or its |
33 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
34 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
35 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
36 |
|
|
* damages, however caused and regardless of the theory of liability, |
37 |
|
|
* arising out of the use of or inability to use software, even if the |
38 |
|
|
* University of Notre Dame has been advised of the possibility of |
39 |
|
|
* such damages. |
40 |
|
|
*/ |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* @file RigidBody.hpp |
44 |
|
|
* @author tlin |
45 |
|
|
* @date 10/23/2004 |
46 |
|
|
* @version 1.0 |
47 |
|
|
*/ |
48 |
gezelter |
2 |
|
49 |
gezelter |
246 |
#ifndef PRIMITIVES_RIGIDBODY_HPP |
50 |
|
|
#define PRIMITIVES_RIGIDBODY_HPP |
51 |
|
|
|
52 |
gezelter |
2 |
#include <vector> |
53 |
gezelter |
246 |
|
54 |
tim |
3 |
#include "primitives/StuntDouble.hpp" |
55 |
gezelter |
246 |
#include "primitives/DirectionalAtom.hpp" |
56 |
|
|
#include "types/AtomStamp.hpp" |
57 |
|
|
namespace oopse{ |
58 |
gezelter |
2 |
class RigidBody : public StuntDouble { |
59 |
gezelter |
246 |
public: |
60 |
tim |
284 |
|
61 |
|
|
typedef std::vector<Atom*>::iterator AtomIterator; |
62 |
|
|
|
63 |
gezelter |
246 |
RigidBody(); |
64 |
gezelter |
2 |
|
65 |
gezelter |
246 |
virtual std::string getType() { return name_;} |
66 |
|
|
|
67 |
|
|
/** Sets the name of this stuntdouble*/ |
68 |
|
|
virtual void setType(const std::string& name) { name_ = name;} |
69 |
|
|
|
70 |
gezelter |
2 |
|
71 |
gezelter |
246 |
/** |
72 |
|
|
* Sets the previous rotation matrix of this stuntdouble |
73 |
|
|
* @param a new rotation matrix |
74 |
|
|
*/ |
75 |
|
|
virtual void setPrevA(const RotMat3x3d& a); |
76 |
|
|
|
77 |
|
|
/** |
78 |
|
|
* Sets the current rotation matrix of this stuntdouble |
79 |
|
|
* @param a new rotation matrix |
80 |
|
|
* @note setA will not change the position and rotation matrix of Directional atoms belong to |
81 |
|
|
* this rigidbody. If you want to do that, use #updateAtoms |
82 |
|
|
*/ |
83 |
|
|
virtual void setA(const RotMat3x3d& a); |
84 |
|
|
/** |
85 |
|
|
* Sets the rotation matrix of this stuntdouble in specified snapshot |
86 |
|
|
* @param a rotation matrix to be set |
87 |
|
|
* @param snapshotNo |
88 |
|
|
* @see #getA |
89 |
|
|
*/ |
90 |
|
|
virtual void setA(const RotMat3x3d& a, int snapshotNo); |
91 |
gezelter |
2 |
|
92 |
gezelter |
246 |
/** |
93 |
|
|
* Returns the inertia tensor of this stuntdouble |
94 |
|
|
* @return the inertia tensor of this stuntdouble |
95 |
|
|
*/ |
96 |
|
|
virtual Mat3x3d getI(); |
97 |
gezelter |
2 |
|
98 |
|
|
|
99 |
gezelter |
246 |
/** Sets the internal unit frame of this stuntdouble by three euler angles */ |
100 |
|
|
void setElectroFrameFromEuler(double phi, double theta, double psi); |
101 |
|
|
|
102 |
|
|
/** |
103 |
|
|
* Returns the gradient of this stuntdouble |
104 |
|
|
* @return the inertia tensor of this stuntdouble |
105 |
|
|
* @see #setI |
106 |
|
|
*/ |
107 |
|
|
virtual std::vector<double> getGrad(); |
108 |
gezelter |
2 |
|
109 |
gezelter |
246 |
virtual void accept(BaseVisitor* v); |
110 |
gezelter |
2 |
|
111 |
gezelter |
246 |
void addAtom(Atom* at, AtomStamp* ats); |
112 |
gezelter |
2 |
|
113 |
gezelter |
246 |
/** calculate the reference coordinates */ |
114 |
|
|
void calcRefCoords(); |
115 |
gezelter |
2 |
|
116 |
gezelter |
246 |
/** Convert Atomic forces and torques to total forces and torques */ |
117 |
|
|
void calcForcesAndTorques(); |
118 |
gezelter |
2 |
|
119 |
gezelter |
246 |
/** update the positions of atoms belong to this rigidbody */ |
120 |
|
|
void updateAtoms(); |
121 |
gezelter |
2 |
|
122 |
gezelter |
246 |
Atom* beginAtom(std::vector<Atom*>::iterator& i); |
123 |
gezelter |
2 |
|
124 |
gezelter |
246 |
Atom* nextAtom(std::vector<Atom*>::iterator& i); |
125 |
gezelter |
2 |
|
126 |
gezelter |
246 |
std::vector<Atom*>::iterator getBeginAtomIter() { |
127 |
|
|
return atoms_.begin(); |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
std::vector<Atom*>::iterator getEndAtomIter() { |
131 |
|
|
return atoms_.end(); |
132 |
|
|
} |
133 |
gezelter |
2 |
|
134 |
gezelter |
246 |
/** |
135 |
|
|
* Returns the atoms of this rigid body |
136 |
|
|
* @return the atoms of this rigid body in a vector |
137 |
|
|
* @deprecate |
138 |
|
|
*/ |
139 |
|
|
std::vector<Atom*> getAtoms() { |
140 |
|
|
return atoms_; |
141 |
|
|
} |
142 |
gezelter |
2 |
|
143 |
gezelter |
246 |
/** |
144 |
|
|
* Returns the number of atoms in this rigid body |
145 |
|
|
* @return the number of atoms in this rigid body |
146 |
|
|
*/ |
147 |
|
|
int getNumAtoms() { |
148 |
|
|
return atoms_.size(); |
149 |
|
|
} |
150 |
gezelter |
2 |
|
151 |
gezelter |
246 |
/** |
152 |
|
|
* Return the position of atom which belongs to this rigid body. |
153 |
|
|
* @return true if index is valid otherwise return false |
154 |
|
|
* @param pos the position of atom which will be set on return if index is valid |
155 |
|
|
* @param index the index of the atom in rigid body's private data member atoms_ |
156 |
|
|
*/ |
157 |
|
|
bool getAtomPos(Vector3d& pos, unsigned int index); |
158 |
gezelter |
2 |
|
159 |
gezelter |
246 |
/** |
160 |
|
|
* Return the position of atom which belongs to this rigid body. |
161 |
|
|
* @return true if atom belongs to this rigid body,otherwise return false |
162 |
|
|
* @param pos position of atom which will be set on return if atom belongs to this rigid body |
163 |
|
|
* @param atom the pointer to an atom |
164 |
|
|
*/ |
165 |
|
|
bool getAtomPos(Vector3d& pos, Atom* atom); |
166 |
gezelter |
2 |
|
167 |
gezelter |
246 |
/** |
168 |
|
|
* Return the velocity of atom which belongs to this rigid body. |
169 |
|
|
* @return true if index is valid otherwise return false |
170 |
|
|
* @param vel the velocity of atom which will be set on return if index is valid |
171 |
|
|
* @param index the index of the atom in rigid body's private data member atoms_ |
172 |
|
|
*/ |
173 |
|
|
bool getAtomVel(Vector3d& vel, unsigned int index); |
174 |
gezelter |
2 |
|
175 |
gezelter |
246 |
/** |
176 |
|
|
* Return the velocity of atom which belongs to this rigid body. |
177 |
|
|
* @return true if atom belongs to this rigid body,otherwise return false |
178 |
|
|
* @param vel velocity of atom which will be set on return if atom belongs to this rigid body |
179 |
|
|
* @param atom the pointer to an atom |
180 |
|
|
*/ |
181 |
|
|
bool getAtomVel(Vector3d& vel, Atom*); |
182 |
gezelter |
2 |
|
183 |
gezelter |
246 |
/** |
184 |
|
|
* Return the reference coordinate of atom which belongs to this rigid body. |
185 |
|
|
* @return true if index is valid otherwise return false |
186 |
|
|
* @param coor the reference coordinate of atom which will be set on return if index is valid |
187 |
|
|
* @param index the index of the atom in rigid body's private data member atoms_ |
188 |
|
|
*/ |
189 |
|
|
bool getAtomRefCoor(Vector3d& coor, unsigned int index); |
190 |
gezelter |
2 |
|
191 |
gezelter |
246 |
/** |
192 |
|
|
* Return the velocity of atom which belongs to this rigid body. |
193 |
|
|
* @return true if atom belongs to this rigid body,otherwise return false |
194 |
|
|
* @param coor velocity of atom which will be set on return if atom belongs to this rigid body |
195 |
|
|
* @param atom the pointer to an atom |
196 |
|
|
*/ |
197 |
|
|
bool getAtomRefCoor(Vector3d& coor, Atom* atom); |
198 |
gezelter |
2 |
|
199 |
gezelter |
246 |
private: |
200 |
|
|
std::string name_; |
201 |
|
|
Mat3x3d inertiaTensor_; |
202 |
|
|
RotMat3x3d sU_; /**< body fixed standard unit vector */ |
203 |
|
|
|
204 |
|
|
std::vector<Atom*> atoms_; |
205 |
|
|
std::vector<Vector3d> refCoords_; |
206 |
|
|
std::vector<RotMat3x3d> refOrients_; |
207 |
|
|
}; |
208 |
gezelter |
2 |
|
209 |
gezelter |
246 |
}//namepace oopse |
210 |
gezelter |
2 |
|
211 |
gezelter |
246 |
#endif //PRIMITIVES_RIGIDBODY_HPP |
212 |
gezelter |
2 |
|