ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/primitives/StuntDouble.hpp
Revision: 3520
Committed: Mon Sep 7 16:31:51 2009 UTC (15 years, 11 months ago) by cli2
File size: 33540 byte(s)
Log Message:
Added new restraint infrastructure
Added MolecularRestraints
Added ObjectRestraints
Added RestraintStamp
Updated thermodynamic integration to use ObjectRestraints
Added Quaternion mathematics for twist swing decompositions
Significantly updated RestWriter and RestReader to use dump-like files
Added selections for x, y, and z coordinates of atoms
Removed monolithic Restraints class
Fixed a few bugs in gradients of Euler angles in DirectionalAtom and RigidBody
Added some rotational capabilities to prinicpalAxisCalculator

File Contents

# User Rev Content
1 gezelter 2204 /*
2 gezelter 1930 * 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 StuntDouble.hpp
44     * @author tlin
45     * @date 10/22/2004
46     * @version 1.0
47     */
48    
49 gezelter 2204 #ifndef PRIMITIVES_STUNTDOUBLE_HPP
50     #define PRIMITIVES_STUNTDOUBLE_HPP
51 gezelter 1490
52 gezelter 1930 #include <vector>
53 gezelter 1490
54 gezelter 1930 #include "visitors/BaseVisitor.hpp"
55     #include "math/Quaternion.hpp"
56     #include "math/SquareMatrix3.hpp"
57     #include "math/Vector3.hpp"
58     #include "utils/PropertyMap.hpp"
59     #include "brains/Snapshot.hpp"
60     #include "brains/SnapshotManager.hpp"
61     namespace oopse{
62 gezelter 1490
63 tim 1625
64 gezelter 1930
65     /**
66     * @class StuntDouble StuntDouble.hpp "Primitives/StuntDouble.hpp"
67     * @brief
68 gezelter 2272 * "Don't move, or you're dead! Stand up! Captain, we've got them!"
69     *
70     * "Spectacular stunt, my friends, but all for naught. Turn around
71     * please. Ha. What a pity. What a pity. So, Princess, you thought
72     * you could outwit the imperious forces of...."
73     *
74     * "You idiots! These are not them. You've captured their stunt
75     * doubles! Search the area. Find them! Find them!"
76     *
77 gezelter 1930 * StuntDouble is a very strange idea. A StuntDouble stands in for
78     * some object that can be manipulated by the Integrators or
79     * Minimizers. Some of the manipulable objects are Atoms, some are
80     * DirectionalAtoms, and some are RigidBodies. StuntDouble
81     * provides an interface for the Integrators and Minimizers to use,
82     * and does some preliminary sanity checking so that the program
83 gezelter 2272 * doesn't try to do something stupid like torque an Atom (The
84     * quotes above are from Spaceballs...)
85     *
86 chuckv 3397 * @note the dynamic data of stuntDouble will be stored outside of the class
87 gezelter 1930 */
88 gezelter 2204 class StuntDouble{
89     public:
90 gezelter 1490
91 gezelter 2204 enum ObjectType{
92     otAtom,
93     otDAtom,
94     otRigidBody
95     };
96 gezelter 1490
97 gezelter 2204 virtual ~StuntDouble();
98 gezelter 1930
99 gezelter 2204 /**
100 chuckv 3397 * Returns the global index of this stuntDouble.
101     * @return the global index of this stuntDouble
102 gezelter 2204 */
103     int getGlobalIndex() {
104     return globalIndex_;
105     }
106 gezelter 1490
107 gezelter 2204 /**
108 chuckv 3397 * Sets the global index of this stuntDouble.
109 gezelter 2204 * @param new global index to be set
110     */
111     void setGlobalIndex(int index) {
112     globalIndex_ = index;
113     }
114 chuckv 3397
115 gezelter 2204 /**
116 chuckv 3397 * Returns the local index of this stuntDouble
117     * @return the local index of this stuntDouble
118 gezelter 2204 */
119     int getLocalIndex() {
120     return localIndex_;
121     }
122 gezelter 1490
123 gezelter 2204 /**
124 chuckv 3397 * Sets the local index of this stuntDouble
125 gezelter 2204 * @param index new index to be set
126     */
127     void setLocalIndex(int index) {
128     localIndex_ = index;
129     }
130 chuckv 3397
131     int getGlobalIntegrableObjectIndex(){
132     return globalIntegrableObjectIndex_;
133     }
134     void setGlobalIntegrableObjectIndex(int index) {
135     globalIntegrableObjectIndex_ = index;
136     }
137 gezelter 1490
138 gezelter 2204 /**
139 chuckv 3397 * Sets the Snapshot Manager of this stuntDouble
140 gezelter 2204 */
141     void setSnapshotManager(SnapshotManager* sman) {
142     snapshotMan_ = sman;
143     }
144 gezelter 1490
145 gezelter 2204 /**
146 chuckv 3397 * Tests if this stuntDouble is an atom
147     * @return true is this stuntDouble is an atom(or a directional atom), return false otherwise
148 gezelter 2204 */
149     bool isAtom(){
150     return objType_ == otAtom || objType_ == otDAtom;
151     }
152 gezelter 1490
153 gezelter 2204 /**
154 chuckv 3397 * Tests if this stuntDouble is an directional atom
155     * @return true if this stuntDouble is an directional atom, return false otherwise
156 gezelter 2204 */
157     bool isDirectionalAtom(){
158     return objType_ == otDAtom;
159     }
160 gezelter 1490
161 gezelter 2204 /**
162 chuckv 3397 * Tests if this stuntDouble is a rigid body.
163     * @return true if this stuntDouble is a rigid body, otherwise return false
164 gezelter 2204 */
165     bool isRigidBody(){
166     return objType_ == otRigidBody;
167     }
168 gezelter 1490
169 gezelter 2204 /**
170 chuckv 3397 * Tests if this stuntDouble is a directional one.
171     * @return true is this stuntDouble is a directional atom or a rigid body, return false otherwise
172 gezelter 2204 */
173     bool isDirectional(){
174     return isDirectionalAtom() || isRigidBody();
175     }
176 gezelter 1490
177 gezelter 2204 /**
178 gezelter 2733 * Freezes out all velocity, angular velocity, forces and torques
179     * on this StuntDouble. Also computes the number of frozen degrees
180     * of freedom.
181     * @return the total number of frozen degrees of freedom
182     */
183     int freeze() {
184    
185     int fdf = 3;
186    
187     setVel(V3Zero);
188     setFrc(V3Zero);
189     if (isDirectional()){
190     setJ(V3Zero);
191     setTrq(V3Zero);
192     if (isLinear())
193     fdf +=2;
194     else
195     fdf +=3;
196     }
197     return fdf;
198     }
199    
200     /**
201 chuckv 3397 * Returns the previous position of this stuntDouble
202     * @return the position of this stuntDouble
203 gezelter 2204 */
204     Vector3d getPrevPos() {
205     return ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_];
206     }
207 gezelter 1930
208 gezelter 2204 /**
209 chuckv 3397 * Returns the current position of this stuntDouble
210     * @return the position of this stuntDouble
211 gezelter 2204 */
212     Vector3d getPos() {
213     return ((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_];
214     }
215 gezelter 1490
216 gezelter 2204 /**
217 chuckv 3397 * Returns the position of this stuntDouble in specified snapshot
218     * @return the position of this stuntDouble
219 gezelter 2204 * @param snapshotNo
220     */
221     Vector3d getPos(int snapshotNo) {
222     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_];
223     }
224 gezelter 1490
225 gezelter 2204 /**
226 chuckv 3397 * Sets the previous position of this stuntDouble
227 gezelter 2204 * @param pos new position
228     * @see #getPos
229     */
230     void setPrevPos(const Vector3d& pos) {
231     ((snapshotMan_->getPrevSnapshot())->*storage_).position[localIndex_] = pos;
232     }
233 gezelter 1930
234 gezelter 2204 /**
235 chuckv 3397 * Sets the current position of this stuntDouble
236 gezelter 2204 * @param pos new position
237     */
238     void setPos(const Vector3d& pos) {
239     DataStorage& data = snapshotMan_->getCurrentSnapshot()->*storage_;
240     data.position[localIndex_] = pos;
241     //((snapshotMan_->getCurrentSnapshot())->*storage_).position[localIndex_] = pos;
242     }
243 gezelter 1490
244 gezelter 2204 /**
245 chuckv 3397 * Sets the position of this stuntDouble in specified snapshot
246 gezelter 2204 * @param pos position to be set
247     * @param snapshotNo
248     * @see #getPos
249     */
250     void setPos(const Vector3d& pos, int snapshotNo) {
251 gezelter 1490
252 gezelter 2204 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).position[localIndex_] = pos;
253 gezelter 1490
254 gezelter 2204 }
255 gezelter 1930
256 gezelter 2204 /**
257 chuckv 3397 * Returns the previous velocity of this stuntDouble
258     * @return the velocity of this stuntDouble
259 gezelter 2204 */
260     Vector3d getPrevVel() {
261     return ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_];
262     }
263 gezelter 1930
264 gezelter 2204 /**
265 chuckv 3397 * Returns the current velocity of this stuntDouble
266     * @return the velocity of this stuntDouble
267 gezelter 2204 */
268     Vector3d getVel() {
269     return ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_];
270     }
271 gezelter 1490
272 gezelter 2204 /**
273 chuckv 3397 * Returns the velocity of this stuntDouble in specified snapshot
274     * @return the velocity of this stuntDouble
275 gezelter 2204 * @param snapshotNo
276     */
277     Vector3d getVel(int snapshotNo) {
278     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_];
279     }
280 gezelter 1490
281 gezelter 2204 /**
282 chuckv 3397 * Sets the previous velocity of this stuntDouble
283 gezelter 2204 * @param vel new velocity
284     * @see #getVel
285     */
286     void setPrevVel(const Vector3d& vel) {
287     ((snapshotMan_->getPrevSnapshot())->*storage_).velocity[localIndex_] = vel;
288     }
289 gezelter 1930
290 gezelter 2204 /**
291 chuckv 3397 * Sets the current velocity of this stuntDouble
292 gezelter 2204 * @param vel new velocity
293     */
294     void setVel(const Vector3d& vel) {
295     ((snapshotMan_->getCurrentSnapshot())->*storage_).velocity[localIndex_] = vel;
296     }
297 gezelter 1930
298 gezelter 2204 /**
299 chuckv 3397 * Sets the velocity of this stuntDouble in specified snapshot
300 gezelter 2204 * @param vel velocity to be set
301     * @param snapshotNo
302     * @see #getVel
303     */
304     void setVel(const Vector3d& vel, int snapshotNo) {
305     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).velocity[localIndex_] = vel;
306     }
307 gezelter 1930
308 gezelter 2204 /**
309 chuckv 3397 * Returns the previous rotation matrix of this stuntDouble
310     * @return the rotation matrix of this stuntDouble
311 gezelter 2204 */
312     RotMat3x3d getPrevA() {
313     return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_];
314     }
315 gezelter 1930
316 gezelter 2204 /**
317 chuckv 3397 * Returns the current rotation matrix of this stuntDouble
318     * @return the rotation matrix of this stuntDouble
319 gezelter 2204 */
320     RotMat3x3d getA() {
321     return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_];
322     }
323 gezelter 1930
324 gezelter 2204 /**
325 chuckv 3397 * Returns the rotation matrix of this stuntDouble in specified snapshot
326 gezelter 2204 *
327 chuckv 3397 * @return the rotation matrix of this stuntDouble
328 gezelter 2204 * @param snapshotNo
329     */
330     RotMat3x3d getA(int snapshotNo) {
331     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_];
332     }
333 gezelter 1930
334 gezelter 2204 /**
335 chuckv 3397 * Sets the previous rotation matrix of this stuntDouble
336 gezelter 2204 * @param a new rotation matrix
337     * @see #getA
338     */
339     virtual void setPrevA(const RotMat3x3d& a) {
340     ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = a;
341     }
342 gezelter 1930
343 gezelter 2204 /**
344 chuckv 3397 * Sets the current rotation matrix of this stuntDouble
345 gezelter 2204 * @param a new rotation matrix
346     */
347     virtual void setA(const RotMat3x3d& a) {
348     ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = a;
349     }
350 gezelter 1930
351 gezelter 2204 /**
352 chuckv 3397 * Sets the rotation matrix of this stuntDouble in specified snapshot
353 gezelter 2204 * @param a rotation matrix to be set
354     * @param snapshotNo
355     * @see #getA
356     */
357     virtual void setA(const RotMat3x3d& a, int snapshotNo) {
358     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = a;
359     }
360 gezelter 1930
361 gezelter 2204 /**
362 chuckv 3397 * Returns the previous angular momentum of this stuntDouble (body-fixed).
363     * @return the angular momentum of this stuntDouble
364 gezelter 2204 */
365     Vector3d getPrevJ() {
366     return ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_];
367     }
368 gezelter 1930
369 gezelter 2204 /**
370 chuckv 3397 * Returns the current angular momentum of this stuntDouble (body -fixed).
371     * @return the angular momentum of this stuntDouble
372 gezelter 2204 */
373     Vector3d getJ() {
374     return ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_];
375     }
376 gezelter 1930
377 gezelter 2204 /**
378 chuckv 3397 * Returns the angular momentum of this stuntDouble in specified snapshot (body-fixed).
379     * @return the angular momentum of this stuntDouble
380 gezelter 2204 * @param snapshotNo
381     */
382     Vector3d getJ(int snapshotNo) {
383     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_];
384     }
385 gezelter 1930
386 gezelter 2204 /**
387 chuckv 3397 * Sets the previous angular momentum of this stuntDouble (body-fixed).
388 gezelter 2204 * @param angMom new angular momentum
389     * @see #getJ
390     */
391     void setPrevJ(const Vector3d& angMom) {
392     ((snapshotMan_->getPrevSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
393     }
394 gezelter 1930
395 gezelter 2204 /**
396 chuckv 3397 * Sets the current angular momentum of this stuntDouble (body-fixed).
397 gezelter 2204 * @param angMom new angular momentum
398     */
399     void setJ(const Vector3d& angMom) {
400     ((snapshotMan_->getCurrentSnapshot())->*storage_).angularMomentum[localIndex_] = angMom;
401     }
402 gezelter 1930
403 gezelter 2204 /**
404 chuckv 3397 * Sets the angular momentum of this stuntDouble in specified snapshot(body-fixed).
405 gezelter 2204 * @param angMom angular momentum to be set
406     * @param snapshotNo
407     * @see #getJ
408     */
409     void setJ(const Vector3d& angMom, int snapshotNo) {
410     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).angularMomentum[localIndex_] = angMom;
411     }
412 chuckv 3110
413 gezelter 2204 /**
414 chuckv 3397 * Returns system Center of Mass for stuntDouble frame from snapshot
415 chuckv 3110 *
416     */
417     Vector3d getCOM(){
418     return (snapshotMan_->getCurrentSnapshot())->getCOM();
419     }
420    
421     /**
422 chuckv 3397 * Returns system Center of Mass velocity for stuntDouble frame from snapshot
423 chuckv 3110 *
424     */
425    
426     Vector3d getCOMvel(){
427     return (snapshotMan_->getCurrentSnapshot())->getCOMvel();
428     }
429    
430     /**
431 chuckv 3397 * Returns system Center of Mass angular momentum for stuntDouble frame from snapshot
432 chuckv 3110 *
433     */
434     Vector3d getCOMw(){
435     return (snapshotMan_->getCurrentSnapshot())->getCOMw();
436     }
437    
438     /**
439 chuckv 3397 * Returns system Center of Mass for stuntDouble frame from snapshot
440 chuckv 3110 *
441     */
442     Vector3d getCOM(int snapshotNo){
443     return (snapshotMan_->getSnapshot(snapshotNo))->getCOM();
444     }
445    
446     /**
447 chuckv 3397 * Returns system Center of Mass velocity for stuntDouble frame from snapshot
448 chuckv 3110 *
449     */
450    
451     Vector3d getCOMvel(int snapshotNo){
452     return (snapshotMan_->getSnapshot(snapshotNo))->getCOMvel();
453     }
454    
455     /**
456 chuckv 3397 * Returns system Center of Mass angular momentum for stuntDouble frame from snapshot
457 chuckv 3110 *
458     */
459     Vector3d getCOMw(int snapshotNo){
460     return (snapshotMan_->getSnapshot(snapshotNo))->getCOMw();
461     }
462    
463     /**
464 chuckv 3397 * Returns the previous quaternion of this stuntDouble
465     * @return the quaternion of this stuntDouble
466 gezelter 2204 */
467     Quat4d getPrevQ() {
468     return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
469     }
470 gezelter 1930
471 gezelter 2204 /**
472 chuckv 3397 * Returns the current quaternion of this stuntDouble
473     * @return the quaternion of this stuntDouble
474 gezelter 2204 */
475     Quat4d getQ() {
476     return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toQuaternion();
477     }
478 gezelter 1930
479 gezelter 2204 /**
480 chuckv 3397 * Returns the quaternion of this stuntDouble in specified snapshot
481     * @return the quaternion of this stuntDouble
482 gezelter 2204 * @param snapshotNo
483     */
484     Quat4d getQ(int snapshotNo) {
485     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toQuaternion();
486     }
487 gezelter 1930
488 gezelter 2204 /**
489 chuckv 3397 * Sets the previous quaternion of this stuntDouble
490 gezelter 2204 * @param q new quaternion
491     * @note actual storage data is rotation matrix
492     */
493     void setPrevQ(const Quat4d& q) {
494     setPrevA(q);
495     }
496 gezelter 1930
497 gezelter 2204 /**
498 chuckv 3397 * Sets the current quaternion of this stuntDouble
499 gezelter 2204 * @param q new quaternion
500     * @note actual storage data is rotation matrix
501     */
502     void setQ(const Quat4d& q) {
503     setA(q);
504     }
505 gezelter 1930
506 gezelter 2204 /**
507 chuckv 3397 * Sets the quaternion of this stuntDouble in specified snapshot
508 gezelter 2204 *
509     * @param q quaternion to be set
510     * @param snapshotNo
511     * @note actual storage data is rotation matrix
512     */
513     void setQ(const Quat4d& q, int snapshotNo) {
514     setA(q, snapshotNo);
515     }
516 gezelter 1930
517 gezelter 2204 /**
518 chuckv 3397 * Returns the previous euler angles of this stuntDouble
519     * @return the euler angles of this stuntDouble
520 gezelter 2204 */
521     Vector3d getPrevEuler() {
522     return ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
523     }
524 gezelter 1930
525 gezelter 2204 /**
526 chuckv 3397 * Returns the current euler angles of this stuntDouble
527     * @return the euler angles of this stuntDouble
528 gezelter 2204 */
529     Vector3d getEuler() {
530     return ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_].toEulerAngles();
531     }
532 gezelter 1930
533 gezelter 2204 /**
534 chuckv 3397 * Returns the euler angles of this stuntDouble in specified snapshot.
535     * @return the euler angles of this stuntDouble
536 gezelter 2204 * @param snapshotNo
537     */
538     Vector3d getEuler(int snapshotNo) {
539     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_].toEulerAngles();
540     }
541 gezelter 1930
542 gezelter 2204 /**
543 chuckv 3397 * Sets the previous euler angles of this stuntDouble.
544 gezelter 2204 * @param euler new euler angles
545     * @see #getEuler
546     * @note actual storage data is rotation matrix
547     */
548     void setPrevEuler(const Vector3d& euler) {
549     ((snapshotMan_->getPrevSnapshot())->*storage_).aMat[localIndex_] = euler;
550     }
551 gezelter 1930
552 gezelter 2204 /**
553 chuckv 3397 * Sets the current euler angles of this stuntDouble
554 gezelter 2204 * @param euler new euler angles
555     */
556     void setEuler(const Vector3d& euler) {
557     ((snapshotMan_->getCurrentSnapshot())->*storage_).aMat[localIndex_] = euler;
558     }
559 gezelter 1930
560 gezelter 2204 /**
561 chuckv 3397 * Sets the euler angles of this stuntDouble in specified snapshot
562 gezelter 2204 *
563     * @param euler euler angles to be set
564     * @param snapshotNo
565     * @note actual storage data is rotation matrix
566     */
567     void setEuler(const Vector3d& euler, int snapshotNo) {
568     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).aMat[localIndex_] = euler;
569     }
570 gezelter 1930
571 gezelter 2204 /**
572 chuckv 3397 * Returns the previous unit vectors of this stuntDouble
573     * @return the unit vectors of this stuntDouble
574 gezelter 2204 */
575     RotMat3x3d getPrevElectroFrame() {
576     return ((snapshotMan_->getPrevSnapshot())->*storage_).electroFrame[localIndex_];
577     }
578 gezelter 1930
579 gezelter 2204 /**
580 chuckv 3397 * Returns the current unit vectors of this stuntDouble
581     * @return the unit vectors of this stuntDouble
582 gezelter 2204 */
583     RotMat3x3d getElectroFrame() {
584     return ((snapshotMan_->getCurrentSnapshot())->*storage_).electroFrame[localIndex_];
585     }
586 gezelter 1930
587 gezelter 2204 /**
588 chuckv 3397 * Returns the unit vectors of this stuntDouble in specified snapshot
589 gezelter 2204 *
590 chuckv 3397 * @return the unit vectors of this stuntDouble
591 gezelter 2204 * @param snapshotNo
592     */
593     RotMat3x3d getElectroFrame(int snapshotNo) {
594     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).electroFrame[localIndex_];
595     }
596 gezelter 1930
597 gezelter 2204 /**
598 chuckv 3397 * Returns the previous force of this stuntDouble
599     * @return the force of this stuntDouble
600 gezelter 2204 */
601     Vector3d getPrevFrc() {
602     return ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_];
603     }
604 gezelter 1930
605 gezelter 2204 /**
606 chuckv 3397 * Returns the current force of this stuntDouble
607     * @return the force of this stuntDouble
608 gezelter 2204 */
609     Vector3d getFrc() {
610     return ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_];
611     }
612 gezelter 1930
613 gezelter 2204 /**
614 chuckv 3397 * Returns the force of this stuntDouble in specified snapshot
615 gezelter 2204 *
616 chuckv 3397 * @return the force of this stuntDouble
617 gezelter 2204 * @param snapshotNo
618     */
619     Vector3d getFrc(int snapshotNo) {
620     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_];
621     }
622 gezelter 1930
623 gezelter 2204 /**
624 chuckv 3397 * Sets the previous force of this stuntDouble
625 gezelter 2204 *
626     * @param frc new force
627     * @see #getFrc
628     */
629     void setPrevFrc(const Vector3d& frc) {
630     ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] = frc;
631     }
632 gezelter 1930
633 gezelter 2204 /**
634 chuckv 3397 * Sets the current force of this stuntDouble
635 gezelter 2204 * @param frc new force
636     */
637     void setFrc(const Vector3d& frc) {
638     ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] = frc;
639     }
640 gezelter 1930
641 gezelter 2204 /**
642 chuckv 3397 * Sets the force of this stuntDouble in specified snapshot
643 gezelter 2204 *
644     * @param frc force to be set
645     * @param snapshotNo
646     * @see #getFrc
647     */
648     void setFrc(const Vector3d& frc, int snapshotNo) {
649     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] = frc;
650     }
651 gezelter 1930
652 gezelter 2204 /**
653 chuckv 3397 * Adds force into the previous force of this stuntDouble
654 gezelter 2204 *
655     * @param frc new force
656     * @see #getFrc
657     */
658     void addPrevFrc(const Vector3d& frc) {
659     ((snapshotMan_->getPrevSnapshot())->*storage_).force[localIndex_] += frc;
660     }
661 gezelter 1930
662 gezelter 2204 /**
663 chuckv 3397 * Adds force into the current force of this stuntDouble
664 gezelter 2204 * @param frc new force
665     */
666     void addFrc(const Vector3d& frc) {
667     ((snapshotMan_->getCurrentSnapshot())->*storage_).force[localIndex_] += frc;
668     }
669 gezelter 1930
670 gezelter 2204 /**
671 chuckv 3397 * Adds force into the force of this stuntDouble in specified snapshot
672 gezelter 2204 *
673     * @param frc force to be set
674     * @param snapshotNo
675     * @see #getFrc
676     */
677     void addFrc(const Vector3d& frc, int snapshotNo) {
678     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).force[localIndex_] += frc;
679     }
680 gezelter 1930
681 gezelter 2204 /**
682 chuckv 3397 * Returns the previous torque of this stuntDouble
683     * @return the torque of this stuntDouble
684 gezelter 2204 */
685     Vector3d getPrevTrq() {
686     return ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_];
687     }
688 gezelter 1930
689 gezelter 2204 /**
690 chuckv 3397 * Returns the current torque of this stuntDouble
691     * @return the torque of this stuntDouble
692 gezelter 2204 */
693     Vector3d getTrq() {
694     return ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_];
695     }
696 gezelter 1930
697 gezelter 2204 /**
698 chuckv 3397 * Returns the torque of this stuntDouble in specified snapshot
699 gezelter 2204 *
700 chuckv 3397 * @return the torque of this stuntDouble
701 gezelter 2204 * @param snapshotNo
702     */
703     Vector3d getTrq(int snapshotNo) {
704     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_];
705     }
706 gezelter 1930
707 gezelter 2204 /**
708 chuckv 3397 * Sets the previous torque of this stuntDouble
709 gezelter 2204 *
710     * @param trq new torque
711     * @see #getTrq
712     */
713     void setPrevTrq(const Vector3d& trq) {
714     ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] = trq;
715     }
716 gezelter 1930
717 gezelter 2204 /**
718 chuckv 3397 * Sets the current torque of this stuntDouble
719 gezelter 2204 * @param trq new torque
720     */
721     void setTrq(const Vector3d& trq) {
722     ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] = trq;
723     }
724 gezelter 1930
725 gezelter 2204 /**
726 chuckv 3397 * Sets the torque of this stuntDouble in specified snapshot
727 gezelter 2204 *
728     * @param trq torque to be set
729     * @param snapshotNo
730     * @see #getTrq
731     */
732     void setTrq(const Vector3d& trq, int snapshotNo) {
733     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] = trq;
734     }
735 gezelter 1930
736 gezelter 2204 /**
737 chuckv 3397 * Adds torque into the previous torque of this stuntDouble
738 gezelter 2204 *
739     * @param trq new torque
740     * @see #getTrq
741     */
742     void addPrevTrq(const Vector3d& trq) {
743     ((snapshotMan_->getPrevSnapshot())->*storage_).torque[localIndex_] += trq;
744     }
745 gezelter 1930
746 gezelter 2204 /**
747 chuckv 3397 * Adds torque into the current torque of this stuntDouble
748 gezelter 2204 * @param trq new torque
749     */
750     void addTrq(const Vector3d& trq) {
751     ((snapshotMan_->getCurrentSnapshot())->*storage_).torque[localIndex_] += trq;
752     }
753 gezelter 1930
754 gezelter 2204 /**
755 chuckv 3397 * Adds torque into the torque of this stuntDouble in specified snapshot
756 gezelter 2204 *
757     * @param trq torque to be add
758     * @param snapshotNo
759     * @see #getTrq
760     */
761     void addTrq(const Vector3d& trq, int snapshotNo) {
762     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).torque[localIndex_] += trq;
763     }
764 gezelter 1930
765    
766 gezelter 3466
767 gezelter 2204 /**
768 gezelter 3466 * Returns the previous particlePot of this stuntDouble
769     * @return the particlePot of this stuntDouble
770     */
771     RealType getPrevParticlePot() {
772     return ((snapshotMan_->getPrevSnapshot())->*storage_).particlePot[localIndex_];
773     }
774    
775     /**
776     * Returns the current particlePot of this stuntDouble
777     * @return the particlePot of this stuntDouble
778     */
779     RealType getParticlePot() {
780     return ((snapshotMan_->getCurrentSnapshot())->*storage_).particlePot[localIndex_];
781     }
782    
783     /**
784     * Returns the particlePot of this stuntDouble in specified snapshot
785     *
786     * @return the particlePot of this stuntDouble
787     * @param snapshotNo
788     */
789     RealType getParticlePot(int snapshotNo) {
790     return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).particlePot[localIndex_];
791     }
792    
793     /**
794     * Sets the previous particlePot of this stuntDouble
795     *
796     * @param particlePot new particlePot
797     * @see #getParticlePot
798     */
799     void setPrevParticlePot(const RealType& particlePot) {
800     ((snapshotMan_->getPrevSnapshot())->*storage_).particlePot[localIndex_] = particlePot;
801     }
802    
803     /**
804     * Sets the current particlePot of this stuntDouble
805     * @param particlePot new particlePot
806     */
807     void setParticlePot(const RealType& particlePot) {
808     ((snapshotMan_->getCurrentSnapshot())->*storage_).particlePot[localIndex_] = particlePot;
809     }
810    
811     /**
812     * Sets the particlePot of this stuntDouble in specified snapshot
813     *
814     * @param particlePot particlePot to be set
815     * @param snapshotNo
816     * @see #getParticlePot
817     */
818     void setParticlePot(const RealType& particlePot, int snapshotNo) {
819     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).particlePot[localIndex_] = particlePot;
820     }
821    
822     /**
823     * Adds particlePot into the previous particlePot of this stuntDouble
824     *
825     * @param particlePot new particlePot
826     * @see #getParticlePot
827     */
828     void addPrevParticlePot(const RealType& particlePot) {
829     ((snapshotMan_->getPrevSnapshot())->*storage_).particlePot[localIndex_] += particlePot;
830     }
831    
832     /**
833     * Adds particlePot into the current particlePot of this stuntDouble
834     * @param particlePot new particlePot
835     */
836     void addParticlePot(const RealType& particlePot) {
837     ((snapshotMan_->getCurrentSnapshot())->*storage_).particlePot[localIndex_] += particlePot;
838     }
839    
840     /**
841     * Adds particlePot into the particlePot of this stuntDouble in specified snapshot
842     *
843     * @param particlePot particlePot to be add
844     * @param snapshotNo
845     * @see #getParticlePot
846     */
847     void addParticlePot(const RealType& particlePot, int snapshotNo) {
848     ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).particlePot[localIndex_] += particlePot;
849     }
850    
851    
852     /**
853 chuckv 3397 * Returns the previous z-angle of this stuntDouble
854     * @return the z-angle of this stuntDouble
855 gezelter 2204 */
856 tim 2759 RealType getPrevZangle() {
857 gezelter 2204 return ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_];
858     }
859 gezelter 1930
860 gezelter 2204 /**
861 chuckv 3397 * Returns the current z-angle of this stuntDouble
862     * @return the z-angle of this stuntDouble
863 gezelter 2204 */
864 tim 2759 RealType getZangle() {
865 gezelter 2204 return ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_];
866     }
867 gezelter 1930
868 gezelter 2204 /**
869 chuckv 3397 * Returns the z-angle of this stuntDouble in specified snapshot
870     * @return the z-angle of this stuntDouble
871 gezelter 2204 * @param snapshotNo
872     */
873 tim 2759 RealType getZangle(int snapshotNo) {
874 gezelter 2204 return ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_];
875     }
876 gezelter 1930
877 gezelter 2204 /**
878 chuckv 3397 * Sets the previous z-angle of this stuntDouble
879 gezelter 2204 * @param angle new z-angle
880     * @see #getZangle
881     */
882 tim 2759 void setPrevZangle(RealType angle) {
883 gezelter 2204 ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] = angle;
884     }
885 gezelter 1930
886 gezelter 2204 /**
887 chuckv 3397 * Sets the current z-angle of this stuntDouble
888 gezelter 2204 * @param angle new z-angle
889     */
890 tim 2759 void setZangle(RealType angle) {
891 gezelter 2204 ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] = angle;
892     }
893 gezelter 1930
894 gezelter 2204 /**
895 chuckv 3397 * Sets the z-angle of this stuntDouble in specified snapshot
896 gezelter 2204 * @param angle z-angle to be set
897     * @param snapshotNo
898     * @see #getZangle
899     */
900 tim 2759 void setZangle(RealType angle, int snapshotNo) {
901 gezelter 2204 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] = angle;
902     }
903 gezelter 1930
904 gezelter 2204 /**
905 chuckv 3397 * Adds z-angle into the previous z-angle of this stuntDouble
906 gezelter 2204 * @param angle new z-angle
907     * @see #getZangle
908     */
909 tim 2759 void addPrevZangle(RealType angle) {
910 gezelter 2204 ((snapshotMan_->getPrevSnapshot())->*storage_).zAngle[localIndex_] += angle;
911     }
912 gezelter 1930
913 gezelter 2204 /**
914 chuckv 3397 * Adds z-angle into the current z-angle of this stuntDouble
915 gezelter 2204 * @param angle new z-angle
916     */
917 tim 2759 void addZangle(RealType angle) {
918 gezelter 2204 ((snapshotMan_->getCurrentSnapshot())->*storage_).zAngle[localIndex_] += angle;
919     }
920 gezelter 1930
921 gezelter 2204 /**
922 chuckv 3397 * Adds z-angle into the z-angle of this stuntDouble in specified snapshot
923 gezelter 2204 * @param angle z-angle to be add
924     * @param snapshotNo
925     * @see #getZangle
926     */
927 tim 2759 void addZangle(RealType angle, int snapshotNo) {
928 gezelter 2204 ((snapshotMan_->getSnapshot(snapshotNo))->*storage_).zAngle[localIndex_] += angle;
929     }
930 gezelter 1930
931 chuckv 3397 /** Set the force of this stuntDouble to zero */
932 gezelter 2204 void zeroForcesAndTorques();
933     /**
934 chuckv 3397 * Returns the inertia tensor of this stuntDouble
935     * @return the inertia tensor of this stuntDouble
936 gezelter 2204 */
937     virtual Mat3x3d getI() = 0;
938 gezelter 1930
939 gezelter 2204 /**
940 chuckv 3397 * Returns the gradient of this stuntDouble
941     * @return the gradient of this stuntDouble
942 gezelter 2204 */
943 tim 2759 virtual std::vector<RealType> getGrad() = 0;
944 gezelter 1930
945 gezelter 2204 /**
946 chuckv 3397 * Tests the if this stuntDouble is a linear rigidbody
947 gezelter 2204 *
948 chuckv 3397 * @return true if this stuntDouble is a linear rigidbody, otherwise return false
949 gezelter 2204 * @note atom and directional atom will always return false
950     *
951     * @see #linearAxis
952     */
953     bool isLinear() {
954     return linear_;
955     }
956 gezelter 1930
957 gezelter 2204 /**
958     * Returns the linear axis of the rigidbody, atom and directional atom will always return -1
959     *
960     * @return the linear axis of the rigidbody
961     *
962     * @see #isLinear
963     */
964     int linearAxis() {
965     return linearAxis_;
966     }
967 gezelter 1930
968 chuckv 3397 /** Returns the mass of this stuntDouble */
969 tim 2759 RealType getMass() {
970 gezelter 2204 return mass_;
971     }
972 gezelter 1930
973 gezelter 2204 /**
974     * Sets the mass of this stuntdoulbe
975     * @param mass the mass to be set
976     */
977 tim 2759 void setMass(RealType mass) {
978 gezelter 2204 mass_ = mass;
979     }
980 gezelter 1930
981 chuckv 3397 /** Returns the name of this stuntDouble */
982 gezelter 2204 virtual std::string getType() = 0;
983 gezelter 1930
984 chuckv 3397 /** Sets the name of this stuntDouble*/
985 gezelter 2204 virtual void setType(const std::string& name) {}
986 gezelter 1930
987 gezelter 2204 /**
988     * Converts a lab fixed vector to a body fixed vector.
989     * @return body fixed vector
990     * @param v lab fixed vector
991     */
992     Vector3d lab2Body(const Vector3d& v) {
993     return getA() * v;
994     }
995 gezelter 1930
996 gezelter 2204 Vector3d lab2Body(const Vector3d& v, int frame) {
997     return getA(frame) * v;
998     }
999 tim 2018
1000 gezelter 2204 /**
1001     * Converts a body fixed vector to a lab fixed vector.
1002     * @return corresponding lab fixed vector
1003     * @param v body fixed vector
1004     */
1005     Vector3d body2Lab(const Vector3d& v){
1006     return getA().transpose() * v;
1007     }
1008 tim 2018
1009 gezelter 2204 Vector3d body2Lab(const Vector3d& v, int frame){
1010     return getA(frame).transpose() * v;
1011     }
1012 chuckv 3397
1013 gezelter 2204 /**
1014     * <p>
1015 cli2 3520 * The purpose of the Visitor Pattern is to encapsulate an
1016     * operation that you want to perform on the elements of a data
1017     * structure. In this way, you can change the operation being
1018     * performed on a structure without the need of changing the
1019     * classes of the elements that you are operating on. Using a
1020     * Visitor pattern allows you to decouple the classes for the data
1021     * structure and the algorithms used upon them
1022 gezelter 2204 * </p>
1023     * @param v visitor
1024     */
1025     virtual void accept(BaseVisitor* v) = 0;
1026 gezelter 1930
1027 gezelter 2204 //below functions are just forward functions
1028     /**
1029     * Adds property into property map
1030     * @param genData GenericData to be added into PropertyMap
1031     */
1032     void addProperty(GenericData* genData);
1033 gezelter 1930
1034 gezelter 2204 /**
1035     * Removes property from PropertyMap by name
1036     * @param propName the name of property to be removed
1037     */
1038     void removeProperty(const std::string& propName);
1039 gezelter 1930
1040 gezelter 2204 /**
1041     * clear all of the properties
1042     */
1043     void clearProperties();
1044 gezelter 1930
1045 gezelter 2204 /**
1046     * Returns all names of properties
1047     * @return all names of properties
1048     */
1049     std::vector<std::string> getPropertyNames();
1050 gezelter 1930
1051 gezelter 2204 /**
1052     * Returns all of the properties in PropertyMap
1053     * @return all of the properties in PropertyMap
1054     */
1055     std::vector<GenericData*> getProperties();
1056 gezelter 1930
1057 gezelter 2204 /**
1058     * Returns property
1059     * @param propName name of property
1060     * @return a pointer point to property with propName. If no property named propName
1061     * exists, return NULL
1062     */
1063     GenericData* getPropertyByName(const std::string& propName);
1064 gezelter 1930
1065 gezelter 2204 protected:
1066 gezelter 1930
1067 gezelter 2204 StuntDouble(ObjectType objType, DataStoragePointer storage);
1068 gezelter 1930
1069 gezelter 2204 StuntDouble(const StuntDouble& sd);
1070     StuntDouble& operator=(const StuntDouble& sd);
1071 gezelter 1930
1072 gezelter 2204 ObjectType objType_;
1073     DataStoragePointer storage_;
1074     SnapshotManager* snapshotMan_;
1075 gezelter 1930
1076 gezelter 2204 bool linear_;
1077     int linearAxis_;
1078 gezelter 1930
1079    
1080 gezelter 2204 int globalIndex_;
1081 tim 2982 int globalIntegrableObjectIndex_;
1082 gezelter 2204 int localIndex_;
1083 gezelter 1930
1084    
1085 tim 2759 RealType mass_;
1086 gezelter 1930
1087 gezelter 2204 private:
1088 gezelter 1930
1089 gezelter 2204 PropertyMap properties_;
1090     };
1091 gezelter 1490
1092 gezelter 1930 }//end namespace oopse
1093     #endif //PRIMITIVES_STUNTDOUBLE_HPP

Properties

Name Value
svn:executable *