1 |
gezelter |
507 |
/* |
2 |
gezelter |
246 |
* 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 |
gezelter |
1390 |
* 1. Redistributions of source code must retain the above copyright |
10 |
gezelter |
246 |
* notice, this list of conditions and the following disclaimer. |
11 |
|
|
* |
12 |
gezelter |
1390 |
* 2. Redistributions in binary form must reproduce the above copyright |
13 |
gezelter |
246 |
* notice, this list of conditions and the following disclaimer in the |
14 |
|
|
* documentation and/or other materials provided with the |
15 |
|
|
* distribution. |
16 |
|
|
* |
17 |
|
|
* This software is provided "AS IS," without a warranty of any |
18 |
|
|
* kind. All express or implied conditions, representations and |
19 |
|
|
* warranties, including any implied warranty of merchantability, |
20 |
|
|
* fitness for a particular purpose or non-infringement, are hereby |
21 |
|
|
* excluded. The University of Notre Dame and its licensors shall not |
22 |
|
|
* be liable for any damages suffered by licensee as a result of |
23 |
|
|
* using, modifying or distributing the software or its |
24 |
|
|
* derivatives. In no event will the University of Notre Dame or its |
25 |
|
|
* licensors be liable for any lost revenue, profit or data, or for |
26 |
|
|
* direct, indirect, special, consequential, incidental or punitive |
27 |
|
|
* damages, however caused and regardless of the theory of liability, |
28 |
|
|
* arising out of the use of or inability to use software, even if the |
29 |
|
|
* University of Notre Dame has been advised of the possibility of |
30 |
|
|
* such damages. |
31 |
gezelter |
1390 |
* |
32 |
|
|
* SUPPORT OPEN SCIENCE! If you use OpenMD or its source code in your |
33 |
|
|
* research, please cite the appropriate papers when you publish your |
34 |
|
|
* work. Good starting points are: |
35 |
|
|
* |
36 |
|
|
* [1] Meineke, et al., J. Comp. Chem. 26, 252-271 (2005). |
37 |
|
|
* [2] Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006). |
38 |
|
|
* [3] Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008). |
39 |
gezelter |
1665 |
* [4] Kuang & Gezelter, J. Chem. Phys. 133, 164101 (2010). |
40 |
|
|
* [5] Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011). |
41 |
gezelter |
246 |
*/ |
42 |
gezelter |
1787 |
|
43 |
|
|
#ifndef CONSTRAINTS_CONTRAINTELEM_HPP |
44 |
|
|
#define CONSTRAINTS_CONTRAINTELEM_HPP |
45 |
|
|
|
46 |
|
|
#include "primitives/StuntDouble.hpp" |
47 |
|
|
#include "utils/GenericData.hpp" |
48 |
|
|
#include "utils/simError.h" |
49 |
|
|
namespace OpenMD { |
50 |
|
|
|
51 |
|
|
/** |
52 |
|
|
* @class ConstraintElem ConstraintElem.hpp "constraints/ConstraintElem.hpp" |
53 |
|
|
* An adapter class of StuntDouble which is used at constraint algorithm |
54 |
|
|
*/ |
55 |
|
|
|
56 |
|
|
class ConstraintElem{ |
57 |
|
|
public: |
58 |
|
|
ConstraintElem(StuntDouble* sd) : sd_(sd) { |
59 |
|
|
GenericData* movedData = sd_->getPropertyByName("Moved"); |
60 |
|
|
if (movedData !=NULL) { //if generic data with keyword "moved" exists, assign it to moved_ |
61 |
|
|
moved_ = dynamic_cast<BoolGenericData*>(movedData); |
62 |
|
|
if (moved_ == NULL) { |
63 |
|
|
sprintf(painCave.errMsg, |
64 |
|
|
"Generic Data with keyword Moved exists, however, it can not be casted to a BoolGenericData.\n"); |
65 |
|
|
painCave.isFatal = 1;; |
66 |
|
|
simError(); |
67 |
|
|
} |
68 |
|
|
}else { //if generic data with keyword "moved" does not exist, create it |
69 |
|
|
moved_ = new BoolGenericData("Moved"); |
70 |
|
|
sd_->addProperty(moved_); |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
GenericData* movingData = sd_->getPropertyByName("Moving"); |
74 |
|
|
if (movingData !=NULL) { |
75 |
|
|
moving_ = dynamic_cast<BoolGenericData*>(movingData); |
76 |
|
|
if (moving_ == NULL) { |
77 |
|
|
sprintf(painCave.errMsg, |
78 |
|
|
"Generic Data with keyword Moving exists, however, it can not be casted to a BoolGenericData.\n"); |
79 |
|
|
painCave.isFatal = 1;; |
80 |
|
|
simError(); |
81 |
|
|
} |
82 |
|
|
}else { |
83 |
|
|
moving_ = new BoolGenericData("Moving"); |
84 |
|
|
sd_->addProperty(moving_); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
bool getMoved() { return moved_->getData(); } |
90 |
|
|
void setMoved(bool moved) { moved_->setData(moved);} |
91 |
|
|
|
92 |
|
|
bool getMoving() { return moving_->getData(); } |
93 |
|
|
void setMoving(bool moving) { moving_->setData(moving); } |
94 |
|
|
|
95 |
|
|
StuntDouble* getStuntDouble() { return sd_; } |
96 |
|
|
|
97 |
|
|
/** |
98 |
|
|
* Returns the global index of this stuntRealType. |
99 |
|
|
* @return the global index of this stuntdouble |
100 |
|
|
*/ |
101 |
|
|
int getGlobalIndex() { |
102 |
|
|
return sd_->getGlobalIndex(); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
/** |
106 |
|
|
* Sets the global index of this stuntRealType. |
107 |
gezelter |
1808 |
* @param index new global index to be set |
108 |
gezelter |
1787 |
*/ |
109 |
|
|
void setGlobalIndex(int index) { |
110 |
|
|
sd_->setGlobalIndex(index); |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
/** |
114 |
|
|
* Returns the local index of this stuntdouble |
115 |
|
|
* @return the local index of this stuntdouble |
116 |
|
|
*/ |
117 |
|
|
int getLocalIndex() { |
118 |
|
|
return sd_->getLocalIndex(); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
/** |
122 |
|
|
* Sets the local index of this stuntdouble |
123 |
|
|
* @param index new index to be set |
124 |
|
|
*/ |
125 |
|
|
void setLocalIndex(int index) { |
126 |
|
|
sd_->setLocalIndex(index); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
/** |
130 |
|
|
* Sets the Snapshot Manager of this stuntdouble |
131 |
|
|
*/ |
132 |
|
|
void setSnapshotManager(SnapshotManager* sman) { |
133 |
|
|
sd_->setSnapshotManager(sman); |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
/** |
137 |
|
|
* Tests if this stuntdouble is an atom |
138 |
|
|
* @return true is this stuntdouble is an atom(or a directional atom), return false otherwise |
139 |
|
|
*/ |
140 |
|
|
bool isAtom(){ |
141 |
|
|
return sd_->isAtom(); |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
/** |
145 |
|
|
* Tests if this stuntdouble is an directional atom |
146 |
|
|
* @return true if this stuntdouble is an directional atom, return false otherwise |
147 |
|
|
*/ |
148 |
|
|
bool isDirectionalAtom(){ |
149 |
|
|
return sd_->isDirectional(); |
150 |
|
|
} |
151 |
|
|
|
152 |
|
|
/** |
153 |
|
|
* Tests if this stuntdouble is a rigid body. |
154 |
|
|
* @return true if this stuntdouble is a rigid body, otherwise return false |
155 |
|
|
*/ |
156 |
|
|
bool isRigidBody(){ |
157 |
|
|
return sd_->isRigidBody(); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
/** |
161 |
|
|
* Tests if this stuntdouble is a directional one. |
162 |
|
|
* @return true is this stuntdouble is a directional atom or a rigid body, return false otherwise |
163 |
|
|
*/ |
164 |
|
|
bool isDirectional(){ |
165 |
|
|
return sd_->isDirectional(); |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
/** |
169 |
|
|
* Returns the previous position of this stuntdouble |
170 |
|
|
* @return the position of this stuntdouble |
171 |
|
|
*/ |
172 |
|
|
Vector3d getPrevPos() { |
173 |
|
|
return sd_->getPrevPos(); |
174 |
|
|
} |
175 |
|
|
|
176 |
|
|
/** |
177 |
|
|
* Returns the current position of this stuntdouble |
178 |
|
|
* @return the position of this stuntdouble |
179 |
|
|
*/ |
180 |
|
|
Vector3d getPos() { |
181 |
|
|
return sd_->getPos(); |
182 |
|
|
} |
183 |
|
|
|
184 |
|
|
/** |
185 |
|
|
* Returns the position of this stuntdouble in specified snapshot |
186 |
|
|
* @return the position of this stuntdouble |
187 |
|
|
* @param snapshotNo |
188 |
|
|
*/ |
189 |
|
|
Vector3d getPos(int snapshotNo) { |
190 |
|
|
return sd_->getPos(snapshotNo); |
191 |
|
|
} |
192 |
|
|
|
193 |
|
|
/** |
194 |
|
|
* Sets the previous position of this stuntdouble |
195 |
|
|
* @param pos new position |
196 |
|
|
* @see #getPos |
197 |
|
|
*/ |
198 |
|
|
void setPrevPos(const Vector3d& pos) { |
199 |
|
|
sd_->setPrevPos(pos); |
200 |
|
|
} |
201 |
|
|
|
202 |
|
|
/** |
203 |
|
|
* Sets the current position of this stuntdouble |
204 |
|
|
* @param pos new position |
205 |
|
|
*/ |
206 |
|
|
void setPos(const Vector3d& pos) { |
207 |
|
|
sd_->setPos(pos); |
208 |
|
|
} |
209 |
|
|
|
210 |
|
|
/** |
211 |
|
|
* Sets the position of this stuntdouble in specified snapshot |
212 |
|
|
* @param pos position to be set |
213 |
|
|
* @param snapshotNo |
214 |
|
|
* @see #getPos |
215 |
|
|
*/ |
216 |
|
|
void setPos(const Vector3d& pos, int snapshotNo) { |
217 |
|
|
sd_->setPos(pos, snapshotNo); |
218 |
|
|
} |
219 |
|
|
|
220 |
|
|
/** |
221 |
|
|
* Returns the previous velocity of this stuntdouble |
222 |
|
|
* @return the velocity of this stuntdouble |
223 |
|
|
*/ |
224 |
|
|
Vector3d getPrevVel() { |
225 |
|
|
return sd_->getPrevVel(); |
226 |
|
|
} |
227 |
|
|
|
228 |
|
|
/** |
229 |
|
|
* Returns the current velocity of this stuntdouble |
230 |
|
|
* @return the velocity of this stuntdouble |
231 |
|
|
*/ |
232 |
|
|
Vector3d getVel() { |
233 |
|
|
return sd_->getVel(); |
234 |
|
|
} |
235 |
|
|
|
236 |
|
|
/** |
237 |
|
|
* Returns the velocity of this stuntdouble in specified snapshot |
238 |
|
|
* @return the velocity of this stuntdouble |
239 |
|
|
* @param snapshotNo |
240 |
|
|
*/ |
241 |
|
|
|
242 |
|
|
Vector3d getVel(int snapshotNo) { |
243 |
|
|
return sd_->getVel(snapshotNo); |
244 |
|
|
} |
245 |
|
|
|
246 |
|
|
/** |
247 |
|
|
* Sets the previous velocity of this stuntdouble |
248 |
|
|
* @param vel new velocity |
249 |
|
|
* @see #getVel |
250 |
|
|
*/ |
251 |
|
|
void setPrevVel(const Vector3d& vel) { |
252 |
|
|
sd_->setPrevVel(vel); |
253 |
|
|
} |
254 |
|
|
|
255 |
|
|
/** |
256 |
|
|
* Sets the current velocity of this stuntdouble |
257 |
|
|
* @param vel new velocity |
258 |
|
|
*/ |
259 |
|
|
void setVel(const Vector3d& vel) { |
260 |
|
|
sd_->setVel(vel); |
261 |
|
|
} |
262 |
|
|
|
263 |
|
|
/** |
264 |
|
|
* Sets the velocity of this stuntdouble in specified snapshot |
265 |
|
|
* @param vel velocity to be set |
266 |
|
|
* @param snapshotNo |
267 |
|
|
* @see #getVel |
268 |
|
|
*/ |
269 |
|
|
void setVel(const Vector3d& vel, int snapshotNo) { |
270 |
|
|
sd_->setVel(vel, snapshotNo); |
271 |
|
|
} |
272 |
|
|
|
273 |
|
|
/** |
274 |
|
|
* Returns the previous rotation matrix of this stuntdouble |
275 |
|
|
* @return the rotation matrix of this stuntdouble |
276 |
|
|
*/ |
277 |
|
|
RotMat3x3d getPrevA() { |
278 |
|
|
return sd_->getPrevA(); |
279 |
|
|
} |
280 |
|
|
|
281 |
|
|
/** |
282 |
|
|
* Returns the current rotation matrix of this stuntdouble |
283 |
|
|
* @return the rotation matrix of this stuntdouble |
284 |
|
|
*/ |
285 |
|
|
RotMat3x3d getA() { |
286 |
|
|
return sd_->getA(); |
287 |
|
|
} |
288 |
|
|
|
289 |
|
|
/** |
290 |
|
|
* Returns the rotation matrix of this stuntdouble in specified snapshot |
291 |
|
|
* |
292 |
|
|
* @return the rotation matrix of this stuntdouble |
293 |
|
|
* @param snapshotNo |
294 |
|
|
*/ |
295 |
|
|
RotMat3x3d getA(int snapshotNo) { |
296 |
|
|
return sd_->getA(snapshotNo); |
297 |
|
|
} |
298 |
|
|
|
299 |
|
|
/** |
300 |
|
|
* Sets the previous rotation matrix of this stuntdouble |
301 |
|
|
* @param a new rotation matrix |
302 |
|
|
* @see #getA |
303 |
|
|
*/ |
304 |
|
|
void setPrevA(const RotMat3x3d& a) { |
305 |
|
|
sd_->setPrevA(a); |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
/** |
309 |
|
|
* Sets the current rotation matrix of this stuntdouble |
310 |
|
|
* @param a new rotation matrix |
311 |
|
|
*/ |
312 |
|
|
void setA(const RotMat3x3d& a) { |
313 |
|
|
sd_->setA(a); |
314 |
|
|
} |
315 |
|
|
|
316 |
|
|
/** |
317 |
|
|
* Sets the rotation matrix of this stuntdouble in specified snapshot |
318 |
|
|
* @param a rotation matrix to be set |
319 |
|
|
* @param snapshotNo |
320 |
|
|
* @see #getA |
321 |
|
|
*/ |
322 |
|
|
void setA(const RotMat3x3d& a, int snapshotNo) { |
323 |
|
|
sd_->setA(a, snapshotNo); |
324 |
|
|
} |
325 |
|
|
|
326 |
|
|
/** |
327 |
|
|
* Returns the previous angular momentum of this stuntdouble (body-fixed). |
328 |
|
|
* @return the angular momentum of this stuntdouble |
329 |
|
|
*/ |
330 |
|
|
Vector3d getPrevJ() { |
331 |
|
|
return sd_->getPrevJ(); |
332 |
|
|
} |
333 |
|
|
|
334 |
|
|
/** |
335 |
|
|
* Returns the current angular momentum of this stuntdouble (body -fixed). |
336 |
|
|
* @return the angular momentum of this stuntdouble |
337 |
|
|
*/ |
338 |
|
|
Vector3d getJ() { |
339 |
|
|
return sd_->getJ(); |
340 |
|
|
} |
341 |
|
|
|
342 |
|
|
/** |
343 |
|
|
* Returns the angular momentum of this stuntdouble in specified snapshot (body-fixed). |
344 |
|
|
* @return the angular momentum of this stuntdouble |
345 |
|
|
* @param snapshotNo |
346 |
|
|
*/ |
347 |
|
|
Vector3d getJ(int snapshotNo) { |
348 |
|
|
return sd_->getJ(snapshotNo); |
349 |
|
|
} |
350 |
|
|
|
351 |
|
|
/** |
352 |
|
|
* Sets the previous angular momentum of this stuntdouble (body-fixed). |
353 |
|
|
* @param angMom new angular momentum |
354 |
|
|
* @see #getJ |
355 |
|
|
*/ |
356 |
|
|
void setPrevJ(const Vector3d& angMom) { |
357 |
|
|
sd_->setPrevJ(angMom); |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
/** |
361 |
|
|
* Sets the current angular momentum of this stuntdouble (body-fixed). |
362 |
|
|
* @param angMom new angular momentum |
363 |
|
|
*/ |
364 |
|
|
void setJ(const Vector3d& angMom) { |
365 |
|
|
sd_->setJ(angMom); |
366 |
|
|
} |
367 |
|
|
|
368 |
|
|
/** |
369 |
|
|
* Sets the angular momentum of this stuntdouble in specified snapshot(body-fixed). |
370 |
|
|
* @param angMom angular momentum to be set |
371 |
|
|
* @param snapshotNo |
372 |
|
|
* @see #getJ |
373 |
|
|
*/ |
374 |
|
|
void setJ(const Vector3d& angMom, int snapshotNo) { |
375 |
|
|
sd_->setJ(angMom, snapshotNo); |
376 |
|
|
} |
377 |
|
|
|
378 |
|
|
/** |
379 |
|
|
* Returns the previous quaternion of this stuntdouble |
380 |
|
|
* @return the quaternion of this stuntdouble |
381 |
|
|
*/ |
382 |
|
|
Quat4d getPrevQ() { |
383 |
|
|
return sd_->getPrevQ(); |
384 |
|
|
} |
385 |
|
|
|
386 |
|
|
/** |
387 |
|
|
* Returns the current quaternion of this stuntdouble |
388 |
|
|
* @return the quaternion of this stuntdouble |
389 |
|
|
*/ |
390 |
|
|
Quat4d getQ() { |
391 |
|
|
return sd_->getQ(); |
392 |
|
|
} |
393 |
|
|
|
394 |
|
|
/** |
395 |
|
|
* Returns the quaternion of this stuntdouble in specified snapshot |
396 |
|
|
* @return the quaternion of this stuntdouble |
397 |
|
|
* @param snapshotNo |
398 |
|
|
*/ |
399 |
|
|
Quat4d getQ(int snapshotNo) { |
400 |
|
|
return sd_->getQ(snapshotNo); |
401 |
|
|
} |
402 |
|
|
|
403 |
|
|
/** |
404 |
|
|
* Sets the previous quaternion of this stuntdouble |
405 |
|
|
* @param q new quaternion |
406 |
|
|
* @note actual storage data is rotation matrix |
407 |
|
|
*/ |
408 |
|
|
void setPrevQ(const Quat4d& q) { |
409 |
|
|
sd_->setPrevQ(q); |
410 |
|
|
} |
411 |
|
|
|
412 |
|
|
/** |
413 |
|
|
* Sets the current quaternion of this stuntdouble |
414 |
|
|
* @param q new quaternion |
415 |
|
|
* @note actual storage data is rotation matrix |
416 |
|
|
*/ |
417 |
|
|
void setQ(const Quat4d& q) { |
418 |
|
|
sd_->setQ(q); |
419 |
|
|
} |
420 |
|
|
|
421 |
|
|
/** |
422 |
|
|
* Sets the quaternion of this stuntdouble in specified snapshot |
423 |
|
|
* |
424 |
|
|
* @param q quaternion to be set |
425 |
|
|
* @param snapshotNo |
426 |
|
|
* @note actual storage data is rotation matrix |
427 |
|
|
*/ |
428 |
|
|
void setQ(const Quat4d& q, int snapshotNo) { |
429 |
|
|
sd_->setQ(q, snapshotNo); |
430 |
|
|
} |
431 |
|
|
|
432 |
|
|
/** |
433 |
|
|
* Returns the previous euler angles of this stuntdouble |
434 |
|
|
* @return the euler angles of this stuntdouble |
435 |
|
|
*/ |
436 |
|
|
Vector3d getPrevEuler() { |
437 |
|
|
return sd_->getPrevEuler(); |
438 |
|
|
} |
439 |
|
|
|
440 |
|
|
/** |
441 |
|
|
* Returns the current euler angles of this stuntdouble |
442 |
|
|
* @return the euler angles of this stuntdouble |
443 |
|
|
*/ |
444 |
|
|
Vector3d getEuler() { |
445 |
|
|
return sd_->getEuler(); |
446 |
|
|
} |
447 |
|
|
|
448 |
|
|
/** |
449 |
|
|
* Returns the euler angles of this stuntdouble in specified snapshot. |
450 |
|
|
* @return the euler angles of this stuntdouble |
451 |
|
|
* @param snapshotNo |
452 |
|
|
*/ |
453 |
|
|
Vector3d getEuler(int snapshotNo) { |
454 |
|
|
return sd_->getEuler(snapshotNo); |
455 |
|
|
} |
456 |
|
|
|
457 |
|
|
/** |
458 |
|
|
* Sets the previous euler angles of this stuntRealType. |
459 |
|
|
* @param euler new euler angles |
460 |
|
|
* @see #getEuler |
461 |
|
|
* @note actual storage data is rotation matrix |
462 |
|
|
*/ |
463 |
|
|
void setPrevEuler(const Vector3d& euler) { |
464 |
|
|
sd_->setPrevEuler(euler); |
465 |
|
|
} |
466 |
|
|
|
467 |
|
|
/** |
468 |
|
|
* Sets the current euler angles of this stuntdouble |
469 |
|
|
* @param euler new euler angles |
470 |
|
|
*/ |
471 |
|
|
void setEuler(const Vector3d& euler) { |
472 |
|
|
sd_->setEuler(euler); |
473 |
|
|
} |
474 |
|
|
|
475 |
|
|
/** |
476 |
|
|
* Sets the euler angles of this stuntdouble in specified snapshot |
477 |
|
|
* |
478 |
|
|
* @param euler euler angles to be set |
479 |
|
|
* @param snapshotNo |
480 |
|
|
* @note actual storage data is rotation matrix |
481 |
|
|
*/ |
482 |
|
|
void setEuler(const Vector3d& euler, int snapshotNo) { |
483 |
|
|
sd_->setEuler(euler, snapshotNo); |
484 |
|
|
} |
485 |
|
|
|
486 |
|
|
/** |
487 |
|
|
* Returns the previous dipole vector of this stuntDouble |
488 |
|
|
* @return the dipole vector of this stuntDouble |
489 |
|
|
*/ |
490 |
|
|
Vector3d getPrevDipole() { |
491 |
|
|
return sd_->getPrevDipole(); |
492 |
|
|
} |
493 |
|
|
|
494 |
|
|
/** |
495 |
|
|
* Returns the current dipole vector of this stuntDouble |
496 |
|
|
* @return the dipole vector of this stuntDouble |
497 |
|
|
*/ |
498 |
|
|
Vector3d getDipole() { |
499 |
|
|
return sd_->getDipole(); |
500 |
|
|
} |
501 |
|
|
|
502 |
|
|
/** |
503 |
|
|
* Returns the dipole vector of this stuntDouble in specified snapshot |
504 |
|
|
* |
505 |
|
|
* @return the dipole vector of this stuntDouble |
506 |
|
|
* @param snapshotNo |
507 |
|
|
*/ |
508 |
|
|
Vector3d getDipole(int snapshotNo) { |
509 |
|
|
return sd_->getDipole(snapshotNo); |
510 |
|
|
} |
511 |
|
|
|
512 |
|
|
|
513 |
|
|
/** |
514 |
|
|
* Returns the previous quadrupole tensor of this stuntDouble |
515 |
|
|
* @return the quadrupole tensor of this stuntDouble |
516 |
|
|
*/ |
517 |
|
|
Mat3x3d getPrevQuadrupole() { |
518 |
|
|
return sd_->getPrevQuadrupole(); |
519 |
|
|
} |
520 |
|
|
|
521 |
|
|
/** |
522 |
|
|
* Returns the current quadrupole tensor of this stuntDouble |
523 |
|
|
* @return the quadrupole tensor of this stuntDouble |
524 |
|
|
*/ |
525 |
|
|
Mat3x3d getQuadrupole() { |
526 |
|
|
return sd_->getQuadrupole(); |
527 |
|
|
} |
528 |
|
|
|
529 |
|
|
/** |
530 |
|
|
* Returns the quadrupole tensor of this stuntDouble in specified snapshot |
531 |
|
|
* |
532 |
|
|
* @return the quadrupole tensor of this stuntDouble |
533 |
|
|
* @param snapshotNo |
534 |
|
|
*/ |
535 |
|
|
Mat3x3d getQuadrupole(int snapshotNo) { |
536 |
|
|
return sd_->getQuadrupole(snapshotNo); |
537 |
|
|
} |
538 |
|
|
|
539 |
|
|
/** |
540 |
|
|
* Returns the previous force of this stuntdouble |
541 |
|
|
* @return the force of this stuntdouble |
542 |
|
|
*/ |
543 |
|
|
Vector3d getPrevFrc() { |
544 |
|
|
return sd_->getPrevFrc(); |
545 |
|
|
} |
546 |
|
|
|
547 |
|
|
/** |
548 |
|
|
* Returns the current force of this stuntdouble |
549 |
|
|
* @return the force of this stuntdouble |
550 |
|
|
*/ |
551 |
|
|
Vector3d getFrc() { |
552 |
|
|
return sd_->getFrc(); |
553 |
|
|
} |
554 |
|
|
|
555 |
|
|
/** |
556 |
|
|
* Returns the force of this stuntdouble in specified snapshot |
557 |
|
|
* |
558 |
|
|
* @return the force of this stuntdouble |
559 |
|
|
* @param snapshotNo |
560 |
|
|
*/ |
561 |
|
|
Vector3d getFrc(int snapshotNo) { |
562 |
|
|
return sd_->getFrc(snapshotNo); |
563 |
|
|
} |
564 |
|
|
|
565 |
|
|
/** |
566 |
|
|
* Sets the previous force of this stuntdouble |
567 |
|
|
* |
568 |
|
|
* @param frc new force |
569 |
|
|
* @see #getFrc |
570 |
|
|
*/ |
571 |
|
|
void setPrevFrc(const Vector3d& frc) { |
572 |
|
|
sd_->setPrevFrc(frc); |
573 |
|
|
} |
574 |
|
|
|
575 |
|
|
/** |
576 |
|
|
* Sets the current force of this stuntdouble |
577 |
|
|
* @param frc new force |
578 |
|
|
*/ |
579 |
|
|
void setFrc(const Vector3d& frc) { |
580 |
|
|
sd_->setFrc(frc); |
581 |
|
|
} |
582 |
|
|
|
583 |
|
|
/** |
584 |
|
|
* Sets the force of this stuntdouble in specified snapshot |
585 |
|
|
* |
586 |
|
|
* @param frc force to be set |
587 |
|
|
* @param snapshotNo |
588 |
|
|
* @see #getFrc |
589 |
|
|
*/ |
590 |
|
|
void setFrc(const Vector3d& frc, int snapshotNo) { |
591 |
|
|
sd_->setFrc(frc, snapshotNo); |
592 |
|
|
} |
593 |
|
|
|
594 |
|
|
/** |
595 |
|
|
* Adds force into the previous force of this stuntdouble |
596 |
|
|
* |
597 |
|
|
* @param frc new force |
598 |
|
|
* @see #getFrc |
599 |
|
|
*/ |
600 |
|
|
void addPrevFrc(const Vector3d& frc) { |
601 |
|
|
sd_->addPrevFrc(frc); |
602 |
|
|
} |
603 |
|
|
|
604 |
|
|
/** |
605 |
|
|
* Adds force into the current force of this stuntdouble |
606 |
|
|
* @param frc new force |
607 |
|
|
*/ |
608 |
|
|
void addFrc(const Vector3d& frc) { |
609 |
|
|
sd_->addFrc(frc); |
610 |
|
|
} |
611 |
|
|
|
612 |
|
|
/** |
613 |
|
|
* Adds force into the force of this stuntdouble in specified snapshot |
614 |
|
|
* |
615 |
|
|
* @param frc force to be set |
616 |
|
|
* @param snapshotNo |
617 |
|
|
* @see #getFrc |
618 |
|
|
*/ |
619 |
|
|
void addFrc(const Vector3d& frc, int snapshotNo) { |
620 |
|
|
sd_->addFrc(frc, snapshotNo); |
621 |
|
|
} |
622 |
|
|
|
623 |
|
|
/** |
624 |
|
|
* Returns the previous torque of this stuntdouble |
625 |
|
|
* @return the torque of this stuntdouble |
626 |
|
|
*/ |
627 |
|
|
Vector3d getPrevTrq() { |
628 |
|
|
return sd_->getPrevTrq(); |
629 |
|
|
} |
630 |
|
|
|
631 |
|
|
/** |
632 |
|
|
* Returns the current torque of this stuntdouble |
633 |
|
|
* @return the torque of this stuntdouble |
634 |
|
|
*/ |
635 |
|
|
Vector3d getTrq() { |
636 |
|
|
return sd_->getTrq(); |
637 |
|
|
} |
638 |
|
|
|
639 |
|
|
/** |
640 |
|
|
* Returns the torque of this stuntdouble in specified snapshot |
641 |
|
|
* |
642 |
|
|
* @return the torque of this stuntdouble |
643 |
|
|
* @param snapshotNo |
644 |
|
|
*/ |
645 |
|
|
Vector3d getTrq(int snapshotNo) { |
646 |
|
|
return sd_->getTrq(snapshotNo); |
647 |
|
|
} |
648 |
|
|
|
649 |
|
|
/** |
650 |
|
|
* Sets the previous torque of this stuntdouble |
651 |
|
|
* |
652 |
|
|
* @param trq new torque |
653 |
|
|
* @see #getTrq |
654 |
|
|
*/ |
655 |
|
|
void setPrevTrq(const Vector3d& trq) { |
656 |
|
|
sd_->setPrevTrq(trq); |
657 |
|
|
} |
658 |
|
|
|
659 |
|
|
/** |
660 |
|
|
* Sets the current torque of this stuntdouble |
661 |
|
|
* @param trq new torque |
662 |
|
|
*/ |
663 |
|
|
void setTrq(const Vector3d& trq) { |
664 |
|
|
sd_->setTrq(trq); |
665 |
|
|
} |
666 |
|
|
|
667 |
|
|
/** |
668 |
|
|
* Sets the torque of this stuntdouble in specified snapshot |
669 |
|
|
* |
670 |
|
|
* @param trq torque to be set |
671 |
|
|
* @param snapshotNo |
672 |
|
|
* @see #getTrq |
673 |
|
|
*/ |
674 |
|
|
void setTrq(const Vector3d& trq, int snapshotNo) { |
675 |
|
|
sd_->setTrq(trq, snapshotNo); |
676 |
|
|
} |
677 |
|
|
|
678 |
|
|
/** |
679 |
|
|
* Adds torque into the previous torque of this stuntdouble |
680 |
|
|
* |
681 |
|
|
* @param trq new torque |
682 |
|
|
* @see #getTrq |
683 |
|
|
*/ |
684 |
|
|
void addPrevTrq(const Vector3d& trq) { |
685 |
|
|
sd_->addPrevTrq(trq); |
686 |
|
|
} |
687 |
|
|
|
688 |
|
|
/** |
689 |
|
|
* Adds torque into the current torque of this stuntdouble |
690 |
|
|
* @param trq new torque |
691 |
|
|
*/ |
692 |
|
|
void addTrq(const Vector3d& trq) { |
693 |
|
|
sd_->addTrq(trq); |
694 |
|
|
} |
695 |
|
|
|
696 |
|
|
/** |
697 |
|
|
* Adds torque into the torque of this stuntdouble in specified snapshot |
698 |
|
|
* |
699 |
|
|
* @param trq torque to be add |
700 |
|
|
* @param snapshotNo |
701 |
|
|
* @see #getTrq |
702 |
|
|
*/ |
703 |
|
|
void addTrq(const Vector3d& trq, int snapshotNo) { |
704 |
|
|
sd_->addTrq(trq, snapshotNo); |
705 |
|
|
} |
706 |
|
|
|
707 |
|
|
/** Set the force of this stuntdouble to zero */ |
708 |
|
|
void zeroForcesAndTorques() { |
709 |
|
|
sd_->zeroForcesAndTorques(); |
710 |
|
|
} |
711 |
|
|
/** |
712 |
|
|
* Returns the inertia tensor of this stuntdouble |
713 |
|
|
* @return the inertia tensor of this stuntdouble |
714 |
|
|
*/ |
715 |
|
|
Mat3x3d getI() { |
716 |
|
|
return sd_->getI(); |
717 |
|
|
} |
718 |
|
|
|
719 |
|
|
/** |
720 |
|
|
* Returns the gradient of this stuntdouble |
721 |
|
|
* @return the gradient of this stuntdouble |
722 |
|
|
*/ |
723 |
|
|
std::vector<RealType> getGrad() { |
724 |
|
|
return sd_->getGrad(); |
725 |
|
|
} |
726 |
|
|
|
727 |
|
|
/** |
728 |
|
|
* Tests the if this stuntdouble is a linear rigidbody |
729 |
|
|
* |
730 |
|
|
* @return true if this stuntdouble is a linear rigidbody, otherwise return false |
731 |
|
|
* @note atom and directional atom will always return false |
732 |
|
|
* |
733 |
|
|
* @see #linearAxis |
734 |
|
|
*/ |
735 |
|
|
bool isLinear() { |
736 |
|
|
return sd_->isLinear(); |
737 |
|
|
} |
738 |
|
|
|
739 |
|
|
/** |
740 |
|
|
* Returns the linear axis of the rigidbody, atom and directional atom will always return -1 |
741 |
|
|
* |
742 |
|
|
* @return the linear axis of the rigidbody |
743 |
|
|
* |
744 |
|
|
* @see #isLinear |
745 |
|
|
*/ |
746 |
|
|
int linearAxis() { |
747 |
|
|
return sd_->linearAxis(); |
748 |
|
|
} |
749 |
|
|
|
750 |
|
|
/** Returns the mass of this stuntdouble */ |
751 |
|
|
RealType getMass() { |
752 |
|
|
return sd_->getMass(); |
753 |
|
|
} |
754 |
|
|
|
755 |
|
|
/** |
756 |
|
|
* Sets the mass of this stuntdoulbe |
757 |
|
|
* @param mass the mass to be set |
758 |
|
|
*/ |
759 |
|
|
void setMass(RealType mass) { |
760 |
|
|
sd_->setMass(mass); |
761 |
|
|
} |
762 |
|
|
|
763 |
|
|
/** Returns the name of this stuntdouble */ |
764 |
|
|
std::string getType() { |
765 |
|
|
return sd_->getType(); |
766 |
|
|
} |
767 |
|
|
|
768 |
|
|
/** Sets the name of this stuntRealType*/ |
769 |
|
|
void setType(const std::string& name) { |
770 |
|
|
sd_->setType(name); |
771 |
|
|
} |
772 |
|
|
|
773 |
|
|
/** |
774 |
|
|
* Converts a lab fixed vector to a body fixed vector. |
775 |
|
|
* @return body fixed vector |
776 |
|
|
* @param v lab fixed vector |
777 |
|
|
*/ |
778 |
|
|
Vector3d lab2Body(const Vector3d& v) { |
779 |
|
|
return sd_->lab2Body(v); |
780 |
|
|
} |
781 |
|
|
|
782 |
|
|
/** |
783 |
|
|
* Converts a body fixed vector to a lab fixed vector. |
784 |
|
|
* @return corresponding lab fixed vector |
785 |
|
|
* @param v body fixed vector |
786 |
|
|
*/ |
787 |
|
|
Vector3d body2Lab(const Vector3d& v){ |
788 |
|
|
return sd_->body2Lab(v); |
789 |
|
|
} |
790 |
|
|
/** |
791 |
|
|
* <p> |
792 |
|
|
* The purpose of the Visitor Pattern is to encapsulate an operation that you want to perform on |
793 |
|
|
* the elements of a data structure. In this way, you can change the operation being performed |
794 |
|
|
* on a structure without the need of changing the classes of the elements that you are operating |
795 |
|
|
* on. Using a Visitor pattern allows you to decouple the classes for the data structure and the |
796 |
|
|
* algorithms used upon them |
797 |
|
|
* </p> |
798 |
|
|
* @param v visitor |
799 |
|
|
*/ |
800 |
|
|
void accept(BaseVisitor* v) { |
801 |
|
|
sd_->accept(v); |
802 |
|
|
} |
803 |
|
|
|
804 |
|
|
//below functions are just forward functions |
805 |
|
|
/** |
806 |
|
|
* Adds property into property map |
807 |
|
|
* @param genData GenericData to be added into PropertyMap |
808 |
|
|
*/ |
809 |
|
|
void addProperty(GenericData* genData){ |
810 |
|
|
sd_->addProperty(genData); |
811 |
|
|
} |
812 |
|
|
|
813 |
|
|
/** |
814 |
|
|
* Removes property from PropertyMap by name |
815 |
|
|
* @param propName the name of property to be removed |
816 |
|
|
*/ |
817 |
|
|
void removeProperty(const std::string& propName) { |
818 |
|
|
sd_->removeProperty(propName); |
819 |
|
|
} |
820 |
|
|
|
821 |
|
|
/** |
822 |
|
|
* clear all of the properties |
823 |
|
|
*/ |
824 |
|
|
void clearProperties() { |
825 |
|
|
sd_->clearProperties(); |
826 |
|
|
} |
827 |
|
|
|
828 |
|
|
/** |
829 |
|
|
* Returns all names of properties |
830 |
|
|
* @return all names of properties |
831 |
|
|
*/ |
832 |
|
|
std::vector<std::string> getPropertyNames() { |
833 |
|
|
return sd_->getPropertyNames(); |
834 |
|
|
} |
835 |
|
|
|
836 |
|
|
/** |
837 |
|
|
* Returns all of the properties in PropertyMap |
838 |
|
|
* @return all of the properties in PropertyMap |
839 |
|
|
*/ |
840 |
|
|
std::vector<GenericData*> getProperties() { |
841 |
|
|
return sd_->getProperties(); |
842 |
|
|
} |
843 |
|
|
|
844 |
|
|
/** |
845 |
|
|
* Returns property |
846 |
|
|
* @param propName name of property |
847 |
|
|
* @return a pointer point to property with propName. If no property named propName |
848 |
|
|
* exists, return NULL |
849 |
|
|
*/ |
850 |
|
|
GenericData* getPropertyByName(const std::string& propName) { |
851 |
|
|
return sd_->getPropertyByName(propName); |
852 |
|
|
} |
853 |
|
|
|
854 |
|
|
private: |
855 |
|
|
StuntDouble* sd_; |
856 |
|
|
BoolGenericData* moved_; |
857 |
|
|
BoolGenericData* moving_; |
858 |
|
|
}; |
859 |
|
|
|
860 |
|
|
} |
861 |
|
|
|
862 |
|
|
#endif |